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:
- 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:
- obj company.Company
Returns:
-
bool
- add (obj)
-
Adds a company to in-memory store.
Called by load and create.
Parameters:
- obj company.Company
Returns:
-
bool
- set_active (pname, comp)
-
Set the active company for a player Performs permission checks.
Parameters:
- pname string
- comp company.Company or string
Returns:
-
bool
- get_active (pname)
-
Get active company for player name
Parameters:
- pname string
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:
- pname string
Returns:
-
optional company.Company
- get_companies_for_player (pname)
-
List companies player is a member or CEO of
Parameters:
- pname string
Returns:
- 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
- nil
- string string Error message
- register_panel (def)
-
Register a panel, shown as colored boxes on the Company GUI
Parameters:
- def table
- register_snippet (name, func)
-
Register a snippet to go on company switchers
Parameters:
- name string
- func function
- 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:to_table ()
-
Export to Lua table
Returns:
- Company:from_table (t)
-
Import from Lua table
Parameters:
- t table
Returns:
-
bool
true on success, false on failure
- Company:set_title_calc_name (title)
-
Calculate an appropriate name from a given title
Parameters:
- title string
- Company:get_ceo_name ()
-
Get the name of the current CEO or president
Returns:
- Company:get_ownership (username)
-
How must does a particular username own of this company?
Parameters:
- username string
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:
- username string
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:
- username string
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