So I’ve encountered a bit of a confusing situation here, and have found nothing in the manual to help with either of these questions.
The scenario: The player can pan or mine for gold, and the gold has a cash value of $20/ounce (the approximate value of gold circa 1850) I simply need to allow the player to check how much gold or cash he has (and also intend to show both in the status bar – after I get to that section of the manual)
First one:
Gold-score is a real number that varies. Gold-score is 0.16.
Cash-score is a real number that varies. Cash-score is 20 times gold-score.
However, upon compiling, Inform complains:
“Problem. The sentence ‘Cash-score is 20 times gold-score’ tells me that ‘Cash-score’, which is a real number that varies, should start out with the value ‘20 times gold-score’, but this is an object and not a real number.” … (I get the same complaint whether I write “Gold-score” or “gold-score,” so it’s not about capitalization)
I had JUST defined “gold-score” as a real number, so why is Inform thinking it’s an object?
That is quite confusing, because I tried a “work-around” for that in another section:
Requesting the cash held is an action out of world. Understand "cash" as requesting the cash held.
Report requesting the cash held:
Say "The cash value of your gold is $[gold-score times 20 to 2 decimal places]."
Which works just fine.
And that brings me to my second question: Is there a way to FORCE numerical display to use a specified number of decimal places?
For instance, in the example as shown so far, the player has 0.16oz of gold. That times $20 per ounce is $3.20. However, when I try to display the amount of cash, it only shown $3.2 … without including the final zero to show $3.20.
You can also use the “gold” command to show the amount of gold collected thus far, and that has the same problem.
Here’s the full code for both bits:
[code]Requesting the gold held is an action out of world. Understand “gold” as requesting the gold held.
Report requesting the gold held:
Say “So far you have amassed [gold-score to 2 decimal places] ounces of gold.”
Requesting the cash held is an action out of world. Understand “cash” as requesting the cash held.
Report requesting the cash held:
Say “The cash value of your gold is $[gold-score times 20 to 2 decimal places].”[/code]
I have read through the chapter “Numbers and Equations” in “Writing With Inform” several times, but can find nothing to help with this.
Perhaps I need to define each with units or notation? But as I understand, you can’t do math with mixed units/notations in Inform. I actually tried fiddling with that as well, but got nowhere fast.