Just take a look... (lua 4.0 to 5.0)
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Just take a look... (lua 4.0 to 5.0)

Started by Khezex, 13 March, 2005, 20:51:01

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Khezex

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

jiten

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

[_XStaTiC_]

this works to

function loadfile(file) 
 local iFile = loadfile(file)
 if iFile then
	iFile()
     end
end

Khezex

#3
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 )

[_XStaTiC_]

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

Khezex

#5
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

jiten

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

SMF spam blocked by CleanTalk