Hey all, noob to LSL (although I have a little knowledge of other languages like c#). I'm really sorry but I have such a dumb issue I simply cant fix myself and I wondered if I could ask for you wise words on this;
What I'm trying to do;
I have a prim with a simple function,#; it toggles a boolean integer value TRUE and FALSE and using a timer, spins a prim for a couple of seconds in one direction if the value is TRUE, the reverses the spin if the value is FALSE, like you would see the swing of a pendulum. I haven't been able to make it change direction. After spending hours going down a rabbit hole thinking my llSetTargetOmega call was dodgy, i realised its actually the control logic that is flawed.
I then wondered whether my state handling was doing it, (the prim has an on off state toggled by touch_start) but when i removed that and just used the default state, I still have the problem.
So here is the code snippet without any state logic and with just the control logic enabled plus a couple of debug messages so I can watch the code paths taken. As you will see when you run it, it never reaches the code in the else statement. I have tried two IF without ELSES, didn't work either.
integer direction = TRUE;
default
{
state_entry()
{
llSetText("ON", <0,1,0>, 1.0);
llSetTimerEvent(2.0);
}
timer()
{
if ( direction = TRUE )
{
llSay(0,"Back");
//llTargetOmega(<0,0,-0.5>,0.5,PI);
}
else
{
llSay(0,"Forth");
//llTargetOmega(<0,0,0.5>,0.5,PI);
}
direction = !direction;
}
}
I'm tearing my hair out here, I thought I knew how to code!! Please could someone help me see what I'm doing wrong?
Many many thanks in advance, Lisa x ♥