Difference between revisions of "MLPV2 RLV Plugin"
Jenni Eales (talk | contribs) (Created page with 'This Plugin combines the possibilities of MLPV2 with the commands of the Restrained Love Viewer. It reads a notecard, which must me named .RLV to define a RLV command for a Pose...') |
Jenni Eales (talk | contribs) |
||
Line 1: | Line 1: | ||
* [[MLPV2]] | |||
* [[MLPV2_Addons]] | |||
This Plugin combines the possibilities of MLPV2 with the commands of the Restrained Love Viewer. | This Plugin combines the possibilities of MLPV2 with the commands of the Restrained Love Viewer. | ||
It reads a notecard, which must me named .RLV to define a RLV command for a Pose. | It reads a notecard, which must me named .RLV to define a RLV command for a Pose. | ||
<lsl>// ---------------------------------------------------------------------------------- | |||
// MLPV2 Plugin for RLV Script V1.0 | |||
// | |||
// Use with a notecard named .RLV with the format: | |||
// Pose|Ball no.: 0,1...*|@RLV-Command | |||
// e.g. | |||
// Missionary|1|@unsit=n | |||
// ---------------------------------------------------------------------------------- | |||
// Copyright (c) 2010, Jenni Eales. All rights reserved. | |||
// ---------------------------------------------------------------------------------- | |||
// Redistribution and use in source and binary forms, with or without modification, | |||
// are permitted provided that the following conditions are met: | |||
// | |||
// * Redistributions of source code must retain the above copyright notice, | |||
// this list of conditions and the following disclaimer. | |||
// * Redistributions in binary form must reproduce the above copyright notice, | |||
// this list of conditions and the following disclaimer in the documentation | |||
// and/or other materials provided with the distribution. | |||
// * The names of its contributors may not be used to endorse or promote products | |||
// derived from this software without specific prior written permission. | |||
// | |||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | |||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |||
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | |||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | |||
// OF SUCH DAMAGE. | |||
// | |||
// Changes: | |||
// ---------------------------------------------------------------------------------- | |||
// Version 1.0 | |||
// - first version released | |||
// ---------------------------------------------------------------------------------- | |||
// | |||
// constants | |||
string NOTECARD = ".RLV"; | |||
integer DEBUG = FALSE; | |||
integer RELAY_CHANNEL = -1812221819; | |||
float TIMER_SEC = 1800.0; // 30 min. | |||
string CMD_RELEASE = "!release"; | |||
// internal use | |||
key kQuery; | |||
integer iLine; | |||
string pose = "stand"; | |||
list poses = []; | |||
list balls = []; | |||
list commands = []; | |||
list avatars = [NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY]; | |||
// log a message | |||
log(string message) | |||
{ | |||
if(DEBUG) llOwnerSay(message); | |||
} | |||
// write a message to the RLV Relay | |||
relay(key avatar, string message) | |||
{ | |||
log("RLV: MLPV2," + (string) avatar + "," + message); | |||
llSay(RELAY_CHANNEL, "MLPV2," + (string) avatar + "," + message); | |||
} | |||
// find commands for pose and play it for avatars on ball | |||
rlv(string pose) | |||
{ | |||
log("command for " + pose); | |||
llSetTimerEvent(TIMER_SEC); | |||
// get index for pose in poses | |||
integer index = llListFindList(poses, [pose]); | |||
// get command from entries | |||
string command = llList2String(commands, index); | |||
// get ball from balls | |||
string ball = llList2String(balls, index); | |||
if (ball == "*") | |||
{ | |||
integer i; | |||
for (i=0; i<6; i++) | |||
{ | |||
// get avatar for ball index | |||
key avatar = llList2Key(avatars, i); | |||
// if not null send command | |||
if(avatar != NULL_KEY) | |||
{ | |||
relay(avatar, command); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
// get avatar for ball index | |||
key avatar = llList2Key(avatars, (integer) ball); | |||
// if not null send command | |||
if(avatar != NULL_KEY) | |||
{ | |||
relay(avatar, command); | |||
} | |||
} | |||
} | |||
// parse and store a line | |||
process_line(string line) | |||
{ | |||
list tokens = llParseString2List(line, ["|"], [""]); | |||
if(llGetListLength(tokens) != 3) return; | |||
string pose = llList2String(tokens, 0); | |||
string ball = llList2String(tokens, 1); | |||
string command = llList2String(tokens, 2); | |||
poses += [pose]; | |||
balls += [ball]; | |||
commands += [command]; | |||
log("Added from " + NOTECARD + ": " + pose + " | " + ball + " | " + command); | |||
} | |||
// check if object is in the inventory | |||
integer exists_notecard(string notecard) { | |||
return llGetInventoryType(notecard) == INVENTORY_NOTECARD; | |||
} | |||
// initialize me | |||
reset() | |||
{ | |||
poses = []; | |||
balls = []; | |||
commands = []; | |||
avatars = [NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY]; | |||
log("Reset"); | |||
if (exists_notecard(NOTECARD)) | |||
{ | |||
log("Reading " + NOTECARD + "..."); | |||
iLine = 0; | |||
kQuery = llGetNotecardLine(NOTECARD, iLine); | |||
} | |||
else | |||
{ | |||
llOwnerSay("Not found: " + NOTECARD ); | |||
} | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
reset(); | |||
} | |||
// reset on Inventory change | |||
changed(integer change) | |||
{ | |||
if (change & CHANGED_INVENTORY) { | |||
reset(); | |||
} | |||
} | |||
// read a line from notecard | |||
dataserver(key _query_id, string _data) { | |||
// were we called to work on notecard? | |||
if (_query_id == kQuery) { | |||
// this is a line of our notecard | |||
if (_data == EOF) { | |||
log(NOTECARD + " read."); | |||
} else { | |||
// increment line count | |||
// data has the current line from this notecard | |||
if(_data != "") { | |||
process_line(_data); | |||
} | |||
// request next line | |||
// read another line when you can | |||
iLine++; | |||
kQuery = llGetNotecardLine(NOTECARD, iLine); | |||
} | |||
} | |||
} | |||
timer() | |||
{ | |||
integer i; | |||
for (i=0; i<6; i++) | |||
{ | |||
// get avatar for ball index | |||
key avatar = llList2Key(avatars, i); | |||
// if not null send command | |||
if(avatar != NULL_KEY) | |||
{ | |||
relay(avatar, CMD_RELEASE); | |||
} | |||
} | |||
llSetTimerEvent(0.0); | |||
} | |||
// link message from MLPV2 | |||
link_message(integer sender_number, integer number, string message, key id) | |||
{ | |||
if (number == 0 && message == "POSEB") { | |||
pose = (string)id; | |||
rlv(pose); | |||
return; | |||
} | |||
// unsit avatar | |||
if (number == -11001) | |||
{ | |||
integer ball = (integer) message; | |||
log("Avatar unsit from ball " + (string) ball +": " + (string) llList2Key(avatars, ball)); | |||
relay(llList2Key(avatars, ball), CMD_RELEASE); | |||
avatars = llListReplaceList(avatars, [NULL_KEY], ball, ball); | |||
} | |||
// sit avatar | |||
if (number == -11000) | |||
{ | |||
list tokens = llParseString2List(message, ["|"], [" "]); | |||
integer ball = llList2Integer(tokens, 0); | |||
log("Avatar sit on ball " + (string) ball +": " + (string) id); | |||
avatars = llListReplaceList(avatars, [id], ball, ball); | |||
rlv(pose); | |||
} | |||
} | |||
}</lsl> | |||
The .RLV notecard might be look like this: | |||
Trapped|0|@unsit=n | |||
Strip|0|@remoutfit:undershirt=force|@remoutfit:underpants=force|@remoutfit:shirt=force|@remoutfit:pants=force|@remoutfit:socks=force | |||
stand|*|!release |
Revision as of 21:57, 19 May 2010
This Plugin combines the possibilities of MLPV2 with the commands of the Restrained Love Viewer.
It reads a notecard, which must me named .RLV to define a RLV command for a Pose.
<lsl>// ---------------------------------------------------------------------------------- // MLPV2 Plugin for RLV Script V1.0 // // Use with a notecard named .RLV with the format: // Pose|Ball no.: 0,1...*|@RLV-Command // e.g. // Missionary|1|@unsit=n // ---------------------------------------------------------------------------------- // Copyright (c) 2010, Jenni Eales. All rights reserved. // ---------------------------------------------------------------------------------- // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * The names of its contributors may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY // OF SUCH DAMAGE. // // Changes: // ---------------------------------------------------------------------------------- // Version 1.0 // - first version released // ---------------------------------------------------------------------------------- // // constants string NOTECARD = ".RLV"; integer DEBUG = FALSE; integer RELAY_CHANNEL = -1812221819; float TIMER_SEC = 1800.0; // 30 min. string CMD_RELEASE = "!release";
// internal use key kQuery; integer iLine;
string pose = "stand"; list poses = []; list balls = []; list commands = []; list avatars = [NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY];
// log a message log(string message) {
if(DEBUG) llOwnerSay(message);
}
// write a message to the RLV Relay relay(key avatar, string message) {
log("RLV: MLPV2," + (string) avatar + "," + message); llSay(RELAY_CHANNEL, "MLPV2," + (string) avatar + "," + message);
}
// find commands for pose and play it for avatars on ball rlv(string pose) {
log("command for " + pose); llSetTimerEvent(TIMER_SEC);
// get index for pose in poses integer index = llListFindList(poses, [pose]);
// get command from entries string command = llList2String(commands, index);
// get ball from balls string ball = llList2String(balls, index);
if (ball == "*") { integer i; for (i=0; i<6; i++) { // get avatar for ball index key avatar = llList2Key(avatars, i);
// if not null send command if(avatar != NULL_KEY) { relay(avatar, command); } } } else { // get avatar for ball index key avatar = llList2Key(avatars, (integer) ball);
// if not null send command if(avatar != NULL_KEY) { relay(avatar, command); } }
}
// parse and store a line process_line(string line) {
list tokens = llParseString2List(line, ["|"], [""]); if(llGetListLength(tokens) != 3) return;
string pose = llList2String(tokens, 0); string ball = llList2String(tokens, 1); string command = llList2String(tokens, 2);
poses += [pose]; balls += [ball]; commands += [command];
log("Added from " + NOTECARD + ": " + pose + " | " + ball + " | " + command);
}
// check if object is in the inventory integer exists_notecard(string notecard) {
return llGetInventoryType(notecard) == INVENTORY_NOTECARD;
}
// initialize me reset() {
poses = []; balls = []; commands = []; avatars = [NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY, NULL_KEY]; log("Reset");
if (exists_notecard(NOTECARD)) { log("Reading " + NOTECARD + "..."); iLine = 0; kQuery = llGetNotecardLine(NOTECARD, iLine); } else { llOwnerSay("Not found: " + NOTECARD ); }
}
default {
state_entry() { reset(); }
// reset on Inventory change changed(integer change) { if (change & CHANGED_INVENTORY) { reset(); } }
// read a line from notecard dataserver(key _query_id, string _data) { // were we called to work on notecard? if (_query_id == kQuery) { // this is a line of our notecard if (_data == EOF) { log(NOTECARD + " read."); } else { // increment line count // data has the current line from this notecard if(_data != "") { process_line(_data); }
// request next line // read another line when you can iLine++; kQuery = llGetNotecardLine(NOTECARD, iLine); } } }
timer() { integer i; for (i=0; i<6; i++) { // get avatar for ball index key avatar = llList2Key(avatars, i);
// if not null send command if(avatar != NULL_KEY) { relay(avatar, CMD_RELEASE); } } llSetTimerEvent(0.0); }
// link message from MLPV2 link_message(integer sender_number, integer number, string message, key id) { if (number == 0 && message == "POSEB") { pose = (string)id; rlv(pose); return; }
// unsit avatar if (number == -11001) { integer ball = (integer) message; log("Avatar unsit from ball " + (string) ball +": " + (string) llList2Key(avatars, ball)); relay(llList2Key(avatars, ball), CMD_RELEASE); avatars = llListReplaceList(avatars, [NULL_KEY], ball, ball); }
// sit avatar if (number == -11000) { list tokens = llParseString2List(message, ["|"], [" "]); integer ball = llList2Integer(tokens, 0); log("Avatar sit on ball " + (string) ball +": " + (string) id); avatars = llListReplaceList(avatars, [id], ball, ball); rlv(pose); } }
}</lsl>
The .RLV notecard might be look like this:
Trapped|0|@unsit=n Strip|0|@remoutfit:undershirt=force|@remoutfit:underpants=force|@remoutfit:shirt=force|@remoutfit:pants=force|@remoutfit:socks=force stand|*|!release