Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ln888 on Mon 26/08/2013 21:51:07

Title: inventory on inventory
Post by: ln888 on Mon 26/08/2013 21:51:07
hi,
I want to use an inventory item, on other inventory item, to create a new item
how to i do that ?
Title: Re: inventory on inventory
Post by: Mouth for war on Mon 26/08/2013 23:22:59
Doubleclick on Inventory items. Then doubleclick on the item you want something to be used on. Click on the lightning bolt and select "Use inventory on this item" In this example I use a magnet

in the script: (without the // stuff)

if (player.ActiveInventory==istring){             //The item to be used on the magnet
cEgo.LoseInventory(imagnet);                     //player lose magnet
cEgo.LoseInventory(istring);                    //player lose string
cEgo.AddInventory(imagstring);                 //player gets magnet with string attached to it
}
else{
Display ("That won't work");                   //player tries to use something else on the magnet
}
}                 
Title: Re: inventory on inventory
Post by: ln888 on Tue 27/08/2013 01:37:34
thank you..... :smiley:
Title: Re: inventory on inventory
Post by: Ryan Timothy B on Tue 27/08/2013 01:40:39
Mouth for war, use the code tags:
(http://www.adventuregamestudio.co.uk/forums/Themes/AGSCompact/images/BBCode/code_code.png)
Second of all, if you're going to post code to assist people, try to use indentation so they can learn from your example instead of spawning even more unreadable script. Thanks.
Because of your lacking indentation you failed to notice you had an extra closing brace.

Code (ags) Select
if (player.ActiveInventory==istring) {   //The item to be used on the magnet
  cEgo.LoseInventory(imagnet);                     //player lose magnet
  cEgo.LoseInventory(istring);                     //player lose string
  cEgo.AddInventory(imagstring);                   //player gets magnet with string attached to it
} else {
  Display ("That won't work");                     //player tries to use something else on the magnet
}
Title: Re: inventory on inventory
Post by: Mouth for war on Tue 27/08/2013 12:12:32
Ahh i was unaware of those tags. Sorry about that  :-)