Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: I<3Pindorama! on Sun 04/01/2015 18:16:28

Title: One button with distinct functions in diferent rooms
Post by: I<3Pindorama! on Sun 04/01/2015 18:16:28
I created a button and would like it take different actions
depending on the room in which it is engaged.

For example, if he is in the room 1 then when clicked
the player will go to room 2, but if he is in the room 2
then the player will go to room 3 or if you are in room 3
the player back to room 1 (or go to any other room that I indicate).

(http://i.imgur.com/WQzJEa2.png)

Always grateful for any help or information where
i find a solution for this question!  :-D
Title: Re: One button with distinct functions in diferent rooms
Post by: Gurok on Sun 04/01/2015 19:17:35
If this is a GUI button and you want to do this from a global script, you can use player.Room

function btnTeleport_OnClick(GUIControl *control, MouseButton button)
{
    if(player.Room == 1)
        player.ChangeRoom(2, 100, 50);
    else
        if(player.Room == 2)
            player.ChangeRoom(3, 100, 50);
        else
            if(player.Room == 3)
                player.ChangeRoom(1, 100, 50);
            else
                Display("No!");
}
Title: Re: One button with distinct functions in diferent rooms
Post by: I<3Pindorama! on Sun 04/01/2015 20:26:06
Perfect!
(http://www.pixeljoint.com/files/icons/full/purple.gif)

It was exactly what I needed!

Sorry for not mentioning this detail (Gui Button) because at first
it did not seem relevant ... naive mistake on my part, given that it
takes a different condition in Ags.

After all you helped me 2 times!
Thank you very much, Gurok!
;-D