Module company

Introduces the concept of companies and the relationship between companies and players.

It adds permissions, but does not add stocks or shares.

Functions

get_by_name (name) Get a company by its name.
check_name (name) Verifies where a given string is a valid company name
create (obj) Creates a new company from a company reference
add (obj) Adds a company to in-memory store.
set_active (pname, comp) Set the active company for a player
get_active (pname) Get active company for player name
check_perm (pname, cname, permission, meta) Check whether a player has a certain permission for a company
get_active_or_msg (pname) Get active company for player name, or send chat message if no active companies.
get_companies_for_player (pname) List companies player is a member or CEO of
set_perms (comp, actor, target, permission, is_grant) Set the permissions for a particular member on a company
register_panel (def) Register a panel, shown as colored boxes on the Company GUI
register_snippet (name, func) Register a snippet to go on company switchers
show_company_select_dialog (name) Shows dialog to select company

Tables

registered_panels
registered_snippets
company company table
permissions Permissions table

Class Company

Company:new (obj) Constructor
Company:to_table () Export to Lua table
Company:from_table (t) Import from Lua table
Company:set_title_calc_name (title) Calculate an appropriate name from a given title
Company:get_ceo_name () Get the name of the current CEO or president
Company:get_ownership (username) How must does a particular username own of this company?
Company:can_become_active (username) Whether a particular player can act as this company
Company:check_perm (username, permission, meta) Check whether a player has a certain permission
Company:add_member (username) Adds a member to the company
Company:is_government () Check whether this company is a governmental entity.


Functions

get_by_name (name)
Get a company by its name. Company names are always in the form “c:[a-z-_]+”

Parameters:

  • name

Returns:

    company.Company
check_name (name)
Verifies where a given string is a valid company name

Parameters:

  • name

Returns:

    bool
create (obj)
Creates a new company from a company reference

Parameters:

Returns:

    bool
add (obj)
Adds a company to in-memory store.

Called by load and create.

Parameters:

Returns:

    bool
set_active (pname, comp)
Set the active company for a player Performs permission checks.

Parameters:

Returns:

    bool
get_active (pname)
Get active company for player name

Parameters:

Returns:

    optional company.Company
check_perm (pname, cname, permission, meta)
Check whether a player has a certain permission for a company Calling with a nil or nonexistent company will always result in a return value of false

Parameters:

  • pname string the username
  • cname optional string
  • permission string permission name, string
  • meta optional table Metadata about this request

Returns:

    bool

See also:

get_active_or_msg (pname)
Get active company for player name, or send chat message if no active companies.

Parameters:

Returns:

    optional company.Company
get_companies_for_player (pname)
List companies player is a member or CEO of

Parameters:

Returns:

    [company.Company]
set_perms (comp, actor, target, permission, is_grant)
Set the permissions for a particular member on a company

Parameters:

  • comp company.Company
  • actor string The player which is performing this action
  • target string The member which is having their perms set
  • permission string Permission name
  • is_grant bool Whether the permission should be added or taken away

Returns:

    true

Or

  1. nil
  2. string string Error message
register_panel (def)
Register a panel, shown as colored boxes on the Company GUI

Parameters:

register_snippet (name, func)
Register a snippet to go on company switchers

Parameters:

show_company_select_dialog (name)
Shows dialog to select company

Parameters:

  • name string Player name to show to

Tables

registered_panels

See also:

registered_snippets

See also:

company
company table
permissions
Permissions table

Fields:

  • SWITCH_TO
  • EDIT_DETAILS
  • TRANSFER_MONEY
  • TRANSFER_LAND
  • SELL_LAND
  • BUY_LAND
  • INTERACT_AREA
  • CHANGE_SPAWN
  • OWNS_AREA
  • SHOP_CREATE
  • SHOP_ADMIN
  • SHOP_CHEST
  • BUY_ITEMS
  • MANAGE_MEMBERS

Class Company

Company Class which represents a company or government entity.
Company:new (obj)
Constructor

Parameters:

  • obj A table to construct an object on top of

Returns:

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

Returns:

    table
Company:from_table (t)
Import from Lua table

Parameters:

Returns:

    bool true on success, false on failure
Company:set_title_calc_name (title)
Calculate an appropriate name from a given title

Parameters:

Company:get_ceo_name ()
Get the name of the current CEO or president

Returns:

    string
Company:get_ownership (username)
How must does a particular username own of this company?

Parameters:

Returns:

    number Proportion of ownership, as a number out of 1.
Company:can_become_active (username)
Whether a particular player can act as this company

Parameters:

Returns:

    bool
Company:check_perm (username, permission, meta)
Check whether a player has a certain permission

Parameters:

  • username string the username
  • permission string permission name, string
  • meta optional table Metadata about this request

Returns:

    bool

See also:

Company:add_member (username)
Adds a member to the company Members are players other than the CEO that can have permissions granted to them by the company

Parameters:

Returns:

    Member table
Company:is_government ()
Check whether this company is a governmental entity.

Note: does NOT check whether the company is public or government-owned. This condition imposes certain requirements on the government entity, such as elections and voting, which do not make sense with government-owned companies.

Returns:

    bool
generated by LDoc 1.4.6 Last updated 2019-01-18 21:14:37