Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: gamemaker349 on Thu 04/11/2010 01:25:09

Title: help with addinventory
Post by: gamemaker349 on Thu 04/11/2010 01:25:09
when i try to add this object to my inventory i get this
room3.asc(43): Error (line 43): Type mismatch: cannot convert 'Object*' to 'InventoryItem*'
can you please tell me what is wrong here is my script
function dragonlily_Interact()
{
player.AddInventory (dragonlily);
}
Title: Re: help with addinventory
Post by: Matti on Thu 04/11/2010 01:30:00

If dragonlily is an object, it needs an "o" before the name, but you can't add objects to the inventory anyway, only items. That would look like this:

player.AddInventory (idragonlily);
Title: Re: help with addinventory
Post by: gamemaker349 on Thu 04/11/2010 01:33:59
Quote from: Matti on Thu 04/11/2010 01:30:00

If dragonlily is an object, it needs an "o" before the name, but you can't add objects to the inventory anyway, only items. That would look like this:

player.AddInventory (idragonlily);
thank you for the help matti
Title: Re: help with addinventory
Post by: Khris on Thu 04/11/2010 09:27:31
It doesn't necessarily need an "o" before the name but this used to be a convention in earlier versions and it's better to still stick to that.

To elaborate a bit, objects appear in rooms and can be walked around, they can block the player's path, move, etc.
Inventory items appear in the player's InventoryWindow on a GUI, they can be added to the inventory, lost, looked at, used, etc.

Now usually the player walks around, picks something up and it is added to their inventory. This means you need both a room object and an inventory item representing the same thing in the game world. As soon as the room object is picked up, it is turned off; while the inventory item is added to the player's inventory.
The only thing that connects the two items is the player's mind; AGS can't.