SOLVED: Sequence issue when using CallRoomScript

Started by johanvepa, Mon 10/06/2013 22:00:55

Previous topic - Next topic

johanvepa

When using CallRoomScript to set a bool for use of a given function, the sequence seems to mess up.

In my global script, I have a button which activates a function leading to a chain of ifs and elses with according events.

In that function, I would like to use a callroomscript to set a bool for the success or failure of a given task, determined by a set of conditions in the room script of each room.

So, in the top of the function, I call roomscript no. 1. In the local script, on_call 1 sets the bool that determines wether the action carried out later in the function is succesful. A little further down in the function, the task is carried out, with success determined by the now-set bool.

But, something's awry. Upon testing many times, I have discovered that the callroomscript is for some reason always carried out AFTER the rest of the contents of the function. even though I put the callroomscrpit at the top, the functions FIRST carries out the other events, THEN calls the roomscript. This means the bool is not set before the event is carried out. it is set after the event is carried out (meaning if I do the action twice, the bool return from the first go-around determines the succes/failure of the next attempt).

Anyone see what I'm getting at?

Khris

Do you mean to tell us that
Quote from: manual, CallRoomScript()The function doesn't get called immediately; instead, the engine will run it in due course, probably during the next game loop, so you can't use any values set by it immediately.
? 8-0

(sorry)

Now. What you do to resolve this is quite simple: in the function that's calling CallRoomScript(), put everything after the call in another function. Now import this second function in the header.
Finally, call it at the end of the room's on_call function, after the variable is set.

johanvepa

There's no need to be sarcastic about it.

Thank you anyway.

Phemar


SMF spam blocked by CleanTalk