From 56d8543bcfa9d5d2a888bf5e36c22a6cdb56cd86 Mon Sep 17 00:00:00 2001 From: Giov4 <5796578-giov4@users.noreply.gitlab.com> Date: Thu, 4 Mar 2021 21:24:18 +0000 Subject: [PATCH] Update README.md --- README.md | 79 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index db6e44d..862658f 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,70 @@ # **API** - -## `currencies.register(currency)` -Use this to register a currency, it is necessary in order to use every other function. -
-## `currencies.set(pl_name, currency, value)` -Use this to set a player's balance. +### `currencies.register(currency, def)` +Use this to register a currency, it is necessary to use every other function. +`def` is a table containing the following values (it isn't demanded):
+```lua +--[[ +{ + min_value : number = + the smallest balance that a player can have. -
+ max_value : number = + the biggest balance that a player can have. + + negative_balance : bool = + if the balance can be less than 0. +} +]] +``` -## `currencies.add(pl_name, currency, value)` -Use this to increase a player's balance. +
-
- -## `currencies.sub(pl_name, currency, value)` -Use this to decrease a player's balance. - -
- -## `currencies.get(pl_name, currency)` +### `currencies.get(currency, pl_name)` Use this to get a player's balance. -

+
+ +### `currencies.set(currency, pl_name, value)` +Use this to set a player's balance. + +
+ +### `currencies.add(currency, pl_name, value)` +Use this to increase a player's balance. + +
+ +### `currencies.sub(currency, pl_name, value)` +Use this to decrease a player's balance. + +
+ +### `currencies.transfer(currency, from_pl_name, to_pl_name, amount)` +Use this to subtract `amount` money `from_pl_name` and add them to `to_pl_name`. + +
+ +### `currencies.exchange(currency, from_pl_name, from_amount, to_pl_name, to_amount)` +Use this to subtract `from_amount` from `from_pl_name` and add `to_amount` to `to_pl_name`. + +
+ +### `currencies.exists(currency)` +Use this to check if a currency has been registered. + +
+ +


## Example ```lua -currencies.register("skywars_money") +currencies.register("skywars_money", {min_value = 250}) -currencies.add("Giov4", "skywars_money", 300) -currencies.sub("Giov4", "skywars_money", 100) +currencies.add("skywars_money", "Giov4", 300) +currencies.sub("skywars_money", "Giov4", 100) -local balance = currencies.get("Giov4", "skywars_money") -print(balance) -- output: 200 +local balance = currencies.get("skywars_money", "Giov4") +print(balance) -- output: 250 ```