Go to file
Giov4 a3b5cb2646 Simplified add and sub functions 2021-03-06 18:06:56 +01:00
LICENSE Add LICENSE 2021-03-04 16:27:56 +00:00
README.md Update README.md 2021-03-04 21:24:18 +00:00
api.lua Simplified add and sub functions 2021-03-06 18:06:56 +01:00
chatcmdbuilder.lua + balance: min and max values + togglable negative ones when registering a currency 2021-03-04 22:04:05 +01:00
commands.lua + balance: min and max values + togglable negative ones when registering a currency 2021-03-04 22:04:05 +01:00
init.lua + balance: min and max values + togglable negative ones when registering a currency 2021-03-04 22:04:05 +01:00
mod.conf Initial commit 2021-03-04 11:33:20 +01:00
utils.lua + balance: min and max values + togglable negative ones when registering a currency 2021-03-04 22:04:05 +01:00

README.md

API


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):

--[[
{
    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.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

currencies.register("skywars_money", {min_value = 250})

currencies.add("skywars_money", "Giov4", 300)
currencies.sub("skywars_money", "Giov4", 100)

local balance = currencies.get("skywars_money", "Giov4")
print(balance)  -- output: 250