SaveGame v. 0.6
Moderator: Moderators
Re: SaveGame v. 0.1
Result: {testingsave={hello={kitty=cat}}}
So... is GG = {testingsave={hello={kitty=cat}}} the same as GG.testingsave = {hello = {kitty = cat}} (the original test value)? That looks right...
So... is GG = {testingsave={hello={kitty=cat}}} the same as GG.testingsave = {hello = {kitty = cat}} (the original test value)? That looks right...
Last edited by Argh on 23 Jan 2010, 04:19, edited 1 time in total.
Re: SaveGame v. 0.1
GG['testingsave'] == GG.testingsave
try it with multiple vars in one or more of the tables, make sure it handles that right
...
you don't want strings encased in quotes?
try it with multiple vars in one or more of the tables, make sure it handles that right
...
you don't want strings encased in quotes?
Re: SaveGame v. 0.1
Hmm. Two first-iteration values:
{testingsave={hello={kitty=cat}},foo={bar={barfoo=boo}}}
Original:
GG.testingsave = {hello = {kitty = 'cat'}}
GG.foo = {bar = {barfoo = 'boo'}}
That second one looks like exactly what is needed: GG = { foo={bar={barfoo=boo}}, }
Oops, nvm, wasn't counting brackets lol, there's one too many.
GG = { foo={bar={barfoo=boo}}, }
not
GG = { foo={bar={barfoo=boo}}}, }
{testingsave={hello={kitty=cat}},foo={bar={barfoo=boo}}}
Original:
GG.testingsave = {hello = {kitty = 'cat'}}
GG.foo = {bar = {barfoo = 'boo'}}
That second one looks like exactly what is needed: GG = { foo={bar={barfoo=boo}}, }
Oops, nvm, wasn't counting brackets lol, there's one too many.
GG = { foo={bar={barfoo=boo}}, }
not
GG = { foo={bar={barfoo=boo}}}, }
Last edited by Argh on 23 Jan 2010, 04:28, edited 1 time in total.
Re: SaveGame v. 0.1
Code: Select all
{
testingsave={
hello={
kitty=cat
}
},
foo={
bar={
barfoo=boo
}
}
}
Re: SaveGame v. 0.1
Ohhh, it's enclosing the whole thing. OK.
Re: SaveGame v. 0.1
right, because GG is a table. do you want it to put quotes around strings?
Re: SaveGame v. 0.1
Yeah. I just ran into that fun problem.
Re: SaveGame v. 0.1
is that a yes? if so, try this.
Code: Select all
local function dumpTable(tab)
if type(tab) == 'table' then
local tmp = {}
for a, b in pairs(tab) do
table.insert(tmp, a .. '=' .. dumpTable(b))
end
return '{' .. table.concat(tmp, ',') .. '}'
elseif type(tab) == 'string' then
return "'" .. tab .. "'"
else
return tab
end
end
Re: SaveGame v. 0.1
Hmm. GG.testingsave == nil
So... um, I guess surround all a's with quotes if not numbers?
Or... GG['testingsave']... shit
Nope.
GG ={['testingsave']={['hello']={['kitty']='cat'}},['foo']={['bar']={['barfoo']='boo'}}}
Both GG.testingsave and GG['testingsave'] return nil
With this function (was going to add math check, but whatever
So... um, I guess surround all a's with quotes if not numbers?
Or... GG['testingsave']... shit
Nope.
GG ={['testingsave']={['hello']={['kitty']='cat'}},['foo']={['bar']={['barfoo']='boo'}}}
Both GG.testingsave and GG['testingsave'] return nil
With this function (was going to add math check, but whatever
Code: Select all
local function dumpTable(tab)
if type(tab) == 'table' then
local tmp = {}
for a, b in pairs(tab) do
table.insert(tmp, "['"..tostring(a).."']".. '=' .. dumpTable(b))
end
return '{' .. table.concat(tmp, ',') .. '}'
elseif type(tab) == 'string' then
return "'" .. tab .. "'"
else
return tab
end
end
Re: SaveGame v. 0.1
what?['testingsave']=
I have no idea why you added that except possibly to break it.
Re: SaveGame v. 0.1
IDK. Sorry, been up since 5AM, I am now officially punch-drunk.
Whatever's going on, the top-level reference doesn't return <table>
Whatever's going on, the top-level reference doesn't return <table>
Re: SaveGame v. 0.1
Wait, I think I got it... did something really silly
Re: SaveGame v. 0.1
did it possibly have something to do with the only line you changed?
Re: SaveGame v. 0.1
No, and it didn't work, either. I still get a value of nil for GG.testingsave.
This is really amazingly stupid. I did a few things like this before I ended up with the hand-coded recursions.
The problem is, GG.testingsave = {blah = {blahblah = 1}} does not appear to be equivalent to GG = {testingsave = {blah = {blahblah = 1}}}
This is really amazingly stupid. I did a few things like this before I ended up with the hand-coded recursions.
The problem is, GG.testingsave = {blah = {blahblah = 1}} does not appear to be equivalent to GG = {testingsave = {blah = {blahblah = 1}}}
Re: SaveGame v. 0.1
Code: Select all
> GG = {}
> GG.testingsave = {blah = {blahblah = 1}}
> ZZ = {testingsave = {blah = {blahblah = 1}}}
> print(dumpTable(GG))
{testingsave={blah={blahblah=1}}}
> print(dumpTable(ZZ))
{testingsave={blah={blahblah=1}}}
Re: SaveGame v. 0.1
Hmm. Code in save-file:
GG ={testingsave=2,foo={bar={barfoo=boo}}}
Spring.Echo(GG.testingsave) returns nil
GG ={testingsave=2,foo={bar={barfoo=boo}}}
Spring.Echo(GG.testingsave) returns nil
Re: SaveGame v. 0.1
Code: Select all
local function dumpTable(tab)
if type(tab) == 'table' then
local tmp = {}
for a, b in pairs(tab) do
table.insert(tmp, tostring(a) .. '=' .. dumpTable(b))
end
return '{' .. table.concat(tmp, ',') .. '}'
elseif type(tab) == 'string' then
return "'" .. tab .. "'"
else
return tostring(tab)
end
end
what's GG? does it allow direct assignment? I'm guessing not.
Re: SaveGame v. 0.1
GG's the gadget global table.
Meh. In previous tests (with that ugly iterative hack):
GG.testingsave = {foo = {bar = barfoo}}
Worked both ways. But that code rebuilds it exactly like that.
Meh. In previous tests (with that ugly iterative hack):
GG.testingsave = {foo = {bar = barfoo}}
Worked both ways. But that code rebuilds it exactly like that.
Re: SaveGame v. 0.1
Code: Select all
for a,b in pairs (GG) do
Spring.SendLuaUIMsg('write_save_file ' .. 'GG.' .. tostring(a) ..'=' .. dumpTable(b))
end
Re: SaveGame v. 0.1
Yeah... that looks like it'll do it.