Problem with Setting the amount of inv.object (SOLVED)

Started by mchammer, Mon 06/02/2006 16:01:18

Previous topic - Next topic

mchammer

I have problem with setting the amount of inventory object.

I have tried to use these scripts:

player.inv[6] = player.inv[5];  (this was ment to set object[6]'s amount equal to
object [5]'s amount)

player.inv[5] = 0; (I try to set inv.object[5] amount to 0)
My 40 bullets - An action/war game.

Ashen

What version of AGS are you using?

As of 2.7, you should use Character.InventoryQuantity[..] rather than character[..].inv[..]. Also, when you change inventory amounts this way, rather than with Character.Add/LoseInventory(...), you may need to run UpdateInventory() before you see any effect, e.g.:
Code: ags

player.InventoryQuantity[6] = player.InventoryQuantity[5];
player.InventoryQuantity[5] = 0;
UpdateInventory();
I know what you're thinking ... Don't think that.

mchammer

#2
thanks.

i checked and i have version 2.62.
Does the same game work fine if I download the new version?

Edit: I installed new version and tried that but it didnt work.


if (player.InventoryQuantity[5] > 0) {   
GUIOn(ROTTENFOOD);
player.InventoryQuantity[6] = player.InventoryQuantity[5];
player.InventoryQuantity[5] = 0;
UpdateInventory();
}


//if command works fine, but game doesnt change the amount of items.
My 40 bullets - An action/war game.

Ashen

#3
Well, as shown here, there are some differences in the code used. You could update your game, if you don't mind doing a bit of rewriting, or if you're only just starting - however if you've made any significant progress, I wouldn't necessarily advise it.

However, what you've got should work fine in 2.62, other than: 1) you may still need to use Update Inventory(), 2) if you have more than one player character. (In V2.62, the player pointer doesn't update when you change player characters.)

What if you use an int rather than directly setting inv[6] = inv[5], e.g.:
Code: ags

 int temp = player.InventoryQuantity[5];
 player.InventoryQuantity[6] = temp;
 player.InventoryQuantity[5] = 0;
 UpdateInventory();


And what if you put the GUIOn(ROTTENFOOD) (gRottenfood.Visible = true in new-speak) after changing the item amounts?
I know what you're thinking ... Don't think that.

mchammer

My mistake! When I compiled the game, it updated the game in the version 2.62's directory. It worked fine. thanks
My 40 bullets - An action/war game.

SMF spam blocked by CleanTalk