Module shop

Adds shops

Functions

get_by_area (aid) Get a shop by its land area ID
get_by_pos (pos)
add_shop (s)
can_admin (pname, pos) Checks whether a user can use the admin interface for the shop
create_shop (pname, pos) Creates shops, checks permissions
unassign_chest (s, pos, inv) Unassigns item allocation of chest.
can_buy (pos, pname, itemname, count, price) Can user buy from shop, checks permissions
buy (pos, pname, item, count) Buy from shop, checks permissions

Class Shop

Shop.StockedItem StockedItem
Shop.Chest Chest
Shop:new (obj) Constructor
Shop:to_table () Export to Lua table
Shop:from_table (tab) Import from Lua table
Shop:get_items () Get table of items sold by this shop
Shop:get_item (name) Get StockedItem by item name
Shop:get_item_or_make (name) Get stock item table by item name, or make it if it doesn’t exist.
Shop:add_chest (pos) Add a chest to store stock in
Shop:get_chest (pos) Get a chest by pos
Shop:get_chests_for_item (name, count, filter) Get a list of chests which contain enough itmes to fulfill the requested name and count, or nil
Shop:chest_poll (pos, inv) Reads chest inventory, and updates stock counts
Shop:chest_add_item (pos, stack) An item has been added to a chest, make note of it
Shop:chest_remove_item (pos, stack) An item has been removed from a chest, make note of it


Functions

get_by_area (aid)
Get a shop by its land area ID

Parameters:

  • aid int
get_by_pos (pos)

Parameters:

add_shop (s)

Parameters:

can_admin (pname, pos)
Checks whether a user can use the admin interface for the shop

Parameters:

create_shop (pname, pos)
Creates shops, checks permissions

Parameters:

Returns:

    true

Or

  1. nil
  2. string Error message
unassign_chest (s, pos, inv)
Unassigns item allocation of chest. Will return any items.

Parameters:

can_buy (pos, pname, itemname, count, price)
Can user buy from shop, checks permissions

Parameters:

Returns:

    true

Or

  1. nil
  2. string Error message
buy (pos, pname, item, count)
Buy from shop, checks permissions

Parameters:

Returns:

    true

Or

  1. nil
  2. string Error message

Class Shop

Shop.StockedItem
StockedItem

Fields:

  • Item string name
  • Count int sold
  • Set int price, -1 for not for sale
  • Count int sold
Shop.Chest
Chest

Fields:

  • pos table Position
  • itemname string Assigned item name, nil for unassigned
  • count int Stored item count
Shop:new (obj)
Constructor

Parameters:

  • obj A table to construct an object on top of

Returns:

    company.Company
Shop:to_table ()
Export to Lua table

Returns:

    table
Shop:from_table (tab)
Import from Lua table

Parameters:

Returns:

    bool true on success, false on failure
Shop:get_items ()
Get table of items sold by this shop

Returns:

    table Keys are resolved item names, values are StockedItem.
Shop:get_item (name)
Get StockedItem by item name

Parameters:

  • name

Returns:

    table
Shop:get_item_or_make (name)
Get stock item table by item name, or make it if it doesn’t exist.

Parameters:

  • name

Returns:

    table
Shop:add_chest (pos)
Add a chest to store stock in

Parameters:

Returns:

    table chest table
Shop:get_chest (pos)
Get a chest by pos

Parameters:

Returns:

    table chest table
Shop:get_chests_for_item (name, count, filter)
Get a list of chests which contain enough itmes to fulfill the requested name and count, or nil

Parameters:

  • name string Item name
  • count int Number of items, >0
  • filter func func(chest_table)

Returns:

    [table] or nil
Shop:chest_poll (pos, inv)
Reads chest inventory, and updates stock counts This should be avoided, and the incremental methods used instead.

Parameters:

Shop:chest_add_item (pos, stack)
An item has been added to a chest, make note of it

Parameters:

  • pos table
  • stack ItemStack
Shop:chest_remove_item (pos, stack)
An item has been removed from a chest, make note of it

Parameters:

  • pos table
  • stack ItemStack
generated by LDoc 1.4.6 Last updated 2019-01-18 21:14:37