Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Anpiel on Sun 16/11/2014 22:12:57

Title: [SOLVED]objects converting to inventory items?
Post by: Anpiel on Sun 16/11/2014 22:12:57
I am trying to do a basic item pick up. Here is what code I used.
Code (asg) Select

function oGiantKey1_Interact ()
{
oGiantKey.Visible = false;
player.AddInventory (oGiantKey1);
}

Why is nothing going on?
Title: Re: objects converting to inventory items?
Post by: Vincent on Sun 16/11/2014 22:35:41
Why the @#[* you are not creating an inventory item in the editor ?! :)

From the Manual :

Every inventory item which the player may carry during the game at one time or another is listed under the "Inventory items" node. Here, each item has a number and a script name which you use in scripts to identify the object. To create a new item, right-click on the "Inventory items" node.


The script then should look like something like this.

Code (ags) Select

function oGiantKey1_Interact ()
{
oGiantKey.Visible = false;
player.AddInventory(iGiantKey1); //add the inventory item
}
Title: Re: objects converting to inventory items?
Post by: Anpiel on Sun 16/11/2014 22:40:48
I am doing that because this is day four for me working on this stuff. Thank you a thousand times over!~
Title: Re: objects converting to inventory items?
Post by: Vincent on Sun 16/11/2014 22:44:01
Oh well, good luck then, you're welcome ~
Title: Re: objects converting to inventory items?
Post by: Anpiel on Sun 16/11/2014 22:48:58
I am still having the same issue
Title: Re: objects converting to inventory items?
Post by: Vincent on Sun 16/11/2014 22:57:47
Okay :)

Did you create the Inventory item ?

To create a new item, right-click on the "Inventory items" node in the tree.

Change the script name of the item, call it :

iGiantKey1

Then, when you interact with the object :
Code (ags) Select

function oGiantKey1_Interact()
{
oGiantKey.Visible = false;
player.AddInventory(iGiantKey1); //add the inventory item
}


Title: Re: objects converting to inventory items?
Post by: Anpiel on Sun 16/11/2014 23:37:19
I made the inventory item but cannot get it into my room. Sorry for being such a n00b about all this.
Title: Re: objects converting to inventory items?
Post by: Vincent on Mon 17/11/2014 00:14:23
Let's say that you have created your inventory item in the node tree, and you rename it : iGiantKey1
Then you can choose if the player start with that item when the game first start
(but this is optional, not to solve this issue)
After this, you interact with your object.
By doing this the object become not visible and the player add the Inventory item, of course, not the object.
So then, where you want to store it ?
In an InventoryWindow i guess.
Just create a Gui. Inside of it add an InventoryWindow.

All you need is to read the dynamic helps. You can check the dynamic helps inside AGS by pressing F1
Title: Re: objects converting to inventory items?
Post by: Anpiel on Mon 17/11/2014 00:36:26
Thank you so much. I was misreading the dynamic help.
Title: Re: [SOLVED]objects converting to inventory items?
Post by: Adeel on Mon 17/11/2014 09:21:09
Hello Anpiel.

There are some tutorials (https://www.facebook.com/video.php?v=945414198816924&permPage=1) which can help you get started with the AGS. There are video tutorials too. :)
Title: Re: [SOLVED]objects converting to inventory items?
Post by: Anpiel on Mon 17/11/2014 09:25:26
Thanks for the heads up