diff options
-rw-r--r-- | lib/LSL.lua | 18 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_compile.c | 3 | ||||
-rw-r--r-- | src/love/love.c | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/lib/LSL.lua b/lib/LSL.lua index cdb560b..571ecf1 100644 --- a/lib/LSL.lua +++ b/lib/LSL.lua | |||
@@ -169,6 +169,7 @@ local function value2string(value, Type) | |||
169 | local temp = "" | 169 | local temp = "" |
170 | 170 | ||
171 | if "float" == Type then temp = temp .. value | 171 | if "float" == Type then temp = temp .. value |
172 | -- elseif "boolean" == Type then if value then temp = '"true"' else temp = '"false"' end | ||
172 | elseif "integer" == Type then temp = temp .. value | 173 | elseif "integer" == Type then temp = temp .. value |
173 | elseif "key" == Type then temp = "\"" .. value .. "\"" | 174 | elseif "key" == Type then temp = "\"" .. value .. "\"" |
174 | elseif "list" == Type then temp = "[" .. args2string(true, unpack(value)) .. "]" | 175 | elseif "list" == Type then temp = "[" .. args2string(true, unpack(value)) .. "]" |
@@ -388,7 +389,8 @@ local constants = | |||
388 | newConst("integer", "TYPE_INVALID", 0), | 389 | newConst("integer", "TYPE_INVALID", 0), |
389 | 390 | ||
390 | newConst("string", "NULL_KEY", "00000000-0000-0000-0000-000000000000"), | 391 | newConst("string", "NULL_KEY", "00000000-0000-0000-0000-000000000000"), |
391 | newConst("string", "EOF", "\\n\\n\\n"), -- Corner case, dealt with later. | 392 | -- newConst("string", "EOF", "\\n\\n\\n"), -- Corner case, dealt with later. |
393 | newConst("string", "EOF", "EndOfFuckingAround"), -- Corner case, dealt with later. | ||
392 | 394 | ||
393 | newConst("rotation", "ZERO_ROTATION", {x=0.0, y=0.0, z=0.0, s=1.0}), | 395 | newConst("rotation", "ZERO_ROTATION", {x=0.0, y=0.0, z=0.0, s=1.0}), |
394 | newConst("vector", "ZERO_VECTOR", {x=0.0, y=0.0, z=0.0}), | 396 | newConst("vector", "ZERO_VECTOR", {x=0.0, y=0.0, z=0.0}), |
@@ -770,7 +772,8 @@ function LSL.mainLoop(sid, name, x) | |||
770 | 772 | ||
771 | SID = sid | 773 | SID = sid |
772 | scriptName = name | 774 | scriptName = name |
773 | LSL.EOF = "\n\n\n" -- Fix this up now. | 775 | -- LSL.EOF = "\n\n\n" -- Fix this up now. |
776 | LSL.EOF = "EndOfFuckingAround" -- Fix this up now. | ||
774 | 777 | ||
775 | LSL.stateChange(x); | 778 | LSL.stateChange(x); |
776 | waitAndProcess(false) | 779 | waitAndProcess(false) |
@@ -912,4 +915,15 @@ function LSL.listConcat(a, b) | |||
912 | return result; | 915 | return result; |
913 | end | 916 | end |
914 | 917 | ||
918 | -- Lua really hates 0, it's not false, and it can't be a table index. | ||
919 | function LSL.toBool(x) | ||
920 | local v = x | ||
921 | local t = type(v) | ||
922 | if 'boolean' == t then return v end | ||
923 | if 'number' == t then return (v ~= 0) end | ||
924 | if 'nil' == t then return false end | ||
925 | -- Is an empty string, empty list, zero vector/rotation false? Fucked if I know. | ||
926 | return true | ||
927 | end | ||
928 | |||
915 | return LSL; | 929 | return LSL; |
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index 90c9ac1..e31e157 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c | |||
@@ -1613,11 +1613,12 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1613 | fprintf(file, " "); | 1613 | fprintf(file, " "); |
1614 | if (LSL_ELSE != statement->type) | 1614 | if (LSL_ELSE != statement->type) |
1615 | { | 1615 | { |
1616 | fprintf(file, "_LSL.toBool("); | ||
1616 | if (statement->parenthesis) | 1617 | if (statement->parenthesis) |
1617 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); | 1618 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); |
1618 | else | 1619 | else |
1619 | outputLeaf(file, mode, statement->expressions); | 1620 | outputLeaf(file, mode, statement->expressions); |
1620 | fprintf(file, " then\n"); | 1621 | fprintf(file, ") then\n"); |
1621 | } | 1622 | } |
1622 | if (statement->block) | 1623 | if (statement->block) |
1623 | outputRawBlock(file, mode, statement->block, FALSE); | 1624 | outputRawBlock(file, mode, statement->block, FALSE); |
diff --git a/src/love/love.c b/src/love/love.c index db4c557..858ba40 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -436,7 +436,7 @@ static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *e | |||
436 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"%s\")", key, temp); | 436 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"%s\")", key, temp); |
437 | } | 437 | } |
438 | else | 438 | else |
439 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", [[\\n\\n\\n]])", key); | 439 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"EndOfFuckingAround\")", key); |
440 | } | 440 | } |
441 | 441 | ||
442 | close(fd); | 442 | close(fd); |