Week 3 UW scripts
Script 3.1:
// UW3.1
// Similar to Listing 2.6: Flip Tag - Label Yourself
integer CHANNEL = 9; // Channel number to listen on
vector RGB = <255,255,255>; // color of the text
default
{
on_rez(integer start_param) {
llResetScript();
}
state_entry() {
llListen(CHANNEL, "", llGetOwner(), "");
}
listen(integer channel, string name, key id, string message) {
llSetText(message, RGB/255.0, 1.0);
}
}
And another, Script 3.2:
// UW3.2
// From Listing 3.4: Mimic Someone
string who = "Someone";
integer CHANNEL = 11;
sayAs(string name, string message) {
string realname = llGetObjectName();
llSetObjectName(name);
llSay(0, message);
llSetObjectName(realname);
}
default
{
on_rez(integer x) { llResetScript(); }
state_entry(){
llOwnerSay("/"+(string)CHANNEL+"=name or /"+(string)CHANNEL+" message");
llListen(CHANNEL, "", llGetOwner(), "");
}
listen(integer channel, string name, key id, string message) {
if ("=" == llGetSubString(message, 0, 0)) {
who = llGetSubString(message,1,-1);
llOwnerSay("Pssst... Got it, boss. I am mimicking "+who);
} else {
sayAs(who, message);
}
}
}
and one more for good measure, Script 3.3 (formatting fixed):
Challenge – do something interesting and/or different with this script (3.3) for next week!
// UW3.3
string emailAddress = "vexstreeter@gmail.com"; // who gets suggestions?
key suggestKey; // key of person making suggestion
string suggestName; // name of person making suggestion
show(string message) {
llSetText(message, <1,1,1>, 1.0);
}
default {
state_entry() {
show("Touch me to\nmake a suggestion");
}
touch(integer p) {
suggestKey = llDetectedKey(0);
suggestName = llDetectedName(0);
state accept;
}
}
state accept {
on_rez(integer p) { llResetScript(); }
state_entry() {
llListen(0, "", suggestKey, "");
show("Listening to "+suggestName);
llSay(0, "Thank you, "+suggestName+" for offering to help. Please type your suggestion now.");
llSetTimerEvent(30.0);
}
listen(integer c, string n, key k, string message) {
llInstantMessage(k, "Thanks for the valuable input!");
show("delivering suggestion...");
llEmail(emailAddress, "Suggestion from "+n, message);
state default;
}
timer() {
llSay(0, "Whoops, ran out of time");
state default;
}
state_exit() {
llSetTimerEvent(0.0);
}
}
