0 votes
by (330 points)
edited by

This is the code and it makes the game cranky...do it do it a little differently or do I scrap it and figure out another way to get the price of items within datamaps?

You want a (print: $selectedItem's "name"), huh? (if: $gold > 10)[Well it'll be  (print: $selectedItem's "gold"). Pay up! (link: "Pay" (print: $selectedItem's "gold") "gold.")[(set: $gold to $gold-$selectedItem's "gold")]](else:)[You're too broke for a (print: $selectedItem's "name") !]

(link: "Back")[(goto: "start")]

The $gold is referring to the money the player has and "gold" is the number set in the item's datamap to determine how much it's worth.

1 Answer

0 votes
by (159k points)

You are doing two things wrong in the code that is trying to create the String parameter of your (link:) macro.

1. The (print:) macro purpose is to output Text onto the page being generated, and you are trying to use it to convert the number stored within the $selectedItem's "gold" property into a String representation of that number. You should be using the (text:) macro to do that.

2. You are trying to join three String values ("Pay", the String from point 1, and "gold.") together to create the String parameter, and you need to use the plus (+) operator to do that.

Try the following.

You want a (print: $selectedItem's "name"), huh? \
(if: $gold > 10)[\
Well it'll be (print: $selectedItem's "gold"). Pay up! \
(link: "Pay " + (text: $selectedItem's "gold") + " gold.")[\
	(set: $gold to $gold - $selectedItem's "gold")\
]\
](else:)[You're too broke for a (print: $selectedItem's "name") !]

(link: "Back")[(goto: "start")]

 

...