From 087d3691376ae46cbcf6a5ce5d0681359e034d25 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 1 Apr 2014 19:44:35 +1000 Subject: Fix up setting Stuff, mostly. Still broken somewhere, but working better than it did before. Third time's the (unlucky) charm. --- ClientHamr/GuiLua/skang.lua | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'ClientHamr/GuiLua/skang.lua') 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) end -- Then see if we can inherit it from Thing. - thingy = Thing[key] - return thingy + return Thing[key] end Thing.__newindex = function (parent, key, value) @@ -532,8 +531,6 @@ Thing.__newindex = function (parent, key, value) if mumThing and mumThing.self then -- This is a proxy table, the values never exist in the real table. In theory. -print('__newindex ' .. mumThing.names[1] .. ' = ' .. key) ---printTableStart(mumThing, '', 'mumThing') -- Find the Thing and get it done. local thingy = mumThing.self.stuff[key] @@ -541,14 +538,11 @@ print('__newindex ' .. mumThing.names[1] .. ' = ' .. key) if not thingy then -- Deal with setting a new Stuff[key]. if mumThing.self.isStuff and (nil == mumThing.__values[key]) then -print('__newindex NEW stufflet ' .. key) - rawset(mumThing.__values, key, copy(parent, key)) ---printTableStart(getmetatable(parent).self, '', 'parent thing') ---printTableStart(mumThing.__values[key], '', 'stufflet') ---printTableStart(getmetatable(mumThing.__values[key]), '', 'stufflet metatable?') ---printTableStart(getmetatable(mumThing.__values[key]).self, '', 'stufflet thing?') - mumThing.self.stuff[key] = {names={key}, types={'table'}, parent=mumThing.__values[key], stuff=getmetatable(mumThing.__values[key]).self, } - + local newThing = copy(parent, key) + rawset(mumThing.__values, key, newThing) + thingy = {names={key}, types={'table'}, parent=newThing, stuff=getmetatable(newThing).self.stuff, } + setmetatable(thingy, {__index = Thing}) -- To pick up isValid, pattern, and the other stuff by default. + mumThing.self.stuff[key] = thingy end end @@ -556,8 +550,6 @@ print('__newindex NEW stufflet ' .. key) local name = thingy.names[1] local valueMeta ---printTableStart(thingy, '', 'thingy') - if 'table' == type(value) then -- Coz setting it via mumThing screws with the __index stuff somehow. local oldValue = mumThing.__values[name] -- cgit v1.1