corrade-lsl-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 36  →  ?path2? @ 37
/source/circular-patrol-movement/circular-patrol-movement.lsl
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 //
// Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// This is an automatic teleporter, and patrol script for the Corrade
@@ -7,13 +7,13 @@
// by following the URL: http://was.fm/secondlife/scripted_agents/corrade
//
// The purpose of this script is to demonstrate patroling with Corrade and
// you are free to use, change, and commercialize it under the CC BY 2.0
// license which can be found at: https://creativecommons.org/licenses/by/2.0
// you are free to use, change, and commercialize it under the GNU/GPLv3
// license which can be found at: http://www.gnu.org/licenses/gpl.html
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
if(llStringLength(data) == 0) return "";
@@ -25,7 +25,7 @@
}
///////////////////////////////////////////////////////////////////////////
// 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);
@@ -40,7 +40,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) {
@@ -52,7 +52,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) {
@@ -323,33 +323,12 @@
return;
}
// DEBUG
//llOwnerSay("Sending stop...");
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
"action", "stop",
"callback", wasURLEscape(callback)
]
)
);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
if(wasKeyValueGet("command", body) != "autopilot" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("Could not get Corrade to stop, restarting script...");
llResetScript();
}
// DEBUG
//llOwnerSay("Sending next move...");
float timeout = 1 + llFrand(WAIT);
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"command", "walkto",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
"position", wasURLEscape(
@@ -357,11 +336,12 @@
llGetPos() + wasCirclePoint(RADIUS)
)
),
"action", "start"
"vicinity", "1",
"timeout", timeout
]
)
);
llSetTimerEvent(1 + llFrand(WAIT));
llSetTimerEvent(timeout);
}
on_rez(integer num) {
llResetScript();
/source/fetch/fetch.lsl
@@ -686,7 +686,7 @@
),
wasKeyValueEncode(
[
"command", "autopilot",
"command", "walkto",
"group", wasURLEscape(
wasKeyValueGet(
"group",
@@ -700,7 +700,8 @@
)
),
"position", autoPilotTarget + wasCirclePoint(1.1),
"action", "start"
"vicinity", 1.1,
"timeout", 60
]
)
);
@@ -1053,4 +1054,4 @@
state_exit() {
llSetTimerEvent(0);
}
}
}
/source/grid-follow/grid-follow.lsl
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 //
// Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// This is an automatic grid follower for the Corrade Second Life / OpenSim
@@ -8,13 +8,13 @@
//
// The follower script works together with a "configuration" notecard and
// that must be placed in the same primitive as this script.
// You are free to use, change, and commercialize it under the CC BY 2.0
// license at: https://creativecommons.org/licenses/by/2.0
// You are free to use, change, and commercialize it under the GNU/GPLv3
// license at: http://www.gnu.org/licenses/gpl.html
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
if(llStringLength(data) == 0) return "";
@@ -26,7 +26,7 @@
}
///////////////////////////////////////////////////////////////////////////
// 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);
@@ -41,7 +41,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
vector wasCirclePoint(float radius) {
float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
@@ -52,7 +52,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
integer wasIsAvatarInSensorRange(key avatar) {
return llListFindList(
@@ -75,7 +75,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) {
@@ -357,12 +357,13 @@
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"command", "walkto",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
// move in a radius around the current primitive.
"position", llGetPos() + wasCirclePoint((integer)RANGE),
"action", "start"
"vicinity", 1,
"timeout", 2500
]
)
);
/source/polygon-patrol-movement/polygon-patrol-movement.lsl
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 //
// Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// This is an automatic teleporter, and patrol script for the Corrade
@@ -7,13 +7,13 @@
// by following the URL: http://was.fm/secondlife/scripted_agents/corrade
//
// The purpose of this script is to demonstrate patroling with Corrade and
// you are free to use, change, and commercialize it under the CC BY 2.0
// license which can be found at: https://creativecommons.org/licenses/by/2.0
// you are free to use, change, and commercialize it under the GNU/GPLv3
// license which can be found at: http://www.gnu.org/licenses/gpl.html
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
if(llStringLength(data) == 0) return "";
@@ -25,7 +25,7 @@
}
///////////////////////////////////////////////////////////////////////////
// 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);
@@ -40,7 +40,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
list wasDualQuicksort(list a, list b) {
if(llGetListLength(a) <= 1) return a+b;
@@ -71,7 +71,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
// determines whether the segment AB intersects the segment CD
integer wasSegmentIntersect(vector A, vector B, vector C, vector D) {
@@ -91,7 +91,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
// www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html //
///////////////////////////////////////////////////////////////////////////
integer wasPointInPolygon(vector p, list polygon) {
@@ -111,7 +111,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
// www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html //
///////////////////////////////////////////////////////////////////////////
list wasPointToPolygon(list polygon, vector point) {
@@ -126,7 +126,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
// www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html //
///////////////////////////////////////////////////////////////////////////
vector wasPolygonCentroid(list polygon, vector start, float tollerance, integer power) {
@@ -144,7 +144,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
vector wasCirclePoint(float radius) {
float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
@@ -155,7 +155,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
vector wasPolygonPoint(list polygon) {
vector c = wasPolygonCentroid(polygon, llList2Vector(polygon, 0), 0.05, 2);
@@ -168,7 +168,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
// determines whether the path between the current positon m and the
// computed next position d will intersect any two sides of the polygon
@@ -192,7 +192,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) {
@@ -505,28 +505,6 @@
return;
}
// DEBUG
//llOwnerSay("Sending stop...");
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
"action", "stop",
"callback", wasURLEscape(callback)
]
)
);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
if(wasKeyValueGet("command", body) != "autopilot" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("Could not get Corrade to stop, restarting script...");
llResetScript();
}
// DEBUG
llOwnerSay("Sending next move...");
// get the next location
location = wasPolygonPath(location, POLYGON);
@@ -534,13 +512,14 @@
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"command", "walkto",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
"position", wasURLEscape(
(string)(<location.x, location.y, pos.z>)
),
"action", "start"
"vicinity", "1",
"duration", "2500"
]
)
);
/source/puppeteer-pathfinding/puppeteer-pathfinding.lsl
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 //
// Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// This is a puppeteer script for the Corrade Second Life / OpenSim bot
@@ -6,45 +6,48 @@
// that, given a set of local coordinates, will make the bot traverse a
// path while also minding collisions with object. You can find more
// details about the Corrade bot and how to get it to work on your machine
// by following the URL: http://grimore.org/secondlife/scripted_agents/corrade
// by following the URL: http://was.fm/secondlife/scripted_agents/corrade
//
// This script works together with a "configuration" notecard that must
// be placed in the same primitive as this script. The purpose of this
// script is to demonstrate how Corrade can be made to walk on a path and
// you are free to use, change, and commercialize it under the CC BY 2.0
// license at: https://creativecommons.org/licenses/by/2.0
// you are free to use, change, and commercialize it under the GNU/GPLv3
// license at: http://www.gnu.org/licenses/gpl.html
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
if(llStringLength(data) == 0) return "";
if(llStringLength(k) == 0) return "";
list a = llParseString2List(data, ["&", "="], []);
integer i = llListFindList(a, [ k ]);
if(i != -1) return llList2String(a, i+1);
string wasKeyValueGet(string var, string kvp) {
list dVars = llParseString2List(kvp, ["&"], []);
do {
list data = llParseString2List(llList2String(dVars, 0), ["="], []);
string k = llList2String(data, 0);
if(k != var) jump continue;
return llList2String(data, 1);
@continue;
dVars = llDeleteSubList(dVars, 0, 0);
} while(llGetListLength(dVars));
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);
list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2);
data = [];
do {
data += llList2String(k, 0) + "=" + llList2String(v, 0);
k = llDeleteSubList(k, 0, 0);
v = llDeleteSubList(v, 0, 0);
} while(llGetListLength(k) != 0);
return llDumpList2String(data, "&");
string wasKeyValueEncode(list kvp) {
if(llGetListLength(kvp) < 2) return "";
string k = llList2String(kvp, 0);
kvp = llDeleteSubList(kvp, 0, 0);
string v = llList2String(kvp, 0);
kvp = llDeleteSubList(kvp, 0, 0);
if(llGetListLength(kvp) < 2) return k + "=" + v;
return k + "=" + v + "&" + wasKeyValueEncode(kvp);
}
 
 
///////////////////////////////////////////////////////////////////////////
// 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) {
@@ -68,7 +71,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) {
@@ -90,9 +93,8 @@
)
);
}
 
