aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LSL.lua38
1 files changed, 27 insertions, 11 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua
index b8e2d4b..676f4ad 100644
--- a/LuaSL/src/LSL.lua
+++ b/LuaSL/src/LSL.lua
@@ -26,6 +26,15 @@ upvalue--either way is a bit more efficient and less error prone.
26local LSL = {}; 26local LSL = {};
27local SID = ""; 27local SID = "";
28local scriptName = ""; 28local scriptName = "";
29local running = true
30local paused = false
31
32
33-- Stuff called from the wire protocol has to be global, but I think this means just global to this file.
34function stop() paused = true end
35function result(...) return {...} end
36function quit() running = false end
37
29 38
30-- Debugging aids 39-- Debugging aids
31 40
@@ -102,11 +111,24 @@ function mt.callAndWait(name, ...)
102 local func = functions[name] 111 local func = functions[name]
103 112
104 mt.callAndReturn(name, ...); 113 mt.callAndReturn(name, ...);
105 114 -- Eventually a sendForth() is called, which should end up passing through SendToChannel().
106--[[ TODO - do a luaproc sync receive() waiting for the result. 115 -- Wait for the result, which should be something like - result({x=0.45, y=0.6, z=1.8})
107 Eventually a sendForth() is called, which should end up passing through SendToChannel(). 116 local message = luaproc.receive(SID)
108 The format of the result should be something like - SID.result({x=0.45, y=0.6, z=1.8}) 117 if message then
109]] 118 result, errorMsg = loadstring(message) -- "The environment of the returned function is the global environment." Though normally, a function inherits it's environment from the function creating it. Which is what we want. lol
119 if nil == result then
120 msg("Not a valid result: " .. message .. " ERROR MESSAGE: " .. errorMsg)
121 else
122 -- Set the functions environment to ours, for the protection of the script, coz loadstring sets it to the global environment instead.
123 setfenv(result, getfenv(1))
124 status, result = pcall(result)
125 if not status then
126 msg("Error from result: " .. message .. " ERROR MESSAGE: " .. result)
127 elseif result then
128 return result
129 end
130 end
131 end
110 132
111 if "float" == func.Type then return 0.0 133 if "float" == func.Type then return 0.0
112 elseif "integer" == func.Type then return 0 134 elseif "integer" == func.Type then return 0
@@ -591,12 +613,6 @@ function LSL.postIncrement(name) local temp = _G[name]; _G[name] = _G[name] + 1;
591-- State stuff 613-- State stuff
592 614
593local currentState = {} 615local currentState = {}
594local running = true
595local paused = false
596
597-- Stuff called from the wire protocol has to be global, but I think this means just global to this file.
598function stop() paused = true end
599function quit() running = false end
600 616
601function LSL.stateChange(x) 617function LSL.stateChange(x)
602 if currentState ~= x then -- Changing to the same state is a NOP. 618 if currentState ~= x then -- Changing to the same state is a NOP.