New value to inventory property

Started by mchammer, Sat 01/09/2007 12:02:40

Previous topic - Next topic

mchammer

Is is possible to set new value to inventory properties by scripting?
I didnt find any commands like SetInvProperty.
My 40 bullets - An action/war game.

strazer

No, you cannot set custom properties at run-time.
Depending on your needs, use variables or check out arrays and structs.

mchammer

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.
My 40 bullets - An action/war game.

GarageGothic

#3
As strazer says, check out arrays and structs. If you declare a global array like this:

Code: ags
int inventoryproperty[AGS_MAX_INV_ITEMS];


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

Code: ags
inventoryproperty[iShovel.ID] = 5;


or

Code: ags
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.

Ashen

#4
Also, Read the BFAQ (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.
I know what you're thinking ... Don't think that.

mchammer

I completely missed that import/export part  ::)

but thnx, now it works.
My 40 bullets - An action/war game.

SMF spam blocked by CleanTalk