diff options
Diffstat (limited to '')
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 20 | ||||
-rw-r--r-- | ClientHamr/GuiLua/test.lua | 10 |
2 files changed, 11 insertions, 19 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index 51e69f2..0a9752b 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -522,8 +522,7 @@ Thing.__index = function (parent, key) | |||
522 | end | 522 | end |
523 | 523 | ||
524 | -- Then see if we can inherit it from Thing. | 524 | -- Then see if we can inherit it from Thing. |
525 | thingy = Thing[key] | 525 | return Thing[key] |
526 | return thingy | ||
527 | end | 526 | end |
528 | 527 | ||
529 | Thing.__newindex = function (parent, key, value) | 528 | Thing.__newindex = function (parent, key, value) |
@@ -532,8 +531,6 @@ Thing.__newindex = function (parent, key, value) | |||
532 | 531 | ||
533 | if mumThing and mumThing.self then | 532 | if mumThing and mumThing.self then |
534 | -- This is a proxy table, the values never exist in the real table. In theory. | 533 | -- This is a proxy table, the values never exist in the real table. In theory. |
535 | print('__newindex ' .. mumThing.names[1] .. ' = ' .. key) | ||
536 | --printTableStart(mumThing, '', 'mumThing') | ||
537 | 534 | ||
538 | -- Find the Thing and get it done. | 535 | -- Find the Thing and get it done. |
539 | local thingy = mumThing.self.stuff[key] | 536 | local thingy = mumThing.self.stuff[key] |
@@ -541,14 +538,11 @@ print('__newindex ' .. mumThing.names[1] .. ' = ' .. key) | |||
541 | if not thingy then | 538 | if not thingy then |
542 | -- Deal with setting a new Stuff[key]. | 539 | -- Deal with setting a new Stuff[key]. |
543 | if mumThing.self.isStuff and (nil == mumThing.__values[key]) then | 540 | if mumThing.self.isStuff and (nil == mumThing.__values[key]) then |
544 | print('__newindex NEW stufflet ' .. key) | 541 | local newThing = copy(parent, key) |
545 | rawset(mumThing.__values, key, copy(parent, key)) | 542 | rawset(mumThing.__values, key, newThing) |
546 | --printTableStart(getmetatable(parent).self, '', 'parent thing') | 543 | thingy = {names={key}, types={'table'}, parent=newThing, stuff=getmetatable(newThing).self.stuff, } |
547 | --printTableStart(mumThing.__values[key], '', 'stufflet') | 544 | setmetatable(thingy, {__index = Thing}) -- To pick up isValid, pattern, and the other stuff by default. |
548 | --printTableStart(getmetatable(mumThing.__values[key]), '', 'stufflet metatable?') | 545 | mumThing.self.stuff[key] = thingy |
549 | --printTableStart(getmetatable(mumThing.__values[key]).self, '', 'stufflet thing?') | ||
550 | mumThing.self.stuff[key] = {names={key}, types={'table'}, parent=mumThing.__values[key], stuff=getmetatable(mumThing.__values[key]).self, } | ||
551 | |||
552 | end | 546 | end |
553 | end | 547 | end |
554 | 548 | ||
@@ -556,8 +550,6 @@ print('__newindex NEW stufflet ' .. key) | |||
556 | local name = thingy.names[1] | 550 | local name = thingy.names[1] |
557 | local valueMeta | 551 | local valueMeta |
558 | 552 | ||
559 | --printTableStart(thingy, '', 'thingy') | ||
560 | |||
561 | if 'table' == type(value) then | 553 | if 'table' == type(value) then |
562 | -- Coz setting it via mumThing screws with the __index stuff somehow. | 554 | -- Coz setting it via mumThing screws with the __index stuff somehow. |
563 | local oldValue = mumThing.__values[name] | 555 | local oldValue = mumThing.__values[name] |
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index 34b1a56..fff9023 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua | |||
@@ -166,8 +166,9 @@ stuff.s = {a=8, sb='9'} | |||
166 | stuff.s.sb = 44 | 166 | stuff.s.sb = 44 |
167 | print('') | 167 | print('') |
168 | --stuff.S.record0 = {} | 168 | --stuff.S.record0 = {} |
169 | stuff.S.record0 = {field0=0, field1='zero'} | 169 | stuff.S['record0'] = {field0='0', field1='zero'} |
170 | --stuff.S['record1'] = {field0='1', field1='one'} | 170 | stuff.S['record1'] = {field0='1', field1='one'} |
171 | -- TODO - adding a third makes isValid() crash. | ||
171 | --stuff.S['record2'] = {field0='2', field1='two'} | 172 | --stuff.S['record2'] = {field0='2', field1='two'} |
172 | 173 | ||
173 | print('') | 174 | print('') |
@@ -202,10 +203,10 @@ print(stuff.s.sb) | |||
202 | --skang.printTableStart(stuff.s, '', 'stuff.s') | 203 | --skang.printTableStart(stuff.s, '', 'stuff.s') |
203 | print('') | 204 | print('') |
204 | 205 | ||
205 | --skang.printTableStart(stuff.S, '', 'stuff.S') | 206 | skang.printTableStart(stuff.S, '', 'stuff.S') |
206 | 207 | ||
207 | print(stuff.S['record0'].field1) | 208 | print(stuff.S['record0'].field1) |
208 | --print(stuff.S['record1'].field1) | 209 | print(stuff.S['record1'].field1) |
209 | --print(stuff.S['record2'].field0) | 210 | --print(stuff.S['record2'].field0) |
210 | 211 | ||
211 | --skang.printTableStart(stuff.S['record0'], '', 'stuff.S[record0]') | 212 | --skang.printTableStart(stuff.S['record0'], '', 'stuff.S[record0]') |
@@ -215,4 +216,3 @@ print(stuff.S['record0'].field1) | |||
215 | --skang.printTableStart(getmetatable(stuff.s), '', 'stuff.s metatable') | 216 | --skang.printTableStart(getmetatable(stuff.s), '', 'stuff.s metatable') |
216 | --skang.printTableStart(getmetatable(stuff), '', 'stuff metatable') | 217 | --skang.printTableStart(getmetatable(stuff), '', 'stuff metatable') |
217 | --skang.printTableStart(getmetatable(stuff.S), '', 'stuff.S metatable') | 218 | --skang.printTableStart(getmetatable(stuff.S), '', 'stuff.S metatable') |
218 | --skang.printTableStart(skang.stuff(stuff, 'S'), '', 'stuff.S Thing') | ||