Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mugs on Sat 07/03/2009 20:20:47

Title: "Selected Graphic" for Inventory Items (Solved for now)
Post by: Mugs on Sat 07/03/2009 20:20:47
I looked everywhere for a solution to my problem,  but I couldn't find one.  Anyways...


I want the graphic of an inventory item to change when it is selected.  This is so that the player knows which inventory item is selected (the game does not use inventory cursors). 

I don't know what details to provide,  but here are some details anyways:

iPencil =  Name of inventory item ("Normal" graphic slot is 46  -  The desired "selected" graphic slot is 48) 
cPlay = Player character (Note:  I plan to have many player characters in the game)

Please tell me if I am missing any necessary details.


Thank you in advance.

Title: Re: "Selected Graphic" for Inventory Items
Post by: AdamM on Sat 07/03/2009 20:32:36
Off the top of my head, do you see any problems with this?

function repeatedly_execute() {

if (cPlay.ActiveInventory == iPencil) {
  iPencil.Graphic = 48
}

else {
iPencil.Graphic = 46
}

}
Title: Re: "Selected Graphic" for Inventory Items (Solved for now)
Post by: Mugs on Sat 07/03/2009 20:51:55
Thank you very much.   I knew that the solution would probably involve iPencil.Graphic,  but it didn't work when I tried it on my own.

The code seems to be working fine, however, I might run into a problem later on.  Its kinda hard to explain. 

I'll post an update if ever I run into another problem.
Title: Re: "Selected Graphic" for Inventory Items (Solved for now)
Post by: AdamM on Sat 07/03/2009 22:45:27
Oh, I can't believe I forgot the semicolons. I'm such an amateur!
Title: Re: "Selected Graphic" for Inventory Items (Solved for now)
Post by: Trent R on Sat 07/03/2009 23:20:01
I'd suggest using some custom properties. Either use one in conjuction with the CursorGraphic property, or use two custom properties. Then you can call something like iPencil.Graphic=iPencil.GetProperty("Selected").

If you have 'handle inventory clicks in script' set to true, I believe you can take this further and have it do it all for you. Otherwise, you'd probably have to hardcode it all with a rep_exec like Adam posted.



~Trent
Title: Re: "Selected Graphic" for Inventory Items (Solved for now)
Post by: Khris on Sun 08/03/2009 09:31:15
Since 3.1.2 there's InventoryItem.CursorGraphic.
I didn't test it, but I guess it'll still return the slot if "Use selected inventory graphic for cursor" isn't checked.