integer error_timeout = 45;
state useful_state {
state_entry() {
llOwnerSay("A"
;sendmsg("send_data",""
;llSetTimerEvent(error_timeout);
llResetTime();
}
timer() {
llOwnerSay("B"
;state default;
}
link_message(integer sender_num, integer num, string msg, key msg2) {
if (msg=="response" && "1" == msg2) {
llOwnerSay("C"
;state moveon;
}
}
}
There's the suspect state I have in my code; "sendmsg" is a function I made that just reformats linkmsg. What I have is this script that sends a message to another script, and receives a response. I have some error catching (it'll restart itself if no response received for example).
What is supposed to happen:
Object: A
Object sends linkmsg
Object initializes the timer for 45 seconds
Object receives message in response
Object: C
Object moves to moveon state.
What actually happens:
Object: A
Object sends linkmsg
Object initializes the timer for 45 seconds
Obecjt: B
Object moves to default state
Object reports a response was received but doesn't know what to do with it (as it's no longer in the correct state to process it)
-- other script timesout and retries --
Object: A
Object sends linkmsg
Object initializes the timer for 45 seconds
Object receives message in response
Object: C
object moves to moveon state.
It's very strange, it always fails the first time around.. but upon second attempt (it automatically keeps retrying until it works) it suddenly works again. I inserted the OwnerSay messages for debugging; that's how I verified that the timer is misfiring within the span of about a second of being called. I don't have the timer misconfigured as far as I can tell; I don't redefine error_timeout anywhere either.
Elsewhere in the script I do make use of the timer, and the error_timeout variable, but this shouldn't conflict when changing states, right?
The error_timeout variable is also reused in several other scripts in the same object.. that shouldn't matter though, right?

Please help!