Set a Gobal.int to an Inventory Item ID [SOLVED]

Started by Stranga, Sat 30/09/2017 07:51:14

Previous topic - Next topic

Stranga

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
  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.

Slasher

You could just put something like this if you used a region which should be used

Code: ags

// After walking on the region
If (player.HasInventory(iLamp)){ // or whichever item you have in your inventory
//Do this
}

Stranga

Thanks for replying Slasher. That is actually my back up plan if I couldn't figure this out.

Khris

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.

SMF spam blocked by CleanTalk