/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2014 - License: CC BY 2.0 // /////////////////////////////////////////////////////////////////////////// // // This is a device that can be used to automatically batch-set the estate // covenant for regions using the Corrade scripted agent. You can find out // more about Corrade by following the URL: // http://grimore.org/secondlife/scripted_agents/corrade // // The script works in conjunction with a "configuration" notecard, a // "regions" notecard and a "covenant" notecard that must all be placed in // the same primitive as this script. // // The purpose of this script is to demonstrate batch-setting the estate // covenant with Corrade 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 // /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // /////////////////////////////////////////////////////////////////////////// string wasProgress(integer percent, integer length, list symbols) { percent /= (integer)((float)100.0/(length)); string p = llList2String(symbols,0); integer itra = 0; do { if(itra>percent-1) p += llList2String(symbols,2); else p += llList2String(symbols,1); } while(++itra, "callback", wasURLEscape(callback) ] ) ); } http_request(key id, string method, string body) { llHTTPResponse(id, 200, "OK"); if(wasKeyValueGet("command", body) != "teleport" || wasKeyValueGet("success", body) != "True") { // DEBUG llOwnerSay("Failed to teleport to: " + region); // Jump to trampoline for re-entry. state teleport_trampoline; } // DEBUG llOwnerSay("Teleported successfully to: " + region); state get_covenant; } timer() { llRequestAgentData((key)CORRADE, DATA_ONLINE); } dataserver(key id, string data) { if(data != "1") { // DEBUG llOwnerSay("Corrade is not online, sleeping..."); state detect; } } on_rez(integer num) { llResetScript(); } changed(integer change) { if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START)) { llResetScript(); } } } state teleport_trampoline { state_entry() { // DEBUG llOwnerSay("Sleeping..."); llSetTimerEvent(5); } timer() { llSetTimerEvent(0); state teleport; } on_rez(integer num) { llResetScript(); } changed(integer change) { if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START)) { llResetScript(); } } } state get_covenant { state_entry() { // Keep checking if Corrade disconnected. llSetTimerEvent(5); // DEBUG llOwnerSay("Getting covenant..."); llInstantMessage( (key)CORRADE, wasKeyValueEncode( [ "command", "getestatecovenant", "group", wasURLEscape(GROUP), "password", wasURLEscape(PASSWORD), "callback", wasURLEscape(callback) ] ) ); } http_request(key id, string method, string body) { llHTTPResponse(id, 200, "OK"); if(wasKeyValueGet("command", body) != "getestatecovenant" || wasKeyValueGet("success", body) != "True") { // DEBUG llOwnerSay("Failed to get covenant for region: " + region); // Jump to trampoline for teleport. state teleport_trampoline; } // DEBUG llOwnerSay("Got covenant for region: " + region); if(llList2Key( wasCSVToList( wasURLUnescape( wasKeyValueGet( "data", body ) ) ), 0 ) == llGetInventoryKey("covenant")) { // DEBUG llOwnerSay("Covenant for region: \"" + region + "\" is set."); ++regionsChanged; llSetText( "Corrade @ " + region + "\n" + "Progress: " + wasProgress( 100 * regionsChanged/llGetListLength(regions), 10, [ "[", "█", "░", "]" ] ) + "[" + (string)regionsChanged + "/" + (string)llGetListLength(regions) + "]", <0, 1, 1>, 1.0 ); state teleport_trampoline; } state set_covenant; } timer() { llRequestAgentData((key)CORRADE, DATA_ONLINE); } dataserver(key id, string data) { if(data != "1") { // DEBUG llOwnerSay("Corrade is not online, sleeping..."); state detect; } } on_rez(integer num) { llResetScript(); } changed(integer change) { if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START)) { llResetScript(); } } } state set_covenant { state_entry() { // Keep checking if Corrade disconnected. llSetTimerEvent(5); // DEBUG llOwnerSay("Setting covenant..."); llInstantMessage( (key)CORRADE, wasKeyValueEncode( [ "command", "setestatecovenant", "group", wasURLEscape(GROUP), "password", wasURLEscape(PASSWORD), "item", llGetInventoryKey("covenant"), "callback", wasURLEscape(callback) ] ) ); } http_request(key id, string method, string body) { llHTTPResponse(id, 200, "OK"); if(wasKeyValueGet("command", body) != "setestatecovenant" || wasKeyValueGet("success", body) != "True") { // DEBUG llOwnerSay("Failed to set covenant for region: " + region); --regionsChanged; // Jump to trampoline for teleport. state teleport_trampoline; } // DEBUG llOwnerSay("Set covenant for region: " + region); state get_covenant; } timer() { llRequestAgentData((key)CORRADE, DATA_ONLINE); } dataserver(key id, string data) { if(data != "1") { // DEBUG llOwnerSay("Corrade is not online, sleeping..."); state detect; } } on_rez(integer num) { llResetScript(); } changed(integer change) { if((change & CHANGED_INVENTORY) || (change & CHANGED_REGION_START)) { llResetScript(); } } }