'ChangeRoom' implies 'return' ? (ANSWERED)

Started by EnterTheStory (aka tolworthy), Thu 12/06/2008 11:19:04

Previous topic - Next topic

EnterTheStory (aka tolworthy)

True or false:

If function1 calls function2, and function2 calls 'ChangeRoom,' then function2 ends, right?
And function1 will end as well? So adding 'return' is redundant?

(Edited for clarity)

SSH

No. The Room Change will occur after the script has completed.
12

EnterTheStory (aka tolworthy)

Quote from: SSH on Thu 12/06/2008 12:16:49
No. The Room Change will occur after the script has completed.
So in this imaginary example:
Code: ags

function do_A()
{ Display("A1");
  player.changeRoom(x); 
 Display("A2");
}
function do_B()
{ Display("B1");
  do_A(); 
 Display("B2");
}

Running do_B() I would expect to see displayed B1, A1,A2,B2, and THEN the room changes?

GarageGothic

#3
Yes, that's indeed what will happen. But wouldn't it be easier just trying it out (like I just did) than writing the code and then post it on the forum?

EnterTheStory (aka tolworthy)

#4
Quote from: GarageGothic on Thu 12/06/2008 19:11:03
Yes, that's indeed what will happen. But wouldn't it be easier just trying it out (like I just did) than writing the code and then post it on the forum?
Often my code SEEMS to be doing one thing, but it's ACTUALLY doing something else and the desired result was only a coincidence. So it's good to check with the experts.

Khris

True, but you COULD'VE tried your imaginary example first ;)

SMF spam blocked by CleanTalk