/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" |
] |
) |
); |