aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LSL.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-04 20:49:07 +1000
committerDavid Walter Seikel2012-02-04 20:49:07 +1000
commit02d2afee7e161f69e38900e60f191186262cbb8c (patch)
tree2ab46040fb0376e1909ce6749219d410f20729cb /LuaSL/src/LSL.lua
parentAdd LSL.lua module, with the constants and functions in it. Functions are ju... (diff)
downloadSledjHamr-02d2afee7e161f69e38900e60f191186262cbb8c.zip
SledjHamr-02d2afee7e161f69e38900e60f191186262cbb8c.tar.gz
SledjHamr-02d2afee7e161f69e38900e60f191186262cbb8c.tar.bz2
SledjHamr-02d2afee7e161f69e38900e60f191186262cbb8c.tar.xz
Move the predefined Lua stuff into the new LSL.lua module, then actualy use it.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LSL.lua25
1 files changed, 22 insertions, 3 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua
index 7557668..cc9b454 100644
--- a/LuaSL/src/LSL.lua
+++ b/LuaSL/src/LSL.lua
@@ -1,12 +1,15 @@
1-- A module of LSL stuffs. 1-- A module of LSL stuffs.
2-- TODO - currently there is a constants.lsl file. Move it into here. 2-- TODO - currently there is a constants.lsl file. Move it into here.
3-- It contains LSL constants and ll*() functions stubs. 3-- It contains LSL constants and ll*() functions stubs.
4-- The compiler compiles this into a LSL_Scripts structure at startup, 4-- The compiler compiles that into a LSL_Scripts structure at startup,
5-- then uses that for function and variable lookups, as well as looking up in the current script. 5-- then uses that for function and variable lookups, as well as looking up in the current script.
6-- Using a module means it gets compiled each time? Maybe not if I can use bytecode files. Perhaps LuaJIT caches these? 6-- I can run this at compiler startup time, then iterate through the LSL table from C to generate that LSL_Script structure.
7
8-- Using a module means it gets compiled each time? Maybe not if I can use bytecode files. Perhaps LuaJIT caches these?
9-- Does not seem to be slowing it down noticably, but that might change once the stubs are filled out.
7 10
8-- Use it like this - 11-- Use it like this -
9-- local lsl = require 'lsl' 12-- local _LSL = require 'LSL'
10 13
11--[[ From http://lua-users.org/wiki/LuaModuleFunctionCritiqued 14--[[ From http://lua-users.org/wiki/LuaModuleFunctionCritiqued
12A related note on C code: The luaL_register [9] function in C is 15A related note on C code: The luaL_register [9] function in C is
@@ -292,6 +295,22 @@ function LSL.llWhisper(--[[integer]] channel, --[[string]] text) end;
292 295
293function LSL.llMessageLinked(--[[integer]] link,--[[integer]] num, --[[string]] text, --[[key]] aKey) end; 296function LSL.llMessageLinked(--[[integer]] link,--[[integer]] num, --[[string]] text, --[[key]] aKey) end;
294 297
298function LSL.preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end;
299function LSL.preIncrement(name) _G[name] = _G[name] + 1; return _G[name]; end;
300function LSL.postDecrement(name) local temp = _G[name]; _G[name] = _G[name] - 1; return temp; end;
301function LSL.postIncrement(name) local temp = _G[name]; _G[name] = _G[name] + 1; return temp; end;
302
303local currentState = {}
304function LSL.stateChange(x)
305 if nil ~= currentState.state_exit then
306 currentState.state_exit();
307 end
308 currentState = x;
309 if nil ~= currentState.state_entry then
310 currentState.state_entry();
311 end
312end;
313
295 314
296return LSL; 315return LSL;
297 316