// The virtual "window" where the StatusMonitor "writes" to. // Copyright (C) 2005-2006 Francisco V. Saldana // // 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 2 // 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, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // Francisco V. Saldana can be contacted using his email account // username: dressedinblue, at domain: gmail.com // and in Second Life by IMming Christopher Omega // ========== For method invocation ========== string randomStr(string chars, integer len) { integer numChars = llStringLength(chars); string ret; integer i; for (i = 0; i < len; i++) { integer randIndex = llFloor(llFrand(numChars)); ret += llGetSubString(chars, randIndex, randIndex); } return ret; } string SEPERATOR_CHARS = "`~!@#$%^&*()-_+[]{}\|'\";/?.>,<"; integer SEPERATOR_LEN = 3; string dumpList2String(list src) { // Generate a seperator not present in any of the // elements in the list. string chars = (string) src; // Squashes all elements together. string seperator; do { seperator = randomStr(SEPERATOR_CHARS, SEPERATOR_LEN); } while (llSubStringIndex(chars, seperator) != -1); return seperator + llDumpList2String(src, seperator); } list parseStringKeepNulls(string src) { // The seperator should be the first SEPERATOR_LEN // characters in the string. return llParseStringKeepNulls(llDeleteSubString(src, 0, SEPERATOR_LEN - 1), [llGetSubString(src, 0, SEPERATOR_LEN - 1)], []); } callMethod(integer callId, string methodName, list parameters) { llMessageLinked(LINK_THIS, callId, dumpList2String(parameters), methodName); } returnValue(string methodName, integer methodIdentifyer, list value) { llMessageLinked(LINK_THIS, methodIdentifyer, dumpList2String(value), methodName + "_ret"); } // ============================================= trigger_setDisplayLineText(integer line, string text) { callMethod(0, "setDisplayLineText", [line, text]); } trigger_setDisplayLineColor(integer line, vector color) { callMethod(0, "setDisplayLineColor", [line, color]); } trigger_pong(string moduleName) { callMethod(0, "pong", [moduleName]); } integer LINE = 12; integer statusBarEnabled = TRUE; string this; default { state_entry() { this = llGetScriptName(); } link_message(integer sender, integer num, string parameters, key methodName) { if (methodName == "displayStatusMessage") { list paramList = parseStringKeepNulls(parameters); // Method signature: // displayStatusMsg(string message) string message = llList2String(paramList, 0); trigger_setDisplayLineText(LINE, message); trigger_setDisplayLineColor(LINE, <1, 1, 1>); } else if (methodName == "setStatusDisplay") { list paramList = parseStringKeepNulls(parameters); // Method signature: // setStatusDisplay(boolean show) integer show = (integer) llList2String(paramList, 0); statusBarEnabled = show; } else if (methodName == "ping") { list paramList = parseStringKeepNulls(parameters); // Method signature: // ping(string moduleName) string moduleName = llList2String(paramList, 0); if (moduleName == this) trigger_pong(this); } } }