aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/skang.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-30 04:26:37 +1000
committerDavid Walter Seikel2014-03-30 04:26:37 +1000
commit21b92a37ccc2b4645f8e3e759384f95bf55d0f63 (patch)
treeb7f25ece5514d0d3e695ba0b33e779796836c55a /ClientHamr/GuiLua/skang.lua
parentLocal thing -> thingy, plus a few minor cleanups around that. (diff)
downloadSledjHamr-21b92a37ccc2b4645f8e3e759384f95bf55d0f63.zip
SledjHamr-21b92a37ccc2b4645f8e3e759384f95bf55d0f63.tar.gz
SledjHamr-21b92a37ccc2b4645f8e3e759384f95bf55d0f63.tar.bz2
SledjHamr-21b92a37ccc2b4645f8e3e759384f95bf55d0f63.tar.xz
Clean up some Thing oddness.
Diffstat (limited to 'ClientHamr/GuiLua/skang.lua')
-rw-r--r--ClientHamr/GuiLua/skang.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index 6588c1d..9b31dbe 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -58,7 +58,7 @@ do -- Only I'm not gonna indent this.
58 58
59 59
60-- There is no ThingSpace, or Stuff, now it's all just in this meta table. Predefined here coz moduleBegin references Thing. 60-- There is no ThingSpace, or Stuff, now it's all just in this meta table. Predefined here coz moduleBegin references Thing.
61Thing = {} 61local Thing = {}
62 62
63 63
64-- TODO - This needs to be expanded a bit to cover things like 1.42 64-- TODO - This needs to be expanded a bit to cover things like 1.42
@@ -138,10 +138,6 @@ moduleBegin = function (name, author, copyright, version, timestamp, skin, isLua
138 -- Next question, does this screw with the environment of the skang module? No it doesn't, coz that's set up at require 'skang' time. 138 -- Next question, does this screw with the environment of the skang module? No it doesn't, coz that's set up at require 'skang' time.
139 end 139 end
140 140
141 local thing = {}
142 thing.names = {name}
143 setmetatable(_M, thing)
144
145 print('Loaded module ' .. _M._NAME .. ' version ' .. _M.VERSION .. ', ' .. _M.COPYRIGHT .. '.\n ' .. _M.VERSION_DESC) 141 print('Loaded module ' .. _M._NAME .. ' version ' .. _M.VERSION .. ', ' .. _M.COPYRIGHT .. '.\n ' .. _M.VERSION_DESC)
146 142
147 return _M 143 return _M
@@ -523,18 +519,23 @@ thing = function (names, ...)
523 local oldNames = {} 519 local oldNames = {}
524 520
525 -- TODO - Double check this comment - No need to bitch and return if no names, this will crash for us. 521 -- TODO - Double check this comment - No need to bitch and return if no names, this will crash for us.
526 local module = params.module or params[8] or getfenv(2) 522
523 -- Grab the environment of the calling function if no module was passed in.
524 local module = (params.module or params[8]) or getfenv(2)
527 local modThing = getmetatable(module) 525 local modThing = getmetatable(module)
528 if nil == modThing then 526 if nil == modThing then
529 modThing = {} 527 modThing = {}
528 modThing.names = {module._NAME}
530 setmetatable(module, modThing) 529 setmetatable(module, modThing)
531 end 530 end
532 -- Coz at module creation time, Thing is an empty table, and setmetatable(modThing, {__index = Thing}) doesn't do the same thing. 531 -- Coz at module creation time, Thing is an empty table, and setmetatable(modThing, {__index = Thing}) doesn't do the same thing.
533 -- Also, module might not be an actual module, this might be Stuff. 532 -- Also, module might not be an actual module, this might be Stuff.
534 if nil == modThing.__stuff then 533 if nil == modThing.__stuff then
535 for k, v in pairs(Thing) do 534-- setmetatable(modThing, {__index = Thing})
536 modThing[k] = modThing[k] or v 535 modThing.__stuff = {}
537 end 536 modThing.__values = {}
537 modThing.__index = Thing.__index
538 modThing.__newindex = Thing.__newindex
538 end 539 end
539 540
540 local thingy = modThing.__stuff[name] 541 local thingy = modThing.__stuff[name]