Monetary Issue

How would I go about setting up a non-decimal money system for a Victorian-era game I am currently working on.

So instead of £'s and p's. Or £12.34 for example, it would be pounds, shillings and pence.

So there are 12 pennies in a shilling, and 20 shillings in a pound.


Do everything internally in your lowest coin, so if something cost £2, set the price to 480. Only worry about pounds and shillings when you display it.

If you are using the desktop version you can write your own version of the DisplayMoney, which takes an integer and returns a string. Then everything else should work fine.

A starting point for your code:

pounds = n / 240
shillings = (n / 12) % 20
pennies = n % 12
return (pounds + "/" + shilling + "/" + pennies)

You should think about how you will display negative values.


Thanks Pixie. That's a great help.


Log in to post a reply.

Support

Forums