Problem with Lua 5.0.2
 

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

Problem with Lua 5.0.2

Started by Tom, 21 February, 2005, 09:01:56

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tom

Hi ppl,

can somebody help me please.

I need convert this script, but that don't convert with plop's convertor, PLS help me!

This is part of the script, which I need convert in LUA 5.0.2:

    arrRR = {}
    fRR = "reqreg.dat"

    function Main()
    frmHub:RegBot(sBot)
    LoadFromFile(fRR)
    end

    function OnExit()
    SaveToFile(fRR,arrRR,"arrRR")
    end

    function SaveToFile(file , table , tablename)
    writeto(file)
    write(Serialize(table, tablename))
    writeto()
    end

    function LoadFromFile(file)
    if (readfrom(file) ~= nil) then
    readfrom(file)
    dostring(read("*all"))
    readfrom()

PLS, help me with convert, it is very important!

    Thank you in advance!!!

plop

give this a try.
arrRR = {}
fRR = "reqreg.dat"

function Main()
   frmHub:RegBot(sBot)
   dofile(fRR)
end

function OnExit()
   SaveToFile(fRR,arrRR,"arrRR")
end

function SaveToFile(file , tTable , tablename)
   fFile = io.open(file, "w")
   fFile:write(Serialize(tTable, tablename))
   fFile:close()
end

function LoadFromFile(file)
   local fFile = io.open(file)
   if fFile then
	dofile(file)
	fFile:close()
   end
end

function Serialize(tTable,sTableName,hFile,sTab)
   sTab = sTab or "";
   fFile:write(hFile,sTab..sTableName.." = {\n");
   for key,value in tTable do
	local sKey = (type(key) == "string") and os.format("[%q]",key) or os.format("[%d]",key);
	if(type(value) == "table") then
	   Serialize(value,sKey,hFile,sTab.."\t");
	else
	   local sValue = (type(value) == "string") and os.format("%q",value) or os.tostring(value);
	   fFile:write(hFile,sTab.."\t"..sKey.." = "..sValue);
	end
	fFile:write(hFile,",\n");
   end
   fFile:write(hFile,sTab.."}");
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk