Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Fri 11/08/2017 12:18:13

Title: Which inventory has been clicked on?
Post by: Slasher on Fri 11/08/2017 12:18:13
Hi,

my question is this:

Adding which inventory has been clicked on when combining inventory items. Player Says the line (which is a Random 'Say' variable).

Already have:

Code (ags) Select

player.SayAt(26, 0, 270,String.Format("To my knowledge %s and %s do not mix.",player.ActiveInventory.Name, inventory.Name));
// rather than just using ID: inventory[6]


Help appreciated

Cheers


Title: Re: Which inventory has been clicked on?
Post by: dayowlron on Fri 11/08/2017 14:27:29
not able to test this but this should work. Where are you putting this call? on_mouse_click?

InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
player.SayAt(26, 0, 270,String.Format("To my knowledge %s and %s do not mix.",player.ActiveInventory.Name, item.Name));
Title: SOLVED: Re: Which inventory has been clicked on?
Post by: Slasher on Fri 11/08/2017 15:12:04
I can't believe I missed that :(

Cheers (nod)


Title: Re: Which inventory has been clicked on?
Post by: Khris on Sun 20/08/2017 15:25:51
You can also use   InventoryItem *item = inventory[game.inv_activated];
Title: Re: Which inventory has been clicked on?
Post by: Slasher on Sun 20/08/2017 15:39:49
Cheers Khris (nod)
Title: Re: Which inventory has been clicked on?
Post by: dayowlron on Mon 21/08/2017 11:35:10
Khris, Wouldn't that give him the inventory item that has been activated and not the one clicked on?
inventory[game.inv_activated] is equivalent to player.ActiveInventory.
Title: Re: Which inventory has been clicked on?
Post by: monkey0506 on Mon 21/08/2017 12:44:12
Quote from: dayowlron on Mon 21/08/2017 11:35:10inventory[game.inv_activated] is equivalent to player.ActiveInventory.

No, it isn't. The names might be confusingly similar, but they are not intrinsically the same value.

Quote from: The Manualâ,,¢ (http://www.adventuregamestudio.co.uk/manual/index.html?page=ags41.htm#gamevariables)game.inv_activated   Inventory item that the player last clicked on. Useful for unhandled_event.