Objects Visible with Certain condition.

Started by GameMaker_95, Wed 13/05/2015 07:37:33

Previous topic - Next topic

GameMaker_95

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


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

Gilbert

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?

GameMaker_95

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.

Snarky

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].

GameMaker_95

Snarky, you are a genius.

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

SMF spam blocked by CleanTalk