Categories of Variables


#1

I was wondering if there is a way to categorise variables? I’m sorry if this has been asked before, but I couldn’t find anything.

I want to make an Inventory on my stats page, and when I have no items, I want it to say
"There is nothing in your Inventory"

The problem is I am using

[b]Inventory[/b]
*if (food > 0)
  *stat_chart
    text Food
  *goto fwater
*label fwater
*if (freshwater > 0)
  *stat_chart
    text Freshwater
  *goto wood
*label wood
*if (wood > 0)
  *stat_chart
    text Wood
  *goto swater
*label swater
*if (saltwater > 0)
  *stat_chart
    text Saltwater
  *goto sword
*label sword
*if (sword > 0)
  *stat_chart
    text Sword
  *finish
*if (((((food = 0) and (freshwater = 0)) and (wood = 0)) and (saltwater = 0)) and (sword = 0))
  *line_break
  There is nothing in your Inventory.
  *finish

which works, but will get really long when I start adding new items.

Is there a way to make food, freshwater, wood etc. all part of a category called Inventory and just use

*if (inventory = 0)
  *line_break
  There is nothing in your Inventory.
  *finish

Thank you :slight_smile:


#2

You could technically do

*set inventory ((((food + freshwater) + wood) + saltwater) + sword)

Then *if inventory =0

But that still has the huge long line.


#3

Might be simplest to use a temp, along the lines of -

[b]Inventory[/b]
*temp inv 0
*if (food > 0)
  *set inv +1
  *stat_chart
    text Food
  *goto fwater
*label fwater
*if (freshwater > 0)
  *set inv +1
  *stat_chart
    text Freshwater
  *goto wood
*label wood
*if (wood > 0)
  *set inv +1
  *stat_chart
    text Wood
  *goto swater
*label swater
*if (saltwater > 0)
  *set inv +1
  *stat_chart
    text Saltwater
  *goto sword
*label sword
*if (sword > 0)
  *set inv +1
  *stat_chart
    text Sword
   *goto inv
*label inv
*if inv = 0
 *line_break
  There is nothing in your Inventory.

Also perhaps take a look at a slightly different inventory system to see if that might better suit your needs:


#4

Thank you both for your replies :slight_smile:
I will have a look at other inventories, but a temp system might work for me.


#5

I use a similar temp system but with a boolean variable instead of a number.

*label inventory
*temp noitems
*set noitems true

*if (flashlight)
 *set noitems false
 A flashlight
 *line_break
 *goto slot2
*if not (flashlight)
 *goto slot2
*label slot2
*if (room139key)
 *set noitems false
 The key to Room 139
 *line_break
 *goto slot3
*if not (room139key)
 *goto slot3
*label slot3
*if (room103key)
 *set noitems false
 The key to Room 103
 *line_break
 *goto slot4
*if not (room103key)
 *goto slot4
*label slot4
*if (comms)
 *set noitems false
 A mobile phone
 *line_break
 *goto slot5
*if not (comms)
 *goto slot5
*label slot5
*if (gasoline != 0)
 *set noitems false
 Gasoline (${gasoline})
 *line_break
 *goto slot6
*else
 *goto slot6
*label slot6
*if (rags != 0)
 *set noitems false
 Rags (${rags})
 *line_break
 *goto slot7
*else
 *goto slot7
*label slot7
*if (bottles = 1)
 *set noitems false
 A bottle
 *line_break
 *goto slot8
*else
 *goto slot8
*label slot8
*if (bottles > 1)
 *set noitems false
 ${bottles} bottles
 *line_break
 *goto slot9
*else
 *goto slot9