Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: mchammer on Sat 01/09/2007 12:02:40

Title: New value to inventory property
Post by: mchammer on Sat 01/09/2007 12:02:40
Is is possible to set new value to inventory properties by scripting?
I didnt find any commands like SetInvProperty.
Title: Re: New value to inventory property
Post by: strazer on Sat 01/09/2007 12:08:41
No, you cannot set custom properties at run-time.
Depending on your needs, use variables or check out arrays and structs (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23527.msg247166#msg247166).
Title: Re: New value to inventory property
Post by: mchammer on Sat 01/09/2007 14:02:52
Thnx, but the problem is I need a value witch can be shared between roomscripts and the global script. I tried to use inventory property because there is only limited amount of global ints and that amount is a way too small for my purposes.
Title: Re: New value to inventory property
Post by: GarageGothic on Sat 01/09/2007 14:13:16
As strazer says, check out arrays and structs. If you declare a global array like this:

int inventoryproperty[AGS_MAX_INV_ITEMS];

You can import it in the script header, and do stuff like:

inventoryproperty[iShovel.ID] = 5;

or

if (inventoryproperty[iShovel.ID] == 5) player.Say("I have no idea why the property for the shovel needs to be 5, but it is!");

in room script.

Edit: I recommend you to work this out by yourself, since it will be a valuable lesson in scripting. But if you should need to change a large number of properties for different inventory items, objects or characters, you could also check out monkey's properties module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27385.0).
Title: Re: New value to inventory property
Post by: Ashen on Sat 01/09/2007 14:14:09
Also, Read the BFAQ (http://americangirlscouts.org/agswiki/Scripting%2C_Code_%26_Interaction#Working_with_variables:_the_basics) (Actually, making global variables is also covered in the link strazer gave you...)

You can make a pretty much unlimited number of your own variables (single ints or Strings, as well as arrays and structs), and make them accessable to Room and Global scripts.
Title: Re: New value to inventory property
Post by: mchammer on Sun 02/09/2007 11:20:06
I completely missed that import/export part  ::)

but thnx, now it works.