How do I make the player lose all their money and give it back later?
Let's say that a thief steals all your money but later joins the party and gives it back as a proof of trust. Or perhaps you want to temporarily put the player in a difficult situation, or you want to swap between different parties.
The lose money command removes money from the player. The party money command tells you how much money the player has. Therefore setting the player's money to zero can be accomplished with:
lose money (party money)
However, if you want to give the player back their money later you should store the original amount in a global variable.
For example:
global variable (22, Your Money) plotscript, rob penniless, begin show text box (73) # Your backpack suddenly feels lighter... Oh no, your gold has vanished! Your Money := party money lose money (Your Money) end
To try it out: place the above into your scripts file, modify the numbers (22, 73) as appropriate, and import it. Edit one of your maps. Pick a free NPC in the NPC editor and give it the 'rob penniless' script. Place the NPC on the map and voilà! When you talk to it your money will go down to zero!
And now: how do you get your money back?
get money (Your Money)
This will give back all the money you got back before meeting the thief, in addition to any gained in the meantime.
Money owned from different characters[edit]
Now let's say they you want to swap between different heroes before making a bigger party like in Dragon Quest IV chapter of the chosen.
You'd need to use several global variables, e.g.:
global variable (14, hero 1 money) global variable (15, hero 2 money) global variable (16, hero 3 money)
For example when you swap away from the first hero (or first party) you write:
hero 1 money := party money lose money (hero 1 money)
and then to swap to the second hero you write
gain money (hero 2 money)
And when hero3 meets hero1 and hero2 and they become a party you just need to add the money the previous 2 got along the way, like so:
get money (hero 1 money) get money (hero 2 money)