Inventory Code Help


#1

Hey everybody, I try making an inventory in my choicescript_stats.txt for a long time and cant get it right. everything’s fine and there is not error messege; except when i actually choose the item the inventory remains empty. Here’s the code:

*if (silenced_pistol)
*set inventory &“Silenced Pistol”
*set comma true
*if (sleepdarts)
*if comma
*set inventory &", “
*set comma true
*set inventory &“Sleep Darts”
*if (taser_gun)
*if comma
*set inventory &”, “
*set comma true
*set inventory &“Taser Gun”
*if (throwing_knives)
*if comma
*set inventory &”, "
*set comma true
*set inventory &“Throwing Knives”

Inventory: ${inventory}


[Tool] Chronicler - ChoiceScript Visual Code Editor
I need help in coding
#2

Should look like this:

*temp inventory
*set inventory " "
*temp comma
*if (silenced_pistol)
    *if comma
        *set inventory &", "
    *set inventory &"Silenced Pistol"
    *set comma true
*if (sleepdarts)
    *if comma
        *set inventory &", "
    *set inventory &"Sleep Darts"
    *set comma true
*if (taser_gun)
    *if comma
        *set inventory &", "
    *set inventory &"Taser Gun"
    *set comma true
*if (throwing_knives)
    *if comma
        *set inventory &", "
     *set inventory &"Throwing Knives"
     *set comma true

Inventory: ${inventory}

Not sure if you had the temp variables at the top of your choicescript_stats.txt. It seems like you forgot the *if comma statement on your silenced pistol.


Inventory help!
#3

If you hate concatenation, like me, you can keep a running count of inventory slots.

Whenever you get another thing, set a variable number_of_items +1. That can then assign it to a slot:

(You get the silenced pistol)
*set number_of_items +1
*set new_item "silenced pistol"
*gosub set_item_slot

(onward with the code)

(Here is the item slot subcode)

*label set_item_slot
*if number_of_items=7
   *set item7 new_item
*return

In the stat screen you now know how many commas to use:

[b]Inventory:[/b]
*if number_of_items=7
   ${item1}, ${item2}, ${item3}, ${item4}, ${item5}, ${item6}, ${item7}

This is also a way to keep slots straight if you’re doing a visual interface of inventory spaces.


#4

Worked, Thanks very much