diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LSL.lua | 25 |
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 |
12 | A related note on C code: The luaL_register [9] function in C is | 15 | A 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 | ||
293 | function LSL.llMessageLinked(--[[integer]] link,--[[integer]] num, --[[string]] text, --[[key]] aKey) end; | 296 | function LSL.llMessageLinked(--[[integer]] link,--[[integer]] num, --[[string]] text, --[[key]] aKey) end; |
294 | 297 | ||
298 | function LSL.preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end; | ||
299 | function LSL.preIncrement(name) _G[name] = _G[name] + 1; return _G[name]; end; | ||
300 | function LSL.postDecrement(name) local temp = _G[name]; _G[name] = _G[name] - 1; return temp; end; | ||
301 | function LSL.postIncrement(name) local temp = _G[name]; _G[name] = _G[name] + 1; return temp; end; | ||
302 | |||
303 | local currentState = {} | ||
304 | function 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 | ||
312 | end; | ||
313 | |||
295 | 314 | ||
296 | return LSL; | 315 | return LSL; |
297 | 316 | ||