User:BUTTONpUSHER Jones/pet protocol/COMMAND
Jump to navigation
Jump to search
// this script is untested // COMMAND script (output) // If chosen action is to command other pets to do an action // this script replaces constants with values, and sends it out. default { link_message(integer sender_num, integer num, string str, key id) { if (llGetSubString(str, 0, 6) == "command") { // llWhisper(0, "outgoing command is " + str); integer wordBegin; wordBegin = llSubStringIndex(str, "|owner"); if (wordBegin != -1) { str = llDeleteSubString(str, wordBegin+1, wordBegin+5); str = llInsertString(str, wordBegin+1, (string)llGetOwner()); // llWhisper(0, "modified command is " + str); } wordBegin = llSubStringIndex(str, "|mykey"); if (wordBegin != -1) { str = llDeleteSubString(str, wordBegin+1, wordBegin+5); str = llInsertString(str, wordBegin+1, (string)llGetKey()); // llWhisper(0, "modified command is " + str); } llWhisper(9000, str); // whisper the command on channel 9000. //***to do*** this channel needs to be picked more intelligently } } }