From a60bb6fbc1ad1e4e7c100d1ccd166d6e219473ac Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 14 May 2014 19:50:41 +1000 Subject: LSL's EOF sucks, Lua's 0 isn't false sucks more. Work around both. --- lib/LSL.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib') 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) local temp = "" if "float" == Type then temp = temp .. value +-- elseif "boolean" == Type then if value then temp = '"true"' else temp = '"false"' end elseif "integer" == Type then temp = temp .. value elseif "key" == Type then temp = "\"" .. value .. "\"" elseif "list" == Type then temp = "[" .. args2string(true, unpack(value)) .. "]" @@ -388,7 +389,8 @@ local constants = newConst("integer", "TYPE_INVALID", 0), newConst("string", "NULL_KEY", "00000000-0000-0000-0000-000000000000"), - newConst("string", "EOF", "\\n\\n\\n"), -- Corner case, dealt with later. +-- newConst("string", "EOF", "\\n\\n\\n"), -- Corner case, dealt with later. + newConst("string", "EOF", "EndOfFuckingAround"), -- Corner case, dealt with later. newConst("rotation", "ZERO_ROTATION", {x=0.0, y=0.0, z=0.0, s=1.0}), newConst("vector", "ZERO_VECTOR", {x=0.0, y=0.0, z=0.0}), @@ -770,7 +772,8 @@ function LSL.mainLoop(sid, name, x) SID = sid scriptName = name - LSL.EOF = "\n\n\n" -- Fix this up now. +-- LSL.EOF = "\n\n\n" -- Fix this up now. + LSL.EOF = "EndOfFuckingAround" -- Fix this up now. LSL.stateChange(x); waitAndProcess(false) @@ -912,4 +915,15 @@ function LSL.listConcat(a, b) return result; end +-- Lua really hates 0, it's not false, and it can't be a table index. +function LSL.toBool(x) + local v = x + local t = type(v) + if 'boolean' == t then return v end + if 'number' == t then return (v ~= 0) end + if 'nil' == t then return false end + -- Is an empty string, empty list, zero vector/rotation false? Fucked if I know. + return true +end + return LSL; -- cgit v1.1