From 21b92a37ccc2b4645f8e3e759384f95bf55d0f63 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 30 Mar 2014 04:26:37 +1000 Subject: Clean up some Thing oddness. --- ClientHamr/GuiLua/skang.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'ClientHamr/GuiLua/skang.lua') 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. -- There is no ThingSpace, or Stuff, now it's all just in this meta table. Predefined here coz moduleBegin references Thing. -Thing = {} +local Thing = {} -- 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 -- 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. end - local thing = {} - thing.names = {name} - setmetatable(_M, thing) - print('Loaded module ' .. _M._NAME .. ' version ' .. _M.VERSION .. ', ' .. _M.COPYRIGHT .. '.\n ' .. _M.VERSION_DESC) return _M @@ -523,18 +519,23 @@ thing = function (names, ...) local oldNames = {} -- TODO - Double check this comment - No need to bitch and return if no names, this will crash for us. - local module = params.module or params[8] or getfenv(2) + + -- Grab the environment of the calling function if no module was passed in. + local module = (params.module or params[8]) or getfenv(2) local modThing = getmetatable(module) if nil == modThing then modThing = {} + modThing.names = {module._NAME} setmetatable(module, modThing) end -- Coz at module creation time, Thing is an empty table, and setmetatable(modThing, {__index = Thing}) doesn't do the same thing. -- Also, module might not be an actual module, this might be Stuff. if nil == modThing.__stuff then - for k, v in pairs(Thing) do - modThing[k] = modThing[k] or v - end +-- setmetatable(modThing, {__index = Thing}) + modThing.__stuff = {} + modThing.__values = {} + modThing.__index = Thing.__index + modThing.__newindex = Thing.__newindex end local thingy = modThing.__stuff[name] -- cgit v1.1