aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-30 04:47:19 +1000
committerDavid Walter Seikel2014-03-30 04:47:19 +1000
commit384bdb9e30644b37d0d14d89a855351768c5ad1c (patch)
treec38aac10d9a9d98e3b68b8566f6f901da76deb51
parentFix "can't store non Things in a Thing controlled module." bug. (diff)
downloadSledjHamr-384bdb9e30644b37d0d14d89a855351768c5ad1c.zip
SledjHamr-384bdb9e30644b37d0d14d89a855351768c5ad1c.tar.gz
SledjHamr-384bdb9e30644b37d0d14d89a855351768c5ad1c.tar.bz2
SledjHamr-384bdb9e30644b37d0d14d89a855351768c5ad1c.tar.xz
Notes about metatable usage, and limitations from Lua.
-rw-r--r--ClientHamr/GuiLua/skang.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index aa3e084..e3c2612 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -528,11 +528,13 @@ thing = function (names, ...)
528 if nil == modThing then 528 if nil == modThing then
529 modThing = {} 529 modThing = {}
530 modThing.names = {module._NAME} 530 modThing.names = {module._NAME}
531 -- This is how the Thing is stored with the module.
531 setmetatable(module, modThing) 532 setmetatable(module, modThing)
532 end 533 end
533 -- Coz at module creation time, Thing is an empty table, and setmetatable(modThing, {__index = Thing}) doesn't do the same thing. 534 -- Coz at module creation time, Thing is an empty table, and setmetatable(modThing, {__index = Thing}) doesn't do the right thing.
534 -- Also, module might not be an actual module, this might be Stuff. 535 -- Also, module might not be an actual module, this might be Stuff.
535 if nil == modThing.__stuff then 536 if nil == modThing.__stuff then
537 -- Seems this does not deal with __index and __newindex, and also screws up __stuff somehow.
536-- setmetatable(modThing, {__index = Thing}) 538-- setmetatable(modThing, {__index = Thing})
537 modThing.__stuff = {} 539 modThing.__stuff = {}
538 modThing.__values = {} 540 modThing.__values = {}
@@ -546,6 +548,7 @@ thing = function (names, ...)
546 thingy = {} 548 thingy = {}
547 thingy.module = module 549 thingy.module = module
548 thingy.names = names 550 thingy.names = names
551 -- To pick up isValid, pattern, and the other stuff.
549 setmetatable(thingy, {__index = Thing}) 552 setmetatable(thingy, {__index = Thing})
550 end 553 end
551 554