mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
More spelling fixes
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
-- each button has the button define(s) given along side an auth function, and optional reason callback
|
-- each button has the button define(s) given along side an auth function, and optional reason callback
|
||||||
-- if a reason callback is used then Store.set(action_name_store,player.name,'BUTTON_NAME') should be called during on_click
|
-- if a reason callback is used then Store.set(action_name_store,player.name,'BUTTON_NAME') should be called during on_click
|
||||||
-- buttons can be removed from the gui by commenting them out of the config at the bottom of this file
|
-- buttons can be removed from the gui by commenting them out of the config at the bottom of this file
|
||||||
-- the key used for the name of the button is the permision name used by the role system
|
-- the key used for the name of the button is the permission name used by the role system
|
||||||
local Gui = require 'expcore.gui'
|
local Gui = require 'expcore.gui'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
local Store = require 'expcore.store'
|
local Store = require 'expcore.store'
|
||||||
@@ -235,7 +235,7 @@ return {
|
|||||||
if not Roles.player_allowed(player,'command/give-warning') then
|
if not Roles.player_allowed(player,'command/give-warning') then
|
||||||
return not Roles.player_has_flag(action_player,'report-immune')
|
return not Roles.player_has_flag(action_player,'report-immune')
|
||||||
end
|
end
|
||||||
end, -- can report any player that isnt immune and you arnt able to give warnings
|
end, -- can report any player that isn't immune and you aren't able to give warnings
|
||||||
reason_callback=report_player_callback,
|
reason_callback=report_player_callback,
|
||||||
report_player
|
report_player
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
command_admin_only = false, -- when true will only allow chat commands for admins
|
command_admin_only = false, -- when true will only allow chat commands for admins
|
||||||
command_permission = 'command/chat-bot', -- the permision used to allow command prefixs
|
command_permission = 'command/chat-bot', -- the permission used to allow command prefixes
|
||||||
command_prefix = '!', -- prefix used for commands below and to print to all players (if enabled above)
|
command_prefix = '!', -- prefix used for commands below and to print to all players (if enabled above)
|
||||||
commands = { -- will trigger only when command prefix is given
|
commands = { -- will trigger only when command prefix is given
|
||||||
['dev']={'chat-bot.not-real-dev'},
|
['dev']={'chat-bot.not-real-dev'},
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ return {
|
|||||||
['infinity-chest']=true
|
['infinity-chest']=true
|
||||||
},
|
},
|
||||||
max_range=50, -- the max range that can be used with the repair command
|
max_range=50, -- the max range that can be used with the repair command
|
||||||
allow_blueprint_repair=false, -- when true will allow blueprints (things not destroied by biters) to be build instently using the repair command
|
allow_blueprint_repair=false, -- when true will allow blueprints (things not destroyed by biters) to be build instantly using the repair command
|
||||||
allow_ghost_revive=true, -- when true will allow ghosts (things destoried by biters) to be build instently using the repair command
|
allow_ghost_revive=true, -- when true will allow ghosts (things destroyed by biters) to be build instantly using the repair command
|
||||||
allow_heal_entities=true -- when true will heal entities to full health that are within range
|
allow_heal_entities=true -- when true will heal entities to full health that are within range
|
||||||
}
|
}
|
||||||
@@ -7,11 +7,11 @@ return {
|
|||||||
show_fastest_rocket = true, -- false will not show the time taken for the fastest rocket
|
show_fastest_rocket = true, -- false will not show the time taken for the fastest rocket
|
||||||
show_total_rockets = true, -- false will not show the total number of rockets launched
|
show_total_rockets = true, -- false will not show the total number of rockets launched
|
||||||
show_game_avg = true, -- false will hide the avg across the entire map time
|
show_game_avg = true, -- false will hide the avg across the entire map time
|
||||||
rolling_avg = { -- each number will be one stat; 5 means the avg time taken for the last 5 rockets
|
rolling_avg = { -- each number will be one statistic; 5 means the avg time taken for the last 5 rockets
|
||||||
5,10,25
|
5,10,25
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
milestones = { -- each number will be one stat; 5 means the time that the 5th rocket was launched
|
milestones = { -- each number will be one statistic; 5 means the time that the 5th rocket was launched
|
||||||
show_milestones=true, -- false will hide this section all together
|
show_milestones=true, -- false will hide this section all together
|
||||||
1,2,5,
|
1,2,5,
|
||||||
10,20,50,
|
10,20,50,
|
||||||
@@ -25,9 +25,9 @@ return {
|
|||||||
allow_zoom_to_map = true, -- false will disable the zoom to map feature
|
allow_zoom_to_map = true, -- false will disable the zoom to map feature
|
||||||
allow_remote_launch = true, -- false removes the remote launch button for all players
|
allow_remote_launch = true, -- false removes the remote launch button for all players
|
||||||
remote_launch_admins_only = false, -- true will remove the remote launch button for all non (game) admins
|
remote_launch_admins_only = false, -- true will remove the remote launch button for all non (game) admins
|
||||||
remote_launch_role_permision = 'gui/rocket-info/remote_launch', -- value used by custom permission system to allow or disllow the button
|
remote_launch_role_permission = 'gui/rocket-info/remote_launch', -- value used by custom permission system to allow or disallow the button
|
||||||
allow_toggle_active = true, -- false removes the remote toggle auto launch button for all players
|
allow_toggle_active = true, -- false removes the remote toggle auto launch button for all players
|
||||||
toggle_active_admins_only = false, -- true will remove the toggle auto launch button for all non (game) admins
|
toggle_active_admins_only = false, -- true will remove the toggle auto launch button for all non (game) admins
|
||||||
toggle_active_role_permision = 'gui/rocket-info/toggle-active' -- value used by custom permission system to allow or disllow the button
|
toggle_active_role_permission = 'gui/rocket-info/toggle-active' -- value used by custom permission system to allow or disallow the button
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ local Roles = require 'expcore.roles'
|
|||||||
local seconds, minutes, hours = 60, 3600, 216000
|
local seconds, minutes, hours = 60, 3600, 216000
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
-- cant use a factory as it has upvalues ;-;
|
-- cant use a factory as it has up values ;-;
|
||||||
local function playtime(time_required)
|
local function playtime(time_required)
|
||||||
return function(player)
|
return function(player)
|
||||||
if player.online_time > time_required then
|
if player.online_time > time_required then
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ return {
|
|||||||
any_user_can_add_new_task = true, -- when false only people with edit permission can make new reports
|
any_user_can_add_new_task = true, -- when false only people with edit permission can make new reports
|
||||||
user_can_edit_own_tasks = true, -- when false only people with edit permission can edit reports
|
user_can_edit_own_tasks = true, -- when false only people with edit permission can edit reports
|
||||||
only_admins_can_edit = false, -- true will hide the edit and delete buttons from non (game) admins
|
only_admins_can_edit = false, -- true will hide the edit and delete buttons from non (game) admins
|
||||||
edit_tasks_role_permision = 'gui/task-list/edit' -- value used with custom permision system
|
edit_tasks_role_permission = 'gui/task-list/edit' -- value used with custom permission system
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,8 @@ return {
|
|||||||
minimum_distance = 100, -- The minimum distance that must be between warp points, creating new ones is blocked when too close
|
minimum_distance = 100, -- The minimum distance that must be between warp points, creating new ones is blocked when too close
|
||||||
activation_range = 4, -- The distance the player must be to a warp in order to use the warp gui, gui can still be viewed but not used
|
activation_range = 4, -- The distance the player must be to a warp in order to use the warp gui, gui can still be viewed but not used
|
||||||
spawn_activation_range = 20, -- A second activation range which is used for the forces spawn point
|
spawn_activation_range = 20, -- A second activation range which is used for the forces spawn point
|
||||||
default_icon = 'discharge-defense-equipment', -- The deafult icon which is used by warps; must be an item name
|
default_icon = 'discharge-defense-equipment', -- The default icon which is used by warps; must be an item name
|
||||||
user_can_edit_own_warps = false, -- When true the user can always edit warps which they created regaudless of other settings
|
user_can_edit_own_warps = false, -- When true the user can always edit warps which they created regardless of other settings
|
||||||
any_user_can_add_new_warp = false, -- When true any user is able to create new warps, however editing may still be restricted
|
any_user_can_add_new_warp = false, -- When true any user is able to create new warps, however editing may still be restricted
|
||||||
only_admins_can_edit = false, -- When true only admins can edit warps
|
only_admins_can_edit = false, -- When true only admins can edit warps
|
||||||
edit_warps_role_permission = 'gui/warp-list/edit', -- Role permission used by the role system to allow editing warps
|
edit_warps_role_permission = 'gui/warp-list/edit', -- Role permission used by the role system to allow editing warps
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
nb: if you do not return reject after you call it then you are still returning nil so there will be a duplicate message
|
nb: if you do not return reject after you call it then you are still returning nil so there will be a duplicate message
|
||||||
|
|
||||||
It should be noted that if you want to expand on an existing parse you can use Commands.parse(type,input,player,reject)
|
It should be noted that if you want to expand on an existing parse you can use Commands.parse(type,input,player,reject)
|
||||||
and this value will either return a new value for the input or nil, if it is nil you should return nil to prevent dobble
|
and this value will either return a new value for the input or nil, if it is nil you should return nil to prevent double
|
||||||
messages to the user:
|
messages to the user:
|
||||||
input = Commands.parse('number-int',input,player,reject)
|
input = Commands.parse('number-int',input,player,reject)
|
||||||
if not input then return end -- nil check
|
if not input then return end -- nil check
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
Commands.print(any,colour[opt]) -- this will return any value value to the user including if it is ran through rcon console
|
Commands.print(any,colour[opt]) -- this will return any value value to the user including if it is ran through rcon console
|
||||||
Commands.error(message[opt]) -- this returns a warning to the user, aka an error that does not prevent execution of the command
|
Commands.error(message[opt]) -- this returns a warning to the user, aka an error that does not prevent execution of the command
|
||||||
return Commands.error(message[opt]) -- this returns an error to the user, and will halt the command execution, ie no success message is returned
|
return Commands.error(message[opt]) -- this returns an error to the user, and will halt the command execution, ie no success message is returned
|
||||||
Commands.success(message[opt]) -- used to return a success message however dont use this method see below
|
Commands.success(message[opt]) -- used to return a success message however don't use this method see below
|
||||||
return Commands.success(message[opt]) -- will return the success message to the user and your given message, halts execution
|
return Commands.success(message[opt]) -- will return the success message to the user and your given message, halts execution
|
||||||
return <any> if any value is returned then it will be returned to the player via a Commands.success call
|
return <any> if any value is returned then it will be returned to the player via a Commands.success call
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ end
|
|||||||
|
|
||||||
--- Intended to be used within other parse functions, runs a parse and returns success and new value
|
--- Intended to be used within other parse functions, runs a parse and returns success and new value
|
||||||
-- @tparam string name the name of the parse to call, must be registered and cant be a function
|
-- @tparam string name the name of the parse to call, must be registered and cant be a function
|
||||||
-- @tparam string input string the input to pass to the parse, will always be a but might not be the orginal input
|
-- @tparam string input string the input to pass to the parse, will always be a but might not be the original input
|
||||||
-- @tparam LuaPlayer player the player that is calling using the command
|
-- @tparam LuaPlayer player the player that is calling using the command
|
||||||
-- @tparam function reject the reject function that was passed by the command hander
|
-- @tparam function reject the reject function that was passed by the command hander
|
||||||
-- @treturn any the new value for the input, may be nil, if nil then either there was an error or input was nil
|
-- @treturn any the new value for the input, may be nil, if nil then either there was an error or input was nil
|
||||||
@@ -497,7 +497,7 @@ function Commands._prototype:add_alias(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Enables auto concatenation of any params on the end so quotes are not needed for last param
|
--- Enables auto concatenation of any params on the end so quotes are not needed for last param
|
||||||
-- nb: this will disable max param checking as they will be concated onto the end of that last param
|
-- nb: this will disable max param checking as they will be concatenated onto the end of that last param
|
||||||
-- this can be useful for reasons or longs text, can only have one per command
|
-- this can be useful for reasons or longs text, can only have one per command
|
||||||
-- @treturn Commands._prototype pass through to allow more functions to be called
|
-- @treturn Commands._prototype pass through to allow more functions to be called
|
||||||
function Commands._prototype:enable_auto_concat()
|
function Commands._prototype:enable_auto_concat()
|
||||||
@@ -628,7 +628,7 @@ function Commands.run_command(command_event)
|
|||||||
local no_quotes = w:sub(2,-2)
|
local no_quotes = w:sub(2,-2)
|
||||||
quote_params[no_spaces]=no_quotes
|
quote_params[no_spaces]=no_quotes
|
||||||
if command_data.auto_concat then
|
if command_data.auto_concat then
|
||||||
-- if auto concat then dont remove quotes as it should be included later
|
-- if auto concat then don't remove quotes as it should be included later
|
||||||
quote_params[no_spaces]=w
|
quote_params[no_spaces]=w
|
||||||
end
|
end
|
||||||
return no_spaces
|
return no_spaces
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
Common.print_grid_value(value, surface, position, scale, offset, immutable) --- Prints a colored value on a location.
|
Common.print_grid_value(value, surface, position, scale, offset, immutable) --- Prints a colored value on a location.
|
||||||
Common.print_colored_grid_value(value, surface, position, offset, immutable,
|
Common.print_colored_grid_value(value, surface, position, offset, immutable,
|
||||||
color_value, base_color, delta_color, under_bound, over_bound) --- Prints a colored value on a location. with extra settings.
|
color_value, base_color, delta_color, under_bound, over_bound) --- Prints a colored value on a location. with extra settings.
|
||||||
Common.clear_flying_text(surface) --- Clears all flying text entites on a surface
|
Common.clear_flying_text(surface) --- Clears all flying text entities on a surface
|
||||||
|
|
||||||
Common.string_contains(s, contains) --- Tests if a string contains a given substring.
|
Common.string_contains(s, contains) --- Tests if a string contains a given substring.
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
Common.table_keys(tbl) --- Returns all the keys of a table
|
Common.table_keys(tbl) --- Returns all the keys of a table
|
||||||
Common.table_values(tbl) --- Returns all the values of a table
|
Common.table_values(tbl) --- Returns all the values of a table
|
||||||
Common.table_alphanumsort(tbl) --- Returns the list is a sorted way that would be expected by people (this is by key)
|
Common.table_alphanumsort(tbl) --- Returns the list is a sorted way that would be expected by people (this is by key)
|
||||||
Common.table_keysort(tbl) --- Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)
|
Common.table_keysort(tbl) --- Returns the list is a sorted way that would be expected by people (this is by key) (faster alternative than above)
|
||||||
|
|
||||||
Common.format_chat_colour(message,color) --- Returns a message with valid chat tags to change its colour
|
Common.format_chat_colour(message,color) --- Returns a message with valid chat tags to change its colour
|
||||||
Common.format_chat_colour_localized(message,color) --- Returns a message with valid chat tags to change its colour, using localization
|
Common.format_chat_colour_localized(message,color) --- Returns a message with valid chat tags to change its colour, using localization
|
||||||
@@ -262,7 +262,7 @@ function Common.move_items(items,surface,position,radius,chest_type)
|
|||||||
local entities = surface.find_entities_filtered{area={{p.x-r,p.y-r},{p.x+r,p.y+r}},name=chest_type} or {}
|
local entities = surface.find_entities_filtered{area={{p.x-r,p.y-r},{p.x+r,p.y+r}},name=chest_type} or {}
|
||||||
local count = #entities
|
local count = #entities
|
||||||
local current = 1
|
local current = 1
|
||||||
-- Makes a new emtpy chest when it is needed
|
-- Makes a new empty chest when it is needed
|
||||||
local function make_new_chest()
|
local function make_new_chest()
|
||||||
local pos = surface.find_non_colliding_position(chest_type,position,32,1)
|
local pos = surface.find_non_colliding_position(chest_type,position,32,1)
|
||||||
local chest = surface.create_entity{name=chest_type,position=pos,force='neutral'}
|
local chest = surface.create_entity{name=chest_type,position=pos,force='neutral'}
|
||||||
@@ -437,7 +437,7 @@ function Common.print_colored_grid_value(value, surface, position, offset, immut
|
|||||||
}.active = false
|
}.active = false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Clears all flying text entites on a surface
|
--- Clears all flying text entities on a surface
|
||||||
-- @tparam LuaSurface surface the surface to clear
|
-- @tparam LuaSurface surface the surface to clear
|
||||||
function Common.clear_flying_text(surface)
|
function Common.clear_flying_text(surface)
|
||||||
local entities = surface.find_entities_filtered{name ='flying-text'}
|
local entities = surface.find_entities_filtered{name ='flying-text'}
|
||||||
@@ -598,7 +598,7 @@ function Common.table_alphanumsort(tbl)
|
|||||||
return _tbl
|
return _tbl
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)
|
--- Returns the list is a sorted way that would be expected by people (this is by key) (faster alternative than above)
|
||||||
-- @tparam table tbl the table to be sorted
|
-- @tparam table tbl the table to be sorted
|
||||||
-- @treturn table the sorted table
|
-- @treturn table the sorted table
|
||||||
function Common.table_keysort(tbl)
|
function Common.table_keysort(tbl)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--- This file is used to require all the different elements of the gui module
|
--- This file is used to require all the different elements of the gui module
|
||||||
-- each module has an outline here but for more details see their seperate files in ./gui
|
-- each module has an outline here but for more details see their separate files in ./gui
|
||||||
|
|
||||||
local Gui = require 'expcore.gui.core'
|
local Gui = require 'expcore.gui.core'
|
||||||
--[[
|
--[[
|
||||||
@@ -13,11 +13,11 @@ local Gui = require 'expcore.gui.core'
|
|||||||
Gui.categorize_by_surface(element) --- A categorize function to be used with add_store, each surface has its own value
|
Gui.categorize_by_surface(element) --- A categorize function to be used with add_store, each surface has its own value
|
||||||
|
|
||||||
Gui.toggle_enabled(element) --- Will toggle the enabled state of an element
|
Gui.toggle_enabled(element) --- Will toggle the enabled state of an element
|
||||||
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
|
Gui.toggle_visible(element) --- Will toggle the visibility of an element
|
||||||
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
||||||
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
|
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
|
||||||
Gui.create_alignment(element,flow_name) --- Allows the creation of a right align flow to place elements into
|
Gui.create_alignment(element,flow_name) --- Allows the creation of a right align flow to place elements into
|
||||||
Gui.destory_if_valid(element) --- Destroies an element but tests for it being present and valid first
|
Gui.destroy_if_valid(element) --- Destroys an element but tests for it being present and valid first
|
||||||
Gui.create_scroll_table(element,table_size,maximal_height,name) --- Creates a scroll area with a table inside, table can be any size
|
Gui.create_scroll_table(element,table_size,maximal_height,name) --- Creates a scroll area with a table inside, table can be any size
|
||||||
Gui.create_header(element,caption,tooltip,right_align,name) --- Creates a header section with a label and button area
|
Gui.create_header(element,caption,tooltip,right_align,name) --- Creates a header section with a label and button area
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ local Gui = require 'expcore.gui.core'
|
|||||||
Prototype:set_caption(value) --- Sets the caption for the element define
|
Prototype:set_caption(value) --- Sets the caption for the element define
|
||||||
Prototype:set_tooltip(value) --- Sets the tooltip for the element define
|
Prototype:set_tooltip(value) --- Sets the tooltip for the element define
|
||||||
Prototype:set_style(style,callback) --- Sets the style for the element define
|
Prototype:set_style(style,callback) --- Sets the style for the element define
|
||||||
Prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
Prototype:set_embedded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||||
|
|
||||||
Prototype:set_pre_authenticator --- Sets an authenticator that blocks the draw function if check fails
|
Prototype:set_pre_authenticator --- Sets an authenticator that blocks the draw function if check fails
|
||||||
Prototype:set_post_authenticator --- Sets an authenticator that disables the element if check fails
|
Prototype:set_post_authenticator --- Sets an authenticator that disables the element if check fails
|
||||||
@@ -55,7 +55,7 @@ Gui.add_instance = Instances.get_elements
|
|||||||
Gui.update_instances = Instances.apply_to_elements
|
Gui.update_instances = Instances.apply_to_elements
|
||||||
Gui.classes.instances = Instances
|
Gui.classes.instances = Instances
|
||||||
--[[
|
--[[
|
||||||
Instances.has_categories(name) --- Returns if a instnace group has a categorise function; must be registerd
|
Instances.has_categories(name) --- Returns if a instance group has a categorise function; must be registered
|
||||||
Instances.is_registered(name) --- Returns if the given name is a registered instance group
|
Instances.is_registered(name) --- Returns if the given name is a registered instance group
|
||||||
Instances.register(name,categorise) --- Registers the name of an instance group to allow for storing element instances
|
Instances.register(name,categorise) --- Registers the name of an instance group to allow for storing element instances
|
||||||
|
|
||||||
@@ -77,12 +77,12 @@ Gui.classes.button = Button
|
|||||||
Button._prototype:on_left_click(player,element) --- Registers a handler for when the button is clicked with the left mouse button
|
Button._prototype:on_left_click(player,element) --- Registers a handler for when the button is clicked with the left mouse button
|
||||||
Button._prototype:on_right_click(player,element) --- Registers a handler for when the button is clicked with the right mouse button
|
Button._prototype:on_right_click(player,element) --- Registers a handler for when the button is clicked with the right mouse button
|
||||||
|
|
||||||
Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite) --- Adds sprites to a button making it a spirte button
|
Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite) --- Adds sprites to a button making it a sprite button
|
||||||
Button._prototype:set_click_filter(filter,...) --- Adds a click / mouse button filter to the button
|
Button._prototype:set_click_filter(filter,...) --- Adds a click / mouse button filter to the button
|
||||||
Button._prototype:set_key_filter(filter,...) --- Adds a control key filter to the button
|
Button._prototype:set_key_filter(filter,...) --- Adds a control key filter to the button
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Checkbox = require 'expcore.gui.elements.checkboxs'
|
local Checkbox = require 'expcore.gui.elements.checkbox'
|
||||||
Gui.new_checkbox = Checkbox.new_checkbox
|
Gui.new_checkbox = Checkbox.new_checkbox
|
||||||
Gui.new_radiobutton = Checkbox.new_radiobutton
|
Gui.new_radiobutton = Checkbox.new_radiobutton
|
||||||
Gui.new_radiobutton_option_set = Checkbox.new_option_set
|
Gui.new_radiobutton_option_set = Checkbox.new_option_set
|
||||||
@@ -98,10 +98,10 @@ Gui.classes.checkbox = Checkbox
|
|||||||
Checkbox._prototype_radiobutton:on_store_update(callback) --- Registers a handler for when the stored value updates
|
Checkbox._prototype_radiobutton:on_store_update(callback) --- Registers a handler for when the stored value updates
|
||||||
Checkbox._prototype_radiobutton:add_as_option(option_set,option_name) --- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
Checkbox._prototype_radiobutton:add_as_option(option_set,option_name) --- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
||||||
|
|
||||||
Checkbox.new_option_set(name,callback,categorize) --- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
|
Checkbox.new_option_set(name,callback,categorize) --- Registers a new option set that can be linked to radiobuttons (only one can be true at a time)
|
||||||
Checkbox.draw_option_set(name,element) --- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
|
Checkbox.draw_option_set(name,element) --- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
|
||||||
|
|
||||||
Checkbox.reset_radiobutton(element,exclude,recursive) --- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
|
Checkbox.reset_radiobutton(element,exclude,recursive) --- Sets all radiobuttons in a element to false (unless excluded) and can act recursively
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Dropdown = require 'expcore.gui.elements.dropdown'
|
local Dropdown = require 'expcore.gui.elements.dropdown'
|
||||||
@@ -176,7 +176,7 @@ Gui.classes.progressbar = ProgressBar
|
|||||||
--[[
|
--[[
|
||||||
ProgressBar.set_maximum(element,amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
ProgressBar.set_maximum(element,amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
||||||
ProgressBar.increment(element,amount) --- Increases the value of the progressbar, if a define is given all of its instances are incremented
|
ProgressBar.increment(element,amount) --- Increases the value of the progressbar, if a define is given all of its instances are incremented
|
||||||
ProgressBar.decrement(element,amount) --- Decreases the value of the progressbar, if a define is given all of its instances are decresed
|
ProgressBar.decrement(element,amount) --- Decreases the value of the progressbar, if a define is given all of its instances are decreased
|
||||||
|
|
||||||
ProgressBar.new_progressbar(name) --- Creates a new progressbar element define
|
ProgressBar.new_progressbar(name) --- Creates a new progressbar element define
|
||||||
ProgressBar._prototype:set_maximum(amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
ProgressBar._prototype:set_maximum(amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
||||||
@@ -188,10 +188,10 @@ Gui.classes.progressbar = ProgressBar
|
|||||||
ProgressBar._prototype:add_element(element,maximum) --- Adds an element into the list of instances that will are waiting to complete, does not work with store
|
ProgressBar._prototype:add_element(element,maximum) --- Adds an element into the list of instances that will are waiting to complete, does not work with store
|
||||||
ProgressBar._prototype:reset_element(element) --- Resets an element, or its store, to be back at the start, either 1 or 0
|
ProgressBar._prototype:reset_element(element) --- Resets an element, or its store, to be back at the start, either 1 or 0
|
||||||
|
|
||||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a progress bar element compeltes (hits 0 or 1)
|
ProgressBar._prototype:on_complete(callback) --- Triggers when a progress bar element completes (hits 0 or 1)
|
||||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a store value completes (hits 0 or 1)
|
ProgressBar._prototype:on_complete(callback) --- Triggers when a store value completes (hits 0 or 1)
|
||||||
ProgressBar._prototype:event_counter(filter) --- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
|
ProgressBar._prototype:event_counter(filter) --- Event handler factory that counts up by 1 every time the event triggers, can filter which elements are incremented
|
||||||
ProgressBar._prototype:event_countdown(filter) --- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
|
ProgressBar._prototype:event_countdown(filter) --- Event handler factory that counts down by 1 every time the event triggers, can filter which elements are decremented
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Toolbar = require 'expcore.gui.concepts.toolbar'
|
local Toolbar = require 'expcore.gui.concepts.toolbar'
|
||||||
@@ -214,16 +214,16 @@ Gui.classes.left_frames = LeftFrames
|
|||||||
LeftFrames.get_flow(player) --- Gets the left frame flow for a player
|
LeftFrames.get_flow(player) --- Gets the left frame flow for a player
|
||||||
LeftFrames.get_frame(name,player) --- Gets one frame from the left flow by its name
|
LeftFrames.get_frame(name,player) --- Gets one frame from the left flow by its name
|
||||||
LeftFrames.get_open(player) --- Gets all open frames for a player, if non are open it will remove the close all button
|
LeftFrames.get_open(player) --- Gets all open frames for a player, if non are open it will remove the close all button
|
||||||
LeftFrames.toggle_frame(name,player,state) --- Toggles the visiblty of a left frame, or sets its visiblty state
|
LeftFrames.toggle_frame(name,player,state) --- Toggles the visibility of a left frame, or sets its visibility state
|
||||||
|
|
||||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
LeftFrames.new_frame(permission_name) --- Creates a new left frame define
|
||||||
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
||||||
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
||||||
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
||||||
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
||||||
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
|
LeftFrames._prototype:toggle(player) --- Toggles the visibility of the left frame
|
||||||
|
|
||||||
LeftFrames._prototype:update(player) --- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
|
LeftFrames._prototype:update(player) --- Updates the contents of the left frame, first tries update callback, other wise will clear and redraw
|
||||||
LeftFrames._prototype:update_all(update_offline) --- Updates the frame for all players, see update
|
LeftFrames._prototype:update_all(update_offline) --- Updates the frame for all players, see update
|
||||||
LeftFrames._prototype:redraw(player) --- Redraws the frame by calling on_draw, will always clear the frame
|
LeftFrames._prototype:redraw(player) --- Redraws the frame by calling on_draw, will always clear the frame
|
||||||
LeftFrames._prototype:redraw_all(update_offline) --- Redraws the frame for all players, see redraw
|
LeftFrames._prototype:redraw_all(update_offline) --- Redraws the frame for all players, see redraw
|
||||||
@@ -245,10 +245,10 @@ Gui.classes.center_frames = CenterFrames
|
|||||||
CenterFrames.get_flow(player) --- Gets the center flow for a player
|
CenterFrames.get_flow(player) --- Gets the center flow for a player
|
||||||
CenterFrames.clear_flow(player) --- Clears the center flow for a player
|
CenterFrames.clear_flow(player) --- Clears the center flow for a player
|
||||||
CenterFrames.draw_frame(player,name) --- Draws the center frame for a player, if already open then will do nothing
|
CenterFrames.draw_frame(player,name) --- Draws the center frame for a player, if already open then will do nothing
|
||||||
CenterFrames.redraw_frame(player,name) --- Draws the center frame for a player, if already open then will destory it and redraw
|
CenterFrames.redraw_frame(player,name) --- Draws the center frame for a player, if already open then will destroy it and redraw
|
||||||
CenterFrames.toggle_frame(player,name,state) --- Toggles if the frame is currently open or not, will open if closed and close if open
|
CenterFrames.toggle_frame(player,name,state) --- Toggles if the frame is currently open or not, will open if closed and close if open
|
||||||
|
|
||||||
CenterFrames.new_frame(permision_name) --- Sets the frame to be the current active gui when opened and closes all other frames
|
CenterFrames.new_frame(permission_name) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||||
CenterFrames._prototype:on_draw(player,frame) --- Use to draw your elements onto the new frame
|
CenterFrames._prototype:on_draw(player,frame) --- Use to draw your elements onto the new frame
|
||||||
CenterFrames._prototype:set_auto_focus(state) --- Sets the frame to be the current active gui when opened and closes all other frames
|
CenterFrames._prototype:set_auto_focus(state) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||||
CenterFrames._prototype:draw_frame(player) --- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
|
CenterFrames._prototype:draw_frame(player) --- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
|
||||||
@@ -266,7 +266,7 @@ Gui.classes.popup_frames = PopupFrames
|
|||||||
PopupFrames.get_flow(player) --- Gets the left flow that contains the popup frames
|
PopupFrames.get_flow(player) --- Gets the left flow that contains the popup frames
|
||||||
PopupFrames.open(define_name,player,open_time,...) --- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
|
PopupFrames.open(define_name,player,open_time,...) --- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
|
||||||
|
|
||||||
PopupFrames.close_progress --- Progress bar which when depleaded will close the popup frame
|
PopupFrames.close_progress --- Progress bar which when depleted will close the popup frame
|
||||||
PopupFrames.close_button --- A button which can be used to close the gui before the timer runs out
|
PopupFrames.close_button --- A button which can be used to close the gui before the timer runs out
|
||||||
|
|
||||||
PopupFrames.new_popup(name) --- Creates a new popup frame define
|
PopupFrames.new_popup(name) --- Creates a new popup frame define
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
CenterFrames.redraw_frame(player,name) --- Draws the center frame for a player, if already open then will destroy it and redraw
|
CenterFrames.redraw_frame(player,name) --- Draws the center frame for a player, if already open then will destroy it and redraw
|
||||||
CenterFrames.toggle_frame(player,name,state) --- Toggles if the frame is currently open or not, will open if closed and close if open
|
CenterFrames.toggle_frame(player,name,state) --- Toggles if the frame is currently open or not, will open if closed and close if open
|
||||||
|
|
||||||
CenterFrames.new_frame(permision_name) --- Sets the frame to be the current active gui when opened and closes all other frames
|
CenterFrames.new_frame(permission_name) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||||
CenterFrames._prototype:on_draw(player,frame) --- Use to draw your elements onto the new frame
|
CenterFrames._prototype:on_draw(player,frame) --- Use to draw your elements onto the new frame
|
||||||
CenterFrames._prototype:set_auto_focus(state) --- Sets the frame to be the current active gui when opened and closes all other frames
|
CenterFrames._prototype:set_auto_focus(state) --- Sets the frame to be the current active gui when opened and closes all other frames
|
||||||
CenterFrames._prototype:draw_frame(player) --- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
|
CenterFrames._prototype:draw_frame(player) --- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
|
||||||
@@ -87,10 +87,10 @@ function CenterFrames.toggle_frame(player,name,state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a new center frame define
|
--- Creates a new center frame define
|
||||||
-- @tparam string permision_name the name that can be used with the permision system
|
-- @tparam string permission_name the name that can be used with the permission system
|
||||||
-- @treturn table the new center frame define
|
-- @treturn table the new center frame define
|
||||||
function CenterFrames.new_frame(permision_name)
|
function CenterFrames.new_frame(permission_name)
|
||||||
local self = Toolbar.new_button(permision_name)
|
local self = Toolbar.new_button(permission_name)
|
||||||
|
|
||||||
self:on_click(function(player,element)
|
self:on_click(function(player,element)
|
||||||
self:toggle_frame(player)
|
self:toggle_frame(player)
|
||||||
|
|||||||
@@ -29,16 +29,16 @@
|
|||||||
LeftFrames.get_flow(player) --- Gets the left frame flow for a player
|
LeftFrames.get_flow(player) --- Gets the left frame flow for a player
|
||||||
LeftFrames.get_frame(name,player) --- Gets one frame from the left flow by its name
|
LeftFrames.get_frame(name,player) --- Gets one frame from the left flow by its name
|
||||||
LeftFrames.get_open(player) --- Gets all open frames for a player, if non are open it will remove the close all button
|
LeftFrames.get_open(player) --- Gets all open frames for a player, if non are open it will remove the close all button
|
||||||
LeftFrames.toggle_frame(name,player,state) --- Toggles the visiblty of a left frame, or sets its visiblty state
|
LeftFrames.toggle_frame(name,player,state) --- Toggles the visibility of a left frame, or sets its visibility state
|
||||||
|
|
||||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
LeftFrames.new_frame(permission_name) --- Creates a new left frame define
|
||||||
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
||||||
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
||||||
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
||||||
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
||||||
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
|
LeftFrames._prototype:toggle(player) --- Toggles the visibility of the left frame
|
||||||
|
|
||||||
LeftFrames._prototype:update(player) --- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
|
LeftFrames._prototype:update(player) --- Updates the contents of the left frame, first tries update callback, other wise will clear and redraw
|
||||||
LeftFrames._prototype:update_all(update_offline) --- Updates the frame for all players, see update
|
LeftFrames._prototype:update_all(update_offline) --- Updates the frame for all players, see update
|
||||||
LeftFrames._prototype:redraw(player) --- Redraws the frame by calling on_draw, will always clear the frame
|
LeftFrames._prototype:redraw(player) --- Redraws the frame by calling on_draw, will always clear the frame
|
||||||
LeftFrames._prototype:redraw_all(update_offline) --- Redraws the frame for all players, see redraw
|
LeftFrames._prototype:redraw_all(update_offline) --- Redraws the frame for all players, see redraw
|
||||||
@@ -106,11 +106,11 @@ function LeftFrames.get_open(player)
|
|||||||
return open
|
return open
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Toggles the visiblty of a left frame, or sets its visiblty state
|
--- Toggles the visibility of a left frame, or sets its visibility state
|
||||||
-- @tparam string name the name of the gui frame to toggle
|
-- @tparam string name the name of the gui frame to toggle
|
||||||
-- @tparam LuaPlayer player the player to get the frame of
|
-- @tparam LuaPlayer player the player to get the frame of
|
||||||
-- @tparam[opt] boolean state when given will be the state that the visiblty is set to
|
-- @tparam[opt] boolean state when given will be the state that the visibility is set to
|
||||||
-- @treturn boolean the new state of the visiblity
|
-- @treturn boolean the new state of the visibility
|
||||||
function LeftFrames.toggle_frame(name,player,state)
|
function LeftFrames.toggle_frame(name,player,state)
|
||||||
local define = LeftFrames.frames[name]
|
local define = LeftFrames.frames[name]
|
||||||
if not define then
|
if not define then
|
||||||
@@ -130,10 +130,10 @@ function LeftFrames.toggle_frame(name,player,state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a new left frame define
|
--- Creates a new left frame define
|
||||||
-- @tparam string permision_name the name that can be used with the permision system
|
-- @tparam string permission_name the name that can be used with the permission system
|
||||||
-- @treturn table the new left frame define
|
-- @treturn table the new left frame define
|
||||||
function LeftFrames.new_frame(permision_name)
|
function LeftFrames.new_frame(permission_name)
|
||||||
local self = Toolbar.new_button(permision_name)
|
local self = Toolbar.new_button(permission_name)
|
||||||
|
|
||||||
local mt = getmetatable(self)
|
local mt = getmetatable(self)
|
||||||
mt.__index = LeftFrames._prototype
|
mt.__index = LeftFrames._prototype
|
||||||
@@ -151,7 +151,7 @@ function LeftFrames.new_frame(permision_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
--- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
||||||
-- @tparam[opt=true] ?boolean|function state the default state of the visiblty, can be a function
|
-- @tparam[opt=true] ?boolean|function state the default state of the visibility, can be a function
|
||||||
-- state param - player LuaPlayer - the player that has joined the game
|
-- state param - player LuaPlayer - the player that has joined the game
|
||||||
-- state param - define_name string - the define name for the frame
|
-- state param - define_name string - the define name for the frame
|
||||||
-- state return - boolean - false will hide the frame
|
-- state return - boolean - false will hide the frame
|
||||||
@@ -167,7 +167,7 @@ function LeftFrames._prototype:set_open_by_default(state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the direction of the frame, either vertical or horizontal
|
--- Sets the direction of the frame, either vertical or horizontal
|
||||||
-- @tparam string direction the direction to have the elements be added to thef frame
|
-- @tparam string direction the direction to have the elements be added to the frame
|
||||||
function LeftFrames._prototype:set_direction(direction)
|
function LeftFrames._prototype:set_direction(direction)
|
||||||
self.direction = direction
|
self.direction = direction
|
||||||
return self
|
return self
|
||||||
@@ -221,9 +221,9 @@ function LeftFrames._prototype:is_open(player)
|
|||||||
return frame and frame.visible or false
|
return frame and frame.visible or false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Toggles the visiblty of the left frame
|
--- Toggles the visibility of the left frame
|
||||||
-- @tparam LuaPlayer player the player to toggle the frame of
|
-- @tparam LuaPlayer player the player to toggle the frame of
|
||||||
-- @treturn boolean the new state of the visiblity
|
-- @treturn boolean the new state of the visibility
|
||||||
function LeftFrames._prototype:toggle(player)
|
function LeftFrames._prototype:toggle(player)
|
||||||
local frame = self:get_frame(player)
|
local frame = self:get_frame(player)
|
||||||
Gui.toggle_visible(frame)
|
Gui.toggle_visible(frame)
|
||||||
@@ -231,7 +231,7 @@ function LeftFrames._prototype:toggle(player)
|
|||||||
return frame.visible
|
return frame.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
|
--- Updates the contents of the left frame, first tries update callback, other wise will clear and redraw
|
||||||
-- @tparam LuaPlayer player the player to update the frame of
|
-- @tparam LuaPlayer player the player to update the frame of
|
||||||
function LeftFrames._prototype:update(player)
|
function LeftFrames._prototype:update(player)
|
||||||
local frame = self:get_frame(player)
|
local frame = self:get_frame(player)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
PopupFrames.get_flow(player) --- Gets the left flow that contains the popup frames
|
PopupFrames.get_flow(player) --- Gets the left flow that contains the popup frames
|
||||||
PopupFrames.open(define_name,player,open_time,...) --- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
|
PopupFrames.open(define_name,player,open_time,...) --- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
|
||||||
|
|
||||||
PopupFrames.close_progress --- Progress bar which when depleaded will close the popup frame
|
PopupFrames.close_progress --- Progress bar which when depleted will close the popup frame
|
||||||
PopupFrames.close_button --- A button which can be used to close the gui before the timer runs out
|
PopupFrames.close_button --- A button which can be used to close the gui before the timer runs out
|
||||||
|
|
||||||
PopupFrames.new_popup(name) --- Creates a new popup frame define
|
PopupFrames.new_popup(name) --- Creates a new popup frame define
|
||||||
@@ -34,17 +34,17 @@ Global.register(PopupFrames.paused_popups,function(tbl)
|
|||||||
PopupFrames.paused_popups = tbl
|
PopupFrames.paused_popups = tbl
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Sets the state of the element in the pasued list, nil or true
|
--- Sets the state of the element in the paused list, nil or true
|
||||||
-- @tparam LuaGuiElement element the element to set the state of
|
-- @tparam LuaGuiElement element the element to set the state of
|
||||||
-- @tparam[opt] boolean state the state to set it to, true will pause the the progress bar
|
-- @tparam[opt] boolean state the state to set it to, true will pause the the progress bar
|
||||||
local function set_pasued_state(element,state)
|
local function set_paused_state(element,state)
|
||||||
local name = element.player_index..':'..element.index
|
local name = element.player_index..':'..element.index
|
||||||
PopupFrames.paused_popups[name] = state
|
PopupFrames.paused_popups[name] = state
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Gets the state of the element in the pasued list, nil or true
|
--- Gets the state of the element in the paused list, nil or true
|
||||||
-- @tparam LuaGuiElement element the element to get the state of
|
-- @tparam LuaGuiElement element the element to get the state of
|
||||||
local function get_pasued_state(element)
|
local function get_paused_state(element)
|
||||||
local name = element.player_index..':'..element.index
|
local name = element.player_index..':'..element.index
|
||||||
return PopupFrames.paused_popups[name]
|
return PopupFrames.paused_popups[name]
|
||||||
end
|
end
|
||||||
@@ -75,11 +75,11 @@ end
|
|||||||
local function close_popup(element)
|
local function close_popup(element)
|
||||||
local frame = element.parent.parent.parent
|
local frame = element.parent.parent.parent
|
||||||
if not frame or not frame.valid then return end
|
if not frame or not frame.valid then return end
|
||||||
set_pasued_state(element.parent[PopupFrames.close_progress:uid()])
|
set_paused_state(element.parent[PopupFrames.close_progress:uid()])
|
||||||
frame.destroy()
|
frame.destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Progress bar which when depleaded will close the popup frame
|
--- Progress bar which when depleted will close the popup frame
|
||||||
PopupFrames.close_progress =
|
PopupFrames.close_progress =
|
||||||
ProgressBar.new_progressbar()
|
ProgressBar.new_progressbar()
|
||||||
:use_count_down()
|
:use_count_down()
|
||||||
@@ -100,20 +100,20 @@ end)
|
|||||||
--- When the progress bar is clicked it will pause its progress, or resume if previously paused
|
--- When the progress bar is clicked it will pause its progress, or resume if previously paused
|
||||||
Gui.on_click(PopupFrames.close_progress:uid(),function(event)
|
Gui.on_click(PopupFrames.close_progress:uid(),function(event)
|
||||||
local element = event.element
|
local element = event.element
|
||||||
if get_pasued_state(element) then
|
if get_paused_state(element) then
|
||||||
set_pasued_state(element)
|
set_paused_state(element)
|
||||||
else
|
else
|
||||||
set_pasued_state(element,true)
|
set_paused_state(element,true)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- When the parent flow of the progress bar is clicked it will pause its progress, or resume if previously paused
|
--- When the parent flow of the progress bar is clicked it will pause its progress, or resume if previously paused
|
||||||
Gui.on_click(PopupFrames.close_frame_name,function(event)
|
Gui.on_click(PopupFrames.close_frame_name,function(event)
|
||||||
local element = event.element[PopupFrames.close_progress:uid()]
|
local element = event.element[PopupFrames.close_progress:uid()]
|
||||||
if get_pasued_state(element) then
|
if get_paused_state(element) then
|
||||||
set_pasued_state(element)
|
set_paused_state(element)
|
||||||
else
|
else
|
||||||
set_pasued_state(element,true)
|
set_paused_state(element,true)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -214,9 +214,9 @@ Event.add(defines.events.on_player_created,function(event)
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Every tick any, not pasued, progress bars will go down by one tick
|
--- Every tick any, not paused, progress bars will go down by one tick
|
||||||
Event.add(defines.events.on_tick,PopupFrames.close_progress:event_countdown(function(element)
|
Event.add(defines.events.on_tick,PopupFrames.close_progress:event_countdown(function(element)
|
||||||
return not get_pasued_state(element)
|
return not get_paused_state(element)
|
||||||
end))
|
end))
|
||||||
|
|
||||||
return PopupFrames
|
return PopupFrames
|
||||||
@@ -22,17 +22,17 @@ local Game = require 'utils.game'
|
|||||||
local mod_gui = require 'mod-gui'
|
local mod_gui = require 'mod-gui'
|
||||||
|
|
||||||
local Toolbar = {
|
local Toolbar = {
|
||||||
permisison_names = {},
|
permission_names = {},
|
||||||
buttons = {}
|
buttons = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Toolbar.allowed(player,define_name)
|
function Toolbar.allowed(player,define_name)
|
||||||
local permisison_name = Toolbar.permisison_names[define_name] or define_name
|
local permission_name = Toolbar.permission_names[define_name] or define_name
|
||||||
return Roles.player_allowed(player,permisison_name)
|
return Roles.player_allowed(player,permission_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Toolbar.permission_alias(define_name,permisison_name)
|
function Toolbar.permission_alias(define_name,permission_name)
|
||||||
Toolbar.permisison_names[define_name] = permisison_name
|
Toolbar.permission_names[define_name] = permission_name
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a new button to the toolbar
|
--- Adds a new button to the toolbar
|
||||||
|
|||||||
@@ -125,7 +125,7 @@
|
|||||||
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
||||||
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
|
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
|
||||||
Gui.create_alignment(element,flow_name) --- Allows the creation of a right align flow to place elements into
|
Gui.create_alignment(element,flow_name) --- Allows the creation of a right align flow to place elements into
|
||||||
Gui.destory_if_valid(element) --- Destroies an element but tests for it being present and valid first
|
Gui.destroy_if_valid(element) --- Destroies an element but tests for it being present and valid first
|
||||||
Gui.create_scroll_table(element,table_size,maximal_height,name) --- Creates a scroll area with a table inside, table can be any size
|
Gui.create_scroll_table(element,table_size,maximal_height,name) --- Creates a scroll area with a table inside, table can be any size
|
||||||
Gui.create_header(element,caption,tooltip,right_align,name) --- Creates a header section with a label and button area
|
Gui.create_header(element,caption,tooltip,right_align,name) --- Creates a header section with a label and button area
|
||||||
]]
|
]]
|
||||||
@@ -288,7 +288,7 @@ end
|
|||||||
--- Destroies an element but tests for it being present and valid first
|
--- Destroies an element but tests for it being present and valid first
|
||||||
-- @tparam LuaGuiElement element the element to be destroied
|
-- @tparam LuaGuiElement element the element to be destroied
|
||||||
-- @treturn boolean true if it was destoried
|
-- @treturn boolean true if it was destoried
|
||||||
function Gui.destory_if_valid(element)
|
function Gui.destroy_if_valid(element)
|
||||||
if element and element.valid then
|
if element and element.valid then
|
||||||
element.destroy()
|
element.destroy()
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Button._prototype:on_left_click(player,element) --- Registers a handler for when the button is clicked with the left mouse button
|
Button._prototype:on_left_click(player,element) --- Registers a handler for when the button is clicked with the left mouse button
|
||||||
Button._prototype:on_right_click(player,element) --- Registers a handler for when the button is clicked with the right mouse button
|
Button._prototype:on_right_click(player,element) --- Registers a handler for when the button is clicked with the right mouse button
|
||||||
|
|
||||||
Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite) --- Adds sprites to a button making it a spirte button
|
Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite) --- Adds sprites to a button making it a sprite button
|
||||||
Button._prototype:set_click_filter(filter,...) --- Adds a click / mouse button filter to the button
|
Button._prototype:set_click_filter(filter,...) --- Adds a click / mouse button filter to the button
|
||||||
Button._prototype:set_key_filter(filter,...) --- Adds a control key filter to the button
|
Button._prototype:set_key_filter(filter,...) --- Adds a control key filter to the button
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ function Button.new_button(name)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds sprites to a button making it a spirte button
|
--- Adds sprites to a button making it a sprite button
|
||||||
-- @tparam SpritePath sprite the sprite path for the default sprite for the button
|
-- @tparam SpritePath sprite the sprite path for the default sprite for the button
|
||||||
-- @tparam[opt] SpritePath hovered_sprite the sprite path for the sprite when the player hovers over the button
|
-- @tparam[opt] SpritePath hovered_sprite the sprite path for the sprite when the player hovers over the button
|
||||||
-- @tparam[opt] SpritePath clicked_sprite the sprite path for the sprite when the player clicks the button
|
-- @tparam[opt] SpritePath clicked_sprite the sprite path for the sprite when the player clicks the button
|
||||||
@@ -103,7 +103,7 @@ end
|
|||||||
|
|
||||||
--- Adds a control key filter to the button
|
--- Adds a control key filter to the button
|
||||||
-- @tparam table filter ?string|table either a of control keys or the first control keys to filter, with a table true means allowed
|
-- @tparam table filter ?string|table either a of control keys or the first control keys to filter, with a table true means allowed
|
||||||
-- @tparam[opt] table ... when filter is not a you can add the control keyss one after each other
|
-- @tparam[opt] table ... when filter is not a you can add the control keys one after each other
|
||||||
-- @treturn self returns the button define to allow chaining
|
-- @treturn self returns the button define to allow chaining
|
||||||
function Button._prototype:set_key_filter(filter,...)
|
function Button._prototype:set_key_filter(filter,...)
|
||||||
if type(filter) == 'string' then
|
if type(filter) == 'string' then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Gui class define for checkboxs and radiobuttons
|
--- Gui class define for checkbox and radiobuttons
|
||||||
--[[
|
--[[
|
||||||
>>>> Using an option set
|
>>>> Using an option set
|
||||||
An option set is a set of radio buttons where only one of them can be active at a time, this means that when one
|
An option set is a set of radio buttons where only one of them can be active at a time, this means that when one
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
Note that these radiobuttons can still have on_element_update events but this may result in a double trigger of events as
|
Note that these radiobuttons can still have on_element_update events but this may result in a double trigger of events as
|
||||||
the option set update is always triggered; also add_store cant be used as the option set acts as the store however get
|
the option set update is always triggered; also add_store cant be used as the option set acts as the store however get
|
||||||
and set store will still work but will effect the option set rather than the indivual radiobuttons.
|
and set store will still work but will effect the option set rather than the individual radiobuttons.
|
||||||
|
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
Checkbox.new_checkbox(name) --- Creates a new checkbox element define
|
Checkbox.new_checkbox(name) --- Creates a new checkbox element define
|
||||||
@@ -38,10 +38,10 @@
|
|||||||
Checkbox._prototype_radiobutton:on_store_update(callback) --- Registers a handler for when the stored value updates
|
Checkbox._prototype_radiobutton:on_store_update(callback) --- Registers a handler for when the stored value updates
|
||||||
Checkbox._prototype_radiobutton:add_as_option(option_set,option_name) --- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
Checkbox._prototype_radiobutton:add_as_option(option_set,option_name) --- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
||||||
|
|
||||||
Checkbox.new_option_set(name,callback,categorize) --- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
|
Checkbox.new_option_set(name,callback,categorize) --- Registers a new option set that can be linked to radiobutton (only one can be true at a time)
|
||||||
Checkbox.draw_option_set(name,element) --- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
|
Checkbox.draw_option_set(name,element) --- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
|
||||||
|
|
||||||
Checkbox.reset_radiobutton(element,exclude,recursive) --- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
|
Checkbox.reset_radiobutton(element,exclude,recursive) --- Sets all radiobutton in a element to false (unless excluded) and can act recursively
|
||||||
|
|
||||||
Other functions present from expcore.gui.core
|
Other functions present from expcore.gui.core
|
||||||
]]
|
]]
|
||||||
@@ -131,7 +131,7 @@ end
|
|||||||
|
|
||||||
--- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
--- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
|
||||||
-- @tparam string option_set the name of the option set to add this element to
|
-- @tparam string option_set the name of the option set to add this element to
|
||||||
-- @tparam string option_name the name of this option that will be used to idenitife it
|
-- @tparam string option_name the name of this option that will be used to identify it
|
||||||
-- @treturn self the define to allow chaining
|
-- @treturn self the define to allow chaining
|
||||||
function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
|
function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
|
||||||
self.option_set = option_set
|
self.option_set = option_set
|
||||||
@@ -166,9 +166,9 @@ function Checkbox._prototype_radiobutton:set_store(category,value,internal)
|
|||||||
return Store.set(location,category,value)
|
return Store.set(location,category,value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
|
--- Registers a new option set that can be linked to radiobuttons (only one can be true at a time)
|
||||||
-- @tparam string name the name of the option set, must be unique
|
-- @tparam string name the name of the option set, must be unique
|
||||||
-- @tparam function callback the update callback when the value of the option set chagnes
|
-- @tparam function callback the update callback when the value of the option set changes
|
||||||
-- callback param - value string - the new selected option for this option set
|
-- callback param - value string - the new selected option for this option set
|
||||||
-- callback param - category string - the category that updated if categorize was used
|
-- callback param - category string - the category that updated if categorize was used
|
||||||
-- @tparam function categorize the function used to convert an element into a string
|
-- @tparam function categorize the function used to convert an element into a string
|
||||||
@@ -208,7 +208,7 @@ function Checkbox.draw_option_set(name,element)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
|
--- Sets all radiobutton in a element to false (unless excluded) and can act recursively
|
||||||
-- @tparam LuaGuiElement element the root gui element to start setting radio buttons from
|
-- @tparam LuaGuiElement element the root gui element to start setting radio buttons from
|
||||||
-- @tparam[opt] table exclude ?string|table the name of the radiobutton to exclude or a of radiobuttons where true will set the state true
|
-- @tparam[opt] table exclude ?string|table the name of the radiobutton to exclude or a of radiobuttons where true will set the state true
|
||||||
-- @tparam[opt=false] ?number|boolean recursive if true will recur as much as possible, if a will recur that number of times
|
-- @tparam[opt=false] ?number|boolean recursive if true will recur as much as possible, if a will recur that number of times
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Gui class define for dropdowns and list boxs
|
--- Gui class define for dropdowns and list box
|
||||||
--[[
|
--[[
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
Dropdown.new_dropdown(name) --- Creates a new dropdown element define
|
Dropdown.new_dropdown(name) --- Creates a new dropdown element define
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
--- Gui element define for progess bars
|
--- Gui element define for progress bars
|
||||||
--[[
|
--[[
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
ProgressBar.set_maximum(element,amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
ProgressBar.set_maximum(element,amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
||||||
ProgressBar.increment(element,amount) --- Increases the value of the progressbar, if a define is given all of its instances are incremented
|
ProgressBar.increment(element,amount) --- Increases the value of the progressbar, if a define is given all of its instances have incremented
|
||||||
ProgressBar.decrement(element,amount) --- Decreases the value of the progressbar, if a define is given all of its instances are decresed
|
ProgressBar.decrement(element,amount) --- Decreases the value of the progressbar, if a define is given all of its instances have decremented
|
||||||
|
|
||||||
ProgressBar.new_progressbar(name) --- Creates a new progressbar element define
|
ProgressBar.new_progressbar(name) --- Creates a new progressbar element define
|
||||||
ProgressBar._prototype:set_maximum(amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
ProgressBar._prototype:set_maximum(amount,count_down) --- Sets the maximum value that represents the end value of the progress bar
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
ProgressBar._prototype:add_element(element,maximum) --- Adds an element into the list of instances that will are waiting to complete, does not work with store
|
ProgressBar._prototype:add_element(element,maximum) --- Adds an element into the list of instances that will are waiting to complete, does not work with store
|
||||||
ProgressBar._prototype:reset_element(element) --- Resets an element, or its store, to be back at the start, either 1 or 0
|
ProgressBar._prototype:reset_element(element) --- Resets an element, or its store, to be back at the start, either 1 or 0
|
||||||
|
|
||||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a progress bar element compeltes (hits 0 or 1)
|
ProgressBar._prototype:on_complete(callback) --- Triggers when a progress bar element completes (hits 0 or 1)
|
||||||
ProgressBar._prototype:on_complete(callback) --- Triggers when a store value completes (hits 0 or 1)
|
ProgressBar._prototype:on_complete(callback) --- Triggers when a store value completes (hits 0 or 1)
|
||||||
ProgressBar._prototype:event_counter(filter) --- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
|
ProgressBar._prototype:event_counter(filter) --- Event handler factory that counts up by 1 every time the event triggers, can filter which elements have incremented
|
||||||
ProgressBar._prototype:event_countdown(filter) --- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
|
ProgressBar._prototype:event_countdown(filter) --- Event handler factory that counts down by 1 every time the event triggers, can filter which elements have decremented
|
||||||
]]
|
]]
|
||||||
local Gui = require 'expcore.gui.core'
|
local Gui = require 'expcore.gui.core'
|
||||||
local Prototype = require 'expcore.gui.prototype'
|
local Prototype = require 'expcore.gui.prototype'
|
||||||
@@ -52,7 +52,7 @@ end
|
|||||||
|
|
||||||
local ProgressBar = {
|
local ProgressBar = {
|
||||||
unregistered={}, -- elements with no callbacks
|
unregistered={}, -- elements with no callbacks
|
||||||
independent={}, -- elements with a link to a deinfe
|
independent={}, -- elements with a link to a define
|
||||||
_prototype=Prototype.extend{
|
_prototype=Prototype.extend{
|
||||||
on_complete = Prototype.event,
|
on_complete = Prototype.event,
|
||||||
on_store_complete = Prototype.event,
|
on_store_complete = Prototype.event,
|
||||||
@@ -84,7 +84,7 @@ end
|
|||||||
|
|
||||||
--- Gets the element data, used when there is no define
|
--- Gets the element data, used when there is no define
|
||||||
-- @tparam LuaGuiElement element the element to get the data of
|
-- @tparam LuaGuiElement element the element to get the data of
|
||||||
-- @treturn table the element data simialr to define
|
-- @treturn table the element data similar to define
|
||||||
local function get_element(element)
|
local function get_element(element)
|
||||||
if not element.valid then return end
|
if not element.valid then return end
|
||||||
local name = element.player_index..':'..element.index
|
local name = element.player_index..':'..element.index
|
||||||
@@ -102,7 +102,7 @@ function ProgressBar.set_maximum(element,amount)
|
|||||||
|
|
||||||
local define = get_define(element)
|
local define = get_define(element)
|
||||||
if define then
|
if define then
|
||||||
define:set_deafult_maximum(amount)
|
define:set_default_maximum(amount)
|
||||||
|
|
||||||
else
|
else
|
||||||
local element_data = get_element(element)
|
local element_data = get_element(element)
|
||||||
@@ -122,7 +122,7 @@ function ProgressBar.set_maximum(element,amount)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Increases the value of the progressbar, if a define is given all of its instances are incremented
|
--- Increases the value of the progressbar, if a define is given all of its instances have incremented
|
||||||
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
|
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
|
||||||
-- @tparam[opt=1] number amount the amount to increase the progressbar by
|
-- @tparam[opt=1] number amount the amount to increase the progressbar by
|
||||||
function ProgressBar.increment(element,amount)
|
function ProgressBar.increment(element,amount)
|
||||||
@@ -149,7 +149,7 @@ function ProgressBar.increment(element,amount)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Decreases the value of the progressbar, if a define is given all of its instances are decresed
|
--- Decreases the value of the progressbar, if a define is given all of its instances have decremented
|
||||||
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
|
-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
|
||||||
-- @tparam[opt=1] number amount the amount to decrease the progressbar by
|
-- @tparam[opt=1] number amount the amount to decrease the progressbar by
|
||||||
function ProgressBar.decrement(element,amount)
|
function ProgressBar.decrement(element,amount)
|
||||||
@@ -178,7 +178,7 @@ end
|
|||||||
|
|
||||||
--- Creates a new progressbar element define
|
--- Creates a new progressbar element define
|
||||||
-- @tparam[opt] string name the optional debug name that can be added
|
-- @tparam[opt] string name the optional debug name that can be added
|
||||||
-- @treturn table the new progressbar elemente define
|
-- @treturn table the new progressbar element define
|
||||||
function ProgressBar.new_progressbar(name)
|
function ProgressBar.new_progressbar(name)
|
||||||
|
|
||||||
local self = Gui.new_define(ProgressBar._prototype,name)
|
local self = Gui.new_define(ProgressBar._prototype,name)
|
||||||
@@ -349,8 +349,8 @@ function ProgressBar._prototype:reset_element(element)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
|
--- Event handler factory that counts up by 1 every time the event triggers, can filter which elements have incremented
|
||||||
-- @tparam[opt] function filter when given will use filtered incerement
|
-- @tparam[opt] function filter when given will use filtered increment
|
||||||
-- @treturn function the event handler
|
-- @treturn function the event handler
|
||||||
function ProgressBar._prototype:event_counter(filter)
|
function ProgressBar._prototype:event_counter(filter)
|
||||||
if type(filter) == 'function' then
|
if type(filter) == 'function' then
|
||||||
@@ -364,8 +364,8 @@ function ProgressBar._prototype:event_counter(filter)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
|
--- Event handler factory that counts down by 1 every time the event triggers, can filter which elements have decremented
|
||||||
-- @tparam[opt] function filter when given will use filtered decerement
|
-- @tparam[opt] function filter when given will use filtered decrement
|
||||||
-- @treturn function the event handler
|
-- @treturn function the event handler
|
||||||
function ProgressBar._prototype:event_countdown(filter)
|
function ProgressBar._prototype:event_countdown(filter)
|
||||||
if type(filter) == 'function' then
|
if type(filter) == 'function' then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Gui class define for silders
|
--- Gui class define for sliders
|
||||||
--[[
|
--[[
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
Slider.new_slider(name) --- Creates a new slider element define
|
Slider.new_slider(name) --- Creates a new slider element define
|
||||||
@@ -128,7 +128,7 @@ function Slider._prototype:set_range(min,max)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Draws a new label and links its value to the value of this slider, if no store then it will only show one value per player
|
--- Draws a new label and links its value to the value of this slider, if no store then it will only show one value per player
|
||||||
-- @tparam LuaGuiElement element the parent element that the lable will be drawn to
|
-- @tparam LuaGuiElement element the parent element that the label will be drawn to
|
||||||
-- @treturn LuaGuiElement the new label element so that styles can be applied
|
-- @treturn LuaGuiElement the new label element so that styles can be applied
|
||||||
function Slider._prototype:draw_label(element)
|
function Slider._prototype:draw_label(element)
|
||||||
local name = self.name..'-label'
|
local name = self.name..'-label'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
--- Gui class define for text fields and text boxs
|
--- Gui class define for text fields and text boxes
|
||||||
--[[
|
--[[
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
Text.new_text_field(name) --- Creates a new text field element define
|
Text.new_text_field(name) --- Creates a new text field element define
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
--- This file is a breakout from core which forcues on instance management of defines
|
--- This file is a breakout from core which forcues on instance management of defines
|
||||||
--[[
|
--[[
|
||||||
>>>> Using registered instance groups
|
>>>> Using registered instance groups
|
||||||
The main use of this module is to register a group of elements refered here as "instances of an element define" in which
|
The main use of this module is to register a group of elements referred here as "instances of an element define" in which
|
||||||
is meant that you define the name of a group of drawn elements that are really just multiple versions of a single element.
|
is meant that you define the name of a group of drawn elements that are really just multiple versions of a single element.
|
||||||
For example this might be that you have one label in multiple places (either for one player or many) and you want to update
|
For example this might be that you have one label in multiple places (either for one player or many) and you want to update
|
||||||
the caption of all of them at once; this is where this module comes it.
|
the caption of all of them at once; this is where this module comes it.
|
||||||
|
|
||||||
First you must register the way that the intances are stored and under what name, using Instances.register you will give the
|
First you must register the way that the instances are stored and under what name, using Instances.register you will give the
|
||||||
name of the collective group of instances followed by an optional categorise function which allows varients to be stored under one
|
name of the collective group of instances followed by an optional categorise function which allows variants to be stored under one
|
||||||
name (like one for each force or player)
|
name (like one for each force or player)
|
||||||
|
|
||||||
-- categorise works in the same way as store categorise
|
-- categorise works in the same way as store categorise
|
||||||
-- so the function will worl here but no value is stored only gui elements
|
-- so the function will world here but no value is stored only gui elements
|
||||||
Instances.register('score',Gui.categorize_by_force)
|
Instances.register('score',Gui.categorize_by_force)
|
||||||
|
|
||||||
Then when you draw the new element to a gui you will want to add the element to the group:
|
Then when you draw the new element to a gui you will want to add the element to the group:
|
||||||
@@ -26,13 +26,13 @@
|
|||||||
element.caption = 0
|
element.caption = 0
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Note that if you dont give a categorise function then you dont need to give a category when getting the elements.
|
Note that if you don't give a categorise function then you don't need to give a category when getting the elements.
|
||||||
|
|
||||||
>>>> Using unregistered instance groups
|
>>>> Using unregistered instance groups
|
||||||
When using a registered group and the functions that go with them it is much simpler to use and more importantly includes error checking
|
When using a registered group and the functions that go with them it is much simpler to use and more importantly includes error checking
|
||||||
for valid instance group names; the down side is that the group must be registered which can only be done during startup and not during runtime.
|
for valid instance group names; the down side is that the group must be registered which can only be done during start-up and not during runtime.
|
||||||
To counter this there are two functions simlair to those above in order to add and get instances but may lead to errors not being noticed due to
|
To counter this there are two functions similar to those above in order to add and get instances but may lead to errors not being noticed due to
|
||||||
the error interal error checking being skiped to allow it to work.
|
the error internal error checking being skipped to allow it to work.
|
||||||
|
|
||||||
The main difference between the two groups of functions is that the category must always be present even if is nil; example below shows how a
|
The main difference between the two groups of functions is that the category must always be present even if is nil; example below shows how a
|
||||||
instance group would work when registered vs unregistered:
|
instance group would work when registered vs unregistered:
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
element.caption = '0'
|
element.caption = '0'
|
||||||
end) -- gets all instances from the player force and sets the caption to 0
|
end) -- gets all instances from the player force and sets the caption to 0
|
||||||
|
|
||||||
-- Registered without category; note that category can just be igroned
|
-- Registered without category; note that category can just be ignored
|
||||||
Instances.register('score') -- all instances will be under one group with no categories
|
Instances.register('score') -- all instances will be under one group with no categories
|
||||||
Instances.add_element('score',new_element) -- adds the new element to the instance list
|
Instances.add_element('score',new_element) -- adds the new element to the instance list
|
||||||
Instances.apply_to_elements('score',function(element)
|
Instances.apply_to_elements('score',function(element)
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
end) -- gets all instances and sets the element caption to 0
|
end) -- gets all instances and sets the element caption to 0
|
||||||
|
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
Instances.has_categories(name) --- Returns if a instnace group has a categorise function; must be registerd
|
Instances.has_categories(name) --- Returns if a instance group has a categorise function; must be registered
|
||||||
Instances.is_registered(name) --- Returns if the given name is a registered instance group
|
Instances.is_registered(name) --- Returns if the given name is a registered instance group
|
||||||
Instances.register(name,categorise) --- Registers the name of an instance group to allow for storing element instances
|
Instances.register(name,categorise) --- Registers the name of an instance group to allow for storing element instances
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ Global.register(Instances.data,function(tbl)
|
|||||||
Instances.data = tbl
|
Instances.data = tbl
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Returns if a instnace group has a categorise function; must be registerd
|
--- Returns if a instance group has a categorise function; must be registered
|
||||||
-- @tparam string name the name of the instance group
|
-- @tparam string name the name of the instance group
|
||||||
-- @treturn boolean true if there is a categorise function
|
-- @treturn boolean true if there is a categorise function
|
||||||
function Instances.has_categories(name)
|
function Instances.has_categories(name)
|
||||||
@@ -104,7 +104,7 @@ end
|
|||||||
-- @tparam[opt] function categorise function used to turn the element into a string
|
-- @tparam[opt] function categorise function used to turn the element into a string
|
||||||
-- categorise param - element LuaGuiElement - the gui element to be turned into a string
|
-- categorise param - element LuaGuiElement - the gui element to be turned into a string
|
||||||
-- categorise return - string - the category that the element will be added to like the player's name or force's name
|
-- categorise return - string - the category that the element will be added to like the player's name or force's name
|
||||||
-- @treturn string the name that was added so it can be used as a varible
|
-- @treturn string the name that was added so it can be used as a variable
|
||||||
function Instances.register(name,categorise)
|
function Instances.register(name,categorise)
|
||||||
if _LIFECYCLE ~= _STAGE.control then
|
if _LIFECYCLE ~= _STAGE.control then
|
||||||
return error('Can only be called during the control stage', 2)
|
return error('Can only be called during the control stage', 2)
|
||||||
@@ -127,7 +127,7 @@ end
|
|||||||
-- @tparam LuaGuiElement element the element to add the the instance group
|
-- @tparam LuaGuiElement element the element to add the the instance group
|
||||||
function Instances.add_element(name,element)
|
function Instances.add_element(name,element)
|
||||||
if not Instances.categorise[name] then
|
if not Instances.categorise[name] then
|
||||||
return error('Inavlid name for instance group: '..name,2)
|
return error('Invalid name for instance group: '..name,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Instances.has_categories(name) then
|
if Instances.has_categories(name) then
|
||||||
@@ -145,7 +145,7 @@ end
|
|||||||
-- @treturn table the table of element instances of which some may be invalid
|
-- @treturn table the table of element instances of which some may be invalid
|
||||||
function Instances.get_elements_raw(name,category)
|
function Instances.get_elements_raw(name,category)
|
||||||
if not Instances.categorise[name] then
|
if not Instances.categorise[name] then
|
||||||
return error('Inavlid name for instance group: '..name,2)
|
return error('Invalid name for instance group: '..name,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Instances.has_categories(name) then
|
if Instances.has_categories(name) then
|
||||||
@@ -158,12 +158,12 @@ end
|
|||||||
--- Gets all valid element instances and has the option of running a callback on those that are valid
|
--- Gets all valid element instances and has the option of running a callback on those that are valid
|
||||||
-- @tparam string name the name of the instance group to get the instances of
|
-- @tparam string name the name of the instance group to get the instances of
|
||||||
-- @tparam[opt] string category the category to get the instances of, not needed when no categorise function
|
-- @tparam[opt] string category the category to get the instances of, not needed when no categorise function
|
||||||
-- @tparan[opt] callback function when given the callback will be ran on all valid elements
|
-- @tparam[opt] callback function when given the callback will be ran on all valid elements
|
||||||
-- callback param - element LuaGuiElement - the current valid element
|
-- callback param - element LuaGuiElement - the current valid element
|
||||||
-- @treturn table the table of element instances with all invalid ones removed
|
-- @treturn table the table of element instances with all invalid ones removed
|
||||||
function Instances.get_valid_elements(name,category,callback)
|
function Instances.get_valid_elements(name,category,callback)
|
||||||
if not Instances.categorise[name] then
|
if not Instances.categorise[name] then
|
||||||
return error('Inavlid name for instance group: '..name,2)
|
return error('Invalid name for instance group: '..name,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
category = category or callback
|
category = category or callback
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
Prototype:set_caption(value) --- Sets the caption for the element define
|
Prototype:set_caption(value) --- Sets the caption for the element define
|
||||||
Prototype:set_tooltip(value) --- Sets the tooltip for the element define
|
Prototype:set_tooltip(value) --- Sets the tooltip for the element define
|
||||||
Prototype:set_style(style,callback) --- Sets the style for the element define
|
Prototype:set_style(style,callback) --- Sets the style for the element define
|
||||||
Prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
Prototype:set_embedded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||||
|
|
||||||
Prototype:set_pre_authenticator --- Sets an authenticator that blocks the draw function if check fails
|
Prototype:set_pre_authenticator --- Sets an authenticator that blocks the draw function if check fails
|
||||||
Prototype:set_post_authenticator --- Sets an authenticator that disables the element if check fails
|
Prototype:set_post_authenticator --- Sets an authenticator that disables the element if check fails
|
||||||
@@ -80,10 +80,10 @@ end
|
|||||||
function Constructor.store(sync,callback)
|
function Constructor.store(sync,callback)
|
||||||
--- Adds a store for the define that is shared between all instances of the define in the same category, categorize is a function that returns a string
|
--- Adds a store for the define that is shared between all instances of the define in the same category, categorize is a function that returns a string
|
||||||
-- @tparam self table the gui define being acted on
|
-- @tparam self table the gui define being acted on
|
||||||
-- @tparam[opt] string location a unique location identifier, when omited a uid location will be used, use when sync is set to true
|
-- @tparam[opt] string location a unique location identifier, when omitted a uid location will be used, use when sync is set to true
|
||||||
-- @tparam[opt] function categorize function used to determine the category of a LuaGuiElement, when omited all share one single category
|
-- @tparam[opt] function categorize function used to determine the category of a LuaGuiElement, when omitted all share one single category
|
||||||
-- categorize param - LuaGuiElement element - the element that needs to be converted
|
-- categorize param - LuaGuiElement element - the element that needs to be converted
|
||||||
-- categorize return - string - a determistic string that referses to a category such as player name or force name
|
-- categorize return - string - a deterministic string that references to a category such as player name or force name
|
||||||
-- @treturn self the element define to allow chaining
|
-- @treturn self the element define to allow chaining
|
||||||
return function(self,location,categorize)
|
return function(self,location,categorize)
|
||||||
if self.store then return end
|
if self.store then return end
|
||||||
@@ -134,8 +134,8 @@ function Constructor.setter(value_type,key,second_key)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return function(self,value)
|
return function(self,value)
|
||||||
local vtype = type(value)
|
local v_type = type(value)
|
||||||
if vtype ~= value_type and (not locale or vtype ~= 'string') then
|
if v_type ~= value_type and (not locale or v_type ~= 'string') then
|
||||||
error(display_message,2)
|
error(display_message,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -213,11 +213,11 @@ end
|
|||||||
--- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
--- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||||
-- @tparam state ?boolean|function when true a padless flow is created to contain the element
|
-- @tparam state ?boolean|function when true a padless flow is created to contain the element
|
||||||
-- @treturn self the element define to allow chaining
|
-- @treturn self the element define to allow chaining
|
||||||
function Prototype:set_embeded_flow(state)
|
function Prototype:set_embedded_flow(state)
|
||||||
if state == false or type(state) == 'function' then
|
if state == false or type(state) == 'function' then
|
||||||
self.embeded_flow = state
|
self.embedded_flow = state
|
||||||
else
|
else
|
||||||
self.embeded_flow = true
|
self.embedded_flow = true
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -249,12 +249,12 @@ function Prototype:draw_to(element,...)
|
|||||||
if not self.pre_authenticator(player,self.name) then return end
|
if not self.pre_authenticator(player,self.name) then return end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.embeded_flow then
|
if self.embedded_flow then
|
||||||
local embeded_name
|
local embedded_name
|
||||||
if type(self.embeded_flow) == 'function' then
|
if type(self.embedded_flow) == 'function' then
|
||||||
embeded_name = self.embeded_flow(element,...)
|
embedded_name = self.embedded_flow(element,...)
|
||||||
end
|
end
|
||||||
element = element.add{type='flow',name=embeded_name}
|
element = element.add{type='flow',name=embedded_name}
|
||||||
element.style.padding = 0
|
element.style.padding = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--- This file creates a teste gui that is used to test every input method
|
--- This file creates a test gui that is used to test every input method
|
||||||
-- note that this does not cover every permutation only features in indepentance
|
-- note that this does not cover every permutation only features in independence
|
||||||
-- for example store in most cases is just by player name, but other store methods are tested with checkbox
|
-- for example store in most cases is just by player name, but other store methods are tested with checkbox
|
||||||
local Gui = require 'expcore.gui'
|
local Gui = require 'expcore.gui'
|
||||||
local format_chat_colour,table_keys = ext_require('expcore.common','format_chat_colour','table_keys')
|
local format_chat_colour,table_keys = ext_require('expcore.common','format_chat_colour','table_keys')
|
||||||
@@ -223,7 +223,7 @@ end)
|
|||||||
|
|
||||||
local checkbox_force =
|
local checkbox_force =
|
||||||
Gui.new_checkbox('test-checkbox-store-force')
|
Gui.new_checkbox('test-checkbox-store-force')
|
||||||
:set_tooltip('Checkboc store force')
|
:set_tooltip('Checkbox store force')
|
||||||
:set_caption('Checkbox Store Force')
|
:set_caption('Checkbox Store Force')
|
||||||
:add_store(Gui.categorize_by_force)
|
:add_store(Gui.categorize_by_force)
|
||||||
:on_element_update(function(player,element,state)
|
:on_element_update(function(player,element,state)
|
||||||
@@ -239,7 +239,7 @@ Gui.new_checkbox('test-checkbox-store-player')
|
|||||||
player.print('Checkbox store player: '..tostring(state))
|
player.print('Checkbox store player: '..tostring(state))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
tests.Checkboxs = {
|
tests.Checkboxes = {
|
||||||
['Local']=checkbox_local,
|
['Local']=checkbox_local,
|
||||||
['Game store']=checkbox_game,
|
['Game store']=checkbox_game,
|
||||||
['Force store']=checkbox_force,
|
['Force store']=checkbox_force,
|
||||||
@@ -425,7 +425,7 @@ Gui.new_list_box('test-list-box-store')
|
|||||||
player.print('Dropdown store: '..tostring(value))
|
player.print('Dropdown store: '..tostring(value))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
tests["List Boxs"] = {
|
tests["List Boxes"] = {
|
||||||
['Local']=list_box_local,
|
['Local']=list_box_local,
|
||||||
['Player']=list_box_player
|
['Player']=list_box_player
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ tests["List Boxs"] = {
|
|||||||
|
|
||||||
local slider_local_default =
|
local slider_local_default =
|
||||||
Gui.new_slider('test-slider-local-default')
|
Gui.new_slider('test-slider-local-default')
|
||||||
:set_tooltip('Silder local default')
|
:set_tooltip('Slider local default')
|
||||||
:on_element_update(function(player,element,value,percent)
|
:on_element_update(function(player,element,value,percent)
|
||||||
player.print('Slider local default: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
player.print('Slider local default: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||||
end)
|
end)
|
||||||
@@ -450,7 +450,7 @@ end)
|
|||||||
|
|
||||||
local slider_player_default =
|
local slider_player_default =
|
||||||
Gui.new_slider('test-slider-store-default')
|
Gui.new_slider('test-slider-store-default')
|
||||||
:set_tooltip('Silder store default')
|
:set_tooltip('Slider store default')
|
||||||
:add_store(Gui.categorize_by_player)
|
:add_store(Gui.categorize_by_player)
|
||||||
:on_element_update(function(player,element,value,percent)
|
:on_element_update(function(player,element,value,percent)
|
||||||
player.print('Slider store default: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
player.print('Slider store default: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||||
@@ -458,7 +458,7 @@ end)
|
|||||||
|
|
||||||
local slider_static =
|
local slider_static =
|
||||||
Gui.new_slider('test-slider-static-range')
|
Gui.new_slider('test-slider-static-range')
|
||||||
:set_tooltip('Silder static range')
|
:set_tooltip('Slider static range')
|
||||||
:set_range(5,50)
|
:set_range(5,50)
|
||||||
:on_element_update(function(player,element,value,percent)
|
:on_element_update(function(player,element,value,percent)
|
||||||
player.print('Slider static range: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
player.print('Slider static range: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||||
@@ -466,7 +466,7 @@ end)
|
|||||||
|
|
||||||
local slider_dynamic =
|
local slider_dynamic =
|
||||||
Gui.new_slider('test-slider-dynamic-range')
|
Gui.new_slider('test-slider-dynamic-range')
|
||||||
:set_tooltip('Silder dynamic range')
|
:set_tooltip('Slider dynamic range')
|
||||||
:set_range(function(player,element)
|
:set_range(function(player,element)
|
||||||
return player.index - 5
|
return player.index - 5
|
||||||
end,function(player,element)
|
end,function(player,element)
|
||||||
@@ -478,7 +478,7 @@ end)
|
|||||||
|
|
||||||
local label_slider_local =
|
local label_slider_local =
|
||||||
Gui.new_slider('test-slider-local-label')
|
Gui.new_slider('test-slider-local-label')
|
||||||
:set_tooltip('Silder local label')
|
:set_tooltip('Slider local label')
|
||||||
:enable_auto_draw_label()
|
:enable_auto_draw_label()
|
||||||
:on_element_update(function(player,element,value,percent)
|
:on_element_update(function(player,element,value,percent)
|
||||||
player.print('Slider local label: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
player.print('Slider local label: '..tostring(math.round(value))..' '..tostring(math.round(percent,1)))
|
||||||
@@ -486,7 +486,7 @@ end)
|
|||||||
|
|
||||||
local label_slider_player =
|
local label_slider_player =
|
||||||
Gui.new_slider('test-slider-store-label')
|
Gui.new_slider('test-slider-store-label')
|
||||||
:set_tooltip('Silder store label')
|
:set_tooltip('Slider store label')
|
||||||
:enable_auto_draw_label()
|
:enable_auto_draw_label()
|
||||||
:add_store(Gui.categorize_by_player)
|
:add_store(Gui.categorize_by_player)
|
||||||
:on_element_update(function(player,element,value,percent)
|
:on_element_update(function(player,element,value,percent)
|
||||||
@@ -610,7 +610,7 @@ tests["Elem Buttons"] = {
|
|||||||
Progress bar tests
|
Progress bar tests
|
||||||
> Simple -- Progress bar that fills every 2 seconds
|
> Simple -- Progress bar that fills every 2 seconds
|
||||||
> Store -- Progress bar that fills every 5 seconds with synced value
|
> Store -- Progress bar that fills every 5 seconds with synced value
|
||||||
> Reverce -- Progress bar that decreases every 2 seconds
|
> Reverse -- Progress bar that decreases every 2 seconds
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local progressbar_one =
|
local progressbar_one =
|
||||||
@@ -651,5 +651,5 @@ end)
|
|||||||
tests["Progress Bars"] = {
|
tests["Progress Bars"] = {
|
||||||
['Simple']=progressbar_one,
|
['Simple']=progressbar_one,
|
||||||
['Store']=progressbar_two,
|
['Store']=progressbar_two,
|
||||||
['Reverce']=progressbar_three
|
['Reverse']=progressbar_three
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
-- here we will create an admin group however we do not want them to use the map editor or mess with the permission groups
|
-- here we will create an admin group however we do not want them to use the map editor or mess with the permission groups
|
||||||
Permission_Groups.new_group('Admin') -- this defines a new group called "Admin"
|
Permission_Groups.new_group('Admin') -- this defines a new group called "Admin"
|
||||||
:allow_all() -- this makes the default to allow any input action unless set other wise
|
:allow_all() -- this makes the default to allow any input action unless set other wise
|
||||||
:disallow{ -- here we disallow the input action we dont want them to use
|
:disallow{ -- here we disallow the input action we don't want them to use
|
||||||
'add_permission_group',
|
'add_permission_group',
|
||||||
'delete_permission_group',
|
'delete_permission_group',
|
||||||
'import_permissions_string',
|
'import_permissions_string',
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
...extras...
|
...extras...
|
||||||
:set_allow_all()
|
:set_allow_all()
|
||||||
|
|
||||||
If you dont do this want this as i would advise you do then you will want to define what the role can do; this comes with
|
If you don't do this want this as i would advise you do then you will want to define what the role can do; this comes with
|
||||||
an optional inheritance system if you like those sort of things in which case disallow may also be of some use to you:
|
an optional inheritance system if you like those sort of things in which case disallow may also be of some use to you:
|
||||||
Roles.new_role('Administrator','Admin')
|
Roles.new_role('Administrator','Admin')
|
||||||
...extras...
|
...extras...
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
>>>>Example System Define:
|
>>>>Example System Define:
|
||||||
Once all roles are defined these steps must be done to ensure the system is ready to use, this includes setting a default
|
Once all roles are defined these steps must be done to ensure the system is ready to use, this includes setting a default
|
||||||
role, assigning a root (all permission) role that the server/system will use and the linier order that the roles fall into:
|
role, assigning a root (all permission) role that the server/system will use and the linear order that the roles fall into:
|
||||||
|
|
||||||
Roles.set_default('Guest')
|
Roles.set_default('Guest')
|
||||||
Roles.set_root('System')
|
Roles.set_root('System')
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
Roles._prototype:set_custom_color(color) --- Sets a custom colour for the role, can be accessed by other code
|
Roles._prototype:set_custom_color(color) --- Sets a custom colour for the role, can be accessed by other code
|
||||||
Roles._prototype:set_permission_group(name,use_factorio_api) --- Sets the permission group for this role, players will be moved to the group of they highest role
|
Roles._prototype:set_permission_group(name,use_factorio_api) --- Sets the permission group for this role, players will be moved to the group of they highest role
|
||||||
Roles._prototype:set_parent(role) --- Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
|
Roles._prototype:set_parent(role) --- Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
|
||||||
Roles._prototype:set_auto_promote_condition(callback) --- Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
|
Roles._prototype:set_auto_promote_condition(callback) --- Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will receive the role
|
||||||
Roles._prototype:set_block_auto_promote(state) --- Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment
|
Roles._prototype:set_block_auto_promote(state) --- Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment
|
||||||
|
|
||||||
Roles._prototype:add_player(player,skip_check,skip_event) --- Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign
|
Roles._prototype:add_player(player,skip_check,skip_event) --- Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign
|
||||||
@@ -295,7 +295,7 @@ function Roles.get_role_by_name(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Get a role with the given order index
|
--- Get a role with the given order index
|
||||||
-- @tparam number index the place in the oder list of the role to get
|
-- @tparam number index the place in the order list of the role to get
|
||||||
-- @treturn Roles._prototype the role with that index in the order list or nil
|
-- @treturn Roles._prototype the role with that index in the order list or nil
|
||||||
function Roles.get_role_by_order(index)
|
function Roles.get_role_by_order(index)
|
||||||
local name = Roles.config.order[index]
|
local name = Roles.config.order[index]
|
||||||
@@ -307,13 +307,13 @@ end
|
|||||||
-- @tparam ?number|string|table any the value used to find the role
|
-- @tparam ?number|string|table any the value used to find the role
|
||||||
-- @treturn Roles._prototype the role that was found or nil see above
|
-- @treturn Roles._prototype the role that was found or nil see above
|
||||||
function Roles.get_role_from_any(any)
|
function Roles.get_role_from_any(any)
|
||||||
local tany = type(any)
|
local t_any = type(any)
|
||||||
if tany == 'number' or tonumber(any) then
|
if t_any == 'number' or tonumber(any) then
|
||||||
any = tonumber(any)
|
any = tonumber(any)
|
||||||
return Roles.get_role_by_order(any)
|
return Roles.get_role_by_order(any)
|
||||||
elseif tany == 'string' then
|
elseif t_any == 'string' then
|
||||||
return Roles.get_role_by_name(any)
|
return Roles.get_role_by_name(any)
|
||||||
elseif tany == 'table' then
|
elseif t_any == 'table' then
|
||||||
return Roles.get_role_by_name(any.name)
|
return Roles.get_role_by_name(any.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -621,7 +621,7 @@ function Roles._prototype:set_parent(role)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
|
--- Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will receive the role
|
||||||
-- nb: this is one way, failing false after already gaining the role will not revoke the role
|
-- nb: this is one way, failing false after already gaining the role will not revoke the role
|
||||||
-- @tparam function callback receives only one param which is player to promote, return true to promote the player
|
-- @tparam function callback receives only one param which is player to promote, return true to promote the player
|
||||||
-- @treturn Roles._prototype allows chaining
|
-- @treturn Roles._prototype allows chaining
|
||||||
|
|||||||
@@ -7,38 +7,38 @@
|
|||||||
This may be useful when storing config values and when they get set you want to make sure it is taken care of, or maybe you want
|
This may be useful when storing config values and when they get set you want to make sure it is taken care of, or maybe you want
|
||||||
to have a value that you can trigger an update of from different places.
|
to have a value that you can trigger an update of from different places.
|
||||||
|
|
||||||
-- this will register a new location called 'scenario.dificutly'
|
-- this will register a new location called 'scenario.difficulty'
|
||||||
-- note that setting a start value is optional and we could take nil to mean normal
|
-- note that setting a start value is optional and we could take nil to mean normal
|
||||||
Store.register('scenario.dificutly',function(value)
|
Store.register('scenario.difficulty',function(value)
|
||||||
game.print('The scenario dificulty has be set to: '..value)
|
game.print('The scenario difficulty has be set to: '..value)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- this will set the value in the store to 'hard' and will trigger the update callback which will print a message to the game
|
-- this will set the value in the store to 'hard' and will trigger the update callback which will print a message to the game
|
||||||
Store.set('scenario.dificutly','hard')
|
Store.set('scenario.difficulty','hard')
|
||||||
|
|
||||||
-- this will return 'hard'
|
-- this will return 'hard'
|
||||||
Store.get('scenario.dificutly')
|
Store.get('scenario.difficulty')
|
||||||
|
|
||||||
>>>> Using Children
|
>>>> Using Children
|
||||||
One limitation of store is that all lcoations must be registered to avoid desyncs, to get round this issue "children" can be used.
|
One limitation of store is that all locations must be registered to avoid desyncs, to get round this issue "children" can be used.
|
||||||
When you set the value of a child it does not have its own update callback so rather the "parent" location which has been registerd
|
When you set the value of a child it does not have its own update callback so rather the "parent" location which has been registered
|
||||||
will have its update value called with a second param of the name of that child.
|
will have its update value called with a second param of the name of that child.
|
||||||
|
|
||||||
This may be useful when you want a value of each player or force and since you cant regisier every player at the start you must use
|
This may be useful when you want a value of each player or force and since you cant register every player at the start you must use
|
||||||
the players name as the child name.
|
the players name as the child name.
|
||||||
|
|
||||||
-- this will register the lcoation 'scenario.score' where we plan to use force names as the child
|
-- this will register the location 'scenario.score' where we plan to use force names as the child
|
||||||
Store.register('scenario.score',function(value,child)
|
Store.register('scenario.score',function(value,child)
|
||||||
game.print(child..' now has a score of '..value)
|
game.print(child..' now has a score of '..value)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- this will return nil, but will not error as children dont need to be registerd
|
-- this will return nil, but will not error as children don't need to be registered
|
||||||
Store.get('scenario.score','player')
|
Store.get('scenario.score','player')
|
||||||
|
|
||||||
-- this will set 'player' to have a value of 10 for 'scenario.score' and trigger the game message print
|
-- this will set 'player' to have a value of 10 for 'scenario.score' and trigger the game message print
|
||||||
Store.set('scenario.score','player',10)
|
Store.set('scenario.score','player',10)
|
||||||
|
|
||||||
-- this would be the silliar to Store.get however this will return the names of all the children
|
-- this would be the similar to Store.get however this will return the names of all the children
|
||||||
Store.get_children('scenario.score')
|
Store.get_children('scenario.score')
|
||||||
|
|
||||||
>>>> Using Sync
|
>>>> Using Sync
|
||||||
@@ -49,16 +49,16 @@
|
|||||||
This may be useful when you want to have a value change effect multiple instances or even if you just want a database to store values so
|
This may be useful when you want to have a value change effect multiple instances or even if you just want a database to store values so
|
||||||
you can sync data between map resets.
|
you can sync data between map resets.
|
||||||
|
|
||||||
-- this example will register the location 'stastics.total-play-time' where we plan to use plan names as the child
|
-- this example will register the location 'statistics.total-play-time' where we plan to use plan names as the child
|
||||||
-- note that the location must be the same across instances
|
-- note that the location must be the same across instances
|
||||||
Store.register('stastics.total-play-time',true,function(value,child)
|
Store.register('statistics.total-play-time',true,function(value,child)
|
||||||
game.print(child..' now has now played for '..value)
|
game.print(child..' now has now played for '..value)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- use of set and are all the same as non synced but you should include from_sync as true
|
-- use of set and are all the same as non synced but you should include from_sync as true
|
||||||
|
|
||||||
>>>> Alternative method
|
>>>> Alternative method
|
||||||
Some people may prefer to use a varible rather than a string for formating reasons here is an example. Also for any times when
|
Some people may prefer to use a variable rather than a string for formating reasons here is an example. Also for any times when
|
||||||
there will be little external input Store.uid_location() can be used to generate non conflicting locations, uid_location will also
|
there will be little external input Store.uid_location() can be used to generate non conflicting locations, uid_location will also
|
||||||
be used if you give a nil location.
|
be used if you give a nil location.
|
||||||
|
|
||||||
@@ -94,15 +94,15 @@ local function error_not_table(value)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check for if a lcoation is registered
|
--- Check for if a location is registered
|
||||||
-- @tparam string location the location to test for
|
-- @tparam string location the location to test for
|
||||||
-- @treturn boolean true if registered
|
-- @treturn boolean true if registered
|
||||||
function Store.is_registered(location)
|
function Store.is_registered(location)
|
||||||
return Store.registered[location]
|
return Store.registered[location]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a unqiue name that can be used for a store
|
--- Returns a unique name that can be used for a store
|
||||||
-- @treturn string a unqiue name
|
-- @treturn string a unique name
|
||||||
function Store.uid_location()
|
function Store.uid_location()
|
||||||
return tostring(Token.uid())
|
return tostring(Token.uid())
|
||||||
end
|
end
|
||||||
@@ -111,7 +111,7 @@ end
|
|||||||
-- @tparam[opt] string location string a unique that points to the data, string used rather than token to allow migration
|
-- @tparam[opt] string location string a unique that points to the data, string used rather than token to allow migration
|
||||||
-- @tparam[opt] boolean synced when true will output changes to a file so it can be synced
|
-- @tparam[opt] boolean synced when true will output changes to a file so it can be synced
|
||||||
-- @tparam[opt] function callback when given the callback will be automatically registered to the update of the value
|
-- @tparam[opt] function callback when given the callback will be automatically registered to the update of the value
|
||||||
-- @treturn string the lcoation that is being used
|
-- @treturn string the location that is being used
|
||||||
function Store.register(location,synced,callback)
|
function Store.register(location,synced,callback)
|
||||||
if _LIFECYCLE ~= _STAGE.control then
|
if _LIFECYCLE ~= _STAGE.control then
|
||||||
return error('Can only be called during the control stage', 2)
|
return error('Can only be called during the control stage', 2)
|
||||||
@@ -231,13 +231,13 @@ end
|
|||||||
--- Gets all non nil children at a location, children can be added and removed during runtime
|
--- Gets all non nil children at a location, children can be added and removed during runtime
|
||||||
-- this is similar to Store.get but will always return a table even if it is empty
|
-- this is similar to Store.get but will always return a table even if it is empty
|
||||||
-- @tparam string location the location to get the children of
|
-- @tparam string location the location to get the children of
|
||||||
-- @treturn table a table containg all the children names
|
-- @treturn table a table containing all the children names
|
||||||
function Store.get_children(location)
|
function Store.get_children(location)
|
||||||
local data = Store.get(location)
|
local data = Store.get(location)
|
||||||
return type(data) == 'table' and table_keys(data) or {}
|
return type(data) == 'table' and table_keys(data) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handels syncing
|
-- Handles syncing
|
||||||
Event.add(Store.events.on_value_update,function(event)
|
Event.add(Store.events.on_value_update,function(event)
|
||||||
if Store.callbacks[event.location] then
|
if Store.callbacks[event.location] then
|
||||||
Store.callbacks[event.location](event.value,event.child)
|
Store.callbacks[event.location](event.value,event.child)
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
-- here we give sudo access to the function under the name "make-admin"
|
-- here we give sudo access to the function under the name "make-admin"
|
||||||
Sudo.register('make-admin',make_admin)
|
Sudo.register('make-admin',make_admin)
|
||||||
|
|
||||||
-- this will allow us to bypass this by runing one tick later outside of any player scope
|
-- this will allow us to bypass this by running one tick later outside of any player scope
|
||||||
Sudo.run('make-admin',game.player)
|
Sudo.run('make-admin',game.player)
|
||||||
|
|
||||||
>>>> Functions
|
>>>> Functions
|
||||||
Sudo.register(name,callback) --- Registers a new callback under the given name, used to avoid desynces
|
Sudo.register(name,callback) --- Registers a new callback under the given name, used to avoid desyncs
|
||||||
Sudo.get(name) --- Gets the function that is registered under the given name
|
Sudo.get(name) --- Gets the function that is registered under the given name
|
||||||
Sudo.run(name,...) --- Runs the function that is registered under the given name, you may supply any number of params as needed
|
Sudo.run(name,...) --- Runs the function that is registered under the given name, you may supply any number of params as needed
|
||||||
]]
|
]]
|
||||||
@@ -33,7 +33,7 @@ Token.register(function(params)
|
|||||||
func(unpack(params.params))
|
func(unpack(params.params))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Registers a new callback under the given name, used to avoid desynces
|
--- Registers a new callback under the given name, used to avoid desyncs
|
||||||
-- @tparam string name the name that will be used to call this function
|
-- @tparam string name the name that will be used to call this function
|
||||||
-- @tparam function callback the function that will be called by this name
|
-- @tparam function callback the function that will be called by this name
|
||||||
function Sudo.register(name,callback)
|
function Sudo.register(name,callback)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ local open_action_bar =
|
|||||||
Gui.new_button()
|
Gui.new_button()
|
||||||
:set_sprites('utility/expand_dots_white')
|
:set_sprites('utility/expand_dots_white')
|
||||||
:set_tooltip{'player-list.open-action-bar'}
|
:set_tooltip{'player-list.open-action-bar'}
|
||||||
:set_embeded_flow(function(element,action_player_name)
|
:set_embedded_flow(function(element,action_player_name)
|
||||||
return action_player_name
|
return action_player_name
|
||||||
end)
|
end)
|
||||||
:set_style('frame_button',function(style)
|
:set_style('frame_button',function(style)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Global.register({
|
|||||||
rocket_silos = tbl.rocket_silos
|
rocket_silos = tbl.rocket_silos
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Gets the name used to refrence the the rocket silo
|
--- Gets the name used to reference the the rocket silo
|
||||||
local function get_silo_name(entity)
|
local function get_silo_name(entity)
|
||||||
local position = entity.position
|
local position = entity.position
|
||||||
return math.floor(position.x)..':'..math.floor(position.y)
|
return math.floor(position.x)..':'..math.floor(position.y)
|
||||||
@@ -44,7 +44,7 @@ local function player_allowed(player,action)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.progress[action..'_role_permision'] and not Roles.player_allowed(player,config.progress[action..'_role_permision']) then
|
if config.progress[action..'_role_permission'] and not Roles.player_allowed(player,config.progress[action..'_role_permission']) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ local launch_rocket =
|
|||||||
Gui.new_button()
|
Gui.new_button()
|
||||||
:set_sprites('utility/center')
|
:set_sprites('utility/center')
|
||||||
:set_tooltip{'rocket-info.launch-tooltip'}
|
:set_tooltip{'rocket-info.launch-tooltip'}
|
||||||
:set_embeded_flow(function(element,rocket_silo_name)
|
:set_embedded_flow(function(element,rocket_silo_name)
|
||||||
return 'launch-'..rocket_silo_name
|
return 'launch-'..rocket_silo_name
|
||||||
end)
|
end)
|
||||||
:set_style('tool_button',function(style)
|
:set_style('tool_button',function(style)
|
||||||
@@ -94,7 +94,7 @@ local toggle_rocket =
|
|||||||
Gui.new_button()
|
Gui.new_button()
|
||||||
:set_sprites('utility/play')
|
:set_sprites('utility/play')
|
||||||
:set_tooltip{'rocket-info.toggle-rocket-tooltip'}
|
:set_tooltip{'rocket-info.toggle-rocket-tooltip'}
|
||||||
:set_embeded_flow(function(element,rocket_silo_name)
|
:set_embedded_flow(function(element,rocket_silo_name)
|
||||||
return 'toggle-'..rocket_silo_name
|
return 'toggle-'..rocket_silo_name
|
||||||
end)
|
end)
|
||||||
:set_style('tool_button',function(style)
|
:set_style('tool_button',function(style)
|
||||||
@@ -118,7 +118,7 @@ end)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Used to toggle the visiblty of the different sections
|
--- Used to toggle the visibility of the different sections
|
||||||
local toggle_section =
|
local toggle_section =
|
||||||
Gui.new_button()
|
Gui.new_button()
|
||||||
:set_sprites('utility/expand_dark','utility/expand')
|
:set_sprites('utility/expand_dark','utility/expand')
|
||||||
@@ -325,7 +325,7 @@ local function generate_milestones(player,frame)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creats the different buttons used with the rocket silos
|
--- Creates the different buttons used with the rocket silos
|
||||||
local function generate_progress_buttons(player,element,rocket_silo_data)
|
local function generate_progress_buttons(player,element,rocket_silo_data)
|
||||||
local silo_name = rocket_silo_data.name
|
local silo_name = rocket_silo_data.name
|
||||||
local status = rocket_silo_data.entity.status == defines.entity_status.waiting_to_launch_rocket
|
local status = rocket_silo_data.entity.status == defines.entity_status.waiting_to_launch_rocket
|
||||||
@@ -394,11 +394,11 @@ local function generate_progress(player,frame)
|
|||||||
for silo_name,rocket_silo_data in pairs(force_silo_data) do
|
for silo_name,rocket_silo_data in pairs(force_silo_data) do
|
||||||
if not rocket_silo_data.entity or not rocket_silo_data.entity.valid then
|
if not rocket_silo_data.entity or not rocket_silo_data.entity.valid then
|
||||||
force_silo_data[silo_name] = nil
|
force_silo_data[silo_name] = nil
|
||||||
Gui.destory_if_valid(element['toggle-'..silo_name])
|
Gui.destroy_if_valid(element['toggle-'..silo_name])
|
||||||
Gui.destory_if_valid(element['launch-'..silo_name])
|
Gui.destroy_if_valid(element['launch-'..silo_name])
|
||||||
Gui.destory_if_valid(element['label-x-'..silo_name])
|
Gui.destroy_if_valid(element['label-x-'..silo_name])
|
||||||
Gui.destory_if_valid(element['label-y-'..silo_name])
|
Gui.destroy_if_valid(element['label-y-'..silo_name])
|
||||||
Gui.destory_if_valid(element[silo_name])
|
Gui.destroy_if_valid(element[silo_name])
|
||||||
|
|
||||||
elseif not element[silo_name] then
|
elseif not element[silo_name] then
|
||||||
local entity = rocket_silo_data.entity
|
local entity = rocket_silo_data.entity
|
||||||
@@ -410,7 +410,7 @@ local function generate_progress(player,frame)
|
|||||||
|
|
||||||
generate_progress_buttons(player,element,rocket_silo_data)
|
generate_progress_buttons(player,element,rocket_silo_data)
|
||||||
|
|
||||||
--- Creats two flows and two labels for the X and Y position
|
--- Creates two flows and two labels for the X and Y position
|
||||||
local name = config.progress.allow_zoom_to_map and zoom_to_map_name or nil
|
local name = config.progress.allow_zoom_to_map and zoom_to_map_name or nil
|
||||||
local tooltip = config.progress.allow_zoom_to_map and {'rocket-info.progress-label-tooltip'} or nil
|
local tooltip = config.progress.allow_zoom_to_map and {'rocket-info.progress-label-tooltip'} or nil
|
||||||
local flow_x = element.add{
|
local flow_x = element.add{
|
||||||
@@ -538,7 +538,7 @@ Event.add(defines.events.on_rocket_launched,function(event)
|
|||||||
--- Adds this 1 to the launch count for this silo
|
--- Adds this 1 to the launch count for this silo
|
||||||
force_silo_data[silo_name].launched = force_silo_data[silo_name].launched+1
|
force_silo_data[silo_name].launched = force_silo_data[silo_name].launched+1
|
||||||
|
|
||||||
--- Updates all the guis (and toolbar since the button may now be visible)
|
--- Updates all the gui's (and toolbar since the button may now be visible)
|
||||||
for _,player in pairs(force.players) do
|
for _,player in pairs(force.players) do
|
||||||
rocket_info:update(player)
|
rocket_info:update(player)
|
||||||
if first_rocket then
|
if first_rocket then
|
||||||
@@ -548,7 +548,7 @@ Event.add(defines.events.on_rocket_launched,function(event)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- When a launch is reiggered it will await reset
|
--- When a launch is triggered it will await reset
|
||||||
Event.add(defines.events.on_rocket_launch_ordered,function(event)
|
Event.add(defines.events.on_rocket_launch_ordered,function(event)
|
||||||
local entity = event.rocket_silo
|
local entity = event.rocket_silo
|
||||||
local silo_name = get_silo_name(entity)
|
local silo_name = get_silo_name(entity)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ local function add_task(player,task_number)
|
|||||||
Store.set(task_store,task_id,'New task')
|
Store.set(task_store,task_id,'New task')
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Removes all refrences to a task
|
--- Removes all references to a task
|
||||||
local function remove_task(task_id)
|
local function remove_task(task_id)
|
||||||
local force_name = task_details[task_id].force
|
local force_name = task_details[task_id].force
|
||||||
Store.clear(task_store,task_id)
|
Store.clear(task_store,task_id)
|
||||||
@@ -69,7 +69,7 @@ local function player_allowed_edit(player,task_id)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.edit_tasks_role_permision and not Roles.player_allowed(player,config.edit_tasks_role_permision) then
|
if config.edit_tasks_role_permission and not Roles.player_allowed(player,config.edit_tasks_role_permission) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -186,9 +186,9 @@ function generate_task(player,element,task_id)
|
|||||||
if not task then
|
if not task then
|
||||||
-- task is nil so remove it from the list
|
-- task is nil so remove it from the list
|
||||||
element.parent.no_tasks.visible = #tasks == 01
|
element.parent.no_tasks.visible = #tasks == 01
|
||||||
Gui.destory_if_valid(element['count-'..task_id])
|
Gui.destroy_if_valid(element['count-'..task_id])
|
||||||
Gui.destory_if_valid(element['edit-'..task_id])
|
Gui.destroy_if_valid(element['edit-'..task_id])
|
||||||
Gui.destory_if_valid(element[task_id])
|
Gui.destroy_if_valid(element[task_id])
|
||||||
|
|
||||||
else
|
else
|
||||||
element.parent.no_tasks.visible = false
|
element.parent.no_tasks.visible = false
|
||||||
@@ -260,7 +260,7 @@ function generate_task(player,element,task_id)
|
|||||||
label.style.maximal_width = 150
|
label.style.maximal_width = 150
|
||||||
|
|
||||||
elseif editing and element_type ~= 'textfield' then
|
elseif editing and element_type ~= 'textfield' then
|
||||||
-- create the text field, edit mode, update it omited as value is being edited
|
-- create the text field, edit mode, update it omitted as value is being edited
|
||||||
if edit_area then
|
if edit_area then
|
||||||
edit_area[edit_task.name].enabled = false
|
edit_area[edit_task.name].enabled = false
|
||||||
end
|
end
|
||||||
@@ -342,7 +342,7 @@ local function generate_container(player,element)
|
|||||||
return flow_table
|
return flow_table
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Registeres the task list
|
--- Registers the task list
|
||||||
local task_list =
|
local task_list =
|
||||||
Gui.new_left_frame('gui/task-list')
|
Gui.new_left_frame('gui/task-list')
|
||||||
:set_sprites('utility/not_enough_repair_packs_icon')
|
:set_sprites('utility/not_enough_repair_packs_icon')
|
||||||
@@ -370,7 +370,7 @@ end)
|
|||||||
|
|
||||||
update_all = task_list 'update_all'
|
update_all = task_list 'update_all'
|
||||||
|
|
||||||
--- When a new task is added it will udpate the task list for everyone on that force
|
--- When a new task is added it will update the task list for everyone on that force
|
||||||
Store.register(task_store,function(value,task_id)
|
Store.register(task_store,function(value,task_id)
|
||||||
local details = task_details[task_id]
|
local details = task_details[task_id]
|
||||||
local force = game.forces[details.force]
|
local force = game.forces[details.force]
|
||||||
@@ -382,7 +382,7 @@ Store.register(task_store,function(value,task_id)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Makess sure the right buttons are present when roles change
|
--- Makes sure the right buttons are present when roles change
|
||||||
Event.add(Roles.events.on_role_assigned,task_list 'redraw')
|
Event.add(Roles.events.on_role_assigned,task_list 'redraw')
|
||||||
Event.add(Roles.events.on_role_unassigned,task_list 'redraw')
|
Event.add(Roles.events.on_role_unassigned,task_list 'redraw')
|
||||||
|
|
||||||
|
|||||||
@@ -422,9 +422,9 @@ function generate_warp(player,element,warp_id)
|
|||||||
|
|
||||||
if not warp_name then
|
if not warp_name then
|
||||||
-- warp is nil so remove it from the list
|
-- warp is nil so remove it from the list
|
||||||
Gui.destory_if_valid(element['icon-'..warp_id])
|
Gui.destroy_if_valid(element['icon-'..warp_id])
|
||||||
Gui.destory_if_valid(element['edit-'..warp_id])
|
Gui.destroy_if_valid(element['edit-'..warp_id])
|
||||||
Gui.destory_if_valid(element[warp_id])
|
Gui.destroy_if_valid(element[warp_id])
|
||||||
|
|
||||||
else
|
else
|
||||||
-- if it is not already present then add it now
|
-- if it is not already present then add it now
|
||||||
|
|||||||
@@ -1,56 +1,56 @@
|
|||||||
return {
|
return {
|
||||||
'Why don’t fish like basketball? Cause they’re afraid of the net',
|
"Why don't fish like basketball? Cause they're afraid of the net",
|
||||||
'What do you get when you cross a banker with a fish? A Loan shark!',
|
"What do you get when you cross a banker with a fish? A Loan shark!",
|
||||||
'How do you make an Octupus laugh? With ten-tickles',
|
"How do you make an Octopus laugh? With ten-tickles",
|
||||||
'What do you call a fish that needs help with his or her vocals? Autotuna',
|
"What do you call a fish that needs help with his or her vocals? Autotuna",
|
||||||
'What is the difference between a piano and a fish? You can tune a piano but you cannot tuna fish.',
|
"What is the difference between a piano and a fish? You can tune a piano but you cannot tuna fish.",
|
||||||
'What did the blind man say when he passed the fish market? Good morning ladies.',
|
"What did the blind man say when he passed the fish market? Good morning ladies.",
|
||||||
'Did you hear about the goldfish who went bankrupt? Now he’s a bronze fish.',
|
"Did you hear about the goldfish who went bankrupt? Now he's a bronze fish.",
|
||||||
'What happens when you put nutella on salmon? You get salmonella',
|
"What happens when you put nutella on salmon? You get salmonella",
|
||||||
'What do you call a fish with no eyes?…Fsh',
|
"What do you call a fish with no eyes?... Fsh",
|
||||||
'What kind of money do fishermen make?…Net profits',
|
"What kind of money do fishermen make?... Net profits",
|
||||||
'What do you get if you cross a salmon, a bird’s leg and a hand?…Birdsthigh fish fingers',
|
"What do you get if you cross a salmon, a bird's leg and a hand?... Birdsthigh fish fingers",
|
||||||
'Why is a fish easy to weigh?…Because it has its own scales',
|
"Why is a fish easy to weigh?... Because it has its own scales",
|
||||||
'Why are gold fish orange?…The water makes them rusty',
|
"Why are gold fish orange?... The water makes them rusty",
|
||||||
'What was the Tsar of Russia’s favorite fish?…Tsardines',
|
"What was the Tsar of Russia's favourite fish?... Tsardines",
|
||||||
'Why did the dog jump into the sea?…He wanted to chase the catfish',
|
"Why did the dog jump into the sea?... He wanted to chase the catfish",
|
||||||
'Which fish dresses the best?…The Swordfish – It always looks sharp',
|
"Which fish dresses the best?... The Swordfish – It always looks sharp",
|
||||||
'What do you get if you cross an abbot with a trout?…Monkfish',
|
"What do you get if you cross an abbot with a trout?... Monkfish",
|
||||||
'What do you call a big fish who makes you an offer you can’t refuse?…The Codfather',
|
"What do you call a big fish who makes you an offer you can't refuse?... The Codfather",
|
||||||
'Why is a swordfish’s nose 11 inches long?…If it were 12 inches long it would be a foot',
|
"Why is a swordfish's nose 11 inches long?... If it were 12 inches long it would be a foot",
|
||||||
'What do you get if you cross a trout with an apartment?…A flat fish',
|
"What do you get if you cross a trout with an apartment?... A flat fish",
|
||||||
'Why are fish no good at tennis?…They don’t like to get too close to the net',
|
"Why are fish no good at tennis?... They don't like to get too close to the net",
|
||||||
'How do the fish get to school?…By octobus',
|
"How do the fish get to school?... By octobus",
|
||||||
'What fish make the best sandwich?…A peanut butter and jellyfish',
|
"What fish make the best sandwich?... A peanut butter and jellyfish",
|
||||||
'Man: Can I have a fly rod and reel for my son?…Fishing Shop Owner: Sorry sir we don’t do trades',
|
"Man: Can I have a fly rod and reel for my son?... Fishing Shop Owner: Sorry sir we don't do trades",
|
||||||
'Where do fish keep their money?…In the river bank',
|
"Where do fish keep their money?... In the river bank",
|
||||||
'Why do fish like arcade games?…Because they are finball wizards',
|
"Why do fish like arcade games?... Because they are finball wizards",
|
||||||
'What is a mermaid?…A deep-she fish',
|
"What is a mermaid?... A deep-she fish",
|
||||||
'What do you get if you cross a whale with rotten fish?…Moby Sick',
|
"What do you get if you cross a whale with rotten fish?... Moby Sick",
|
||||||
'Why didn’t the lobster share his toys?…He was too shellfish',
|
"Why didn't the lobster share his toys?... He was too shellfish",
|
||||||
'What do fish use to make telephone calls?…a Shell phone',
|
"What do fish use to make telephone calls?... a Shell phone",
|
||||||
'Why don’t fish make very good tennis balls?…They keep getting caught in the net',
|
"Why don't fish make very good tennis balls?... They keep getting caught in the net",
|
||||||
'Electric eels and electric rays have enough electricity to kill a horse.',
|
"Electric eels and electric rays have enough electricity to kill a horse.",
|
||||||
'Most fish have taste buds all over their body.',
|
"Most fish have taste buds all over their body.",
|
||||||
'Most brands of lipstick contain fish scales.',
|
"Most brands of lipstick contain fish scales.",
|
||||||
'A fish does not add new scales as it grows, but the scales it has increase in size. In this way, growth rings are formed and the rings reveal the age of a fish.',
|
"A fish does not add new scales as it grows, but the scales it has increase in size. In this way, growth rings are formed and the rings reveal the age of a fish.",
|
||||||
'An inflated porcupine fish can reach a diameter of up to 35 inches. It puffs up by swallowing water and then storing it in its stomach.',
|
"An inflated porcupine fish can reach a diameter of up to 35 inches. It puffs up by swallowing water and then storing it in its stomach.",
|
||||||
'Most fish cannot swim backwards. Those that can are mainly members of one of the eel families.',
|
"Most fish cannot swim backwards. Those that can are mainly members of one of the eel families.",
|
||||||
'The fastest fish is the sailfish. It can swim as fast as a car travels on the highway.',
|
"The fastest fish is the sailfish. It can swim as fast as a car travels on the highway.",
|
||||||
'Some desert pupfish can live in hot springs that reach temperatures greater than 113° F.',
|
"Some desert pupfish can live in hot springs that reach temperatures greater than 113° F.",
|
||||||
'Anableps, four-eyed fish, can see above and below water at the same time.',
|
"Anableps, four-eyed fish, can see above and below water at the same time.",
|
||||||
'Catfish have over 27,000 taste buds. Humans have around 7,000.',
|
"Catfish have over 27,000 taste buds. Humans have around 7,000.",
|
||||||
'One hagfish can make enough slime in one minute to fill a bucket.',
|
"One hagfish can make enough slime in one minute to fill a bucket.",
|
||||||
'A female sunfish can lay 300 million eggs each year.',
|
"A female sunfish can lay 300 million eggs each year.",
|
||||||
'Fish feel pain and suffer stress just like mammals and birds.',
|
"Fish feel pain and suffer stress just like mammals and birds.",
|
||||||
'The Dwarf Seahorse is so slow you can’t see it move',
|
"The Dwarf Seahorse is so slow you can't see it move",
|
||||||
'Some fish are as small as a grain of rice',
|
"Some fish are as small as a grain of rice",
|
||||||
"There's a species of fish called 'Slippery Dick'",
|
"There's a species of fish called \"Slippery Dick\"",
|
||||||
'Herrings communicate through farts.',
|
"Herrings communicate through farts.",
|
||||||
'One Puffer Fish contains enough poison to kill 30 medium-biters.',
|
"One Puffer Fish contains enough poison to kill 30 medium-biters.",
|
||||||
'When Anglerfish mate, they melt into each other and share their bodies forever.',
|
"When Anglerfish mate, they melt into each other and share their bodies forever.",
|
||||||
"A koi fish named 'Hanako' lived for 225 years.",
|
"A koi fish named \"Hanako\" lived for 225 years.",
|
||||||
"What did the fish say when he posted bail? I'm off the hook!",
|
"What did the fish say when he posted bail? I'm off the hook!",
|
||||||
'There was a sale at the fish market today. I went to see what was the catch.',
|
"There was a sale at the fish market today. I went to see what was the catch.",
|
||||||
'There are over 25,000 identified species of fish on the earth.'
|
"There are over 25,000 identified species of fish on the earth."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ local function calculate_total(count, spawner, evolution)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Creates the spawner_request structure required for AlienEvolutionProgress.get_aliens for all
|
---Creates the spawner_request structure required for AlienEvolutionProgress.get_aliens for all
|
||||||
---available spawners. If dividing the total spawners by the total aliens causes a fraction, the
|
---available spawner's. If dividing the total spawner's by the total aliens causes a fraction, the
|
||||||
---fraction will decide a chance to spawn. 1 alien for 2 spawners will have 50% on both.
|
---fraction will decide a chance to spawn. 1 alien for 2 spawner's will have 50% on both.
|
||||||
---@param total_aliens table
|
---@param total_aliens table
|
||||||
function AlienEvolutionProgress.create_spawner_request(total_aliens)
|
function AlienEvolutionProgress.create_spawner_request(total_aliens)
|
||||||
local per_spawner = total_aliens / memory.spawner_specifications_count
|
local per_spawner = total_aliens / memory.spawner_specifications_count
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ local deprecated_command_alternatives = {
|
|||||||
|
|
||||||
local notify_on_commands = {
|
local notify_on_commands = {
|
||||||
['version'] = 'RedMew has a version as well, accessible via /redmew-version',
|
['version'] = 'RedMew has a version as well, accessible via /redmew-version',
|
||||||
['color'] = 'RedMew allows color saving and a color randomizer: check out /redmew-color',
|
['color'] = 'RedMew allows color saving and a color randomiser: check out /redmew-color',
|
||||||
['ban'] = 'In case your forgot: please remember to include a message on how to appeal a ban'
|
['ban'] = 'In case your forgot: please remember to include a message on how to appeal a ban'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ local option_names = {
|
|||||||
['description'] = 'A description of the command',
|
['description'] = 'A description of the command',
|
||||||
['arguments'] = 'A table of arguments, example: {"foo", "bar"} would map the first 2 arguments to foo and bar',
|
['arguments'] = 'A table of arguments, example: {"foo", "bar"} would map the first 2 arguments to foo and bar',
|
||||||
['default_values'] = 'A default value for a given argument when omitted, example: {bar = false}',
|
['default_values'] = 'A default value for a given argument when omitted, example: {bar = false}',
|
||||||
['required_rank'] = 'Set this to determins what rank is required to execute a command',
|
['required_rank'] = 'Set this to determines what rank is required to execute a command',
|
||||||
['donator_only'] = 'Set this to true if only donators may execute this command',
|
['donator_only'] = 'Set this to true if only donators may execute this command',
|
||||||
['debug_only'] = 'Set this to true if it should be registered when _DEBUG is true',
|
['debug_only'] = 'Set this to true if it should be registered when _DEBUG is true',
|
||||||
['cheat_only'] = 'Set this to true if it should be registered when _CHEATS is true',
|
['cheat_only'] = 'Set this to true if it should be registered when _CHEATS is true',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ local hours_to_ticks = 60 * 60 * 60
|
|||||||
local ticks_to_minutes = 1 / minutes_to_ticks
|
local ticks_to_minutes = 1 / minutes_to_ticks
|
||||||
local ticks_to_hours = 1 / hours_to_ticks
|
local ticks_to_hours = 1 / hours_to_ticks
|
||||||
|
|
||||||
-- local vars
|
-- local variables
|
||||||
local Module = {}
|
local Module = {}
|
||||||
|
|
||||||
--- Measures distance between pos1 and pos2
|
--- Measures distance between pos1 and pos2
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ local function remove(tbl, handler)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- the handler we are looking for is more likly to be at the back of the array.
|
-- the handler we are looking for is more likely to be at the back of the array.
|
||||||
for i = #tbl, 1, -1 do
|
for i = #tbl, 1, -1 do
|
||||||
if tbl[i] == handler then
|
if tbl[i] == handler then
|
||||||
table_remove(tbl, i)
|
table_remove(tbl, i)
|
||||||
@@ -272,11 +272,11 @@ function Event.add_removable_function(event_name, func)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
local funcs = function_handlers[event_name]
|
local functions = function_handlers[event_name]
|
||||||
if not funcs then
|
if not functions then
|
||||||
function_handlers[event_name] = {func}
|
function_handlers[event_name] = {func}
|
||||||
else
|
else
|
||||||
funcs[#funcs + 1] = func
|
functions[#functions + 1] = func
|
||||||
end
|
end
|
||||||
|
|
||||||
if handlers_added then
|
if handlers_added then
|
||||||
@@ -293,15 +293,15 @@ function Event.remove_removable_function(event_name, func)
|
|||||||
if _LIFECYCLE == stage_load then
|
if _LIFECYCLE == stage_load then
|
||||||
error('cannot call during on_load', 2)
|
error('cannot call during on_load', 2)
|
||||||
end
|
end
|
||||||
local funcs = function_handlers[event_name]
|
local functions = function_handlers[event_name]
|
||||||
|
|
||||||
if not funcs then
|
if not functions then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local handlers = event_handlers[event_name]
|
local handlers = event_handlers[event_name]
|
||||||
|
|
||||||
remove(funcs, func)
|
remove(functions, func)
|
||||||
remove(handlers, func)
|
remove(handlers, func)
|
||||||
|
|
||||||
if #handlers == 0 then
|
if #handlers == 0 then
|
||||||
@@ -382,11 +382,11 @@ function Event.add_removable_nth_tick_function(tick, func)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
local funcs = function_nth_tick_handlers[tick]
|
local functions = function_nth_tick_handlers[tick]
|
||||||
if not funcs then
|
if not functions then
|
||||||
function_nth_tick_handlers[tick] = {func}
|
function_nth_tick_handlers[tick] = {func}
|
||||||
else
|
else
|
||||||
funcs[#funcs + 1] = func
|
functions[#functions + 1] = func
|
||||||
end
|
end
|
||||||
|
|
||||||
if handlers_added then
|
if handlers_added then
|
||||||
@@ -403,15 +403,15 @@ function Event.remove_removable_nth_tick_function(tick, func)
|
|||||||
if _LIFECYCLE == stage_load then
|
if _LIFECYCLE == stage_load then
|
||||||
error('cannot call during on_load', 2)
|
error('cannot call during on_load', 2)
|
||||||
end
|
end
|
||||||
local funcs = function_nth_tick_handlers[tick]
|
local functions = function_nth_tick_handlers[tick]
|
||||||
|
|
||||||
if not funcs then
|
if not functions then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local handlers = on_nth_tick_event_handlers[tick]
|
local handlers = on_nth_tick_event_handlers[tick]
|
||||||
|
|
||||||
remove(funcs, func)
|
remove(functions, func)
|
||||||
remove(handlers, func)
|
remove(handlers, func)
|
||||||
|
|
||||||
if #handlers == 0 then
|
if #handlers == 0 then
|
||||||
@@ -427,9 +427,9 @@ local function add_handlers()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for event_name, funcs in pairs(function_handlers) do
|
for event_name, functions in pairs(function_handlers) do
|
||||||
for i = 1, #funcs do
|
for i = 1, #functions do
|
||||||
local handler = funcs[i]
|
local handler = functions[i]
|
||||||
core_add(event_name, handler)
|
core_add(event_name, handler)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -441,9 +441,9 @@ local function add_handlers()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for tick, funcs in pairs(function_nth_tick_handlers) do
|
for tick, functions in pairs(function_nth_tick_handlers) do
|
||||||
for i = 1, #funcs do
|
for i = 1, #functions do
|
||||||
local handler = funcs[i]
|
local handler = functions[i]
|
||||||
core_on_nth_tick(tick, handler)
|
core_on_nth_tick(tick, handler)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ end
|
|||||||
--- Returns the flow where top elements can be added and will be effected by google visibility
|
--- Returns the flow where top elements can be added and will be effected by google visibility
|
||||||
-- For the toggle to work it must be registed with Gui.allow_player_to_toggle_top_element_visibility(element_name)
|
-- For the toggle to work it must be registed with Gui.allow_player_to_toggle_top_element_visibility(element_name)
|
||||||
-- @tparam LuaPlayer player pointer to the player who has the gui
|
-- @tparam LuaPlayer player pointer to the player who has the gui
|
||||||
-- @treturn LuaGuiEelement the top element flow
|
-- @treturn LuaGuiElement the top element flow
|
||||||
function Gui.get_top_element_flow(player)
|
function Gui.get_top_element_flow(player)
|
||||||
player = Game.get_player_from_any(player)
|
player = Game.get_player_from_any(player)
|
||||||
return mod_gui.get_button_flow(player)
|
return mod_gui.get_button_flow(player)
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ math.clamp = function(num, min, max)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Takes two points and calculates the slope of a line
|
--- Takes two points and calculates the slope of a line
|
||||||
-- @param x1, y1 numbers - cordinates of a point on a line
|
-- @param x1, y1 numbers - coordinates of a point on a line
|
||||||
-- @param x2, y2 numbers - cordinates of a point on a line
|
-- @param x2, y2 numbers - coordinates of a point on a line
|
||||||
-- @return number - the slope of the line
|
-- @return number - the slope of the line
|
||||||
math.calculate_slope = function(x1, y1, x2, y2)
|
math.calculate_slope = function(x1, y1, x2, y2)
|
||||||
return math.abs((y2 - y1) / (x2 - x1))
|
return math.abs((y2 - y1) / (x2 - x1))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ local tostring = tostring
|
|||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local format = string.format
|
local format = string.format
|
||||||
|
|
||||||
--- Contains a set of callables that will attempt to sanitize and transform the input
|
--- Contains a set of callable that will attempt to sanitize and transform the input
|
||||||
local settings_type = {
|
local settings_type = {
|
||||||
fraction = function (input)
|
fraction = function (input)
|
||||||
input = tonumber(input)
|
input = tonumber(input)
|
||||||
@@ -163,7 +163,7 @@ function Public.get(player_index, name)
|
|||||||
return player_setting ~= nil and player_setting or setting.default
|
return player_setting ~= nil and player_setting or setting.default
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns a table of all settings for a given player in a key => value setup
|
---Returns a table of all settings for a given player in a key => value set-up
|
||||||
---@param player_index number
|
---@param player_index number
|
||||||
function Public.all(player_index)
|
function Public.all(player_index)
|
||||||
local player_settings = memory[player_index] or {}
|
local player_settings = memory[player_index] or {}
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ local function month_length(m, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function day_of_year(day, month, year)
|
local function day_of_year(day, month, year)
|
||||||
local yday = months_to_days_cumulative[month]
|
local y_day = months_to_days_cumulative[month]
|
||||||
if month > 2 and is_leap(year) then
|
if month > 2 and is_leap(year) then
|
||||||
yday = yday + 1
|
y_day = y_day + 1
|
||||||
end
|
end
|
||||||
return yday + day
|
return y_day + day
|
||||||
end
|
end
|
||||||
|
|
||||||
local function leap_years_since(year)
|
local function leap_years_since(year)
|
||||||
@@ -80,7 +80,7 @@ local function normalise(year, month, day, hour, min, sec)
|
|||||||
|
|
||||||
-- Propagate out of range values up
|
-- Propagate out of range values up
|
||||||
-- e.g. if `min` is 70, `hour` increments by 1 and `min` becomes 10
|
-- e.g. if `min` is 70, `hour` increments by 1 and `min` becomes 10
|
||||||
-- This has to happen for all columns after borrowing, as lower radixes may be pushed out of range
|
-- This has to happen for all columns after borrowing, as lower radix's may be pushed out of range
|
||||||
min, sec = carry(min, sec, 60) -- TODO: consider leap seconds?
|
min, sec = carry(min, sec, 60) -- TODO: consider leap seconds?
|
||||||
hour, min = carry(hour, min, 60)
|
hour, min = carry(hour, min, 60)
|
||||||
day, hour = carry(day, hour, 24)
|
day, hour = carry(day, hour, 24)
|
||||||
@@ -119,10 +119,10 @@ local function normalise(year, month, day, hour, min, sec)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Converts unix epoch timestamp into table {year: number, month: number, day: number, hour: number, min: number, sec: number}
|
--- Converts unix epoch timestamp into table {year: number, month: number, day: number, hour: number, min: number, sec: number}
|
||||||
-- @param sec<number> unix epoch timestamp
|
-- @param seconds<number> unix epoch timestamp
|
||||||
-- @return {year: number, month: number, day: number, hour: number, min: number, sec: number}
|
-- @return {year: number, month: number, day: number, hour: number, min: number, sec: number}
|
||||||
function Public.to_timetable(secs)
|
function Public.to_timetable(seconds)
|
||||||
return normalise(1970, 1, 1, 0, 0, secs)
|
return normalise(1970, 1, 1, 0, 0, seconds)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Converts timetable into unix epoch timestamp
|
--- Converts timetable into unix epoch timestamp
|
||||||
@@ -142,10 +142,10 @@ function Public.from_timetable(timetable)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Converts unix epoch timestamp into human readable string.
|
--- Converts unix epoch timestamp into human readable string.
|
||||||
-- @param secs<type> unix epoch timestamp
|
-- @param seconds<type> unix epoch timestamp
|
||||||
-- @return string
|
-- @return string
|
||||||
function Public.to_string(secs)
|
function Public.to_string(seconds)
|
||||||
local tt = normalise(1970, 1, 1, 0, 0, secs)
|
local tt = normalise(1970, 1, 1, 0, 0, seconds)
|
||||||
return strformat('%04u-%02u-%02u %02u:%02u:%02d', tt.year, tt.month, tt.day, tt.hour, tt.min, tt.sec)
|
return strformat('%04u-%02u-%02u %02u:%02u:%02d', tt.year, tt.month, tt.day, tt.hour, tt.min, tt.sec)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ local tokens = {}
|
|||||||
|
|
||||||
local counter = 0
|
local counter = 0
|
||||||
|
|
||||||
--- Assigns a unquie id for the given var.
|
--- Assigns a unique id for the given var.
|
||||||
-- This function cannot be called after on_init() or on_load() has run as that is a desync risk.
|
-- This function cannot be called after on_init() or on_load() has run as that is a desync risk.
|
||||||
-- Typically this is used to register functions, so the id can be stored in the global table
|
-- Typically this is used to register functions, so the id can be stored in the global table
|
||||||
-- instead of the function. This is becasue closures cannot be safely stored in the global table.
|
-- instead of the function. This is because closures cannot be safely stored in the global table.
|
||||||
-- @param var<any>
|
-- @param var<any>
|
||||||
-- @return number the unique token for the variable.
|
-- @return number the unique token for the variable.
|
||||||
function Token.register(var)
|
function Token.register(var)
|
||||||
|
|||||||
Reference in New Issue
Block a user