diff options
author | David Walter Seikel | 2012-02-05 16:38:50 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-05 16:38:50 +1000 |
commit | 53fe89764f8f679f3f4cbaa39c2393918898815f (patch) | |
tree | 6e6889754e1292d48ce407e2ba93b9bea4f827f6 /LuaSL/src/LSL.lua | |
parent | A commented out debuggie that I might need later. (diff) | |
download | SledjHamr-53fe89764f8f679f3f4cbaa39c2393918898815f.zip SledjHamr-53fe89764f8f679f3f4cbaa39c2393918898815f.tar.gz SledjHamr-53fe89764f8f679f3f4cbaa39c2393918898815f.tar.bz2 SledjHamr-53fe89764f8f679f3f4cbaa39c2393918898815f.tar.xz |
Implement the script main loop, and the script UUID, which we call SID, though for now it's only the file name.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LSL.lua | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua index 0b02077..975f219 100644 --- a/LuaSL/src/LSL.lua +++ b/LuaSL/src/LSL.lua | |||
@@ -335,16 +335,40 @@ function LSL.stateChange(x) | |||
335 | end | 335 | end |
336 | end; | 336 | end; |
337 | 337 | ||
338 | function LSL.mainLoop(x) | 338 | function LSL.mainLoop(SID, x) |
339 | -- TODO - disabled the stuff that waits until I implement the stuff that makes it stop waiting. lol | ||
340 | local sid = SID .. ".events" | ||
341 | local status, errorMsg = "disabled" -- = luaproc.newchannel(sid) | ||
342 | local result | ||
343 | |||
344 | if not status then | ||
345 | print("Can't open the luaproc channel " .. sid .. " ERROR MESSAGE: " .. errorMsg) | ||
346 | return | ||
347 | end | ||
348 | |||
339 | LSL.stateChange(x); | 349 | LSL.stateChange(x); |
340 | --[[ TODO - | 350 | |
341 | Sits around waiting for events. This should be "wait for a message" in luaproc. | 351 | -- TODO - Need a FIFO stack of incoming events. Which will be in the C main thread, coz that's listening on the socket for us. |
342 | Incoming events can be the same format as the OpenSim SID.event.* protocol on the wiki. | 352 | |
343 | When we get an event, run it, then go back to waiting. | 353 | -- while true do |
344 | 354 | local message = luaproc.receive(sid) | |
345 | Need a FIFO stack of incoming events. | 355 | if message then |
346 | Which will be in the C main thread, coz that's listening on the socket for us. | 356 | result, errorMsg = loadstring(message) |
347 | ]] | 357 | if nil == result then |
358 | print("Not a valid event: " .. message .. " ERROR MESSAGE: " .. errorMsg) | ||
359 | else | ||
360 | status, result = pcall(result()) | ||
361 | if not status then | ||
362 | print("Error from event: " .. message .. " ERROR MESSAGE: " .. result) | ||
363 | elseif result then | ||
364 | status, errorMsg = luaproc.send(sid, result) | ||
365 | if not status then | ||
366 | print("Error sending results from event: " .. message .. " ERROR MESSAGE: " .. errorMsg) | ||
367 | end | ||
368 | end | ||
369 | end | ||
370 | end | ||
371 | -- end | ||
348 | end | 372 | end |
349 | 373 | ||
350 | -- Typecasting stuff. | 374 | -- Typecasting stuff. |