Jump to content

Magic 8 Ball

Kelly Kuroda

You are about to reply to a thread that has been inactive for 4808 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 :))




// 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 = [
"As I see it, yes.",
"It is certain.",
"It is decidedly so.",
"Most likely.",
"Outlook good.",
"Signs point to yes.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"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 = [
    dHandle = llListen(dChannel,"","",""); 

FadeTextIn(string R){
    integer s = -1;
    integer e = 11;
    for(; s < e; ++s){
FadeTextOut(string R){
    llParticleSystem([]);//stop particle effects
    integer s = 11;
    integer e = -1;
    for(; s > e; --s){
    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;
// 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;
        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   ]);

        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);
    timer(){//timer hear to clear the effects &
    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 4808 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

  • Create New...