Jump to content

Simple on/off not working


Ultea
 Share

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

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

Recommended Posts

I got this working perfectly, then tried to change it, broke it, and forgot how it worked. Now I'm starting over.

Basically, I'm trying to get the script to make certain prims visible in a certain sequence when responding to a HUD, and either turn off or on depending on if the prim is already on (cupon), or another linked prim is already on (on). The HUD works fine. The problem is for some reason, despite the script's toggles being set "OFF," the script behaves as if they're "TRUE" when being triggered by the HUD, and it doesn't toggle, it just repeats the same function (power_off()) over and over. power_on(), power_off(),  and cup_on just make different prims visible in different colors. I figure I'm missing something obvious but am at my wit's end. Any help would be appreciated.


all_off()
{
    llSetLinkPrimitiveParamsFast( LINK_ALL_CHILDREN, [ PRIM_GLOW, ALL_SIDES, 0.0, PRIM_COLOR, ALL_SIDES, white, 0.0 ] );
    llSetLinkPrimitiveParamsFast( 3, [ PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 1.0, 1.0]);
    on = FALSE;
    cupon = FALSE;
}
default

{
state_entry()
    {
    llSetLinkPrimitiveParamsFast( LINK_ALL_CHILDREN, [ PRIM_GLOW, ALL_SIDES, 0.0, PRIM_COLOR, ALL_SIDES, white, 0.0 ] );
    llSetLinkPrimitiveParamsFast( 3, [ PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 1.0, 1.0]);
    on = FALSE;
    cupon = FALSE;     
    HUD_channel=-11*llAbs((integer)("0x"+ llGetSubString(llGetOwner(),0,7)));
    key owner = llGetOwner();
    llListen(HUD_channel,"","","");
    }
listen( integer channel, string name, key id, string message )
    {
        if( message == "SHUD92" )
            {
                if(on = TRUE)
                    {
                        if(cupon = TRUE)
                        {
                            power_off();
                            all_off();
                        }
                        else
                        {
                            power_on();
                            on = TRUE;
                            cupon = TRUE;
                        }
                    }
                else if (on = FALSE)
                    {
                        cup_on();
                        on = TRUE;
                        cupon = TRUE;
                    }
            }
    }
}

Link to comment
Share on other sites

Thank you! I knew I missed something obvious. But while that changed the behavior in the right direction, it's still not working. Now it just repeats this step:

else if (on == FALSE)
                    {
                        cup_on();
                        on == TRUE;
                        cupon == TRUE;

}

Over and over again

Edit: To clarify, when I say "over and over" I mean, when i hit the HUD button again it repeats, not that it's repeating on its own after one message from the HUD

Edited by Ultea
Link to comment
Share on other sites

2 minutes ago, Ultea said:

Thank you! I knew I missed something obvious. But while that changed the behavior in the right direction, it's still not working. Now it just repeats this step:

else if (on == FALSE)
                    {
                        cup_on();
                        on == TRUE;
                        cupon == TRUE;

}

Over and over again

Remember "==" compares two values. "=" assigns them. 

So you will have to at least make the following changes: 
 

			on = TRUE;
			cupon = TRUE;

 

Link to comment
Share on other sites

3 minutes ago, Ultea said:

else if (on == FALSE)
                    {
                        cup_on();
                        on == TRUE;
                        cupon == TRUE;

When you want to compare two things to see if they're equal, you need to use == as you did in the if-condition.

When you want to set (assign) a value, you need to use =.

You changed too much, you don't want those two last lines to be comparisons.

Link to comment
Share on other sites

Yes thank you, I was adding more lines just to be extra sure things were working right; originally I didn't have any of those statements written out, and will just use all_off/power_on/power_off again from now on!

Link to comment
Share on other sites

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