Hello one and all... i've been trieing since for 2 days now, to update my bot (it's about 3 mb worth of text >.< ) ...
umm got cut up when tried to change this:
Quotefunction loadfile (data)
assert(readfrom(data))
dostring(read("*all"))
readfrom()
end
TO this:
Quotefunction loadfile (data)
local iFile = io.readfrom(data)
if iFile then
dofile(data)
iFile:close()
end
end
I am not even sure if it has been corectly converted (found the piece of transfer on the forum...) ... umm my head hurts like crap right now... I keep getting "attempt to call field `readfrom' (a nil value)"
... anybody have any ideas ?
P.S. it's a fact, my head is in pain... changed io.readfrom to io.input ... and it dosen't give an error anymore... gotta se if it works dough
Try this:
function loadfile(data)
local handle = io.open(data,"r")
if (handle ~= nil) then
dofile(data)
handle:flush()
handle:close()
end
end
Best regards,
jiten
this works to
function loadfile(file)
local iFile = loadfile(file)
if iFile then
iFile()
end
end
Umm jiten, thanks worked like a charm :D... you rock :P
function dosave(curUser)
test = "UserTable = {\r\n"
for a,b in UserTable do
if b == 1 then
writeto(SAVE)
test = test.."[\""..a.."\"]=\""..b.."\","
end
test = test.."\r\n}"
write(test)
writeto()
end
end
What about this one? :P
P.S. Static... you have function x... with local iFile = x(file) .... i get a stack overflow problem cause of self calling withouth a break controller :) .... just thought i should point that out :D
P.S.S: umm actually scratch that last one... i fixed it myself =))
Wow, just realized i didn't need a topic bot.... =)) (after 20 minutes of trying to edit the bot :P )
Try this, maybe it will work.... Not tested
function dosave(curUser)
local f = io.open(SAVE, "w+")
assert(SAVE)
f:write("UserTable = {\n")
for a,b in UserTable do
if b == 1 then
f:write("[\""..a.."\"]=\""..b.."\",\n")
end
end
f:write("}")
f:flush()
f:close()
end
Static thanks... i kinda did that one on my own :P
Umm can anybody help me with the "APPENDTO" function?...
i have smth like this
FILE="name.txt"
io.appendto(FILE)
But i keep getting a "attempt to call field `appendto' (a nil value)" error... i really don't get it o.o... what am i doing wrong ?
i changed the code....
io.open(NEWS,"a")
handle= io.write("something to write")
io.close()
NOW... i get an " attempt to use a closed file " error.... sigh
Try to use this and change the values according to the files u got:
function AppendToFile(filename)
local file = io.open(filename, "a+") -- "a+"
file:write("appending this text to file "..filename.."\r\n")
file:write("continuing appending / writing text to file\r\n")
file:close()
end