Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sylvr on Mon 25/03/2013 15:40:53

Title: How to check if a single object was looked at
Post by: Sylvr on Mon 25/03/2013 15:40:53
Perhaps this doesn't belong in the beginner's forum, but since it seems a simpler problem than my reference thread....

My goal here is to have the player only able to get the waffle from the freezer, if the menu, as an inventory item, was looked at first. The only thread on the matter I could find was this (http://www.adventuregamestudio.co.uk/forums/index.php?topic=47182.msg633899#msg633899) one, but I can't figure out how to simplify the code for just one single item. I understand that it needs to involve the global script though, since iMenu could be looked at in any room.

My current fix is "if player has iMenu, waffles are attainable. just click on the freezer door."

Thanks!
Title: Re: How to check if a single object was looked at
Post by: Khris on Mon 25/03/2013 15:46:59
Just add a global bool variable in the Global Variables pane (name: looked_at_menu, initial value: false)

In iMenu's Lookat: looked_at_menu = true;

In the freezer's code, do
Code (ags) Select
  if (looked_at_menu) {
    // get waffles
  }
  else {
    player.Say("I'm not sure what to look for.");
  }
Title: Re: How to check if a single object was looked at
Post by: Sylvr on Mon 25/03/2013 16:10:22
Totally forgot about global variables. Thanks so much!