From 22cf268c7419eb0477d07af0c78a558ffde845fc Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Apr 2014 07:04:53 +1000 Subject: Load any matching .properties files into a module. --- ClientHamr/GuiLua/skang.lua | 7 ++++++- ClientHamr/GuiLua/test.lua | 2 +- ClientHamr/GuiLua/test.properties | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'ClientHamr/GuiLua') diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index 67df94b..d5622fd 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua @@ -141,7 +141,12 @@ end -- Restore the environment. moduleEnd = function (module) - -- TODO - Look for _NAME.properties, and load it into the modules Things. + -- See if there is a properties file, and run it in the modules environment. + local properties = loadfile(module._NAME .. '.properties') + if properties then + setfenv(properties, getfenv(2)) + properties() + end -- TODO - Parse command line parameters at some point. -- http://stackoverflow.com/questions/3745047/help-locate-c-sample-code-to-read-lua-command-line-arguments if module.isLua then setfenv(2, module.savedEnvironment) end diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index 9de7082..4ddbc1d 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua @@ -27,7 +27,7 @@ this.func(1, 'two') print('code') -- A variable that is private to this module. -local fool +local fool = 22 -- TODO - Could have a table of tables, and ipair through the top level, passing the inner ones to skang.thingasm{}. diff --git a/ClientHamr/GuiLua/test.properties b/ClientHamr/GuiLua/test.properties index 81bdff0..d6d29cb 100644 --- a/ClientHamr/GuiLua/test.properties +++ b/ClientHamr/GuiLua/test.properties @@ -1 +1 @@ -test.foo = 'forty two' +foo = 'forty two' -- cgit v1.1