Topic api.lua
Server Shops API
Functions
server_shop.currency_is_registered () | Checks if there are registered currencies in order to give refunds. |
server_shop.get_currencies () | Retrieves registered currencies & values. |
server_shop.register_currency (item, value) | Registers an item that can be used as currency. |
server_shop.format_id (id) | Checks ID string for invalid characters. |
server_shop.register (id, name, products[, buyer]) | Registers a shop. |
server_shop.unregister (Shop) | Unregisters a shop. |
server_shop.register_seller (id, name, products) | Registers a seller shop. |
server_shop.register_buyer (id, name, products) | Registers a buyer shop. |
server_shop.get_shop (id, buyer) | Retrieves shop product list. |
server_shop.is_registered (id, buyer) | Checks if a shop is registered. |
server_shop.shop_type (id) | |
server_shop.is_shop_admin (player) | Checks if a player has admin rights to for managing shop. |
server_shop.is_shop_owner (pos, player) | Checks if a player is the owner of node. |
server_shop.file_load () | Loads configuration from world path. |
server_shop.file_register (id, def) | Permanently registers a shop. |
server_shop.file_add_product (id, name, value[, idx]) | Permanently adds a product to a shop. |
server_shop.file_unregister (id) | Unregisters a shop & updates configuration. |
server_shop.prune_shops () | Prunes unknown items & updates aliases in shops. |
Functions
- server_shop.currency_is_registered ()
-
Checks if there are registered currencies in order to give refunds.
Returns:
-
bool
true
if at least one currency item is registered. - server_shop.get_currencies ()
-
Retrieves registered currencies & values.
Returns:
-
table
Registered currencies.
- server_shop.register_currency (item, value)
-
Registers an item that can be used as currency.
Parameters:
- item string Item name.
- value int Value the item should represent.
- server_shop.format_id (id)
-
Checks ID string for invalid characters.
Parameters:
- id string Shop identifier string.
Returns:
-
string
Formatted string.
- server_shop.register (id, name, products[, buyer])
-
Registers a shop.
Aliases:
- server_shop.register_shop
Parameters:
- id string Shop string identifier.
- name Can be a human readable string name or a table with fiels "name", "products", & "buyer".
- products table[string,int] List of products & prices in format {item_name, price}.
- buyer
bool
Denotes whether to register seller or buyer shop (default:
false
(seller)). (optional)
- server_shop.unregister (Shop)
-
Unregisters a shop.
Parameters:
- Shop string ID.
Returns:
-
bool
true
if shop was unregistered. - server_shop.register_seller (id, name, products)
-
Registers a seller shop.
Parameters:
- id string Shop string identifier.
- name string Human readable name.
- products table[string,int] List of products & prices in format {item_name, price}.
- server_shop.register_buyer (id, name, products)
-
Registers a buyer shop.
Parameters:
- id string Shop string identifier.
- name string Human readable name.
- products table[string,int] List of products & prices in format {item_name, price}.
- server_shop.get_shop (id, buyer)
-
Retrieves shop product list.
Parameters:
- id string String identifier of shop.
- buyer bool Denotes whether seller or buyer shops will be parsed (default: false) (deprecated).
Returns:
-
table
Table of shop contents.
- server_shop.is_registered (id, buyer)
-
Checks if a shop is registered.
Parameters:
- id string Shop string identifier.
- buyer bool Denotes whether to check seller or buyer shops (default: false) (deprecated).
Returns:
-
bool
true
if the shop ID is found. - server_shop.shop_type (id)
-
Parameters:
- id string
- server_shop.is_shop_admin (player)
-
Checks if a player has admin rights to for managing shop.
Parameters:
- player ObjectRef Player requesting permissions.
Returns:
true
if player has server priv. - server_shop.is_shop_owner (pos, player)
-
Checks if a player is the owner of node.
Parameters:
Returns:
-
bool
true
if player is owner. - server_shop.file_load ()
-
Loads configuration from world path.
Configuration file is
/server_shops.json - server_shop.file_register (id, def)
-
Permanently registers a shop.
Parameters:
- id string Shop identifier.
- def ShopDef Shop definition.
- server_shop.file_add_product (id, name, value[, idx])
-
Permanently adds a product to a shop.
Parameters:
- server_shop.file_unregister (id)
-
Unregisters a shop & updates configuration.
Parameters:
- id string Shop identifier.
Returns:
-
bool
- server_shop.prune_shops ()
- Prunes unknown items & updates aliases in shops.