Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Stranga on Sat 30/09/2017 07:51:14

Title: Set a Gobal.int to an Inventory Item ID [SOLVED]
Post by: Stranga on Sat 30/09/2017 07:51:14
EDIT:

I worked it out but it took a while. What I had to do was make 2 inventory windows 1 for the actual inventory menu and the other for the equip box.
Then I used this:

Code (ags) Select
  InventoryItem *i = InventoryItem.GetAtScreenXY(InventoryWindow2.X, InventoryWindow2.Y);
            if (i != null) ItemSelect = i.ID;


I worked out that you need to gave a visible GUI to use GetAtScreen(Take it easy, I'm a newb at scripting)
But I may upload this inventory system I made if or when I get time. It's easy and simple to use if you want to make a full keyboard integrated game plus you use AGS's inbuilt inventory system rather than create your own from scratch. :)

Hey everyone,

Basically what it says in the subject (If that makes sense). What I'm trying to achieve is when the player has an "equipped item" do something.
For example:

player has a key equipped
(pardon the very watered down code)

if player stands on a hotspot and item.ID = 2;
{
Do something

}

So basically all I need is something to tell and set say a global variable "ItemSelect" what item ID is in the equip box OR at the top of the inventory window.
Title: Re: Set a Gobal.int to an Inventory Item ID
Post by: Slasher on Sat 30/09/2017 08:49:06
You could just put something like this if you used a region which should be used

Code (ags) Select

// After walking on the region
If (player.HasInventory(iLamp)){ // or whichever item you have in your inventory
//Do this
}
Title: Re: Set a Gobal.int to an Inventory Item ID
Post by: Stranga on Sat 30/09/2017 08:58:46
Thanks for replying Slasher. That is actually my back up plan if I couldn't figure this out.
Title: Re: Set a Gobal.int to an Inventory Item ID [SOLVED]
Post by: Khris on Mon 02/10/2017 10:37:23
Quote from: Stranga on Sat 30/09/2017 07:51:14if player stands on a hotspot and item.ID = 2;
I realize this is pseudo-code, but no semi-colon before the if-block. Common beginner's mistake.
Also, don't use the "stands on hotspot" event, use regions like Slasher says.