Functions and how to use them

I have a nice little function working (as well as many others) but I can’t seem to call it correctly.
I want to init some gold for my player. Here is my To-decide function:

To decide what number is initGold of (p - a person):
	say "Generating initGold";
	let G be a number;
	now G is a 5 d 4 roll;  		[5d4 gold pieces]
	now the gold of p is G;
	decide on G; 

Inside an every turn action (which happens only once), I have this statement:

Every turn when stage is stInven:
	initGold of player;

I can’t even get the function to be called (the say statement never gets executed).
There should be a simple fix for this that I can’t figure out. Can anyone help with this?

initGold returns a value, so you need to use that value some way, e.g.,

    let x be initGold of player;

But if you dont need the return value, just define a phrase:

To initGold of (p - a person):
	say "Generating initGold";
	let G be a number;
	now G is a 5 d 4 roll;  		[5d4 gold pieces]
	now the gold of p is G;
1 Like

Thx. Do I just need to create a dummy variable. I prefer the throwaway return value (since I assign the value directly into the player) that you suggested.

Inform cares a lot about type-checking, and that means if a function returns a value, you have to do something with it. That “something” might be “throw it away and never look at it again”, but you have to specifically make that choice.

I actually misspoke above. I prefer to throw away the return value in the function instead of creating dummy variables from which I can misconstrue the code. My code is working fine as a result. Thank you all.