Show amount of gold in inventory

0 votes
46 views
asked Oct 7 in Authoring by Mareus

Hey there!

Can anyone tell me what code should i write for showing the amount of gold in my inventory upon looking at it? The way I added gold into my game was via attributes/integrers. Whenever I find gold I just write the following code:
player.gold = player.gold + 100 -> And then i get 100 gold.

It appears neatly in my bar under the health, but I wish to be able to write a command: "examine gold/look at gold" and then get a description: "You have xx amount of gold in your inventory."

Can anyone help me with that? There has to be a simple code to show this. I tried ListObjectContents (this), but this only gives me a list of objects i am carrying in my inventory. Basically it just tells me "You are carrying gold", but it doesnt tell me the amount. Thanks in advance.

1 Answer

0 votes
answered Oct 9 by The Pixie (121 points)

The simple way would be to have an object, called gold, in the player's inventory from the start. Set it to be undroppable, and for the look at text:
You have {player.gold} of gold in your inventory.

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...