Trying to set up a horizontally read inventory *Fixed :)

First off, I want to say a huge thank you to everyone. You all rock, big time! On to my next “what am I thinking???” moment…

I’m trying to set up an inventory readout for when the pc goes to a shop, so they can see what they already have before they decide to buy or sell something. This is the code I’ve written, based on what I read in a tutorial.

*label gsInv
Currently you have: 
*if (rations != 0)
    *set inventory &"${rations} rations"
    *set comma true
*if (bandages != 0)
*if comma
    *set inventory &", "
*set inventory &"${bandages} bandages"
*set comma true
*if (ointment != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${ointment} ointment"
    *set comma true
*if (hppotion != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${hppotion} hp potions"
    *set comma true
*if (mppotion != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${mppotion} mp potions"
    *set comma true
*if (healerkit != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${healerkit} healerkits"
    *set comma true
*if (chamomile != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${chamomile} chamomile"
    *set comma true
*if (sage != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${sage} sage"
    *set comma true
*if (salt != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${salt} salt"
    *set comma true
*if (basil != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${basil} basil"
    *set comma true
*if (passionflower != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${passionflower} passionflower"
    *set comma true
*if (clove != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${clove} clove"
    *set comma true
*if (pepper != 0)
    *if comma
        *set inventory ", "
    *set inventory &"${pepper} pepper"
    *set comma true
*if (witchvine != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${witchvine} witchvine"
    *set comma true
*if (parsley != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${parsley} parsley"
    *set comma true
*if (rosemary != 0)
    *if comma
        *set inventory &", "
    *set inventory &"${rosemary} rosemary"
    *set comma true
*if (lavender != 0)
    *if comma
        *set inventory ", "
    *set inventory &"${lavender} lavender"
    *set comma true
${inventory}
*goto gsChs

I want the end result to read like “You have 5 bandages, 6 salt, 12 rosemary, 20 lavender”
(just names and numbers I’m pulling out of this air, obviously|!) Since the current plan is to use shops in more than one scene/city, *inventory, *comma, and all the item names are created in startup - well reuse combined with atrocious luck when it comes to using *temp variables :slight_smile:

The values are setting correctly in all the items when I play through. When I hit the point where the inventory script is running all that displays is the last part (ex. “,5 lavender”). Can anyone make a suggestion about what I’m doing wrong and point me in a direction to fix it?

Thank you,
Lessa

*EDIT
I got it fixed :slight_smile:
Here is the fixed code, if anyone’s interested in looking at it.

*label gsInv
Currently you have: 
*if (rations != 0)
    *set inventory &("${rations} rations")
    *set comma true
*if (bandages != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${bandages} bandages")
    *set comma true
*if (ointment != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${ointment} ointment")
    *set comma true
*if (hppotion != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${hppotion} hp potions")
    *set comma true
*if (mppotion != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${mppotion} mp potions")
    *set comma true
*if (healerkit != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${healerkit} healerkits")
    *set comma true
*if (chamomile != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${chamomile} chamomile")
    *set comma true
*if (sage != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${sage} sage")
    *set comma true
*if (salt != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${salt} salt")
    *set comma true
*if (basil != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${basil} basil")
    *set comma true
*if (passionflower != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${passionflower} passionflower")
    *set comma true
*if (clove != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${clove} clove")
    *set comma true
*if (pepper != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${pepper} pepper")
    *set comma true
*if (witchvine != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${witchvine} witchvine")
    *set comma true
*if (parsley != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${parsley} parsley")
    *set comma true
*if (rosemary != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${rosemary} rosemary")
    *set comma true
*if (lavender != 0)
    *if comma
        *set inventory &(", ")
    *set inventory &("${lavender} lavender")
    *set comma true
${inventory}

Thanks again to everyone who has helped me so far!

Lessa

3 Likes