diff options
Diffstat (limited to '')
-rw-r--r-- | lib/LSL.lua | 34 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 5 | ||||
-rw-r--r-- | src/love/love.c | 3 |
3 files changed, 33 insertions, 9 deletions
diff --git a/lib/LSL.lua b/lib/LSL.lua index 6f627e8..f4c7fd4 100644 --- a/lib/LSL.lua +++ b/lib/LSL.lua | |||
@@ -206,7 +206,7 @@ function mt.callAndWait(name, ...) | |||
206 | mt.callAndReturn(name, ...); | 206 | mt.callAndReturn(name, ...); |
207 | -- Eventually a sendForth() is called, which should end up passing through SendToChannel(). | 207 | -- Eventually a sendForth() is called, which should end up passing through SendToChannel(). |
208 | -- Wait for the result, which should be a Lua value as a string. | 208 | -- Wait for the result, which should be a Lua value as a string. |
209 | return waitAndProcess(true) | 209 | return waitAndProcess(true, name, ...) |
210 | end | 210 | end |
211 | 211 | ||
212 | local function newConst(Type, name, value) | 212 | local function newConst(Type, name, value) |
@@ -1982,25 +1982,36 @@ function LSL.mainLoop(sid, name, x) | |||
1982 | LSL.EOF = "EndOfFuckingAround" -- Fix this up now. | 1982 | LSL.EOF = "EndOfFuckingAround" -- Fix this up now. |
1983 | 1983 | ||
1984 | LSL.stateChange(x); | 1984 | LSL.stateChange(x); |
1985 | waitAndProcess(false) | 1985 | waitAndProcess(false, "LSL.mainLoop") |
1986 | -- msg("LSL.Lua: Script quitting " .. scriptName) | 1986 | -- msg("LSL.Lua: Script quitting " .. scriptName) |
1987 | end | 1987 | end |
1988 | 1988 | ||
1989 | function waitAndProcess(returnWanted) | 1989 | function waitAndProcess(returnWanted, name, ...) |
1990 | local Type = "event" | 1990 | local Type = "event" |
1991 | 1991 | ||
1992 | if returnWanted then Type = "result" end | 1992 | if returnWanted then |
1993 | Type = "result" | ||
1994 | if running then | ||
1995 | -- print(">" .. SID .. "_" .. scriptName, " - REQUESTING " .. name) | ||
1996 | else | ||
1997 | -- print("?" .. SID .. "_" .. scriptName, " - STOPPED???? ") | ||
1998 | end | ||
1999 | else | ||
2000 | -- print("." .. SID .. "_" .. scriptName, " waitAndProcess(false, " .. name .. ")") | ||
2001 | end | ||
2002 | |||
1993 | while running do | 2003 | while running do |
1994 | local message = Runnr.receive() | 2004 | local message = Runnr.receive() |
1995 | if message then | 2005 | if message then |
1996 | --print('GOT MESSAGE for script ' .. scriptName .. ' - "' .. message .. '"') | 2006 | --print(" " .. SID .. "_" .. scriptName .. ' GOT MESSAGE - "' .. message .. '"') |
1997 | -- TODO - should we be discarding return values while paused? I don't think so, so we need to process those, | 2007 | -- TODO - should we be discarding return values while paused? I don't think so, so we need to process those, |
1998 | if paused then | 2008 | if paused then |
1999 | if "start()" == message then paused = false end | 2009 | if "start()" == message then paused = false end |
2000 | else | 2010 | else |
2001 | local 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 | 2011 | local 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 |
2002 | if nil == result then | 2012 | if nil == result then |
2003 | msg("Not a valid " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg) | 2013 | msg("Not a valid " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg) |
2014 | -- print("Not a valid " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg) | ||
2004 | else | 2015 | else |
2005 | -- Set the functions environment to ours, for the protection of the script, coz loadstring sets it to the global environment instead. | 2016 | -- Set the functions environment to ours, for the protection of the script, coz loadstring sets it to the global environment instead. |
2006 | -- TODO - On the other hand, we will need the global environment when we call event handlers. So we should probably stash it around here somewhere. | 2017 | -- TODO - On the other hand, we will need the global environment when we call event handlers. So we should probably stash it around here somewhere. |
@@ -2009,11 +2020,14 @@ function waitAndProcess(returnWanted) | |||
2009 | local status, result1 = pcall(result) | 2020 | local status, result1 = pcall(result) |
2010 | if not status then | 2021 | if not status then |
2011 | msg("Error from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. result1) | 2022 | msg("Error from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. result1) |
2023 | print("Error from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. result1) | ||
2012 | elseif result1 then | 2024 | elseif result1 then |
2013 | -- Check if we are waiting for a return, and got it. | 2025 | -- Check if we are waiting for a return, and got it. |
2014 | if returnWanted and string.match(message, "^return ") then | 2026 | if returnWanted and string.match(message, "^return ") then |
2015 | -- print("RETURNING " .. result1) | 2027 | -- print("<" .. SID .. "_" .. scriptName, " - RETURNING " .. type(result1) .. " " .. message .. " TO " .. name) |
2016 | return result1 | 2028 | return result1 |
2029 | else | ||
2030 | -- print("." .. SID .. "_" .. scriptName, " - IGNORING " .. type(result1) .. " " .. message .. " TO " .. name) | ||
2017 | end | 2031 | end |
2018 | -- Otherwise, just run it and keep looping. | 2032 | -- Otherwise, just run it and keep looping. |
2019 | -- TODO - Not sure why I had this here. "sid" is not set anywhere, and SID would just send it to ourselves. | 2033 | -- TODO - Not sure why I had this here. "sid" is not set anywhere, and SID would just send it to ourselves. |
@@ -2021,6 +2035,12 @@ function waitAndProcess(returnWanted) | |||
2021 | -- if not status then | 2035 | -- if not status then |
2022 | -- msg("Error sending results from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg) | 2036 | -- msg("Error sending results from " .. Type .. ": " .. message .. " ERROR MESSAGE: " .. errorMsg) |
2023 | -- end | 2037 | -- end |
2038 | else | ||
2039 | if string.match(message, "^return ") then | ||
2040 | print("!" .. SID .. "_" .. scriptName, " - IN AN ODD PLACE!!!!!" .. message) | ||
2041 | else | ||
2042 | -- print("!" .. SID .. "_" .. scriptName, " - " .. message) | ||
2043 | end | ||
2024 | end | 2044 | end |
2025 | end | 2045 | end |
2026 | end | 2046 | end |
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 7e9d935..f8931e6 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -223,7 +223,7 @@ static Eina_Bool parser(void *data, Connection *connection, char *SID, char *com | |||
223 | gameGlobals *ourGlobals = data; | 223 | gameGlobals *ourGlobals = data; |
224 | char buf[PATH_MAX]; | 224 | char buf[PATH_MAX]; |
225 | 225 | ||
226 | //PD("COMMAND - %s", command); | 226 | //PD("PARSE COMMAND - %s", command); |
227 | if (0 == strncmp(command, "compile(", 8)) | 227 | if (0 == strncmp(command, "compile(", 8)) |
228 | { | 228 | { |
229 | char *temp; | 229 | char *temp; |
@@ -279,7 +279,10 @@ PD("Running script %s", me->fileName); | |||
279 | ecore_main_loop_quit(); | 279 | ecore_main_loop_quit(); |
280 | } | 280 | } |
281 | else | 281 | else |
282 | { | ||
283 | //PD("Sending -> script %s : %s", SID, command); | ||
282 | send2script(SID, command); | 284 | send2script(SID, command); |
285 | } | ||
283 | 286 | ||
284 | return ECORE_CALLBACK_RENEW; | 287 | return ECORE_CALLBACK_RENEW; |
285 | } | 288 | } |
diff --git a/src/love/love.c b/src/love/love.c index b296b58..f8ce522 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -197,7 +197,7 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
197 | char buf[PATH_MAX]; | 197 | char buf[PATH_MAX]; |
198 | LoveScript *me; | 198 | LoveScript *me; |
199 | 199 | ||
200 | PD("COMMAND - %s - %s", SID, command); | 200 | //PD("COMMAND - %s - %s", SID, command); |
201 | me = eina_hash_find(ourGlobals->scripts, SID); | 201 | me = eina_hash_find(ourGlobals->scripts, SID); |
202 | if (0 == strncmp(command, "compilerWarning(", 16)) | 202 | if (0 == strncmp(command, "compilerWarning(", 16)) |
203 | { | 203 | { |
@@ -282,6 +282,7 @@ PD("COMMAND - %s - %s", SID, command); | |||
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | //PD("FAKING (maybe) %s", command); | ||
285 | // Send back some random or fixed values for testing. | 286 | // Send back some random or fixed values for testing. |
286 | if (0 == strcmp(command, "llGetKey()")) | 287 | if (0 == strcmp(command, "llGetKey()")) |
287 | sendForth(ourGlobals->serverLuaSL, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); | 288 | sendForth(ourGlobals->serverLuaSL, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); |