/source/eggdrop/eval.lsl |
@@ -1,5 +1,5 @@ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // |
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// |
// A module that evaluates a mathematical expression for Corrade Eggdrop. |
@@ -17,9 +17,9 @@ |
if(i != -1) return llList2String(a, 2*i+1); |
return ""; |
} |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
string wasKeyValueEncode(list data) { |
list k = llList2ListStrided(data, 0, -1, 2); |
@@ -34,7 +34,7 @@ |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// http://was.fm/secondlife/wanderer |
vector wasCirclePoint(float radius) { |
@@ -46,7 +46,7 @@ |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// escapes a string in conformance with RFC1738 |
string wasURLEscape(string i) { |
@@ -70,7 +70,7 @@ |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
list wasCSVToList(string csv) { |
list l = []; |
@@ -109,7 +109,7 @@ |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
string wasListToCSV(list l) { |
list v = []; |
@@ -117,18 +117,18 @@ |
string a = llDumpList2String( |
llParseStringKeepNulls( |
llList2String( |
l, |
l, |
0 |
), |
["\""], |
), |
["\""], |
[] |
), |
"\"\"" |
); |
if(llParseStringKeepNulls( |
a, |
a, |
[" ", ",", "\n", "\""], [] |
) != |
) != |
(list) a |
) a = "\"" + a + "\""; |
v += a; |
@@ -138,7 +138,7 @@ |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// unescapes a string in conformance with RFC1738 |
string wasURLUnescape(string i) { |
@@ -147,15 +147,15 @@ |
llParseString2List( |
llDumpList2String( |
llParseString2List( |
i, |
["+"], |
i, |
["+"], |
[] |
), |
), |
" " |
), |
["%0D%0A"], |
["%0D%0A"], |
[] |
), |
), |
"\n" |
) |
); |
@@ -168,7 +168,7 @@ |
if(llGetListLength(lst)<=1) return lst; |
return wasListReverse(llList2List(lst, 1, llGetListLength(lst))) + llList2List(lst,0,0); |
} |
|
|
////////////////////////////////////////////////////////// |
// Deletes elements delete from list input. |
////////////////////////////////////////////////////////// |
@@ -185,7 +185,7 @@ |
} while(delete = llDeleteSubList(delete, 0, 0)); |
return input; |
} |
|
|
////////////////////////////////////////////////////////// |
// Returns a list of operators and operands. |
////////////////////////////////////////////////////////// |
@@ -194,7 +194,7 @@ |
list result = llParseString2List(input, [], op); |
return wasSubtractSubList(result, [" "]); |
} |
|
|
////////////////////////////////////////////////////////// |
// Transforms an infix expression to a postfix expression. |
////////////////////////////////////////////////////////// |
@@ -235,9 +235,9 @@ |
@continue; |
} while(llGetListLength(infix) != 0); |
result += wasListReverse(opStack); |
return result; |
return result; |
} |
|
|
////////////////////////////////////////////////////////// |
// Evaluate a postfix expression. |
////////////////////////////////////////////////////////// |
@@ -326,8 +326,6 @@ |
|
// configuration data |
string configuration = ""; |
// callback URL |
string URL = ""; |
// store message over state. |
string data = ""; |
|
@@ -355,8 +353,8 @@ |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
@@ -375,33 +373,36 @@ |
// We only care about notifications now. |
if(id != "notification") |
return; |
|
|
// This script only processes group notifications. |
if(wasKeyValueGet("type", message) != "group") |
if(wasKeyValueGet("type", message) != "group" || |
(wasKeyValueGet("type", message) == "group" && |
wasURLUnescape(wasKeyValueGet("group", message)) != |
wasKeyValueGet("group", configuration))) |
return; |
|
|
// Get the sent message. |
data = wasURLUnescape( |
wasKeyValueGet( |
"message", |
"message", |
message |
) |
); |
|
|
// Check if this is an eggdrop command. |
if(llGetSubString(data, 0, 0) != |
if(llGetSubString(data, 0, 0) != |
wasKeyValueGet("command", configuration)) |
return; |
|
|
// Check if the command matches the current module. |
list command = llParseString2List(data, [" "], []); |
if(llList2String(command, 0) != |
if(llList2String(command, 0) != |
wasKeyValueGet("command", configuration) + "eval") |
return; |
|
|
// Remove command. |
command = llDeleteSubList(command, 0, 0); |
|
|
// Dump the rest of the message. |
data = (string)wasPostfixEval( |
wasInfixToPostfix( |
@@ -413,7 +414,7 @@ |
) |
) |
); |
|
|
state tell; |
} |
on_rez(integer num) { |
@@ -420,8 +421,8 @@ |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
@@ -434,21 +435,21 @@ |
llOwnerSay("[Eval] Sending to group."); |
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
"corrade", |
configuration |
), |
), |
wasKeyValueEncode( |
[ |
"command", "tell", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
"password", |
configuration |
) |
), |