//
// The line above should be left blank to avoid script errors in OpenSim.
/*
* ossl_message.lslp
* Part of the Sloodle project (www.sloodle.org)
*
* Copyright (c) 2011-06 contributors (see below)
* Released under the GNU GPL v3
* -------------------------------------------
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* All scripts must maintain this copyrite information, including the contributer information listed
*
* Contributors:
* Paul Preibisch
* Edmund Edgar
*
* DESCRIPTION
*
*/
integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343; // an arbitrary channel the sloodle scripts will use to talk to each other. Doesn't atter what it is, as long as the same thing is set in the sloodle_slave script.
string sloodleserverroot = "";
integer sloodlecontrollerid = 0;
string sloodlepwd = "";
integer sloodlemoduleid = 0;
integer sloodleobjectaccessleveluse = 0; // Who can use this object?
integer sloodleobjectaccesslevelctrl = 0; // Who can control this object?
integer sloodleserveraccesslevel = 0; // Who can use the server resource? (Value passed straight back to Moodle)
integer isconfigured = FALSE; // Do we have all the configuration data we need?
string SLOODLE_EOF = "sloodleeof";
integer eof = FALSE; // Have we reached the end of the configuration data?
integer SLOODLE_CHANNEL_QUIZ_MASTER_REQUEST= -1639277006;
integer SLOODLE_CHANNEL_USER_TOUCH = -1639277002;//user touched object
integer SLOODLE_CHANNEL_QUIZ_MASTER_RESPONSE= -1639277008;
integer SLOODLE_CHANNEL_QUIZ_LOADING_QUIZ = -1639271109;
integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;
integer SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST=-1828374651;
string SLOODLE_TRANSLATE_HOVER_TEXT = "hovertext"; // 2 output parameters: colour , and alpha value
string SLOODLE_TRANSLATE_WHISPER = "whisper"; // 1 output parameter: chat channel number
string SLOODLE_TRANSLATE_SAY = "say"; // 1 output parameter: chat channel number
string SLOODLE_TRANSLATE_OWNER_SAY = "ownersay"; // No output parameters
string SLOODLE_TRANSLATE_DIALOG = "dialog"; // Recipient avatar should be identified in link message keyval. At least 2 output parameters: first the channel number for the dialog, and then 1 to 12 button label strings.
string SLOODLE_TRANSLATE_LOAD_URL = "loadurl"; // Recipient avatar should be identified in link message keyval. 1 output parameter giving URL to load.
string SLOODLE_TRANSLATE_IM = "instantmessage"; // Recipient avatar should be identified in link message keyval. No output parameters.
integer SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC = 0;
integer SLOODLE_OBJECT_ACCESS_LEVEL_OWNER = 1;
integer SLOODLE_OBJECT_ACCESS_LEVEL_GROUP = 2;
vector RED =<1.00000, 0.00000, 0.00000>;
vector ORANGE=<1.00000, 0.43763, 0.02414>;
vector YELLOW=<1.00000, 1.00000, 0.00000>;
vector GREEN=<0.00000, 1.00000, 0.00000>;
vector BLUE=<0.00000, 0.00000, 1.00000>;
vector BABYBLUE=<0.00000, 1.00000, 1.00000>;
vector PINK=<1.00000, 0.00000, 1.00000>;
vector PURPLE=<0.57338, 0.25486, 1.00000>;
vector BLACK= <0.00000, 0.00000, 0.00000>;
vector WHITE= <1.00000, 1.00000, 1.00000>;
vector AVCLASSBLUE= <0.06274,0.247058,0.35294>;
vector AVCLASSLIGHTBLUG=<0.8549,0.9372,0.9686>;//#daeff7
string region;
vector landing_point;
vector look_at;
string ossl_message;
sloodle_error_code(string method, key avuuid,integer statuscode, string msg){
llMessageLinked(LINK_SET, SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST, method+"|"+(string)avuuid+"|"+(string)statuscode+"|"+(string)msg, NULL_KEY);
}
sloodle_debug(string msg){
llMessageLinked(LINK_THIS, DEBUG_CHANNEL, msg, NULL_KEY);
}
// Send a translation request link message
sloodle_translation_request(string output_method, list output_params, string string_name, list string_params, key keyval, string batch){
llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_TRANSLATION_REQUEST, output_method + "|" + llList2CSV(output_params) + "|" + string_name + "|" + llList2CSV(string_params) + "|" + batch, keyval);
}
print_message(string message){
string CommandList = ""; // Storage for our drawing commands
integer font_size=42;
vector Extents = osGetDrawStringSize( "vector", message, "Arial", font_size );
CommandList = osSetFontSize( CommandList, font_size ); // Use 10-point text
integer xpos = 512 - ((integer) Extents.x >> 1); // Center the text horizontally
integer ypos = 255 - ((integer) Extents.y >> 1); // and vertically
CommandList = osMovePen( CommandList, xpos, ypos ); // Position the text
CommandList = osDrawText( CommandList, ossl_message ); // Place some text
// Now draw the image
osSetDynamicTextureData( "", "vector", CommandList, "width:1024,height:512", 0 );
}
// Configure by receiving a linked message from another script in the object
// Returns TRUE if the object has all the data it needs
integer sloodle_handle_command(string str){
list bits = llParseString2List(str,["|"],[]);
integer numbits = llGetListLength(bits);
string name = llList2String(bits,0);
string value1 = "";
string value2 = "";
if (numbits > 1) value1 = llList2String(bits,1);
if (numbits > 2) value2 = llList2String(bits,2);
if (name == "set:sloodleserverroot") sloodleserverroot = value1;
else if (name == "set:sloodlepwd") {
// The password may be a single prim password, or a UUID and a password
if (value2 != "") {
sloodlepwd = value1 + "|" + value2;
}
else {
sloodlepwd = value1;
}
}
else if (name == "set:ossl_message") {
ossl_message = value1;
debug("ossl_message: "+ossl_message);
print_message(ossl_message);
}
else if (name == "set:sloodlecontrollerid"){
sloodlecontrollerid = (integer)value1;
debug("sloodlecontrollerid: "+(string)sloodlecontrollerid);
}
else if (name == "set:sloodlemoduleid") {
sloodlemoduleid = (integer)value1;
debug("sloodlemoduleid: "+(string)sloodlemoduleid);
}
else if (name == "set:sloodleobjectaccessleveluse") {
sloodleobjectaccessleveluse = (integer)value1;
debug("sloodleobjectaccessleveluse: "+(string)sloodleobjectaccessleveluse);
}
else if (name == "set:sloodleserveraccesslevel") {
sloodleserveraccesslevel = (integer)value1;
debug("sloodleserveraccesslevel: "+(string)sloodleserveraccesslevel);
}
else if (name == SLOODLE_EOF) eof = TRUE;
return (sloodleserverroot != "" && sloodlecontrollerid > 0);
}
debug (string message ){
list params = llGetPrimitiveParams ([PRIM_MATERIAL ]);
if (llList2Integer (params ,0)==PRIM_MATERIAL_FLESH){
llOwnerSay("memory: "+(string)llGetFreeMemory()+" Script name: "+llGetScriptName ()+": " +message );
}
}
default {
on_rez(integer start_param) {
llResetScript();
}
state_entry(){
isconfigured = FALSE;
eof = FALSE;
}
link_message( integer sender_num, integer chan, string str, key user_key){
// Check the channel for configuration messages
if (chan == SLOODLE_CHANNEL_OBJECT_DIALOG) {
// Split the message into lines
list lines = llParseString2List(str, ["\n"], []);
integer numlines = llGetListLength(lines);
integer i = 0;
for (i=0; i < numlines; i++) {
isconfigured = sloodle_handle_command(llList2String(lines, i));
}
// If we've got all our data AND reached the end of the configuration data (eof), then move on
if (eof == TRUE) {
if (isconfigured == TRUE) {
sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configurationreceived", [], NULL_KEY, "");
state ready;
} else {
// Go all configuration but, it's not complete... request reconfiguration
sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configdatamissing", [llGetScriptName()], NULL_KEY, "");
llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reconfigure", NULL_KEY);
eof = FALSE;
}
}
}
}
}
state ready{
on_rez(integer start_param) {
llResetScript();
}
state_entry() {
eof == FALSE;
isconfigured=FALSE;
}
link_message( integer sender_num, integer chan, string str, key user_key){
// Check the channel for configuration messages
if (chan == SLOODLE_CHANNEL_OBJECT_DIALOG) {
// Split the message into lines
list lines = llParseString2List(str, ["\n"], []);
integer numlines = llGetListLength(lines);
integer i = 0;
for (i=0; i < numlines; i++) {
isconfigured = sloodle_handle_command(llList2String(lines, i));
}
// If we've got all our data AND reached the end of the configuration data (eof), then move on
if (eof == TRUE) {
if (isconfigured == TRUE) {
sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configurationreceived", [], NULL_KEY, "");
} else {
// Go all configuration but, it's not complete... request reconfiguration
sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configdatamissing", [llGetScriptName()], NULL_KEY, "");
llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reconfigure", NULL_KEY);
eof = FALSE;
}
}
}
}
}