Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: testingstuff on Sun 13/08/2006 15:40:38

Title: 'Type mismatch: Cannot convert Int to inventoryitem*'
Post by: testingstuff on Sun 13/08/2006 15:40:38
test
Title: Re: 'Type mismatch: Cannot convert Int to inventoryitem*'
Post by: Ishmael on Sun 13/08/2006 16:19:01
(http://koti.mbnet.fi/tk-/img/RTFM.gif), because it's quite clearly stated in there:

AddInventory

(Formerly known as global function AddInventory, which is now obsolete)
(Formerly known as global function AddInventoryToCharacter, which is now obsolete)


Character.AddInventory(InventoryItem *item, optional int addAtIndex)

Adds the specified item to the character's inventory. This ensures that the item gets added to the character's inventory list, and that any on-screen inventory display gets updated if appropriate.
The first parameter is the inventory item's Script O-Name from the editor (for example, iPoster).

By default, the new item is added to the end of the character's inventory list. However, you can insert it in a particular position in the list by supplying the second parameter. The new item is inserted before the current item at addAtIndex. Indexes are numbered from 0, so to add the item at the start of the list, pass 0 as the second parameter.

Example:

character[EGO].AddInventory(iKey);

will give inventory item iKey to character EGO.
Title: Re: 'Type mismatch: Cannot convert Int to inventoryitem*'
Post by: monkey0506 on Sun 13/08/2006 20:25:46
If you want to use an integer index, you can do it like this:

cEgo.AddInventory(inventory[1]);