Jump to content

Magic 8 Ball


Kelly Kuroda
 Share

You are about to reply to a thread that has been inactive for 4725 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi Guys. Can anyone suggest the best way to make this 8 ball script only answer questions in local chat, that are posed by the owner? I have looked at channels and listeners, but can't seem to make it happen. :(( Thank you :))

 

 

//•/•/•/•/•/•/•/Ð/A/M/E/N/•/H/A/X/•/•/•/•/•/•/•/•/•//

// basic randomizing of lists, listening for a sentence ending with a ? to trigger random response.
// thanks to Polymerase Writer retexturing/rescaling; making it look better than it did =]

string Result = "~Magic 8 Ball~";
integer dHandle;
integer dChannel = 0;//channel we listen on
vector tColor = <0.386,1.000,0.949>;//text color
float tAlpha = 1.0;//text alpha
float Volume = 1.0;// 0.00 to 1.00
float EffectsDelay = 2.5;//how long(in seconds) to keep particle effects & floating text
float tDelay = 0.1;//fade speed of the floating text

string OnRezInfo = " How-to/Info;
1. Ask a question that I can respond to with a yes or no answer.
2. Say something in chat that ends with a question mark, like this line you're reading?
3. If the answer seems wrong.. ask if it's lieing ;)

Note; I will respond to any question ending with a question mark.";

