aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-01 23:08:59 +1000
committerDavid Walter Seikel2014-04-01 23:08:59 +1000
commit628987e1151d9b1639377e2dfb87b2810c8efd4c (patch)
treefd09dfac2356be917e325e69dfdfb3a04567d307 /ClientHamr
parentSeparate out the metatable __ stuff from Thing, put it into Mum. (diff)
downloadSledjHamr-628987e1151d9b1639377e2dfb87b2810c8efd4c.zip
SledjHamr-628987e1151d9b1639377e2dfb87b2810c8efd4c.tar.gz
SledjHamr-628987e1151d9b1639377e2dfb87b2810c8efd4c.tar.bz2
SledjHamr-628987e1151d9b1639377e2dfb87b2810c8efd4c.tar.xz
valueMeta -> oldMum, plus some comments.
Diffstat (limited to 'ClientHamr')
-rw-r--r--ClientHamr/GuiLua/skang.lua16
-rw-r--r--ClientHamr/GuiLua/test.lua2
2 files changed, 11 insertions, 7 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index de0a0af..24f3dbc 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -572,24 +572,28 @@ __newindex = function (parent, key, value)
572 572
573 if thingy then 573 if thingy then
574 local name = thingy.names[1] 574 local name = thingy.names[1]
575 local valueMeta 575 local oldMum
576 576
577 if 'table' == type(value) then 577 if 'table' == type(value) then
578 -- Coz setting it via metaMum screws with the __index stuff somehow. 578 -- Coz setting it via metaMum screws with the __index stuff somehow.
579 local oldValue = metaMum.__values[name] 579 local oldValue = metaMum.__values[name]
580 if 'table' == type(oldValue) then 580 if 'table' == type(oldValue) then
581 valueMeta = getmetatable(oldValue) 581 oldMum = getmetatable(oldValue)
582 if valueMeta then 582 if oldMum then
583 -- TODO - This SHOULD work, but doesn't.
584 --setmetatable(value, oldMum)
585 -- Instead we do this -
583 -- TODO - This wont clear out any values in the old table that are not in the new table. Should it? 586 -- TODO - This wont clear out any values in the old table that are not in the new table. Should it?
584 for k, v in pairs(value) do 587 for k, v in pairs(value) do
585 local newK = valueMeta.__self.stuff[k] 588 local newK = oldMum.__self.stuff[k]
586 if newK then newK = newK.names[1] else newK = k end 589 if newK then newK = newK.names[1] else newK = k end
587 valueMeta.__values[newK] = v 590 oldMum.__values[newK] = v
588 end 591 end
592
589 end 593 end
590 end 594 end
591 end 595 end
592 if nil == valueMeta then metaMum.__values[name] = value end 596 if nil == oldMum then metaMum.__values[name] = value end
593 -- NOTE - invalid values are still stored, this is by design. 597 -- NOTE - invalid values are still stored, this is by design.
594 if not thingy:isValid(parent) then 598 if not thingy:isValid(parent) then
595 for i, v in ipairs(thingy.errors) do 599 for i, v in ipairs(thingy.errors) do
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua
index 60d4200..9e3000a 100644
--- a/ClientHamr/GuiLua/test.lua
+++ b/ClientHamr/GuiLua/test.lua
@@ -163,7 +163,7 @@ stuff.s.sb = 22
163stuff.s.b = 33 163stuff.s.b = 33
164-- NOTE - This triggers isValid twice for each table element. 164-- NOTE - This triggers isValid twice for each table element.
165stuff.s = {a=8, sb='9'} 165stuff.s = {a=8, sb='9'}
166stuff.s.sb = 44 166stuff.s.sb = 99
167print('') 167print('')
168--stuff.S.record0 = {} 168--stuff.S.record0 = {}
169stuff.S['record0'] = {field0=0, field1='zero'} 169stuff.S['record0'] = {field0=0, field1='zero'}