diff options
author | David Walter Seikel | 2014-03-30 15:39:03 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-03-30 15:39:03 +1000 |
commit | 1826d93467341dec9947e0592bc1e9b7deddcf51 (patch) | |
tree | c236e17d1f20349b28ffd73e69e9eef6214f2e56 /ClientHamr | |
parent | Various fixes, mostly to do with stufflets, which are still slightly broken. (diff) | |
download | SledjHamr-1826d93467341dec9947e0592bc1e9b7deddcf51.zip SledjHamr-1826d93467341dec9947e0592bc1e9b7deddcf51.tar.gz SledjHamr-1826d93467341dec9947e0592bc1e9b7deddcf51.tar.bz2 SledjHamr-1826d93467341dec9947e0592bc1e9b7deddcf51.tar.xz |
Fix up using aliases in Stufflets, plus it helps if the alias is in the right call. lol
Diffstat (limited to 'ClientHamr')
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 13 | ||||
-rw-r--r-- | ClientHamr/GuiLua/test.lua | 13 |
2 files changed, 15 insertions, 11 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index a742845..e0123fb 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -479,10 +479,15 @@ Thing.__newindex = function (module, key, value) | |||
479 | local valueMeta | 479 | local valueMeta |
480 | if 'table' == type(value) then | 480 | if 'table' == type(value) then |
481 | -- Coz setting it via modThing screws with the __index stuff somehow. | 481 | -- Coz setting it via modThing screws with the __index stuff somehow. |
482 | valueMeta = getmetatable(modThing.__values[name]) | 482 | local oldValue = modThing.__values[name] |
483 | if valueMeta then | 483 | if 'table' == type(oldValue) then |
484 | for k, v in pairs(value) do | 484 | valueMeta = getmetatable(oldValue) |
485 | valueMeta.__values[k] = v | 485 | if valueMeta then |
486 | for k, v in pairs(value) do | ||
487 | local newK = valueMeta.__stuff[k] | ||
488 | if newK then newK = newK.names[1] else newK = k end | ||
489 | valueMeta.__values[newK] = v | ||
490 | end | ||
486 | end | 491 | end |
487 | end | 492 | end |
488 | end | 493 | end |
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index d74e22c..9f98520 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua | |||
@@ -125,8 +125,8 @@ skang.thing{'a', module=stuff, help = 'A test stufflet'} | |||
125 | skang.thing{'b', module=stuff.t, help = 'A sub stufflet'} | 125 | skang.thing{'b', module=stuff.t, help = 'A sub stufflet'} |
126 | skang.thing{'c', module=stuff.t, help = 'Another sub stufflet'} | 126 | skang.thing{'c', module=stuff.t, help = 'Another sub stufflet'} |
127 | skang.thing{'s', module=stuff, help = 'A Stuff', types='table'} | 127 | skang.thing{'s', module=stuff, help = 'A Stuff', types='table'} |
128 | skang.thing{'sa', module=stuff.s, help = 'A stufflet in a Stuff'} | 128 | skang.thing{'sa,a', module=stuff.s, help = 'A stufflet in a Stuff'} |
129 | skang.thing{'sb', module=stuff.s, help = 'Another stufflet in a Stuff'} | 129 | skang.thing{'sb,b', module=stuff.s, help = 'Another stufflet in a Stuff'} |
130 | 130 | ||
131 | print('*********************************') | 131 | print('*********************************') |
132 | skang.fixNames(skang, 'skang') | 132 | skang.fixNames(skang, 'skang') |
@@ -140,11 +140,12 @@ print(skang.get(stuff, 'a', 'help')) | |||
140 | print(skang.get(stuff.t, 'b', 'help')) | 140 | print(skang.get(stuff.t, 'b', 'help')) |
141 | print(skang.get(stuff.t, 'c', 'help')) | 141 | print(skang.get(stuff.t, 'c', 'help')) |
142 | print(skang.get(stuff, 's', 'help')) | 142 | print(skang.get(stuff, 's', 'help')) |
143 | print(skang.get(stuff.s, 'sa,a', 'help')) | 143 | print(skang.get(stuff.s, 'sa', 'help')) |
144 | print(skang.get(stuff.s, 'sb,b', 'help')) | 144 | print(skang.get(stuff.s, 'sb', 'help')) |
145 | skang.thing{'baz,b', module=test, help = 'A test stufflet for test'} | 145 | skang.thing{'baz,b', module=test, help = 'A test stufflet for test'} |
146 | print(skang.get(test, 'b', 'help')) | 146 | print(skang.get(test, 'b', 'help')) |
147 | print(skang.get(test, 'f', 'help')) | 147 | print(skang.get(test, 'f', 'help')) |
148 | --skang.printTableStart(getmetatable(stuff.s), '', 'stuff.s metatable') | ||
148 | -- Should fail isValid() | 149 | -- Should fail isValid() |
149 | stuff.a = 1 | 150 | stuff.a = 1 |
150 | stuff.t.b = '2' | 151 | stuff.t.b = '2' |
@@ -154,12 +155,10 @@ test.f = 5 | |||
154 | test_c.cbar = '666' | 155 | test_c.cbar = '666' |
155 | -- This one doesn't actually exist. | 156 | -- This one doesn't actually exist. |
156 | test_c.bar = '7' | 157 | test_c.bar = '7' |
157 | -- The sa should fail isValid() | ||
158 | stuff.s.sa = true | 158 | stuff.s.sa = true |
159 | stuff.s.sb = 22 | 159 | stuff.s.sb = 22 |
160 | -- TODO - This one should fail, but doesn't. It goes through to the real stuff.s table. | ||
161 | stuff.s.b = 33 | 160 | stuff.s.b = 33 |
162 | -- TODO - And the 'a' one just gets dropped. | 161 | -- NOTE - This triggers isValid twice for each table element. |
163 | stuff.s = {a=8, sb='9'} | 162 | stuff.s = {a=8, sb='9'} |
164 | stuff.s.sb = 44 | 163 | stuff.s.sb = 44 |
165 | print('') | 164 | print('') |