diff options
author | David Walter Seikel | 2014-04-20 05:24:24 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-04-20 05:24:24 +1000 |
commit | e101059595b6003d42cbc033675a24c7f2a387a2 (patch) | |
tree | a1c19f41da3e6de5cbf498b98f1acf132cee7325 | |
parent | For the module command, make the loaded module global. (diff) | |
download | SledjHamr-e101059595b6003d42cbc033675a24c7f2a387a2.zip SledjHamr-e101059595b6003d42cbc033675a24c7f2a387a2.tar.gz SledjHamr-e101059595b6003d42cbc033675a24c7f2a387a2.tar.bz2 SledjHamr-e101059595b6003d42cbc033675a24c7f2a387a2.tar.xz |
Have the skin loader add the correct require line, and fix up test to suit.
Diffstat (limited to '')
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 5 | ||||
-rw-r--r-- | ClientHamr/GuiLua/test.lua | 8 | ||||
-rw-r--r-- | ClientHamr/GuiLua/test.skang | 9 |
3 files changed, 8 insertions, 14 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index af315e3..4fb84f1 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -144,7 +144,7 @@ moduleBegin = function (name, author, copyright, version, timestamp, skin, isLua | |||
144 | f:close() | 144 | f:close() |
145 | end | 145 | end |
146 | if skin then | 146 | if skin then |
147 | skin = "local skang = require 'skang'\nlocal this = require 'test'\n" .. skin | 147 | skin = "local skang = require 'skang'\nlocal " .. name .. " = require '" .. name .. "'\n" .. skin |
148 | if nil == mainSkin._NAME then mainSkin = _M end | 148 | if nil == mainSkin._NAME then mainSkin = _M end |
149 | end | 149 | end |
150 | _M.DEFAULT_SKANG = skin | 150 | _M.DEFAULT_SKANG = skin |
@@ -358,8 +358,7 @@ moduleEnd = function (module) | |||
358 | 358 | ||
359 | -- Run the main skin, which is the first skin that is defined. In theory, the skin from the main module. | 359 | -- Run the main skin, which is the first skin that is defined. In theory, the skin from the main module. |
360 | if mainSkin == module then | 360 | if mainSkin == module then |
361 | print("~~~~~~~~~~~~~~~~~RUNNING SKIN FOR " .. module._NAME) | 361 | print("RUNNING SKIN FOR " .. module._NAME) |
362 | print(module.DEFAULT_SKANG .. '\n~~~~~~~~~~~~~~~~~') | ||
363 | local skin, err = loadstring(module.DEFAULT_SKANG) | 362 | local skin, err = loadstring(module.DEFAULT_SKANG) |
364 | if skin then | 363 | if skin then |
365 | setfenv(skin, getfenv(2)) | 364 | setfenv(skin, getfenv(2)) |
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua index 65e686f..705f7ad 100644 --- a/ClientHamr/GuiLua/test.lua +++ b/ClientHamr/GuiLua/test.lua | |||
@@ -4,11 +4,9 @@ do -- Only I'm not gonna indent this. | |||
4 | 4 | ||
5 | local skang = require 'skang' | 5 | local skang = require 'skang' |
6 | local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ | 6 | local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ |
7 | 7 | local win = skang.window(500, 500, "G'day planet.", 'testWindow') | |
8 | skang.clear | 8 | skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} |
9 | skang.window(200, 200, "G'day planet.") | 9 | win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translat 'quit' into the Lua 'skang.quit()'? |
10 | quitter = skang.button('Quit', 0.5, 0.5, 0.5, 0.5) | ||
11 | quitter:action('quit') | ||
12 | ]]) | 10 | ]]) |
13 | 11 | ||
14 | print('code') | 12 | print('code') |
diff --git a/ClientHamr/GuiLua/test.skang b/ClientHamr/GuiLua/test.skang index 518207b..de417da 100644 --- a/ClientHamr/GuiLua/test.skang +++ b/ClientHamr/GuiLua/test.skang | |||
@@ -1,9 +1,7 @@ | |||
1 | #!/usr/bin/env skang -l test -- Lua allows this shell hack. | 1 | #!/usr/bin/env skang -l test -- Lua allows this shell hack. |
2 | 2 | ||
3 | -- There's an implied local this = require 'test' | ||
4 | -- There's an implied local skang = require 'skang' | 3 | -- There's an implied local skang = require 'skang' |
5 | 4 | -- There's an implied local test = require 'test' | |
6 | -- local other = require 'otherPackageName' | ||
7 | 5 | ||
8 | -- This is a bit more verbose than I wanted. lol | 6 | -- This is a bit more verbose than I wanted. lol |
9 | local win = skang.window(500, 500, "G'day planet.", 'testWindow') | 7 | local win = skang.window(500, 500, "G'day planet.", 'testWindow') |
@@ -12,6 +10,5 @@ win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.c | |||
12 | 10 | ||
13 | skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'} | 11 | skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'} |
14 | 12 | ||
15 | --other.foo = 'stuff' | 13 | test.bar = 'things' |
16 | this.bar = 'things' | 14 | test.ffunc(1, 'two') |
17 | this.ffunc(1, 'two') | ||