aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-20 05:24:24 +1000
committerDavid Walter Seikel2014-04-20 05:24:24 +1000
commite101059595b6003d42cbc033675a24c7f2a387a2 (patch)
treea1c19f41da3e6de5cbf498b98f1acf132cee7325 /ClientHamr
parentFor the module command, make the loaded module global. (diff)
downloadSledjHamr-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 'ClientHamr')
-rw-r--r--ClientHamr/GuiLua/skang.lua5
-rw-r--r--ClientHamr/GuiLua/test.lua8
-rw-r--r--ClientHamr/GuiLua/test.skang9
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)
362print(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
5local skang = require 'skang' 5local skang = require 'skang'
6local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ 6local _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
14print('code') 12print('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
9local win = skang.window(500, 500, "G'day planet.", 'testWindow') 7local 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
13skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'} 11skang.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' 13test.bar = 'things'
16this.bar = 'things' 14test.ffunc(1, 'two')
17this.ffunc(1, 'two')