Thanks Shaz! But I'm actually doing a bit of a 4th wall breaking thing where I'd like to tell the player the script call to query the gold 🙂
A bit of a weird question I suppose, but I'd love to include it!
The script call to query gold is
$gameParty.gold()
And how might I save that number to a variable?
You can do any of the following, which will create a variable named "gold":
var gold = $gameParty.gold(); looks either oldschool or amateurish.
let gold = $gameParty.gold(); the more modern and recommended approach.
const gold = $gameParty.gold(); creates a constant named "gold", instead of a variable. The value of a constant can not be changed afterwards.
If you want to go a bit further with your 4th wall breaking, you could use the
const option to store the party's gold into the
gold variable, then you could try to overwrite the variable using for example:
gold = 0; or
gold = 42; or similar, and then showing the following error message:
Uncaught TypeError: Assignment to constant variable.
If you want to save the gold to an RPG Maker variable instead, use:
$gameVariables.setValue(1, $gameParty.gold());, which will save the gold value to variable #0001. To use a different variable, just replace the
1 with any other positive integer greater than 0. Avoid using numbers with leading zeroes, such as
0010. Most people won't notice, but this is actually octal notation in JavaScript (0010 in the octal system is 8 in our decimal system). If you want to be particularly nerdy, you can use a binary number like
0b10 (which is 2 in our decimal system), or a hexadecimal number like
0xff (which is 255 in our decimal system).
Personally, I'd recommend using one of the former options, because
$gameVariables is needlessly obscure and doesn't really provide any benefit to your players, whether they know how to code or not.