Question on setting a variable to a list

When using *'create’ to make a variable, is it possible to set that variable to a list and append items to it throughout the story?

For instance, I want to create an inventory for the character, it will show up as a variable in show stats but as the character picks up items throughout the game it will append more items into the list.

Example:

*create Inventory [item0, item1, item2, item3]

I know basic python, I’m pretty advanced when it comes to HTML/CSS, but I’m complete trash when it comes to JavaScript. I know this is possible but I have a hard time understanding it because everything is thrown around as far as languages go.

Thanks in advance!

Well, AFAIK, if you mess up with the .js files and stuffs, there’s a chance that your game won’t make it through CoG/HG publication.

Now, about inventory, this link have an example of inventory system so you may learn from it.

On my own WIP, though, I assign 2 kind of variables for each items that can be picked up by the player: boolean and “string”.
Boolean is used whenever the player owns or not the said item, “string” for the amount and name of the item.

2 Likes

Anything here of help?

1 Like

@Kalyn Here’s another example of how this might be done:

*temp item1 "Sword"
*temp item2 "Shield"
*temp item3 "Boots"
*temp item4 "Rope"
*temp item5 "Dagger"
*temp item6 "Food"
*temp item7 "Beer"
*temp item8 "Poison"
*temp inventory ""

*label menu
Hello, this is your inventory:

*if length(inventory) = 0
 (Your inventory is empty.)
*if length(inventory) > 0
 ${inventory}

What do you want to add to your inventory?

*choice
 *disable_reuse #Sword
  *if length(inventory) = 0
   *set inventory item1
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item1
   *goto menu
 *disable_reuse #Shield
  *if length(inventory) = 0
   *set inventory item2
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item2
   *goto menu
 *disable_reuse #Boots
  *if length(inventory) = 0
   *set inventory item3
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item3
   *goto menu
 *disable_reuse #Rope
  *if length(inventory) = 0
   *set inventory item4
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item4
   *goto menu
 *disable_reuse #Dagger
  *if length(inventory) = 0
   *set inventory item5
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item5
   *goto menu
 *disable_reuse #Food
  *if length(inventory) = 0
   *set inventory item6
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item6
   *goto menu
 *disable_reuse #Beer
  *if length(inventory) = 0
   *set inventory item7
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item7
   *goto menu
 *disable_reuse #Poison
  *if length(inventory) = 0
   *set inventory item8
   *goto menu
  *if length(inventory) > 0
   *set inventory (inventory&", ")&item8
   *goto menu
 #That's all.
  *goto menu2

*label menu2

Inventory: ${inventory}
*line_break
(Link this to your game.)
1 Like