///////////////////////////////////////////////////////////////////////////
// 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 = [];
@@ -344,7 +346,7 @@
// DEBUG
llOwnerSay("Binding to the collision notification...");
llInstantMessage(
(key)CORRADE,
CORRADE,
wasKeyValueEncode(
[
"command", "notify",
@@ -469,26 +471,28 @@
PATH = llDeleteSubList(PATH, 0, 0);
PATH += next;
// We now determine the waiting time for Corrade to reach
// its next destination by extracting time as a function
// of the distance it has to walk and the speed of travel:
// t = s / v
// This, of course, is prone to error since the distance
// is calculated on the shortest direct path. Nevertheless,
// it is a pretty good appoximation for terrain that is
// mostly flat and without too many curvatures.
// NB. 3.20 m/s is the walking speed of an avatar.
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"command", "walkto",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
"position", next,
"action", "start"
"vicinity", "1",
"timeout", llVecDist(origin, next)/3.20
]
)
);
// We now determine the waiting time for Corrade to reach
// its next destination by extracting time as a function
// of the distance it has to walk and the speed of travel:
// t = s / v
// This, of course, is prone to error since the distance
// is calculated on the shortest direct path. Nevertheless,
// it is a pretty good appoximation for terrain that is
// mostly flat and without too many curvatures.
// NB. 3.20 m/s is the walking speed of an avatar.
 
llSetTimerEvent(llVecDist(origin, next)/3.20);
}
http_request(key id, string method, string body) {
@@ -501,17 +505,7 @@
llOwnerSay("Collided...");
llHTTPResponse(id, 200, "OK");
llInstantMessage(CORRADE,
wasKeyValueEncode(
[
"command", "autopilot",
"group", wasURLEscape(GROUP),
"password", wasURLEscape(PASSWORD),
"action", "stop"
]
)
);
 
// We did not reach our destination since we collided with
// something on our path, so switch directly to waiting and
// attempt to reach the next destination on our path.