Module api.lua

API

Functions

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_seller (id, name, def) Registers a seller shop.
server_shop.register_buyer (id, name, def) Registers a buyer shop.
server_shop.register_shop (id, name, def, buyer) Registers a shop.
server_shop.get_shop (id, buyer) Retrieves shop product list.
server_shop.is_registered (id, buyer, true) Checks if a shop is registered.
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.

Tables

server_shop.registered_currencies Currencies registered for trade.


Functions

server_shop.register_currency (item, value)

Registers an item that can be used as currency.

TODO:

  • after registering currency, should re-organize table from highest value to lowest

Parameters:

  • item string Item name.
  • value int Value the item should represent.
server_shop.format_id (id)
Checks ID string for invalid characters.

FIXME: replace whitespace with underscore (_)

Parameters:

  • id string Shop identifier string.

Returns:

    string Formatted string.
server_shop.register_seller (id, name, def)
Registers a seller shop.

Parameters:

  • id string Shop string identifier.
  • name string Human readable name.
  • def table[string,int] List of products & prices in format {item_name, price}.
server_shop.register_buyer (id, name, def)
Registers a buyer shop.

Parameters:

  • id string Shop string identifier.
  • name string Human readable name.
  • def table[string,int] List of products & prices in format {item_name, price}.
server_shop.register_shop (id, name, def, buyer)
Registers a shop.

Added for backwards compatibility.

Parameters:

  • id string Shop string identifier.
  • name string Human readable name.
  • def 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)).
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).

Returns:

    table Table of shop contents.
server_shop.is_registered (id, buyer, true)
Checks if a shop is registered.

Parameters:

  • id string Shop string identifier.
  • buyer bool Denotes whether to check seller or buyer shops (default: false).
  • true bool ` if the shop ID is found.
server_shop.is_shop_admin (player)
Checks if a player has admin rights to for managing shop.

Parameters:

  • player 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:

  • pos Position of shop node.
  • player Player to be checked.

Returns:

    true if player is owner.

Tables

server_shop.registered_currencies
Currencies registered for trade.
generated by LDoc 1.4.6 Last updated 2021-05-14 13:34:59