list aList;
list Answers = [
//affirmative
"As I see it, yes.",
"It is certain.",
"It is decidedly so.",
"Most likely.",
"Outlook good.",
"Signs point to yes.",
"Without a doubt.",
"Yes.",
"Yes - definitely.",
"You may rely on it.",
//non-committal
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
//negative
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."];

list sList;
//play a random sound each time answer is given
list Sounds = [
"0dad44ae-60a7-1275-1fec-60d0eb177a35",
"27f3bfb2-e973-a67d-d725-dadf4bd36aec",
"5b89fff5-6d45-b705-bb93-c5fde97c03a8",
"58222dc3-e222-03fe-78ae-703c27f5a051",
"aedc24d2-73dd-8e9a-a8cd-134379911863",
"8feb5208-9477-2f0c-3660-2c13b922b204",
"57934ded-7e33-4a04-3b5c-0d6aa8f0934f",
"0f0db9f1-edef-7ed8-dd6c-3d7bc91a0465",
"ceaa0705-5ea7-70d2-7e9b-5dfe5d090d20",
"66e82ee2-4b74-cf13-3d74-7727f17726b0",
"d08e3b76-c749-e112-8152-1862cb114295",
"a01d3fca-a3a5-bf8c-6fd0-aa5e91c682f3",
"bac77957-e838-6d3e-b9af-89edae882b8b",
"812f5aa1-77c4-282d-f698-6e995d9310cc",
"2bc60226-2cbf-084d-47d2-8cc665aa0700",
"fc2a539f-e72c-07d1-db41-bfff5b320ba7"];
//listen
Listen(){
    llListenRemove(dHandle);
    dHandle = llListen(dChannel,"","",""); 
}

FadeTextIn(string R){
    integer s = -1;
    integer e = 11;
    for(; s < e; ++s){
        llSleep(tDelay);
        llSetText(R,tColor,((float)s/10));
    }
}
FadeTextOut(string R){
    llParticleSystem([]);//stop particle effects
    integer s = 11;
    integer e = -1;
    for(; s > e; --s){
        llSleep(tDelay);
        llSetText(R,tColor,((float)s/10));
    }
    llSetTimerEvent(0.0);//stop timer to prevent endless loop
}
//Particle Params
integer effectFlags;
integer running             = TRUE;
integer colorInterpolation  = TRUE;
vector  startColor          = <0.310,0.897,1.000>;
vector  endColor            = <0.646,0.811,1.000>;
float   startAlpha          = 1.0;
float   endAlpha            = 0.0;
integer glowEffect          = TRUE;
integer sizeInterpolation   = TRUE;
vector  startSize           = <FALSE, 0.04,FALSE>;
vector  endSize             = <0.04, 0.50, FALSE>;
integer followVelocity      = TRUE;
string  texture             = "b31b25aa-de9a-32d7-7c3d-6cfb997c37ba";
float   particleLife        = 1.0;
float   SystemLife          = 0.0;
float   emissionRate        = 0.04;
integer partPerEmission     = 44;
float   radius              = 0.0;
float   innerAngle          = 1.55;
float   outerAngle          = 1.54;
vector  omega               = <0, 0, 0>;
float   minSpeed            = 0.044;
float   maxSpeed            = 0.044;
vector  acceleration        = ZERO_VECTOR;
integer windEffect          = FALSE;
integer bounceEffect        = FALSE;
integer followSource        = FALSE;
key     target              = NULL_KEY;
integer randomAcceleration  = FALSE;
integer randomVelocity      = FALSE;
integer particleTrails      = FALSE;
//   integer pattern = PSYS_SRC_PATTERN_DROP;
//   integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
//   integer pattern = PSYS_SRC_PATTERN_ANGLE;
//   integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
integer pattern = PSYS_SRC_PATTERN_EXPLODE;
//integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY;
Particles(){
// Here is where to set the current target
// llGetKey() targets this script's container object
// llGetOwner() targets the owner of this script
// Feel free to insert any other valid key
key target = "";
    if (colorInterpolation) effectFlags = effectFlags|PSYS_PART_INTERP_COLOR_MASK;
    if (sizeInterpolation)  effectFlags = effectFlags|PSYS_PART_INTERP_SCALE_MASK;
    if (windEffect)         effectFlags = effectFlags|PSYS_PART_WIND_MASK;
    if (bounceEffect)       effectFlags = effectFlags|PSYS_PART_BOUNCE_MASK;
    if (followSource)       effectFlags = effectFlags|PSYS_PART_FOLLOW_SRC_MASK;
    if (followVelocity)     effectFlags = effectFlags|PSYS_PART_FOLLOW_VELOCITY_MASK;
    if (target!="")       effectFlags = effectFlags|PSYS_PART_TARGET_POS_MASK;
    if (glowEffect)         effectFlags = effectFlags|PSYS_PART_EMISSIVE_MASK;
//Uncomment the following selections once they've been implemented
//    if (randomAcceleration) effectFlags = effectFlags|PSYS_PART_RANDOM_ACCEL_MASK;
//    if (randomVelocity)     effectFlags = effectFlags|PSYS_PART_RANDOM_VEL_MASK;
//    if (particleTrails)     effectFlags = effectFlags|PSYS_PART_TRAIL_MASK;
    llParticleSystem([
        PSYS_PART_FLAGS,            effectFlags,
        PSYS_SRC_PATTERN,           pattern,
        PSYS_PART_START_COLOR,      startColor,
        PSYS_PART_END_COLOR,        endColor,
        PSYS_PART_START_ALPHA,      startAlpha,
        PSYS_PART_END_ALPHA,        endAlpha,
        PSYS_PART_START_SCALE,      startSize,
        PSYS_PART_END_SCALE,        endSize,   
        PSYS_PART_MAX_AGE,          particleLife,
        PSYS_SRC_ACCEL,             acceleration,
        PSYS_SRC_TEXTURE,           texture,
        PSYS_SRC_BURST_RATE,        emissionRate,
        PSYS_SRC_INNERANGLE,        innerAngle,
        PSYS_SRC_OUTERANGLE,        outerAngle,
        PSYS_SRC_BURST_PART_COUNT,  partPerEmission,     
        PSYS_SRC_BURST_RADIUS,      radius,
        PSYS_SRC_BURST_SPEED_MIN,   minSpeed,
        PSYS_SRC_BURST_SPEED_MAX,   maxSpeed,
        PSYS_SRC_MAX_AGE,           SystemLife,
        PSYS_SRC_TARGET_KEY,        target,
        PSYS_SRC_OMEGA,             omega   ]);
}

default{
//
    state_entry(){
        llSetObjectName("Magic 8 Ball ~");
        Listen();//set up the listen, so we can hear whats said on the channel we're listening to
    }
//
    on_rez(integer x){
        llWhisper(0,"/me "+OnRezInfo);
        llResetScript();
    }
// 
    timer(){//timer hear to clear the effects &
        FadeTextOut(Result);
    }
//
    listen(integer channel, string name, key id, string msg){
        //if(channel != dChannel)return;//if not on our set channel.. ignore it, leave event.
//SubString examples from lslwiki.net
//string result = llGetSubString("abcd", 0, -1); // gets "abcd"
//string result = llGetSubString("abcd", 1, -2); // gets "bc"
//string result = llGetSubString("abcd", 1, 3); // gets "bcd"
//string result = llGetSubString("abcd", -2, -1); // gets "cd"
        string qMark =llGetSubString(msg, -1, -1);//we single out the very last character from message posted in chat
        if(qMark == "?"){//if the last character in the message posted into chat is a ?
            Particles();//start particle effect
            aList = llListRandomize(Answers, 1);//randomize our list of answers
            sList = llListRandomize(Sounds, 1);//randomize our list of sounds
            Result = llList2String(aList, 0);
            llTriggerSound(llList2String(sList, 0), Volume);//trigger our now random sound
            FadeTextIn(Result);//send our result to be faded into visible floating text
            llSay(0,"/me "+Result);//say in chat (channel 0) our random string from answers list
            llSetTimerEvent(EffectsDelay);//set timer event to stop particle effects & clear floating text.
        }
    }
//
}


 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4725 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...