|
Post by joseltr on Mar 13, 2019 10:34:39 GMT
my txt file store my account's informations (ID/PW) to login to the game: account@gmail.com 111111
my code: function typeLine(ln) fileName = scriptPath() .. "Accinfo.txt"
fh,err = io.open(fileName, "r")
if (err) then scriptExit("file opening failed") end
local lnnum = 0
for line in fh:lines() do
lnnum = lnnum + 1
if lnnum == ln then
print(line) -- (1) type(typeOf(line)) -- (2) type(line) -- (3) end
end
end
typeLine(2) --> if this function works as i expected, it must type("111111") onto textfield
but the result i get is: (1)print(line) >>> "111111" (works great) (2)type(typeOf(line)) >>> it returns (String) type, then input "string" onto textfield (3)type(line) >>> this line really not work, it types nothing.
plus, when coding "type(line)", tooltip shows: "void type(v) Returns the type of its only argument, coded as string. The possible results of this function are nil" what does it mean? please help thanks sir!
|
|
|
Post by AnkuLua on Mar 14, 2019 15:27:27 GMT
Did you click on the input field first?
|
|
|
Post by joseltr on Mar 16, 2019 4:50:43 GMT
sure, as my (2) i wrote, it typed "string" on the textfield, but not the (3). this is really weird
|
|
|
Post by joseltr on Mar 16, 2019 4:57:31 GMT
|
|
|
Post by AnkuLua on Mar 16, 2019 5:33:33 GMT
|
|
|
Post by joseltr on Mar 16, 2019 6:00:48 GMT
i already checked that article before i posted this thread. still not any help. cause in my txt file has no special character, you can see in my picture, there has 6 zeros 000000, still dont know why it can't type on textfield
|
|
|
Post by joseltr on Mar 16, 2019 7:06:48 GMT
up! i just test, both of my code and your code (in the link you gave me) have the same problem.
it only type the last line. still dont know why
|
|
|
Post by Mercobots on Mar 16, 2019 13:27:57 GMT
Hi there, can you share your text file and this shunk of code, this way we can help you further Thank you
|
|
|
Post by joseltr on Mar 17, 2019 4:30:22 GMT
Hi there, can you share your text file and this shunk of code, this way we can help you further Thank you this is my code: btw, my txt has only has test line as: line1 > account@mail.com, line2 > 000000 function typeLine(ln)
fileName = scriptPath() .. "Accinfo.txt"
fh,err = io.open(fileName, "r")
if (err) then scriptExit("file opening failed") end
local lnnum = 0
for line in fh:lines() do
lnnum = lnnum + 1
if lnnum == ln then
print(line)
type(line)
end
end
end
typeLine(5)
|
|
|
Post by joseltr on Mar 17, 2019 7:39:24 GMT
mercobots: the problem is anyline is not typing on textfield, excepted the "last line" but it can print correctly. i still dont know why!
|
|
|
Post by Mercobots on Mar 17, 2019 12:44:05 GMT
mercobots: the problem is anyline is not typing on textfield, excepted the "last line" but it can print correctly. i still dont know why! beside that, i have to ask , why don't use a table instead
|
|
|
Post by Mercobots on Mar 17, 2019 12:59:15 GMT
so i tested using trim function and it works
function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end
function typeLine(ln)
fileName = scriptPath() .. "Accinfo.txt"
fh,err = io.open(fileName, "r")
if (err) then scriptExit("file opening failed") end
local lnnum = 0
for line in fh:lines() do
lnnum = lnnum + 1
if lnnum == ln then
print(line)
type(trim(line))
end
end
end
typeLine(1) typeLine(2)
using a table as i mentioned before
Accinfo.txt
return { { id = "account@mail.com", pass = "000000", }, }
main.lua
acc = dofile(scriptPath() .. "Accinfo.txt") type(acc[1].id) type(acc[1].pass)
|
|
|
Post by joseltr on Mar 18, 2019 3:18:41 GMT
when i try dofile() ankulua shows this alert. thanks sir, Mercobots, for helping
|
|
|
Post by Mercobots on Mar 18, 2019 8:51:08 GMT
when i try dofile() ankulua shows this alert. thanks sir, Mercobots, for helping if im not wrong... try a different editor to create your Accinfo file , like notepad
|
|
|
Post by AnkuLua on Mar 18, 2019 10:30:22 GMT
when i try dofile() ankulua shows this alert. thanks sir, Mercobots, for helping if im not wrong... try a different editor to create your Accinfo file , like notepad Suggest using Intellij IDEA Editor. Your problem on .txt is in fact caused by the same cause.
|
|