How to show the amount of money the player has?

Xilefenko
30 Sept 2016, 21:11

Basic question here:
I want that when I type in "Gold" that it shows me how much gold I have

"You have 5 Gold at the Time"

I'm new btw


The Pixie
30 Sept 2016, 22:23

Give the player an attribute, say money. If using the off-line editor, go to the _Attributes_tab of the player object, and set it to be an integer. If on-line, go to the Stripts tab of the game object, click on Code view for the Start script, and paste this in:

player.money = 100

That sets up the starting money.

Now create a new command (Commands, Add), and type in "gold" for the pattern. In fact, type in "gold;money;cash", then the player can use any of them.

From the script bit, add a new script to print a message. In the text for that, paste in:

You have {player.money} Gold at this time.

If using the off-line editor, you might want to ook at my Shop Library (you cannot use libraries on-line, sadly):
https://github.com/ThePix/quest/wiki/Shop-Library


Xilefenko
01 Oct 2016, 08:42

Thanks a lot


hegemonkhan
03 Oct 2016, 05:06

if you can follow along with this, it can be of help too:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

and learning Attribute usage and the 'if' Script is a huge benefit, as it lets you do 90% of everything you want to do in your game.