Having multiple of the same item in the inventory.
Palatheio
05 May 2017, 18:37Hello everyone! I was wondering if there is any way to have two (or more) of the same item in the inventory. I'm trying to make it so that when an enemy is killed, it drops an item. However, there are multiple enemies, and although it says that I loot the enemy upon every death, and find the item, I still only have one in my inventory. Is there any way to introduce multiple instances of the same item?

Anonynn
06 May 2017, 00:16You'll need to make clones of the items. You can try this..
x = CloneObject (cloaknhood)
MoveObjectHere (x)
But keep in mind that you have to set up each item to be it's own unique item. For example, let's say you have...
Health Potion
Flag Boolean Attribute
If you have code that does this...
{if health_potion.flag=True:Do this}
or
if (health_potion.flag=False) {
{
Then the game won't recognize the duplicate item and will count the item as the same (that's why only one appears). So instead of the above...you need...
{if this.flag=True:Do this}
and
if (this.flag=False) {
{
It's a very long and arduous process setting up duplicates and making sure all of them work! Prepare yourself! I hope this helps a little bit.
Anonynn.

DarkLizerd
06 May 2017, 03:56Option 2: (used by older games)
Create a list of every "treasure" item, start on paper
Then make the list in Quest:
player.treasure_item1 (what ever you want to call it...)
player.treasure_item2
player.treasure_item3
player.treasure_item4
(and so on)
You kill an enemy, it drops Item3
You loot it, player.treasure_item3=player.treasure_item3+1
When you check your inventory:
if(player.treasure_item1>0){
list item
}
This may not be Quest standard, but it worked back in the day of 8bit computers...
May not work with Quest's inventory window...

DarkLizerd
06 May 2017, 03:59If you have code that does this...
{if health_potion.flag=True:Do this}
why not:
{if health_potion.count>0:Do this}
???
Then you can have more than 1 health potion...
hegemonkhan
06 May 2017, 06:17you can also take a look at Sora's 'stackable' library, but it's not been updated to the current version of quest:
http://textadventures.co.uk/forum/samples/topic/3515/stackable-library
this is beyond my ability, so you'll need to see if someone else can help you with it, if you need help with it.
also, in conjuntion with a 'stackable' system, you can/should also have a 'storage' system too (a separate 'custom-inventory' that organizes the items and that you're able to do various storage system actions with), so you don't have your inventory filled up.
hegemonkhan
06 May 2017, 07:14for example... a small incomplete sample (but it gives you an idea of what such a system is like if/when taken to full completion)
<object name="storage_object">
<object name="item_item_storage_object">
<object name="item_storage_object">
<object name="healing_item_storage_object">
</object>
<object name="battle_item_storage_object">
</object>
<object name="event_or_quest_item_storage_object">
</object>
</object>
<object name="equipment_storage_object">
<object name="weapon_storage_object">
<object name="sword_storage_object">
</object>
</object>
<object name="armor_storage_object">
</object>
<object name="clothing_storage_object">
</object>
</object>
</object>
<object name="magic_storage_object">
<object name="fire_storage_object">
</object>
<object name="water_storage_object">
</object>
<object name="air_storage_object">
</object>
<object name="earth_storage_object">
</object>
</object>
</object>
<object name="katana_object">
<inherit name="sword_type" />
</object>
<object name="fireball_object">
<inherit name="fire_type" />
</object>
<type name="sword_type">
</type>
<type name="fire_type">
</type>
<function name="deposit_storage_function" parameters="object_parameter">
if (DoesInherit (object_parameter, "sword_type")) {
object_parameter.parent = sword_storage_object
} else if (DoesInherit (object_parameter, "fire_type")) {
object_parameter.parent = fire_storage_object
}
</function
<function name="withdraw_storage_function" parameters="object_parameter">
if (Contains (storage_object, object_parameter)) {
object_parameter.parent = player
}
</function>
<function name="inventory_storage_function" parameters="string_parameter">
string_variable = string_parameter + "_storage_object
if (Contains (storage_object, string_variable)) {
DisplayList (GetDirectChildren (string_variable), false)
}
</function>
<function name="examine_storage_function" parameters="object_parameter">
if (Contains (storage_object, object_parameter)) {
info_function (object_parameter)
}
</function>
<function name="info_function" parameters="object_parameter">
</function>
Palatheio
09 May 2017, 15:06Thank all of you so much! Unfortunately, it seems that what I was looking to do is impossible, but I've worked around it. Thank all of you for the help!

DarkLizerd
09 May 2017, 17:00If you can code... nothing is impossible...
But it can be difficult...