diff options
author | David Walter Seikel | 2014-03-27 00:00:54 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-03-27 00:00:54 +1000 |
commit | 67f822eeb04229c06b42297675cfa53bdcb414de (patch) | |
tree | 6b32a4cf4df1791ea13d2e5b9522c01bb48d12c8 | |
parent | More Stuff notes. (diff) | |
download | SledjHamr-67f822eeb04229c06b42297675cfa53bdcb414de.zip SledjHamr-67f822eeb04229c06b42297675cfa53bdcb414de.tar.gz SledjHamr-67f822eeb04229c06b42297675cfa53bdcb414de.tar.bz2 SledjHamr-67f822eeb04229c06b42297675cfa53bdcb414de.tar.xz |
No need to pass module to skang.thing(), it can work it out.
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 17 | ||||
-rw-r--r-- | ClientHamr/GuiLua/test.lua | 7 |
2 files changed, 14 insertions, 10 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index e81c598..adf4edf 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -304,7 +304,10 @@ end | |||
304 | -- required - "boolean" to say if this thing is required. TODO - Maybe fold this into types somehow, or acl? | 304 | -- required - "boolean" to say if this thing is required. TODO - Maybe fold this into types somehow, or acl? |
305 | -- acl - Access Control List defining security restrains. | 305 | -- acl - Access Control List defining security restrains. |
306 | -- boss - the Thing or person that owns this Thing, otherwise it is self owned. | 306 | -- boss - the Thing or person that owns this Thing, otherwise it is self owned. |
307 | thing = function (module, names, help, default, types, widget, required, acl, boss) | 307 | thing = function (names, help, default, types, widget, required, acl, boss) |
308 | -- Grad the environment of the calling function, so this new thing automatically becomes a global in it. | ||
309 | module = getfenv(2) | ||
310 | |||
308 | -- Break out the names. | 311 | -- Break out the names. |
309 | local n = {} | 312 | local n = {} |
310 | local i = 1 | 313 | local i = 1 |
@@ -382,12 +385,12 @@ end | |||
382 | quit = function () | 385 | quit = function () |
383 | end | 386 | end |
384 | 387 | ||
385 | thing(_M, 'nada', 'Do nothing.', nada) | 388 | thing('nada', 'Do nothing.', nada) |
386 | thing(_M, 'clear', 'The current skin is cleared of all widgets.', clear) | 389 | thing('clear', 'The current skin is cleared of all widgets.', clear) |
387 | thing(_M, 'window', 'The size and title of the application Frame.', window, 'x,y,name', nil, nil, 'GGG') | 390 | thing('window', 'The size and title of the application Frame.', window, 'x,y,name', nil, nil, 'GGG') |
388 | thing(_M, 'module', 'Load a module.', module, 'file,acl') | 391 | thing('module', 'Load a module.', module, 'file,acl') |
389 | thing(_M, 'skang', 'Parse the contents of a skang file or URL.', skang, 'URL') | 392 | thing('skang', 'Parse the contents of a skang file or URL.', skang, 'URL') |
390 | thing(_M, 'quit', 'Quit, exit, remove thyself.', quit) | 393 | thing('quit', 'Quit, exit, remove thyself.', quit) |
391 | 394 | ||
392 | 395 | ||
393 | moduleEnd(_M) | 396 | moduleEnd(_M) |
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index 6a38cde..5a5fda1 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua | |||
@@ -30,11 +30,12 @@ print('code') | |||
30 | -- A variable that is private to this module. | 30 | -- A variable that is private to this module. |
31 | local foo | 31 | local foo |
32 | 32 | ||
33 | skang.thing(_M, 'fooble,f', 'Help text goes here', 1, 'number', '"edit", "The fooble:", 1, 1, 10, 50', true) | 33 | skang.thing('fooble,f', 'Help text goes here', 1, 'number', '"edit", "The fooble:", 1, 1, 10, 50', true) |
34 | skang.thing(_M, 'bar', 'Help text', "Default") | 34 | skang.thing('bar', 'Help text', "Default") |
35 | skang.thing('foo') | ||
35 | 36 | ||
36 | -- We can use inline functions if we don't need the function internally. | 37 | -- We can use inline functions if we don't need the function internally. |
37 | skang.thing(_M, 'ffunc', 'Help Text', function (arg1, arg2) | 38 | skang.thing('ffunc', 'Help Text', function (arg1, arg2) |
38 | print('Inside test.ffunc ' .. arg1 .. ', ' .. arg2) | 39 | print('Inside test.ffunc ' .. arg1 .. ', ' .. arg2) |
39 | end, 'number,string') | 40 | end, 'number,string') |
40 | 41 | ||