Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GameMaker_95 on Wed 13/05/2015 07:37:33

Title: Objects Visible with Certain condition.
Post by: GameMaker_95 on Wed 13/05/2015 07:37:33
Hi,

I have a problem with two objects which are characters. I need one to be visible and the other not, unless I have a certain object in my Inventory
In which case, reverse that. I have tried a number of different variations, object visible from start and such, but all I get is only one visible and
that being the wrong one, or both visible. Here is the code I am using, I can't get it to work and it could be completely obvious, in which case, sorry in
advance.

Code (ags) Select


function room_Load()
{
      if (player.HasInventory(iBurnie)) {
        object[2].Visible = false;
        object[3].Visible = true;
    } else {
        object[2].Visible = true;
        object[3].Visible = false;       
    }
}   
   
 

Thanks,
GameMaker95
Title: Re: Objects Visible with Certain condition.
Post by: Gilbert on Wed 13/05/2015 08:28:42
Hmmm. The code seems legit to me. Are there any other lines in the room script that reference the two objects and may change their properties?
Title: Re: Objects Visible with Certain condition.
Post by: GameMaker_95 on Wed 13/05/2015 08:37:32
Hi Gilbert

I checked and the only things in the rooms script that reference the objects are the look, interact, talk
messages. Other than that, no, nothing to interfere.
Title: Re: Objects Visible with Certain condition.
Post by: Snarky on Wed 13/05/2015 08:50:31
Have you tried using the script names of the objects instead of the object[i] array indices? It's generally a better way, since it's easy to get mixed up about which objects are object[2] and object[3].
Title: Re: Objects Visible with Certain condition.
Post by: GameMaker_95 on Wed 13/05/2015 09:00:23
Snarky, you are a genius.

I changed it and it works perfectly now, thanks so much.