Numbers and real numbers

I want to create two numbers that are combined. Gold and silver (number of coins) are numbers where 1 gold = 10 silver. When combined, my currency is G.S.
For example, 3 gold plus 7 silver = 3.7 money. However, I am having difficulty with the calculation. The parser says it doesn’t understand the expression.
My (edited) source code is

An adventurer has a number called gold. Gold is initially 0.
An adventurer has a number called silver. Silver is initially 0.
Every turn when stage is stInven:
	now money of player is initMoney of player;
	say "init money = [money of player]";	
        . . . 

To decide what real number is initMoney of (p - a person):
		let G be a number;
		now G is a 5 d 4 roll;  		[gold pieces]
		say "init gold = [G] ";
		let G be the gold of p;
		let S be a number;
		now S is a 5 d 4 roll;  		[silver pieces]
		let S be S;
		say "init silver = [S] ";
		now S is the silver of p;
		let initCash be a real number;
		now initCash is initCash + G + S/ 10.0;
		decide on initCash;

btw, a player is an adventurer.

I found the line that seems to be in error.
I changed

now initCash is initCash + G + S/ 10.0;

to

now initCash is G + (S divided by 10.0);

However, initCash always comes back 0 despite G and S having the correct values.
What’s going on here?

I also found that the destination variable must be first:

		now the gold of p is G;

instead of

		now G is the gold of p;

Is this solved? Or is it still not working?

I know this isn’t your initial question, but I was wondering if you had studied the Nickel and Dimed example from the documentation, which seems to offer an integrated management system for monetary activities (structuring, ownership, transactions…) that is quite comprehensive and easily transferable to fantasy settings.

1 Like

Yes, I did get this working.
Thanks for checking.

No I haven’t. I will check into that pronto.
Thanks for the tip!

1 Like

You’re welcome. I’m probably going to use this example as a basis to integrate the monetary system into my WIP by the end of October. If you’d like, we could share our feedback and experiences.

Collaboration is always a plus. I did look into Nickel and Dimed and it is more complicated than I need. However, one of the simpler examples is what I used in my story.

1 Like