Money

Banknotes

A banknote item

Banknotes use the item type qldminecraft_banknote_item and by default have a value of 0.

Like most custom QLD Minecraft items, data for the banknote item is stored within the first line of the items lore, after the : character. The text, including the : character is usually black in colour to hide it from the player.

Creating a Banknote

To retain the default lore information and apply the lore formatting expected by the player, it is recommended to use the procedure qldminecraftp.banknote.create with a single context item that is the value of the banknote to create. The procedure will return a banknote item that can then be given to the player or placed into an inventory.

# Create a banknote item to the value of 1 gold, 50 silver and 25 copper
# and give it to the player
- define banknote_item:<proc[qldminecraftp.banknote.create].context[15025]>
- give <[banknote_item]>

Obtaining the value of a Banknote

A banknote stores its value as an integer within the first line of its lore, after the : character. This data, including the : character is usually black in colour to disguise it from the player.

QLD Minecraft has the helper procedure qldminecraftp.banknote.value that takes a single context item of a banknote item, returning the banknotes value as an integer.

# Obtain the value of the banknote in the players hand, give that amount
# of money to the player and destroy the banknote
- define amount:<proc[qldminecraftp.banknote.value].context[<player.item_in_hand>]>
- give money quantity:<[amount]>
- take <player.item_in_hand>

Parsing Money

The result of an integer parsed as money

You can parse an integer into a text formated money by using the procedure qldminecraftp.parse.money and passing an integer as a single context item.

The result of the parse can be destructive to formatting when appending to other elements.

# Parse the players money and narrate it onto the screen
- narrate <proc[qldminecraftp.parse.money].context[<player.money>]>