Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: teenage_musings on Tue 27/05/2008 14:20:42

Title: Using an inventory item to make an object change image...
Post by: teenage_musings on Tue 27/05/2008 14:20:42
 ??? I was wondering if it would be possible to script it so an item that clicked on an object would be able to change the object's image.

Example: (image of wardrobe closed -- click with item such as key --> image of open wardrobe)

If so, how would you script it? Some help would be much appreciated.
Title: Re: Using an inventory item to make an object change image...
Post by: Snake on Tue 27/05/2008 15:24:13
If it is the wardrobe being open and closed, you could simply turn the objects (wardrobe open, wardrobe closed) on and off.

Example:
Wardrobe Closed - Object 1
Wardrobe Open - Object 2

//player clicks key on object 1
Display("You use the key to open the wardobe...");
object[1].Visible=false;
object[2].Visible=true;


Then for when the player interacts with object 2, run whatever script you'd like.

I hope this helps,

//--EDIT--//
There is another way to do it. You can directly change the image of the object and keep the object the same. Then just use local/global variables to tell when the image has changed. I can't remember which command it is, but it's in the manual somewhere.

//--EDIT 2--//

Here it is:

object[1].Graphic = 100;

Whichever object the Wardrobe is and whatever sprite slot the sprite is in (in the sprite manager - the number under the image).


--Snake