Jump to content

Glow-changing script-thingy?


Symphicat
 Share

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

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

Recommended Posts

Hey!

 

I'll try and jump straight to the point: I can't code.

 

 

I've been trying to make a script that listens to a numeric valuable given to it in the /1 channel with the keyword "energy".

 

The lowest possible value being 0 & the highest possible value being 100.

 

I want this script to do the following: automatically set full bright on an object, and the glow value to 0.23, and then lower the Glow value for every time I subtract the "energy" value by 25, so that when the "energy" value hits zero, Glow is at 0.00 and full bright is turned off.

However, I also want full bright to be on the moment the "energy" value is 1 or higher.

 

My attempts failed, I am not good enough for it. My script wasn't even remotely what I was looking for, so now I'm asking for some help! Does anyone have a script like that for me to study, mod & use, or know about a script that would suit my needs?

 

I would honestly prefer to be able to see the code so I can learn from it if you do <3

 

Peace!

Link to comment
Share on other sites

You're not likely to find a pre-made script that does exactly that just lying around.  You have all the logic you need, though.  The function you need to play with is llSetPrimitiveParams, which will let you give values to each of the parameters you want to change ...  PRIM_FULLBRIGHT and PRIM_GLOW.  So, all you need to do is assign a global variable to each of those two parameters and then listen for the value of "energy" that you hear in chat.  The rest is all a set of if statements ....

 

if (energy > 1){    fullbright = TRUE;}if (energy > 75){    glow = 0.23;}else if (energy > 50){    glow = 0.12;}// blah blah blahelse{    fullbright = FALSE;    glow = 0.0;}llSetPrimitiveParams([PRIM_FULLBRIGHT,fullbright,PRIM_GLOW,glow]);

 

 

 

  • Like 1
Link to comment
Share on other sites

This is one way to do it I think.

 

default {
    state_entry() {
        llListen(1, llKey2Name(llGetOwner()), llGetOwner(), "");
    }

    listen(integer channel, string name, key id, string message) {
        list temp = llParseString2List(message, [" "], []);
        if (llToLower(llList2String(temp, 0)) == "energy") {
            integer energy = (integer)llList2String(temp, 1);
            if (energy > 100) energy = 100;
            else if (energy < 0) energy = 0;
            float glow = 0.23 / 4 * energy / 25;
            llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, llRound(glow + .4977), PRIM_GLOW, ALL_SIDES, glow]);
        }
    }
}

 

  • Like 1
Link to comment
Share on other sites

  • 8 years later...
You are about to reply to a thread that has been inactive for 1617 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...