corrade-lsl-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 41  →  ?path2? @ 42
/source/eggdrop/fortune.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 fortune module 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"
)
);
@@ -192,8 +192,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();
}
@@ -229,8 +229,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();
}
@@ -246,41 +246,44 @@
// 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) + "fortune")
return;
 
// Remove command.
command = llDeleteSubList(command, 0, 0);
 
data = llList2String(
nList,
nList,
(integer)
llFrand(
llGetListLength(nList)
)
);
 
state tell;
}
on_rez(integer num) {
@@ -287,8 +290,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();
}
@@ -301,21 +304,21 @@
llOwnerSay("[Fortune] Sending to group.");
llInstantMessage(
wasKeyValueGet(
"corrade",
"corrade",
configuration
),
),
wasKeyValueEncode(
[
"command", "tell",
"group", wasURLEscape(
wasKeyValueGet(
"group",
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
"password",
configuration
)
),