mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-01-01 13:11:40 +09:00
Merge branch 'feature/player-list' into dev
This commit is contained in:
@@ -26,19 +26,20 @@ return {
|
|||||||
'modules.addons.chat-popups',
|
'modules.addons.chat-popups',
|
||||||
'modules.addons.damage-popups',
|
'modules.addons.damage-popups',
|
||||||
'modules.addons.death-logger',
|
'modules.addons.death-logger',
|
||||||
'modules.addons.advanced-starting-items',
|
'modules.addons.advanced-start',
|
||||||
'modules.addons.spawn-area',
|
'modules.addons.spawn-area',
|
||||||
'modules.addons.compilatron',
|
'modules.addons.compilatron',
|
||||||
'modules.addons.scorched-earth',
|
'modules.addons.scorched-earth',
|
||||||
'modules.addons.pollution-grading',
|
'modules.addons.pollution-grading',
|
||||||
'modules.addons.random-player-colours',
|
'modules.addons.random-player-colours',
|
||||||
-- GUI
|
-- GUI
|
||||||
|
'modules.gui.player-list',
|
||||||
'modules.commands.debug',
|
'modules.commands.debug',
|
||||||
-- Config Files
|
-- Config Files
|
||||||
'config.command_auth_admin', -- commands tagged with admin_only are blocked for non admins
|
'config.expcore-commands.auth_admin', -- commands tagged with admin_only are blocked for non admins
|
||||||
'config.command_auth_roles', -- commands must be allowed via the role config
|
'config.expcore-commands.auth_roles', -- commands must be allowed via the role config
|
||||||
'config.command_auth_runtime_disable', -- allows commands to be enabled and disabled during runtime
|
'config.expcore-commands.auth_runtime_disable', -- allows commands to be enabled and disabled during runtime
|
||||||
'config.permission_groups', -- loads some predefined permission groups
|
'config.permission_groups', -- loads some predefined permission groups
|
||||||
'config.roles', -- loads some predefined roles
|
'config.roles', -- loads some predefined roles
|
||||||
'expcore.gui.test'
|
'expcore.gui.test' -- loads multiple gui defines to test the gui system
|
||||||
}
|
}
|
||||||
192
config/action_buttons.lua
Normal file
192
config/action_buttons.lua
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
local Gui = require 'expcore.gui'
|
||||||
|
local Roles = require 'expcore.roles'
|
||||||
|
local Store = require 'expcore.store'
|
||||||
|
local Game = require 'utils.game'
|
||||||
|
local Reports = require 'modules.addons.reports-control'
|
||||||
|
local Jail = require 'modules.addons.jail-control'
|
||||||
|
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||||
|
|
||||||
|
local action_player_store = 'gui.left.player-list.action-player'
|
||||||
|
local action_name_store = 'gui.left.player-list.action-name'
|
||||||
|
|
||||||
|
local function tool_button_style(style)
|
||||||
|
Gui.set_padding_style(style,-1,-1,-1,-1)
|
||||||
|
style.height = 28
|
||||||
|
style.width = 28
|
||||||
|
end
|
||||||
|
|
||||||
|
local function auth_lower_role(player,action_player_name)
|
||||||
|
local player_highest = Roles.get_player_highest_role(player)
|
||||||
|
local action_player_highest = Roles.get_player_highest_role(action_player_name)
|
||||||
|
if player_highest.index < action_player_highest.index then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_action_player(player)
|
||||||
|
local action_player_name = Store.get_child(action_player_store,player.name)
|
||||||
|
local action_player = Game.get_player_from_any(action_player_name)
|
||||||
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
|
return action_player,action_player_name_color
|
||||||
|
end
|
||||||
|
|
||||||
|
local function teleport(from_player,to_player)
|
||||||
|
local surface = to_player.surface
|
||||||
|
local position = surface.find_non_colliding_position('character',to_player.position,32,1)
|
||||||
|
if not position then return false end -- return false if no new position
|
||||||
|
if from_player.driving then from_player.driving = false end -- kicks a player out a vehicle if in one
|
||||||
|
from_player.teleport(position,surface)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local goto_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/export')
|
||||||
|
:set_tooltip{'player-list.goto-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
teleport(player,action_player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local bring_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/import')
|
||||||
|
:set_tooltip{'player-list.bring-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
teleport(action_player,player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local kill_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/too_far')
|
||||||
|
:set_tooltip{'player-list.kill-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
if action_player.character then
|
||||||
|
action_player.character.die()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local report_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/spawn_flag')
|
||||||
|
:set_tooltip{'player-list.report-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_name_store,player.name,'command/report')
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function report_player_callback(player,reason)
|
||||||
|
local action_player,action_player_name_color = get_action_player(player)
|
||||||
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
|
game.print{'expcom-report.non-admin',action_player_name_color,reason}
|
||||||
|
Roles.print_to_roles_higher('Trainee',{'expcom-report.admin',action_player_name_color,by_player_name_color,reason})
|
||||||
|
Reports.report_player(action_player,reason,player.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
local jail_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/item_editor_icon')
|
||||||
|
:set_tooltip{'player-list.jail-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_name_store,player.name,'command/jail')
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function jail_player_callback(player,reason)
|
||||||
|
local action_player,action_player_name_color = get_action_player(player)
|
||||||
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
|
game.print{'expcom-jail.give',action_player_name_color,by_player_name_color,reason}
|
||||||
|
Jail.jail_player(action_player,player.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
local temp_ban_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/clock')
|
||||||
|
:set_tooltip{'player-list.temp-ban-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_name_store,player.name,'command/temp-ban')
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function temp_ban_player_callback(player,reason)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
Jail.temp_ban_player(action_player,player.name,reason)
|
||||||
|
end
|
||||||
|
|
||||||
|
local kick_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/warning_icon')
|
||||||
|
:set_tooltip{'player-list.kick-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_name_store,player.name,'command/kick')
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function kick_player_callback(player,reason)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
game.kick_player(action_player,reason)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ban_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/danger_icon')
|
||||||
|
:set_tooltip{'player-list.ban-player'}
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_name_store,player.name,'command/ban')
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function ban_player_callback(player,reason)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
game.ban_player(action_player,reason)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
['command/teleport'] = {
|
||||||
|
auth=function(player,action_player_name)
|
||||||
|
return player.name ~= action_player_name
|
||||||
|
end,
|
||||||
|
goto_player,
|
||||||
|
bring_player
|
||||||
|
},
|
||||||
|
['command/kill'] = {
|
||||||
|
auth=function(player,action_player_name)
|
||||||
|
if player.name == action_player_name then
|
||||||
|
return true
|
||||||
|
elseif Roles.player_allowed(player,'command/kill/always') then
|
||||||
|
return auth_lower_role(player,action_player_name)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
kill_player
|
||||||
|
},
|
||||||
|
['command/report'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
reason_callback=report_player_callback,
|
||||||
|
report_player
|
||||||
|
},
|
||||||
|
['command/jail'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
reason_callback=jail_player_callback,
|
||||||
|
jail_player
|
||||||
|
},
|
||||||
|
['command/temp-ban'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
reason_callback=temp_ban_player_callback,
|
||||||
|
temp_ban_player
|
||||||
|
},
|
||||||
|
['command/kick'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
reason_callback=kick_player_callback,
|
||||||
|
kick_player
|
||||||
|
},
|
||||||
|
['command/ban'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
reason_callback=ban_player_callback,
|
||||||
|
ban_player
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[command-auth]
|
|
||||||
admin-only=This command is for (game) admins only!
|
|
||||||
command-disabled=This command has been disabled by management!
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
local auto_complete = ext_require('expcore.common','auto_complete')
|
local auto_complete = ext_require('expcore.common','auto_complete')
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
Commands.add_parse('role',function(input,player,reject)
|
Commands.add_parse('role',function(input,player,reject)
|
||||||
if not input then return end
|
if not input then return end
|
||||||
@@ -94,6 +94,8 @@ Roles.new_role('Trainee','TrMod')
|
|||||||
'command/give-warning',
|
'command/give-warning',
|
||||||
'command/get-warnings',
|
'command/get-warnings',
|
||||||
'command/get-reports',
|
'command/get-reports',
|
||||||
|
'command/kick',
|
||||||
|
'command/ban',
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Trusted Roles
|
--- Trusted Roles
|
||||||
@@ -181,6 +183,7 @@ local default = Roles.new_role('Guest','')
|
|||||||
'command/chelp',
|
'command/chelp',
|
||||||
'command/list-roles',
|
'command/list-roles',
|
||||||
'command/report',
|
'command/report',
|
||||||
|
'gui/player-list',
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Jail role
|
--- Jail role
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ ext_require = require('expcore.common').ext_require
|
|||||||
|
|
||||||
-- Please go to config/file_loader.lua to edit the files that are loaded
|
-- Please go to config/file_loader.lua to edit the files that are loaded
|
||||||
log('[INFO] Getting file loader config')
|
log('[INFO] Getting file loader config')
|
||||||
local files = require 'config.file_loader'
|
local files = require 'config._file_loader'
|
||||||
|
|
||||||
-- Loads all files from the config and logs that they are loaded
|
-- Loads all files from the config and logs that they are loaded
|
||||||
local total_file_count = string.format('%3d',#files)
|
local total_file_count = string.format('%3d',#files)
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ local Gui = require 'expcore.gui.core'
|
|||||||
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
|
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
|
||||||
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
|
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
|
||||||
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
|
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
|
||||||
|
Gui._prototype:set_style(style,callback) --- Sets the style for the element define
|
||||||
|
Gui._prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||||
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
|
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
|
||||||
|
|
||||||
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
|
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
|
||||||
@@ -34,6 +36,7 @@ local Gui = require 'expcore.gui.core'
|
|||||||
|
|
||||||
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
|
Gui.toggle_enable(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 visiblity of an element
|
||||||
|
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Instances = require 'expcore.gui.instances'
|
local Instances = require 'expcore.gui.instances'
|
||||||
@@ -195,6 +198,7 @@ Gui.classes.left_frames = LeftFrames
|
|||||||
|
|
||||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
LeftFrames.new_frame(permision_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: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 visiblty of the left frame
|
||||||
|
|||||||
@@ -128,6 +128,8 @@
|
|||||||
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
|
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
|
||||||
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
|
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
|
||||||
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
|
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
|
||||||
|
Gui._prototype:set_style(style,callback) --- Sets the style for the element define
|
||||||
|
Gui._prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||||
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
|
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
|
||||||
|
|
||||||
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
|
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
|
||||||
@@ -149,6 +151,8 @@
|
|||||||
|
|
||||||
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
|
Gui.toggle_enable(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 visiblity of an 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
|
||||||
]]
|
]]
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Game = require 'utils.game'
|
local Game = require 'utils.game'
|
||||||
@@ -316,6 +320,28 @@ function Gui._prototype:set_tooltip(tooltip)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the style for the element define
|
||||||
|
-- @tparam style string the style that will be used for this element when drawn
|
||||||
|
-- @tapram[opt] callback function function is called when element is drawn to alter its style
|
||||||
|
-- @treturn self the element define to allow chaining
|
||||||
|
function Gui._prototype:set_style(style,callback)
|
||||||
|
self.draw_data.style = style
|
||||||
|
self.events.on_style = callback
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- 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
|
||||||
|
-- @treturn self the element define to allow chaining
|
||||||
|
function Gui._prototype:set_embeded_flow(state)
|
||||||
|
if state == false or type(state) == 'function' then
|
||||||
|
self.embeded_flow = state
|
||||||
|
else
|
||||||
|
self.embeded_flow = true
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Sets an authenticator that blocks the draw function if check fails
|
--- Sets an authenticator that blocks the draw function if check fails
|
||||||
-- @tparam callback function the function that will be ran to test if the element should be drawn or not
|
-- @tparam callback function the function that will be ran to test if the element should be drawn or not
|
||||||
-- callback param - player LuaPlayer - the player that the element is being drawn to
|
-- callback param - player LuaPlayer - the player that the element is being drawn to
|
||||||
@@ -358,8 +384,21 @@ function Gui._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
|
||||||
|
local embeded_name
|
||||||
|
if type(self.embeded_flow) == 'function' then
|
||||||
|
embeded_name = self.embeded_flow(element,...)
|
||||||
|
end
|
||||||
|
element = element.add{type='flow',name=embeded_name}
|
||||||
|
Gui.set_padding(element)
|
||||||
|
end
|
||||||
|
|
||||||
local new_element = element.add(self.draw_data)
|
local new_element = element.add(self.draw_data)
|
||||||
|
|
||||||
|
if self.events.on_style then
|
||||||
|
self.events.on_style(new_element.style)
|
||||||
|
end
|
||||||
|
|
||||||
if self.post_authenticator then
|
if self.post_authenticator then
|
||||||
new_element.enabled = self.post_authenticator(player,self.name)
|
new_element.enabled = self.post_authenticator(player,self.name)
|
||||||
end
|
end
|
||||||
@@ -510,4 +549,17 @@ function Gui.set_padding(element,up,down,left,right)
|
|||||||
style.right_padding = right or 0
|
style.right_padding = right or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the padding for a gui style
|
||||||
|
-- @tparam element LuaStyle the element to set the padding for
|
||||||
|
-- @tparam[opt=0] up number the amount of padding on the top
|
||||||
|
-- @tparam[opt=0] down number the amount of padding on the bottom
|
||||||
|
-- @tparam[opt=0] left number the amount of padding on the left
|
||||||
|
-- @tparam[opt=0] right number the amount of padding on the right
|
||||||
|
function Gui.set_padding_style(style,up,down,left,right)
|
||||||
|
style.top_padding = up or 0
|
||||||
|
style.bottom_padding = down or 0
|
||||||
|
style.left_padding = left or 0
|
||||||
|
style.right_padding = right or 0
|
||||||
|
end
|
||||||
|
|
||||||
return Gui
|
return Gui
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
LeftFrames.new_frame(permision_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: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 visiblty of the left frame
|
||||||
@@ -159,6 +160,13 @@ function LeftFrames._prototype:set_open_by_default(state)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the direction of the frame, either vertical or horizontal
|
||||||
|
-- @tparam direction string the direction to have the elements be added to thef frame
|
||||||
|
function LeftFrames._prototype:set_direction(direction)
|
||||||
|
self.direction = direction
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Gets the frame for this define from the left frame flow
|
--- Gets the frame for this define from the left frame flow
|
||||||
-- @tparam player LuaPlayer the player to get the frame of
|
-- @tparam player LuaPlayer the player to get the frame of
|
||||||
-- @treturn LuaGuiElement the frame in the left frame flow for this define
|
-- @treturn LuaGuiElement the frame in the left frame flow for this define
|
||||||
@@ -212,7 +220,7 @@ end
|
|||||||
-- @tparam player LuaPlayer the player to update the frame of
|
-- @tparam player LuaPlayer the player to update the frame of
|
||||||
function LeftFrames._prototype:redraw(player)
|
function LeftFrames._prototype:redraw(player)
|
||||||
local frame = self:get_frame(player)
|
local frame = self:get_frame(player)
|
||||||
frame.claer()
|
frame.clear()
|
||||||
if self.events.on_draw then
|
if self.events.on_draw then
|
||||||
self.events.on_draw(player,frame)
|
self.events.on_draw(player,frame)
|
||||||
end
|
end
|
||||||
@@ -232,14 +240,17 @@ end
|
|||||||
function LeftFrames._prototype:event_handler(action)
|
function LeftFrames._prototype:event_handler(action)
|
||||||
action = action or 'update'
|
action = action or 'update'
|
||||||
return function(event)
|
return function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player
|
||||||
|
if event.player_index then
|
||||||
|
player = Game.get_player_by_index(event.player_index)
|
||||||
|
end
|
||||||
self[action](self,player)
|
self[action](self,player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
LeftFrames.toggle_button =
|
LeftFrames.toggle_button =
|
||||||
Buttons.new_button()
|
Buttons.new_button()
|
||||||
:set_tooltip('Close Windows')
|
:set_tooltip{'expcore-gui.left-button-tooltip'}
|
||||||
:set_caption('<')
|
:set_caption('<')
|
||||||
:on_click(function(player,element)
|
:on_click(function(player,element)
|
||||||
for _,define in pairs(LeftFrames.frames) do
|
for _,define in pairs(LeftFrames.frames) do
|
||||||
@@ -263,7 +274,8 @@ Event.add(defines.events.on_player_created,function(event)
|
|||||||
for _,define in pairs(LeftFrames.frames) do
|
for _,define in pairs(LeftFrames.frames) do
|
||||||
local frame = flow.add{
|
local frame = flow.add{
|
||||||
type='frame',
|
type='frame',
|
||||||
name=define.name
|
name=define.name,
|
||||||
|
direction=define.direction
|
||||||
}
|
}
|
||||||
|
|
||||||
if define.events.on_draw then
|
if define.events.on_draw then
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
[expcore-commands]
|
|
||||||
unauthorized=401 - Unbefugt: Zugang verweigert. Du hast keinen Zugriff auf diese Befehle!
|
|
||||||
reject-number-range=ungültige Reichweite, Min: __1__, Max: __2__
|
|
||||||
reject-string-max-length=ungültige Länge, Max: __1__
|
|
||||||
reject-player=ungültiger Spieler Name, __1__ , Versuche "Tab" zu benutzen, damit sich der Name automatisch vervollständigt.
|
|
||||||
reject-player-online=Der betroffene Spieler ist offline, Befehl konnte nicht ausgeführt werden.
|
|
||||||
reject-player-alive=Der betroffene Spieler ist Tod, Befehl konnte nicht ausgeführt werden.
|
|
||||||
invalid-inputs=ungültige Eingabe, /__1__ __2__
|
|
||||||
command-ran=Befehl ausgeführt.
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
time-symbol-days-short=__1__d
|
|
||||||
|
|
||||||
[expcore-commands]
|
|
||||||
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
|
||||||
reject-string-options=Invalid Option, Must be one of: __1__
|
|
||||||
reject-string-max-length=Invalid Length, Max: __1__
|
|
||||||
reject-number=Invalid Number.
|
|
||||||
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__
|
|
||||||
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
|
||||||
reject-player-online=Player is offline.
|
|
||||||
reject-player-alive=Player is dead.
|
|
||||||
reject-force=Invaild Force Name.
|
|
||||||
reject-surface=Invaild Surface Name.
|
|
||||||
invalid-inputs=Invalid Input, /__1__ __2__
|
|
||||||
invalid-param=Invalid Param "__1__"; __2__
|
|
||||||
command-help=__1__ - __2__
|
|
||||||
command-ran=Command Complete
|
|
||||||
command-fail=Command failed to run: __1__
|
|
||||||
command-error-log-format=[ERROR] command/__1__ :: __2__
|
|
||||||
|
|
||||||
[expcore-roles]
|
|
||||||
error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
|
|
||||||
error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__
|
|
||||||
game-message-assign=__1__ has been assigned to __2__ by __3__
|
|
||||||
game-message-unassign=__1__ has been unassigned from __2__ by __3__
|
|
||||||
reject-role=Invalid Role Name.
|
|
||||||
reject-player-role=Player has a higher role.
|
|
||||||
|
|
||||||
[gui_util]
|
|
||||||
button_tooltip=Shows / hides the Toolbar Gui buttons.
|
|
||||||
|
|
||||||
[expcore-gui]
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
[expcore-commands]
|
|
||||||
unauthorized=401 - Onbevoegd: toegang wordt geweigerd vanwege ongeldige inloggegevens
|
|
||||||
reject-number-range=Onjuiste radius, Min: __1__, Max: __2__
|
|
||||||
reject-string-max-length=Onjuiste lengte, Max: __1__
|
|
||||||
reject-player=Onjuiste naam, __1__ , probeer tab te gebruiken om de naam automatisch in te vullen
|
|
||||||
reject-player-online=Speler is offline.
|
|
||||||
reject-player-alive=Speler is dood.
|
|
||||||
invalid-inputs=Onjuiste invoer, /__1__ __2__
|
|
||||||
command-ran=Commando uitgevoerd.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
[expcore-commands]
|
|
||||||
unauthorized=401 - Otillåten: Tillgång nekas på grund av otillräcklig säkerhetsprövning.
|
|
||||||
reject-number-range=Invalid räckvid, Min: __1__, Max: __2__
|
|
||||||
reject-string-max-length=ogiltig längd, Max: __1__
|
|
||||||
reject-player=Ogiltigt spelarnamn, __1__ , försök använda tab-tangenten för att auto-slutföra namn.
|
|
||||||
reject-player-online=Spelare är offline. Kommando misslyckades med att köras.
|
|
||||||
reject-player-alive=Spelare är död. Kommando misslyckades med att köras.
|
|
||||||
invalid-inputs=Igiltig inmatning, /__1__ __2__
|
|
||||||
command-ran=Kommandot slutfört
|
|
||||||
@@ -1,38 +1,56 @@
|
|||||||
[exp-commands]
|
[expcom-kill]
|
||||||
kill-already-dead=You are already dead.
|
already-dead=You are already dead.
|
||||||
admin-chat-format=[Admin Chat] __1__: __2__
|
|
||||||
tp-no-position-found=No position to teleport to was found, please try again later.
|
[expcom-admin-chat]
|
||||||
tp-to-self=Player can not be teleported to themselves.
|
format=[Admin Chat] __1__: __2__
|
||||||
chelp-title=Help results for "__1__":
|
|
||||||
chelp-footer=[__1__ results found; page __2__ of __3__]
|
[expcom-tp]
|
||||||
chelp-format=/__1__ __2__ - __3__ __4__
|
no-position-found=No position to teleport to was found, please try again later.
|
||||||
chelp-alias=Alias: __1__
|
to-self=Player can not be teleported to themselves.
|
||||||
chelp-out-of-range=__1__ is an invalid page number.
|
|
||||||
roles-higher-role=The role you tried to assign is higher than your highest.
|
[expcom-chelp]
|
||||||
roles-list=All roles are: __1__
|
title=Help results for "__1__":
|
||||||
roles-list-player=__1__ has: __2__
|
footer=[__1__ results found; page __2__ of __3__]
|
||||||
roles-list-element=__1__, __2__
|
format=/__1__ __2__ - __3__ __4__
|
||||||
jail-give=__1__ was jailed by __2__. Reason: __3__
|
alias=Alias: __1__
|
||||||
jail-remove=__1__ was unjailed by __2__.
|
out-of-range=__1__ is an invalid page number.
|
||||||
jail-already-jailed=__1__ is already in jail.
|
|
||||||
jail-not-jailed=__1__ is not currently in jail.
|
[expcom-roles]
|
||||||
jail-temp-ban=__1__ was temp banned until next reset by __2__. Reason: __3__
|
higher-role=The role you tried to assign is higher than your highest.
|
||||||
jail-temp-ban-clear=__1__ was cleared from temp banned by __2__.
|
list=All roles are: __1__
|
||||||
jail-not-temp-banned=__1__ is not currently temp banned.
|
list-player=__1__ has: __2__
|
||||||
jail-already-banned=__1__ is already banned.
|
list-element=__1__, __2__
|
||||||
report-player-immune=This player can not be reported.
|
|
||||||
report-non-admin=__1__ was reported for __2__.
|
[expcom-jail]
|
||||||
report-admin=__1__ was reported by __2__ for __3__.
|
give=__1__ was jailed by __2__. Reason: __3__
|
||||||
report-already-reported=You can only report a player once, you can ask a moderator to clear this report.
|
remove=__1__ was unjailed by __2__.
|
||||||
report-not-reported=The player had no reports on them.
|
already-jailed=__1__ is already in jail.
|
||||||
report-player-count-title=The following players have reports against them:
|
not-jailed=__1__ is not currently in jail.
|
||||||
report-player-report-title=__1__ has the following reports agasinst them:
|
temp-ban=__1__ was temp banned until next reset by __2__. Reason: __3__
|
||||||
report-list=__1__: __2__
|
temp-ban-clear=__1__ was cleared from temp banned by __2__.
|
||||||
report-removed=__1__ has one or more reports removed by __2__.
|
not-temp-banned=__1__ is not currently temp banned.
|
||||||
warnings-received=__1__ recived a warning from __2__ for __3__.
|
already-banned=__1__ is already banned.
|
||||||
warnings-player=__1__ has __2__ warnings and __3__/__4__ script warnings.
|
|
||||||
warnings-list-tilte=The following player have this many warnings (and this many script warnings):
|
[expcom-report]
|
||||||
warnings-list=__1__: __2__ (__3__/__4__)
|
player-immune=This player can not be reported.
|
||||||
warnings-cleared=__1__ had all they warnings cleared by __2__.
|
non-admin=__1__ was reported for __2__.
|
||||||
spawn-unavailable=They was a problem getting you to spawn, please try again later.
|
admin=__1__ was reported by __2__ for __3__.
|
||||||
repair-result=__1__ entites were revived and __2__ were healed to max health.
|
already-reported=You can only report a player once, you can ask a moderator to clear this report.
|
||||||
|
not-reported=The player had no reports on them.
|
||||||
|
player-count-title=The following players have reports against them:
|
||||||
|
player-report-title=__1__ has the following reports agasinst them:
|
||||||
|
list=__1__: __2__
|
||||||
|
removed=__1__ has one or more reports removed by __2__.
|
||||||
|
|
||||||
|
[expcom-warnings]
|
||||||
|
received=__1__ recived a warning from __2__ for __3__.
|
||||||
|
player=__1__ has __2__ warnings and __3__/__4__ script warnings.
|
||||||
|
list-tilte=The following player have this many warnings (and this many script warnings):
|
||||||
|
list=__1__: __2__ (__3__/__4__)
|
||||||
|
cleared=__1__ had all they warnings cleared by __2__.
|
||||||
|
|
||||||
|
[expcom-spawn]
|
||||||
|
unavailable=They was a problem getting you to spawn, please try again later.
|
||||||
|
|
||||||
|
[expcom-repair]
|
||||||
|
result=__1__ entites were revived and __2__ were healed to max health.
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
time-symbol-days-short=__1__d
|
time-symbol-days-short=__1__d
|
||||||
|
color-tag=[color=__1__]__2__[/color]
|
||||||
|
|
||||||
|
[time-format]
|
||||||
|
simple-format-tagged=__1__ __2__
|
||||||
|
simple-format-div=__1__:__2__
|
||||||
|
|
||||||
[expcore-commands]
|
[expcore-commands]
|
||||||
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
||||||
@@ -27,6 +32,7 @@ reject-role=Invalid Role Name.
|
|||||||
reject-player-role=Player has a higher role.
|
reject-player-role=Player has a higher role.
|
||||||
|
|
||||||
[gui_util]
|
[gui_util]
|
||||||
button_tooltip=Shows / hides the Toolbar Gui buttons.
|
button_tooltip=Shows/hides the toolbar.
|
||||||
|
|
||||||
[expcore-gui]
|
[expcore-gui]
|
||||||
|
left-button-tooltip=Hide all open windows.
|
||||||
14
locale/en/gui.cfg
Normal file
14
locale/en/gui.cfg
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[player-list]
|
||||||
|
open-action-bar=Options
|
||||||
|
close-action-bar=Close Options
|
||||||
|
reason-confirm=Confirm Reason
|
||||||
|
reason-entry=Enter Reason
|
||||||
|
goto-player=Goto player
|
||||||
|
bring-player=Bring player
|
||||||
|
kill-player=Kill player
|
||||||
|
report-player=Report player
|
||||||
|
jail-player=Jail player
|
||||||
|
temp-ban-player=Temp ban player
|
||||||
|
kick-player=Kick player
|
||||||
|
ban-player=Ban player
|
||||||
|
afk-time=__1__% of total map time\nLast moved __2__ ago
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
--- Adds a better method of player starting items based on production levels.
|
--- Adds a better method of player starting items based on production levels.
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Game = require 'utils.game'
|
local Game = require 'utils.game'
|
||||||
local config = require 'config.advanced_starting_items'
|
local config = require 'config.advanced_start'
|
||||||
local items = config.items
|
local items = config.items
|
||||||
|
|
||||||
Event.add(defines.events.on_player_created, function(event)
|
Event.add(defines.events.on_player_created, function(event)
|
||||||
@@ -9,15 +9,13 @@ Global.register(config,function(tbl)
|
|||||||
config = tbl
|
config = tbl
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local white = Colours.white
|
|
||||||
local black = Colours.black
|
|
||||||
Event.add(defines.events.on_player_created,function(event)
|
Event.add(defines.events.on_player_created,function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = Game.get_player_by_index(event.player_index)
|
||||||
local color = 'white'
|
local color = 'white'
|
||||||
if config.players[player.name] then
|
if config.players[player.name] then
|
||||||
color = config.players[player.name]
|
color = config.players[player.name]
|
||||||
else
|
else
|
||||||
while not config.disallow[color] do
|
while config.disallow[color] do
|
||||||
color = table.get_random_dictionary_entry(Colours,true)
|
color = table.get_random_dictionary_entry(Colours,true)
|
||||||
end
|
end
|
||||||
color = Colours[color]
|
color = Colours[color]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
|
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
|
||||||
:add_param('message',false) -- the message to send in the admin chat
|
:add_param('message',false) -- the message to send in the admin chat
|
||||||
@@ -11,7 +11,7 @@ Commands.new_command('admin-chat','Sends a message in chat that only admins can
|
|||||||
local player_name_colour = format_chat_player_name(player)
|
local player_name_colour = format_chat_player_name(player)
|
||||||
for _,return_player in pairs(game.connected_players) do
|
for _,return_player in pairs(game.connected_players) do
|
||||||
if return_player.admin then
|
if return_player.admin then
|
||||||
return_player.print{'exp-commands.admin-chat-format',player_name_colour,message}
|
return_player.print{'expcom-admin-chat.format',player_name_colour,message}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return Commands.success -- prevents command complete message from showing
|
return Commands.success -- prevents command complete message from showing
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
Commands.new_command('toggle-cheat-mode','Toggles cheat mode for your player, or another player.')
|
Commands.new_command('toggle-cheat-mode','Toggles cheat mode for your player, or another player.')
|
||||||
:add_param('player',true,'player') -- player to toggle chest mode of, can be nil for self
|
:add_param('player',true,'player') -- player to toggle chest mode of, can be nil for self
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local move_items = ext_require('expcore.common','move_items')
|
local move_items = ext_require('expcore.common','move_items')
|
||||||
require 'config.command_parse_roles'
|
require 'config.expcore-commands.parse_roles'
|
||||||
|
|
||||||
Commands.new_command('clear-inventory','Clears a players inventory')
|
Commands.new_command('clear-inventory','Clears a players inventory')
|
||||||
:add_param('player',false,'player-role-alive')
|
:add_param('player',false,'player-role-alive')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
local results_per_page = 5
|
local results_per_page = 5
|
||||||
|
|
||||||
@@ -42,9 +42,9 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
|
|||||||
-- adds the new command to the page
|
-- adds the new command to the page
|
||||||
page_count = page_count + 1
|
page_count = page_count + 1
|
||||||
found = found + 1
|
found = found + 1
|
||||||
local alias_format = #command_data.aliases > 0 and {'exp-commands.chelp-alias',table.concat(command_data.aliases,', ')} or ''
|
local alias_format = #command_data.aliases > 0 and {'expcom-chelp.alias',table.concat(command_data.aliases,', ')} or ''
|
||||||
table.insert(pages[current_page],{
|
table.insert(pages[current_page],{
|
||||||
'exp-commands.chelp-format',
|
'expcom-chelp.format',
|
||||||
command_data.name,
|
command_data.name,
|
||||||
command_data.description,
|
command_data.description,
|
||||||
command_data.help,
|
command_data.help,
|
||||||
@@ -60,15 +60,15 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
|
|||||||
end
|
end
|
||||||
-- print the requested page
|
-- print the requested page
|
||||||
keyword = keyword == '' and '<all>' or keyword
|
keyword = keyword == '' and '<all>' or keyword
|
||||||
Commands.print({'exp-commands.chelp-title',keyword},'cyan')
|
Commands.print({'expcom-chelp.title',keyword},'cyan')
|
||||||
if pages[page] then
|
if pages[page] then
|
||||||
for _,command in pairs(pages[page]) do
|
for _,command in pairs(pages[page]) do
|
||||||
Commands.print(command)
|
Commands.print(command)
|
||||||
end
|
end
|
||||||
Commands.print({'exp-commands.chelp-footer',found,page,#pages},'cyan')
|
Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
|
||||||
else
|
else
|
||||||
Commands.print({'exp-commands.chelp-footer',found,page,#pages},'cyan')
|
Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
|
||||||
return Commands.error{'exp-commands.chelp-out-of-range',page}
|
return Commands.error{'expcom-chelp.out-of-range',page}
|
||||||
end
|
end
|
||||||
-- blocks command complete message
|
-- blocks command complete message
|
||||||
return Commands.success
|
return Commands.success
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local JailControl = require 'modules.addons.jail-control'
|
local JailControl = require 'modules.addons.jail-control'
|
||||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||||
require 'config.command_parse_roles'
|
require 'config.expcore-commands.parse_roles'
|
||||||
|
|
||||||
Commands.new_command('jail','Puts a player into jail and removes all other roles.')
|
Commands.new_command('jail','Puts a player into jail and removes all other roles.')
|
||||||
:add_param('player',false,'player-role')
|
:add_param('player',false,'player-role')
|
||||||
@@ -12,9 +12,9 @@ Commands.new_command('jail','Puts a player into jail and removes all other roles
|
|||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
if JailControl.jail_player(action_player,player.name) then
|
if JailControl.jail_player(action_player,player.name) then
|
||||||
game.print{'exp-commands.jail-give',action_player_name_color,by_player_name_color,reason}
|
game.print{'expcom-jail.give',action_player_name_color,by_player_name_color,reason}
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.jail-already-jailed',action_player_name_color}
|
return Commands.error{'expcom-jail.already-jailed',action_player_name_color}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -26,9 +26,9 @@ Commands.new_command('unjail','Puts a player into jail and removes all other rol
|
|||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
if JailControl.unjail_player(action_player,player.name) then
|
if JailControl.unjail_player(action_player,player.name) then
|
||||||
game.print{'exp-commands.jail-remove',action_player_name_color,by_player_name_color}
|
game.print{'expcom-jail.remove',action_player_name_color,by_player_name_color}
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.jail-not-jailed',action_player_name_color}
|
return Commands.error{'expcom-jail.not-jailed',action_player_name_color}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -40,9 +40,9 @@ Commands.new_command('temp-ban','Temp bans a player until the next reset; this r
|
|||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
if JailControl.temp_ban_player(action_player,player.name,reason) then
|
if JailControl.temp_ban_player(action_player,player.name,reason) then
|
||||||
game.print{'exp-commands.jail-temp-ban',action_player_name_color,by_player_name_color,reason}
|
game.print{'expcom-jail.temp-ban',action_player_name_color,by_player_name_color,reason}
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.jail-already-banned',action_player_name_color}
|
return Commands.error{'expcom-jail.already-banned',action_player_name_color}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -54,8 +54,8 @@ Commands.new_command('clear-temp-ban','Removes temp ban from a player; this will
|
|||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
if JailControl.clear_temp_ban_player(action_player,player.name) then
|
if JailControl.clear_temp_ban_player(action_player,player.name) then
|
||||||
game.print{'exp-commands.jail-temp-ban-clear',action_player_name_color,by_player_name_color}
|
game.print{'expcom-jail.temp-ban-clear',action_player_name_color,by_player_name_color}
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.jail-not-temp-banned',action_player_name_color}
|
return Commands.error{'expcom-jail.not-temp-banned',action_player_name_color}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
require 'config.command_parse_roles'
|
require 'config.expcore-commands.parse_roles'
|
||||||
|
|
||||||
Commands.new_command('kill','Kills yourself or another player.')
|
Commands.new_command('kill','Kills yourself or another player.')
|
||||||
:add_param('player',true,'player-role-alive') -- the player to kill, must be alive to be valid
|
:add_param('player',true,'player-role-alive') -- the player to kill, must be alive to be valid
|
||||||
@@ -14,7 +14,7 @@ end}
|
|||||||
:register(function(player,action_player,raw)
|
:register(function(player,action_player,raw)
|
||||||
if not action_player then
|
if not action_player then
|
||||||
-- can only be nil if no player given and the user is dead
|
-- can only be nil if no player given and the user is dead
|
||||||
return Commands.error{'exp-commands.kill-already-dead'}
|
return Commands.error{'expcom-kill.already-dead'}
|
||||||
end
|
end
|
||||||
if player == action_player then
|
if player == action_player then
|
||||||
action_player.character.die()
|
action_player.character.die()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local config = require 'config.repair'
|
local config = require 'config.repair'
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
local max_time_to_live = 4294967295 -- unit32 max
|
local max_time_to_live = 4294967295 -- unit32 max
|
||||||
Commands.new_command('repair','Repairs entities on your force around you')
|
Commands.new_command('repair','Repairs entities on your force around you')
|
||||||
@@ -40,5 +40,5 @@ Commands.new_command('repair','Repairs entities on your force around you')
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return Commands.success{'exp-commands.repair-result',revive_count,heal_count}
|
return Commands.success{'expcom-repair.result',revive_count,heal_count}
|
||||||
end)
|
end)
|
||||||
@@ -2,14 +2,14 @@ local Roles = require 'expcore.roles'
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local ReportsControl = require 'modules.addons.reports-control'
|
local ReportsControl = require 'modules.addons.reports-control'
|
||||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
Commands.new_command('report','Reports a player and notifies moderators')
|
Commands.new_command('report','Reports a player and notifies moderators')
|
||||||
:add_param('player',false,function(input,player,reject)
|
:add_param('player',false,function(input,player,reject)
|
||||||
input = Commands.parse('player',input,player,reject)
|
input = Commands.parse('player',input,player,reject)
|
||||||
if not input then return end
|
if not input then return end
|
||||||
if Roles.player_has_flag(input,'report-immune') then
|
if Roles.player_has_flag(input,'report-immune') then
|
||||||
return reject{'exp-commands.report-player-immune'}
|
return reject{'expcom-report.player-immune'}
|
||||||
else
|
else
|
||||||
return input
|
return input
|
||||||
end
|
end
|
||||||
@@ -21,10 +21,10 @@ end)
|
|||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
if ReportsControl.report_player(action_player,reason,player.name) then
|
if ReportsControl.report_player(action_player,reason,player.name) then
|
||||||
game.print{'exp-commands.report-non-admin',action_player_name_color,reason}
|
game.print{'expcom-report.non-admin',action_player_name_color,reason}
|
||||||
Roles.print_to_roles_higher('Trainee',{'exp-commands.report-admin',action_player_name_color,by_player_name_color,reason})
|
Roles.print_to_roles_higher('Trainee',{'expcom-report.admin',action_player_name_color,by_player_name_color,reason})
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.report-already-reported'}
|
return Commands.error{'expcom-report.already-reported'}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -35,18 +35,18 @@ Commands.new_command('get-reports','Gets a list of all reports that a player has
|
|||||||
if action_player then
|
if action_player then
|
||||||
local reports = ReportsControl.get_player_reports(action_player)
|
local reports = ReportsControl.get_player_reports(action_player)
|
||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
Commands.print{'exp-commands.report-player-report-title',action_player_name_color}
|
Commands.print{'expcom-report.player-report-title',action_player_name_color}
|
||||||
for player_name,reason in pairs(reports) do
|
for player_name,reason in pairs(reports) do
|
||||||
local by_player_name_color = format_chat_player_name(player_name)
|
local by_player_name_color = format_chat_player_name(player_name)
|
||||||
Commands.print{'exp-commands.report-list',by_player_name_color,reason}
|
Commands.print{'expcom-report.list',by_player_name_color,reason}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local user_reports = ReportsControl.user_reports
|
local user_reports = ReportsControl.user_reports
|
||||||
Commands.print{'exp-commands.report-player-count-title'}
|
Commands.print{'expcom-report.player-count-title'}
|
||||||
for player_name,reports in pairs(user_reports) do
|
for player_name,reports in pairs(user_reports) do
|
||||||
local player_name_color = format_chat_player_name(player_name)
|
local player_name_color = format_chat_player_name(player_name)
|
||||||
local report_count = ReportsControl.count_player_reports(player_name)
|
local report_count = ReportsControl.count_player_reports(player_name)
|
||||||
Commands.print{'exp-commands.report-list',player_name_color,report_count}
|
Commands.print{'expcom-report.list',player_name_color,report_count}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -57,14 +57,14 @@ Commands.new_command('clear-reports','Clears all reports from a player or just t
|
|||||||
:register(function(player,action_player,from_player,raw)
|
:register(function(player,action_player,from_player,raw)
|
||||||
if from_player then
|
if from_player then
|
||||||
if not ReportsControl.remove_player_report(action_player,from_player.name) then
|
if not ReportsControl.remove_player_report(action_player,from_player.name) then
|
||||||
return Commands.error{'exp-commands.report-not-reported'}
|
return Commands.error{'expcom-report.not-reported'}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not ReportsControl.clear_player_reports(action_player) then
|
if not ReportsControl.clear_player_reports(action_player) then
|
||||||
return Commands.error{'exp-commands.report-not-reported'}
|
return Commands.error{'expcom-report.not-reported'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
game.print{'exp-commands.report-removed',action_player_name_color,by_player_name_color}
|
game.print{'expcom-report.removed',action_player_name_color,by_player_name_color}
|
||||||
end)
|
end)
|
||||||
@@ -16,7 +16,7 @@ Commands.new_command('assign-role','Assigns a role to a player')
|
|||||||
if player_highest.index < role.index then
|
if player_highest.index < role.index then
|
||||||
Roles.assign_player(action_player,role,player.name)
|
Roles.assign_player(action_player,role,player.name)
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.roles-higher-role'}
|
return Commands.error{'expcom-roles.higher-role'}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Commands.new_command('unassign-role','Unassigns a role from a player')
|
|||||||
if player_highest.index < role.index then
|
if player_highest.index < role.index then
|
||||||
Roles.unassign_player(action_player,role,player.name)
|
Roles.unassign_player(action_player,role,player.name)
|
||||||
else
|
else
|
||||||
return Commands.error{'exp-commands.roles-higher-role'}
|
return Commands.error{'expcom-roles.higher-role'}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ Commands.new_command('list-roles','Lists all roles in they correct order')
|
|||||||
:add_alias('lsroles','roles')
|
:add_alias('lsroles','roles')
|
||||||
:register(function(player,action_player,raw)
|
:register(function(player,action_player,raw)
|
||||||
local roles = Roles.config.order
|
local roles = Roles.config.order
|
||||||
local message = {'exp-commands.roles-list'}
|
local message = {'expcom-roles.list'}
|
||||||
if action_player then
|
if action_player then
|
||||||
roles = Roles.get_player_roles(action_player)
|
roles = Roles.get_player_roles(action_player)
|
||||||
end
|
end
|
||||||
@@ -48,13 +48,13 @@ Commands.new_command('list-roles','Lists all roles in they correct order')
|
|||||||
local colour = role.custom_color or Colours.white
|
local colour = role.custom_color or Colours.white
|
||||||
local role_name = format_chat_colour_localized(role.name,colour)
|
local role_name = format_chat_colour_localized(role.name,colour)
|
||||||
if index == 1 then
|
if index == 1 then
|
||||||
message = {'exp-commands.roles-list',role_name}
|
message = {'expcom-roles.list',role_name}
|
||||||
if action_player then
|
if action_player then
|
||||||
local player_name_colour = format_chat_player_name(action_player)
|
local player_name_colour = format_chat_player_name(action_player)
|
||||||
message = {'exp-commands.roles-list-player',player_name_colour,role_name}
|
message = {'expcom-roles.list-player',player_name_colour,role_name}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
message = {'exp-commands.roles-list-element',message,role_name}
|
message = {'expcom-roles.list-element',message,role_name}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return Commands.success(message)
|
return Commands.success(message)
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ Commands.new_command('go-to-spawn','Teleport to spawn')
|
|||||||
:add_alias('spawn','tp-spawn')
|
:add_alias('spawn','tp-spawn')
|
||||||
:register(function(player,action_player)
|
:register(function(player,action_player)
|
||||||
if not action_player then
|
if not action_player then
|
||||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
return Commands.error{'expcom-spawn.unavailable'}
|
||||||
elseif action_player == player then
|
elseif action_player == player then
|
||||||
if not teleport(player) then
|
if not teleport(player) then
|
||||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
return Commands.error{'expcom-spawn.unavailable'}
|
||||||
end
|
end
|
||||||
elseif Roles.player_allowed(player,'command/go-to-spawn/always') then
|
elseif Roles.player_allowed(player,'command/go-to-spawn/always') then
|
||||||
if not teleport(action_player) then
|
if not teleport(action_player) then
|
||||||
return Commands.error{'exp-commands.spawn-unavailable'}
|
return Commands.error{'expcom-spawn.unavailable'}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return Commands.error{'expcore-commands.unauthorized'}
|
return Commands.error{'expcore-commands.unauthorized'}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
require 'config.command_parse_roles'
|
require 'config.expcore-commands.parse_roles'
|
||||||
|
|
||||||
Commands.new_command('tag','Sets your player tag.')
|
Commands.new_command('tag','Sets your player tag.')
|
||||||
:add_param('tag',false,'string-max-length',20) -- new tag for your player max 20 char
|
:add_param('tag',false,'string-max-length',20) -- new tag for your player max 20 char
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
require 'config.command_parse_general'
|
require 'config.expcore-commands.parse_general'
|
||||||
|
|
||||||
local function teleport(from_player,to_player)
|
local function teleport(from_player,to_player)
|
||||||
local surface = to_player.surface
|
local surface = to_player.surface
|
||||||
@@ -18,11 +18,11 @@ Commands.new_command('teleport','Teleports a player to another player.')
|
|||||||
:register(function(player,from_player,to_player,raw)
|
:register(function(player,from_player,to_player,raw)
|
||||||
if from_player.index == to_player.index then
|
if from_player.index == to_player.index then
|
||||||
-- return if attempting to teleport to self
|
-- return if attempting to teleport to self
|
||||||
return Commands.error{'exp-commands.tp-to-self'}
|
return Commands.error{'expcom-tp.to-self'}
|
||||||
end
|
end
|
||||||
if not teleport(from_player,to_player) then
|
if not teleport(from_player,to_player) then
|
||||||
-- return if the teleport failed
|
-- return if the teleport failed
|
||||||
return Commands.error{'exp-commands.tp-no-position-found'}
|
return Commands.error{'expcom-tp.no-position-found'}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -32,11 +32,11 @@ Commands.new_command('bring','Teleports a player to you.')
|
|||||||
:register(function(player,from_player,raw)
|
:register(function(player,from_player,raw)
|
||||||
if from_player.index == player.index then
|
if from_player.index == player.index then
|
||||||
-- return if attempting to teleport to self
|
-- return if attempting to teleport to self
|
||||||
return Commands.error{'exp-commands.tp-to-self'}
|
return Commands.error{'expcom-tp.to-self'}
|
||||||
end
|
end
|
||||||
if not teleport(from_player,player) then
|
if not teleport(from_player,player) then
|
||||||
-- return if the teleport failed
|
-- return if the teleport failed
|
||||||
return Commands.error{'exp-commands.tp-no-position-found'}
|
return Commands.error{'expcom-tp.no-position-found'}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -47,10 +47,10 @@ Commands.new_command('goto','Teleports you to a player.')
|
|||||||
:register(function(player,to_player,raw)
|
:register(function(player,to_player,raw)
|
||||||
if to_player.index == player.index then
|
if to_player.index == player.index then
|
||||||
-- return if attempting to teleport to self
|
-- return if attempting to teleport to self
|
||||||
return Commands.error{'exp-commands.tp-to-self'}
|
return Commands.error{'expcom-tp.to-self'}
|
||||||
end
|
end
|
||||||
if not teleport(player,to_player) then
|
if not teleport(player,to_player) then
|
||||||
-- return if the teleport failed
|
-- return if the teleport failed
|
||||||
return Commands.error{'exp-commands.tp-no-position-found'}
|
return Commands.error{'expcom-tp.no-position-found'}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -2,7 +2,7 @@ local Commands = require 'expcore.commands'
|
|||||||
local WarningsControl = require 'modules.addons.warnings-control'
|
local WarningsControl = require 'modules.addons.warnings-control'
|
||||||
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
|
||||||
local config = require 'config.warnings'
|
local config = require 'config.warnings'
|
||||||
require 'config.command_parse_roles'
|
require 'config.expcore-commands.parse_roles'
|
||||||
|
|
||||||
Commands.new_command('give-warning','Gives a warning to a player; may lead to automatic script action.')
|
Commands.new_command('give-warning','Gives a warning to a player; may lead to automatic script action.')
|
||||||
:add_param('player',false,'player-role')
|
:add_param('player',false,'player-role')
|
||||||
@@ -13,7 +13,7 @@ Commands.new_command('give-warning','Gives a warning to a player; may lead to au
|
|||||||
WarningsControl.add_warnings(action_player,player.name)
|
WarningsControl.add_warnings(action_player,player.name)
|
||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
game.print{'exp-commands.warnings-received',action_player_name_color,by_player_name_color,reason}
|
game.print{'expcom-warnings.received',action_player_name_color,by_player_name_color,reason}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Commands.new_command('get-warnings','Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.')
|
Commands.new_command('get-warnings','Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.')
|
||||||
@@ -24,7 +24,7 @@ Commands.new_command('get-warnings','Gets the number of warnings a player has. I
|
|||||||
local warnings = WarningsControl.get_warnings(action_player)
|
local warnings = WarningsControl.get_warnings(action_player)
|
||||||
local script_warnings = WarningsControl.get_temp_warnings(action_player)
|
local script_warnings = WarningsControl.get_temp_warnings(action_player)
|
||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
Commands.print{'exp-commands.warnings-player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
|
Commands.print{'expcom-warnings.player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
|
||||||
else
|
else
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
local user_warnings = WarningsControl.user_warnings
|
local user_warnings = WarningsControl.user_warnings
|
||||||
@@ -38,10 +38,10 @@ Commands.new_command('get-warnings','Gets the number of warnings a player has. I
|
|||||||
end
|
end
|
||||||
rtn[player_name][2] = #warnings
|
rtn[player_name][2] = #warnings
|
||||||
end
|
end
|
||||||
Commands.print{'exp-commands.warnings-list-tilte'}
|
Commands.print{'expcom-warnings.list-tilte'}
|
||||||
for player_name,warnings in pairs(rtn) do
|
for player_name,warnings in pairs(rtn) do
|
||||||
local player_name_color = format_chat_player_name(player_name)
|
local player_name_color = format_chat_player_name(player_name)
|
||||||
Commands.print{'exp-commands.warnings-list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit}
|
Commands.print{'expcom-warnings.list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -53,5 +53,5 @@ Commands.new_command('clear-warnings','Clears all warnings (and script warnings)
|
|||||||
WarningsControl.clear_temp_warnings(action_player,player.name)
|
WarningsControl.clear_temp_warnings(action_player,player.name)
|
||||||
local action_player_name_color = format_chat_player_name(action_player)
|
local action_player_name_color = format_chat_player_name(action_player)
|
||||||
local by_player_name_color = format_chat_player_name(player)
|
local by_player_name_color = format_chat_player_name(player)
|
||||||
game.print{'exp-commands.warnings-cleared',action_player_name_color,by_player_name_color}
|
game.print{'expcom-warnings.cleared',action_player_name_color,by_player_name_color}
|
||||||
end)
|
end)
|
||||||
319
modules/gui/player-list.lua
Normal file
319
modules/gui/player-list.lua
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
--- Gui left frame define for a player list
|
||||||
|
local Gui = require 'expcore.gui'
|
||||||
|
local Roles = require 'expcore.roles'
|
||||||
|
local Store = require 'expcore.store'
|
||||||
|
local Game = require 'utils.game'
|
||||||
|
local Event = require 'utils.event'
|
||||||
|
local format_time = ext_require('expcore.common','format_time')
|
||||||
|
local config = require 'config.action_buttons'
|
||||||
|
local Colors = require 'resources.color_presets'
|
||||||
|
|
||||||
|
local action_player_store = 'gui.left.player-list.action-player'
|
||||||
|
local action_name_store = 'gui.left.player-list.action-name'
|
||||||
|
|
||||||
|
--- Button used to open the action bar
|
||||||
|
local open_action_bar =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/expand_dots_white')
|
||||||
|
:set_tooltip{'player-list.open-action-bar'}
|
||||||
|
:set_embeded_flow(function(element,action_player_name)
|
||||||
|
return action_player_name
|
||||||
|
end)
|
||||||
|
:set_style('frame_button',function(style)
|
||||||
|
Gui.set_padding_style(style,-2,-2,-2,-2)
|
||||||
|
style.width = 8
|
||||||
|
style.height = 14
|
||||||
|
end)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_player_store,player.name,element.parent.name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- Button used to close the action bar
|
||||||
|
local close_action_bar =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/close_black')
|
||||||
|
:set_tooltip{'player-list.close-action-bar'}
|
||||||
|
:set_style('tool_button',function(style)
|
||||||
|
Gui.set_padding_style(style,-1,-1,-1,-1)
|
||||||
|
style.height = 28
|
||||||
|
style.width = 28
|
||||||
|
end)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
Store.set_child(action_player_store,player.name,nil)
|
||||||
|
Store.set_child(action_name_store,player.name,nil)
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- Button used to confirm a reason
|
||||||
|
local reasonc_confirm =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/confirm_slot')
|
||||||
|
:set_tooltip{'player-list.reason-confirm'}
|
||||||
|
:set_style('tool_button',function(style)
|
||||||
|
Gui.set_padding_style(style,-1,-1,-1,-1)
|
||||||
|
style.height = 28
|
||||||
|
style.width = 28
|
||||||
|
end)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local reason = element.parent.entry.text or 'Non Given'
|
||||||
|
local action_name = Store.get_child(action_name_store,player.name)
|
||||||
|
local reason_callback = config[action_name].reason_callback
|
||||||
|
reason_callback(player,reason)
|
||||||
|
Store.set_child(action_player_store,player.name,nil)
|
||||||
|
Store.set_child(action_name_store,player.name,nil)
|
||||||
|
element.parent.entry.text = ''
|
||||||
|
end)
|
||||||
|
|
||||||
|
--[[ Creates the main gui areas for the player list
|
||||||
|
element
|
||||||
|
> container
|
||||||
|
>> scroll
|
||||||
|
>>> table
|
||||||
|
>> action_bar
|
||||||
|
]]
|
||||||
|
local function generate_container(player,element)
|
||||||
|
Gui.set_padding(element,2,2,2,2)
|
||||||
|
element.style.minimal_width = 200
|
||||||
|
|
||||||
|
-- main container which contains the other elements
|
||||||
|
local container =
|
||||||
|
element.add{
|
||||||
|
name='container',
|
||||||
|
type='frame',
|
||||||
|
direction='vertical',
|
||||||
|
style='window_content_frame_packed'
|
||||||
|
}
|
||||||
|
Gui.set_padding(container)
|
||||||
|
|
||||||
|
-- a scroll bar which allows 8 players to be seen at once
|
||||||
|
local list_scroll =
|
||||||
|
container.add{
|
||||||
|
name='scroll',
|
||||||
|
type='scroll-pane',
|
||||||
|
direction='vertical',
|
||||||
|
horizontal_scroll_policy='never',
|
||||||
|
vertical_scroll_policy='auto-and-reserve-space'
|
||||||
|
}
|
||||||
|
Gui.set_padding(list_scroll,1,1,2,2)
|
||||||
|
list_scroll.style.horizontally_stretchable = true
|
||||||
|
list_scroll.style.maximal_height = 200
|
||||||
|
|
||||||
|
-- 3 wide table to contain: action button, player name, and play time
|
||||||
|
local list_table =
|
||||||
|
list_scroll.add{
|
||||||
|
name='table',
|
||||||
|
type='table',
|
||||||
|
column_count=3
|
||||||
|
}
|
||||||
|
Gui.set_padding(list_table)
|
||||||
|
list_table.style.horizontally_stretchable = true
|
||||||
|
list_table.style.vertical_align = 'center'
|
||||||
|
list_table.style.cell_padding = 0
|
||||||
|
|
||||||
|
-- action bar which contains the different action buttons
|
||||||
|
local action_bar =
|
||||||
|
container.add{
|
||||||
|
name='action_bar',
|
||||||
|
type='frame',
|
||||||
|
style='subfooter_frame'
|
||||||
|
}
|
||||||
|
Gui.set_padding(action_bar,1,1,3,3)
|
||||||
|
action_bar.style.horizontally_stretchable = true
|
||||||
|
action_bar.style.height = 35
|
||||||
|
|
||||||
|
-- reason bar which contains the reason text field and confirm button
|
||||||
|
local reason_bar =
|
||||||
|
container.add{
|
||||||
|
name='reason_bar',
|
||||||
|
type='frame',
|
||||||
|
style='subfooter_frame'
|
||||||
|
}
|
||||||
|
Gui.set_padding(reason_bar,-1,-1,3,3)
|
||||||
|
reason_bar.style.horizontally_stretchable = true
|
||||||
|
reason_bar.style.height = 35
|
||||||
|
local action_name = Store.get_child(action_name_store,player.name)
|
||||||
|
reason_bar.visible = action_name ~= nil
|
||||||
|
|
||||||
|
-- text entry for the reason bar
|
||||||
|
local reason_field =
|
||||||
|
reason_bar.add{
|
||||||
|
name='entry',
|
||||||
|
type='textfield',
|
||||||
|
style='stretchable_textfield',
|
||||||
|
tooltip={'player-list.reason-entry'}
|
||||||
|
}
|
||||||
|
Gui.set_padding(reason_field)
|
||||||
|
reason_field.style.height = 28
|
||||||
|
reason_field.style.minimal_width = 160
|
||||||
|
|
||||||
|
reasonc_confirm(reason_bar)
|
||||||
|
|
||||||
|
return list_table, action_bar
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds buttons and permission flows to the action bar
|
||||||
|
local function generate_action_bar(player,element)
|
||||||
|
close_action_bar(element)
|
||||||
|
local action_player = Store.get_child(action_player_store,player.name)
|
||||||
|
|
||||||
|
for action_name,buttons in pairs(config) do
|
||||||
|
local permission_flow =
|
||||||
|
element.add{
|
||||||
|
type='flow',
|
||||||
|
name=action_name
|
||||||
|
}
|
||||||
|
|
||||||
|
for _,button in ipairs(buttons) do
|
||||||
|
button(permission_flow)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not Roles.player_allowed(player,action_name) then
|
||||||
|
permission_flow.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if buttons.auth and action_player and not buttons.auth(player,action_player) then
|
||||||
|
permission_flow.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not action_player then
|
||||||
|
element.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Updates the action bar
|
||||||
|
local player_list_name
|
||||||
|
local function update_action_bar(player)
|
||||||
|
local frame = Gui.classes.left_frames.get_frame(player_list_name,player)
|
||||||
|
local element = frame.container.action_bar
|
||||||
|
local action_player = Store.get_child(action_player_store,player.name)
|
||||||
|
|
||||||
|
if not action_player then
|
||||||
|
element.visible = false
|
||||||
|
else
|
||||||
|
element.visible = true
|
||||||
|
for action_name,buttons in pairs(config) do
|
||||||
|
if buttons.auth and not buttons.auth(player,action_player) then
|
||||||
|
element[action_name].visible = false
|
||||||
|
else
|
||||||
|
element[action_name].visible = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function add_player(list_table,player,role_name)
|
||||||
|
open_action_bar(list_table,player.name)
|
||||||
|
|
||||||
|
-- player name with the tooltip of their highest role and in they colour
|
||||||
|
local player_name =
|
||||||
|
list_table.add{
|
||||||
|
type='label',
|
||||||
|
caption=player.name,
|
||||||
|
tooltip=player.name..' '..player.tag..'\n'..role_name
|
||||||
|
}
|
||||||
|
Gui.set_padding(player_name,0,0,0,2)
|
||||||
|
player_name.style.font_color = player.chat_color
|
||||||
|
|
||||||
|
-- flow which allows right align for the play time
|
||||||
|
local time_flow =
|
||||||
|
list_table.add{
|
||||||
|
name='player-time-'..player.index,
|
||||||
|
type='flow'
|
||||||
|
}
|
||||||
|
Gui.set_padding(time_flow)
|
||||||
|
time_flow.style.horizontal_align = 'right'
|
||||||
|
time_flow.style.horizontally_stretchable = true
|
||||||
|
|
||||||
|
-- time given in Xh Ym and is right aligned
|
||||||
|
local tick = game.tick > 0 and game.tick or 1
|
||||||
|
local percent = math.round(player.online_time/tick,3)*100
|
||||||
|
local time =
|
||||||
|
time_flow.add{
|
||||||
|
name='label',
|
||||||
|
type='label',
|
||||||
|
caption=format_time(player.online_time),
|
||||||
|
tooltip={'player-list.afk-time',percent,format_time(player.afk_time,{minutes=true,long=true})}
|
||||||
|
}
|
||||||
|
Gui.set_padding(time)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Adds fake players to the player list
|
||||||
|
local function add_fake_players(list_table,count)
|
||||||
|
local role_name = 'Fake Player'
|
||||||
|
for i = 1,count do
|
||||||
|
add_player(list_table,{
|
||||||
|
name='Player '..i,
|
||||||
|
online_time=math.random(0,game.tick),
|
||||||
|
afk_time=math.random(0,game.tick),
|
||||||
|
chat_color=table.get_random_dictionary_entry(Colors)
|
||||||
|
},role_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Registers the player list
|
||||||
|
local player_list =
|
||||||
|
Gui.new_left_frame('gui/player-list')
|
||||||
|
:set_sprites('entity/character')
|
||||||
|
:set_open_by_default()
|
||||||
|
:set_direction('vertical')
|
||||||
|
:on_draw(function(player,element)
|
||||||
|
local list_table,action_bar = generate_container(player,element)
|
||||||
|
generate_action_bar(player,action_bar)
|
||||||
|
|
||||||
|
local players = {}
|
||||||
|
for _,next_player in pairs(game.connected_players) do
|
||||||
|
local highest_role = Roles.get_player_highest_role(next_player)
|
||||||
|
if not players[highest_role.name] then
|
||||||
|
players[highest_role.name] = {}
|
||||||
|
end
|
||||||
|
table.insert(players[highest_role.name],next_player)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,role_name in pairs(Roles.config.order) do
|
||||||
|
if players[role_name] then
|
||||||
|
for _,next_player in pairs(players[role_name]) do
|
||||||
|
add_player(list_table,next_player,role_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--add_fake_players(list_table,20)
|
||||||
|
end)
|
||||||
|
:on_update(function(player,element)
|
||||||
|
local list = element.container.scroll.table
|
||||||
|
for _,next_player in pairs(game.connected_players) do
|
||||||
|
local time_element_name = 'player-time-'..next_player.index
|
||||||
|
local time_element = list[time_element_name]
|
||||||
|
if time_element and time_element.valid then
|
||||||
|
time_element.label.caption = format_time(next_player.online_time)
|
||||||
|
local tick = game.tick > 0 and game.tick or 1
|
||||||
|
local percent = math.round(player.online_time/tick,3)*100
|
||||||
|
time_element.label.tooltip = {'player-list.afk-time',percent,format_time(player.afk_time,{minutes=true,long=true})}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
player_list_name = player_list:uid()
|
||||||
|
|
||||||
|
--- When the action player is changed the action bar will update
|
||||||
|
Store.register(action_player_store,function(value,category)
|
||||||
|
local player = Game.get_player_from_any(category)
|
||||||
|
update_action_bar(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- When the action name is changed the reason input will update
|
||||||
|
Store.register(action_name_store,function(value,category)
|
||||||
|
local player = Game.get_player_from_any(category)
|
||||||
|
local frame = Gui.classes.left_frames.get_frame(player_list_name,player)
|
||||||
|
local element = frame.container.reason_bar
|
||||||
|
element.visible = value ~= nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- Many events which trigger the gui to be re drawn, it will also update the times every 30 seconds
|
||||||
|
Event.on_nth_tick(1800,player_list 'update_all')
|
||||||
|
Event.add(defines.events.on_player_joined_game,player_list 'redraw_all')
|
||||||
|
Event.add(defines.events.on_player_left_game,player_list 'redraw_all')
|
||||||
|
Event.add(Roles.player_role_assigned,player_list 'redraw_all')
|
||||||
|
Event.add(Roles.player_role_unassigned,player_list 'redraw_all')
|
||||||
|
|
||||||
|
return player_list
|
||||||
Reference in New Issue
Block a user