Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Surplusguy on Sat 28/09/2013 00:38:21

Title: Avoid conflicting action error?
Post by: Surplusguy on Sat 28/09/2013 00:38:21
So I've set up a minigame to run like this. Several objects fly at the player, who must click on them to make them stop moving.
Once all the objects are hit, a rep_exec variable makes the player move to the next room. If the player is hit, they move to a
"game over" screen. The problem is, if the player is hit while they are about to move to the next room, an error occurs where both can't be executed at once, of course. What I want to know is, besides making the objects disappear instantly when hit, is there a way to avoid this error?

Cheers, Surplus
Title: Re: Avoid conflicting action error?
Post by: Khris on Sat 28/09/2013 00:59:11
The error you're getting is because your code allows both conditions (win & lose) to be true in the same frame.
You can avoid this by not calling player.ChangeRoom() directly when the win or lose condition is met:

Code (ags) Select
  // in repeatedly_execute (pseudo code)
  int next_room = 0;
  if (player loses) next_room = 3;
  if (player wins) next_room = 4; // winning takes precedence
  if (next_room) player.ChangeRoom(next_room);


That way you can't end up with two room changes in the queue.
Title: Re: Avoid conflicting action error?
Post by: Surplusguy on Sat 28/09/2013 03:22:12
And I thought I could get out of some extra work by not setting up two separate variables for the actions... Oh well.

Thanks for the help, Khris!
Title: Re: Avoid conflicting action error?
Post by: Khris on Sat 28/09/2013 08:47:31
Wait, how are you setting up two separate variables? My code doesn't.