Could one of you clever people suggest where I'm going wrong? The following script is supposed to do nothing more than make a prim go up if it's below a certain height and down if it's above a certain height. Annoyingly, it seems to really, really want to go down.
It's probably hopelessly over-complicated for what it is, but I've been fiddling with it all evening, and should have gone to bed hours ago. Thanks in advance.
// Unbelievably annoying up/down script
// by Ford "Go up, damn you, for the love of all that's merciful, just go up" Static
vector startPosition;
vector newPosition;
vector targetPositionA;
vector targetPositionB;
integer isup = FALSE;
default
{
state_entry()
{
startPosition = llGetPos();
targetPositionA = (startPosition + <0.0, 0.0, 8.0>

targetPositionB = (startPosition + <0.0, 0.0, -8.0>

}
touch_start(integer total_number)
{
if (isup = FALSE)
{
llSay(0, "False"

state moveup;
}
else
{
llSay(0, "True"

state movedown;
}
}
}
state moveup
{
state_entry()
{
newPosition = llGetPos();
if (newPosition.z < targetPositionA.z)
{
llSetPos(newPosition + <0.0, 0.0, 0.2>

state newupstate;
}
else
{
isup = TRUE;
state default;
}
}
}
state newupstate
{
state_entry()
{
state moveup;
}
}
state movedown
{
state_entry()
{
newPosition = llGetPos();
if (newPosition.z > targetPositionB.z)
{
llSetPos(newPosition + <0.0, 0.0, -0.2>

state newdownstate;
}
else
{
isup = FALSE;
state default;
}
state newdownstate;
}
}
state newdownstate
{
state_entry()
{
state movedown;
}
}