by Kate » Thu Oct 11, 2007 3:03 pm
I'm not sure on the state of the inventory system as to whether this is possible or not, so I'm sure there's a 50/50 chance of this getting marked with
[Can't be done].
Code: Select all
int UseInventoryItem (str ClassName)
If the player has an item of this type in their inventory, the function attempts to use it.
If the item was successfully used, the function returns
1 (
TRUE), otherwise if the player doesn't have this type of item or it was not used because of some other condition, it returns
0 (
FALSE).
Or if it isn't possible to get the state of the item's usage, then having it's return be
void would be fine since one could simply check the amounts before and after to see of it decreased by one.
When scripting my inventory system, I noticed a function like this was completely lacking, despite there being a check, take, give, and clear.
I'm not sure on the state of the inventory system as to whether this is possible or not, so I'm sure there's a 50/50 chance of this getting marked with [b][Can't be done][/b].
[code]int UseInventoryItem (str ClassName)[/code]If the player has an item of this type in their inventory, the function attempts to use it.
If the item was successfully used, the function returns [b]1[/b] ([b]TRUE[/b]), otherwise if the player doesn't have this type of item or it was not used because of some other condition, it returns [b]0[/b] ([b]FALSE[/b]).
Or if it isn't possible to get the state of the item's usage, then having it's return be [i]void[/i] would be fine since one could simply check the amounts before and after to see of it decreased by one.
When scripting my inventory system, I noticed a function like this was completely lacking, despite there being a check, take, give, and clear.