Checking for multiple of the same item in inventory?

lightwriter
I'm working on a better inventory system for my game where things actually stack (The current Stackable Library is out of date and buggy with the current version)
I've got the DoDrop part working fine, now I need to do the hard part, how do I determine if the player has the item in their inventory? It has to use the alias due to cloned objects having different names...
So how would I go about doing this?

HegemonKhan
this is just the basics of checking the inventory for an item (in case you don't know already), but I'm unable to help any further, as Sora's Stackable library is beyond my ability~understanding, I can't help you past this basic way of checking an item in your inventory (or whatever ObjectList Attribute):

http://docs.textadventures.co.uk/quest/ ... tains.html
http://docs.textadventures.co.uk/quest/ ... tains.html
http://docs.textadventures.co.uk/quest/ ... tains.html

Object Lists (and~or important String Lists, which aren't for this topic but useful to know, aka: displayverbs, inventoryverbs):

http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... ldren.html
http://docs.textadventures.co.uk/quest/ ... ments.html (displayverbs, inventoryverbs)
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/ ... ntory.html
http://docs.textadventures.co.uk/quest/ ... y/got.html

you may want to take a look at these two list+dictionary guides of mine as well:

viewtopic.php?f=18&t=5137 (guide on using lists and dictionaries)
viewtopic.php?f=18&t=5138 (you can see how the 'contains~listcontains~dictionarycontains' works in this, I think)

----------

an example syntax-code would be:

the Stack (conceptual "container", but NOT an actual Object Type: container) Object:

Object0: life_50_potion_stack
Alias0: life 50 potion stack
// initial setting of its Integer Attribute, quantity: life_50_potion_stack.quantity = 0 // or whatever you want
// Final Displayed Alias0: life 50 potion stack (quantity)*

the Individual Objects:

Object1: life_50_potion_1 // it restores your current life by +50
Alias1: life 50 potion

Object2: life_50_potion_2
Alias2: life 50 potion

etc etc etc

* see below:
http://docs.textadventures.co.uk/quest/ ... alias.html
life_50_potion_stack.alias = GetDisplayAlias(life_50_potion_stack) + "(life_50_potion_stack.quantity)"
// GetDisplayAlias (life_50_potion_stack) --> life 50 potion stack
// + "(life_50_potion_stack.quantity)" --> (quantity, let's say it's: 99)
// life_50_potion_stack.alias = GetDisplayAlias(life_50_potion_stack) + "(life_50_potion_stack.quantity)" --> life 50 potion stack (99)

<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_variable, ScopeInventory()) {
if (object_variable.alias = "life 50 potion") {
life_50_potion_stack.quantity = life_50_potion_stack.quantity + 1
destroy (object_variable.name)
}
}
<script>
</turnscript>

lightwriter
I'm getting a general idea but still not resolved, I'd like a solution that doesn't cause me to have to manually code each item.
UPDATE: I have found a somewhat working solution to this issue, for the most part it updates:
I created a timer with a 1 second interval and used this code:

foreach (item, ScopeInventory()) {
for (i, 1, 100) {
l = ScopeInventory()
n = GetRandomInt (0, ListCount(l)-1)
item1 = ObjectListItem(l,n)
}
for (z, 1, 100) {
x = ScopeInventory()
y = GetRandomInt (0, ListCount(x)-1)
item2 = ObjectListItem(x,y)
}
if (item1.name = item2.name) {
}
else if (item1.alias = item2.alias) {
item1.quantity = item1.quantity + item2.quantity
item2.parent = garbage
}
else {
}
}

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums