Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: En garde! on Wed 13/04/2005 02:10:27

Title: Operating a switch [SOLVED]
Post by: En garde! on Wed 13/04/2005 02:10:27
Okay, here's the thing: I have a room with a hotspot, you press it once and an object appears. What I need is to make the object disappear once you press the same hotspot again. Basically I need an on/off switch. Easy, isn't it? Well, no. I think I've tried everything and nothing. Can somebody tell me an easy way? As usual, asume that you are talking with an idiot without the slightest idea of programming.
Title: Re: Operating a switch
Post by: strazer on Wed 13/04/2005 02:19:22

// script for hotspot: Interact with hotspot

  if (IsObjectOn(THEOBJECTNUMBER)) ObjectOff(THEOBJECTNUMBER);
  else ObjectOn(THEOBJECTNUMBER);
Title: Re: Operating a switch
Post by: En garde! on Wed 13/04/2005 02:37:03
Ha! It worked! Well, if I'm going to make stoopid newbie questions, I may as well go along with it.

Um... a way to make the same making the object on and off AND a different spot being enabled and disabled with it?
Title: Re: Operating a switch
Post by: strazer on Wed 13/04/2005 02:47:15

// script for hotspot: Interact with hotspot

  if (IsObjectOn(THEOBJECTNUMBER)) {
    ObjectOff(THEOBJECTNUMBER);
    DisableHotspot(THEHOTSPOTNUMBER);
  }
  else {
    ObjectOn(THEOBJECTNUMBER);
    EnableHotspot(THEHOTSPOTNUMBER);
  }
Title: Re: Operating a switch
Post by: En garde! on Wed 13/04/2005 02:58:01
Thanks a bunch. I owe you one.
Title: Re: Operating a switch
Post by: strazer on Wed 13/04/2005 03:00:09
You're welcome. :)