aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr
diff options
context:
space:
mode:
Diffstat (limited to 'ClientHamr')
-rw-r--r--ClientHamr/GuiLua/test.lua59
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 @@
1local 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.
2local result = {}; 2-- By virtue of the fact we are stuffing our result into package.loaded[], just plain running this works as "loading the module".
3result.author = 'onefang' 3-- TODO - Except for the "passing the name in as ..." part. B-(
4result.version = '0.72 alpha 2004-11-19 16:28:00' 4do -- Only I'm not gonna indent this.
5local bar 5
6-- The first argument would be the name of a local variable / method. Which could be accessed via _G? 6local 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-)
8result.bar = skang.newParam('bar', "Required", "Shortcut", "Default", "Help text") 8local _M = skang.moduleBegin('test', 'David Seikel', '2014', '0.0', '2014-03-19 14:01:00', [[
9result.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
14local widget = require 'widget'
15-- local other = require 'otherPackageName'
16
17skang.clear
18skang.window(200, 200, "G'day planet.")
19
20quitter = widget.button('Quit', 0.5, 0.5, 0.5, 0.5)
21quitter:action('quit') -- 'quit' is looked up in ThingSpace.commands, and translated into the Lua 'skang.quit()'.
22
23--other.foo = 'stuff'
24this.bar = 'things'
25this.func(1, 'two')
26]])
27
28
29print('code')
30
31-- A variable that is private to this module.
32local foo
33
34skang.newParam(_M, 'bar', "Required", "Shortcut", "Default", "Help text")
35
36-- We can use inline functions if we don't need the function internally.
37skang.newCommand(_M, 'func', 'number,data', 'Help Text', function (arg1, arg2)
10-- do something here 38-- do something here
11end) 39end)
12 40
13-- do something here
14 41
15return result; 42print('Ending soon')
43
44skang.moduleEnd(_M)
45
46end
47
48
49-- Test it.
50local skang = require 'skang'
51local test = package.loaded['test']
52print('End ' .. test.bar .. ' ' .. test.VERSION .. ' ' .. skang.ThingSpace.commands.func.help)