diff options
Diffstat (limited to 'ClientHamr')
-rw-r--r-- | ClientHamr/GuiLua/test.lua | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index 7e668d2..fdb1448 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua | |||
@@ -1,15 +1,52 @@ | |||
1 | local skang = require('skang') | 1 | -- Wrapping the entire module in do .. end helps if people just join a bunch of modules together, which apparently is popular. |
2 | local result = {}; | 2 | -- By virtue of the fact we are stuffing our result into package.loaded[], just plain running this works as "loading the module". |
3 | result.author = 'onefang' | 3 | -- TODO - Except for the "passing the name in as ..." part. B-( |
4 | result.version = '0.72 alpha 2004-11-19 16:28:00' | 4 | do -- Only I'm not gonna indent this. |
5 | local bar | 5 | |
6 | -- The first argument would be the name of a local variable / method. Which could be accessed via _G? | 6 | local skang = require 'skang' |
7 | -- Not sure if we could use a global bar, AND use it directly. | 7 | --On the other hand, having 'Copyright 2014 David Seikel' here makes the copyright self documenting. B-) |
8 | result.bar = skang.newParam('bar', "Required", "Shortcut", "Default", "Help text") | 8 | local _M = skang.moduleBegin('test', 'David Seikel', '2014', '0.0', '2014-03-19 14:01:00', [[ |
9 | result.func = skang.newCommand('number,data', 'Help Text', function (arg1, arg2) | 9 | #!skang test.skang -- This is Lua, so this might not work. |
10 | |||
11 | -- There's an implied local this = require 'test' | ||
12 | -- There's an implied local skang = require 'skang' | ||
13 | |||
14 | local widget = require 'widget' | ||
15 | -- local other = require 'otherPackageName' | ||
16 | |||
17 | skang.clear | ||
18 | skang.window(200, 200, "G'day planet.") | ||
19 | |||
20 | quitter = widget.button('Quit', 0.5, 0.5, 0.5, 0.5) | ||
21 | quitter:action('quit') -- 'quit' is looked up in ThingSpace.commands, and translated into the Lua 'skang.quit()'. | ||
22 | |||
23 | --other.foo = 'stuff' | ||
24 | this.bar = 'things' | ||
25 | this.func(1, 'two') | ||
26 | ]]) | ||
27 | |||
28 | |||
29 | print('code') | ||
30 | |||
31 | -- A variable that is private to this module. | ||
32 | local foo | ||
33 | |||
34 | skang.newParam(_M, 'bar', "Required", "Shortcut", "Default", "Help text") | ||
35 | |||
36 | -- We can use inline functions if we don't need the function internally. | ||
37 | skang.newCommand(_M, 'func', 'number,data', 'Help Text', function (arg1, arg2) | ||
10 | -- do something here | 38 | -- do something here |
11 | end) | 39 | end) |
12 | 40 | ||
13 | -- do something here | ||
14 | 41 | ||
15 | return result; | 42 | print('Ending soon') |
43 | |||
44 | skang.moduleEnd(_M) | ||
45 | |||
46 | end | ||
47 | |||
48 | |||
49 | -- Test it. | ||
50 | local skang = require 'skang' | ||
51 | local test = package.loaded['test'] | ||
52 | print('End ' .. test.bar .. ' ' .. test.VERSION .. ' ' .. skang.ThingSpace.commands.func.help) | ||