mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Merge pull request #171 from Cooldude2606/feature/general-clean-up
Cleanup before master merge
This commit is contained in:
@@ -4,115 +4,117 @@
|
|||||||
local Async = require 'expcore.async'
|
local Async = require 'expcore.async'
|
||||||
local format_time = _C.format_time --- @dep expcore.common
|
local format_time = _C.format_time --- @dep expcore.common
|
||||||
|
|
||||||
|
-- eg Async(async_message, is_command or player, message)
|
||||||
local async_message = Async.register(function(player, message)
|
local async_message = Async.register(function(player, message)
|
||||||
player.print(message)
|
if player == true then game.print(message) else player.print(message) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- luacheck:ignore 212/player 212/is_command
|
||||||
return {
|
return {
|
||||||
allow_command_prefix_for_messages = true, --- @setting allow_command_prefix_for_messages when true any message trigger will print to all player when prefixed
|
allow_command_prefix_for_messages = true, --- @setting allow_command_prefix_for_messages when true any message trigger will print to all player when prefixed
|
||||||
messages = { --- @setting messages will trigger when ever the word is said
|
messages = { --- @setting messages will trigger when ever the word is said
|
||||||
['discord']={'info.discord'},
|
['discord'] = {'info.discord'},
|
||||||
['expgaming']={'info.website'},
|
['expgaming'] = {'info.website'},
|
||||||
['website']={'info.website'},
|
['website'] = {'info.website'},
|
||||||
['wiki']={'info.wiki'},
|
['wiki'] = {'info.wiki'},
|
||||||
['status']={'info.status'},
|
['status'] = {'info.status'},
|
||||||
['github']={'info.github'},
|
['github'] = {'info.github'},
|
||||||
['patreon']={'info.patreon'},
|
['patreon'] = {'info.patreon'},
|
||||||
['donate']={'info.patreon'},
|
['donate'] = {'info.patreon'},
|
||||||
['command']={'info.custom-commands'},
|
['command'] = {'info.custom-commands'},
|
||||||
['commands']={'info.custom-commands'},
|
['commands'] = {'info.custom-commands'},
|
||||||
['softmod']={'info.softmod'},
|
['softmod'] = {'info.softmod'},
|
||||||
['script']={'info.softmod'},
|
['script'] = {'info.softmod'},
|
||||||
['loop']={'chat-bot.loops'},
|
['loop'] = {'chat-bot.loops'},
|
||||||
['rhd']={'info.lhd'},
|
['rhd'] = {'info.lhd'},
|
||||||
['lhd']={'info.lhd'},
|
['lhd'] = {'info.lhd'},
|
||||||
['roundabout']={'chat-bot.loops'},
|
['roundabout'] = {'chat-bot.loops'},
|
||||||
['roundabouts']={'chat-bot.loops'},
|
['roundabouts'] = {'chat-bot.loops'},
|
||||||
['redmew']={'info.redmew'},
|
['redmew'] = {'info.redmew'},
|
||||||
['afk']=function(player)
|
['afk'] = function(player)
|
||||||
local max=player
|
local max = player
|
||||||
for _,next_player in pairs(game.connected_players) do
|
for _, next_player in pairs(game.connected_players) do
|
||||||
if max.afk_time < next_player.afk_time then
|
if max.afk_time < next_player.afk_time then
|
||||||
max=next_player
|
max = next_player
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return {'chat-bot.afk',max.name,format_time(max.afk_time,{minutes=true,seconds=true,long=true})}
|
return {'chat-bot.afk', max.name, format_time(max.afk_time, {minutes = true, seconds = true, long = true})}
|
||||||
end,
|
end,
|
||||||
['players']=function()
|
['players'] = function()
|
||||||
return {'chat-bot.players',#game.players}
|
return {'chat-bot.players', #game.players}
|
||||||
end,
|
end,
|
||||||
['online']=function()
|
['online'] = function()
|
||||||
return {'chat-bot.players-online',#game.connected_players}
|
return {'chat-bot.players-online', #game.connected_players}
|
||||||
end,
|
end,
|
||||||
['r!verify']=function(player)
|
['r!verify'] = function(player)
|
||||||
return {'chat-bot.verify',player.name}
|
return {'chat-bot.verify', player.name}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
command_admin_only = false, --- @setting command_admin_only when true will only allow chat commands for admins
|
command_admin_only = false, --- @setting command_admin_only when true will only allow chat commands for admins
|
||||||
command_permission = 'command/chat-bot', --- @setting command_permission the permission used to allow command prefixes
|
command_permission = 'command/chat-bot', --- @setting command_permission the permission used to allow command prefixes
|
||||||
command_prefix = '!', --- @setting command_prefix prefix used for commands below and to print to all players (if enabled above)
|
command_prefix = '!', --- @setting command_prefix prefix used for commands below and to print to all players (if enabled above)
|
||||||
commands = { --- @setting commands will trigger only when command prefix is given
|
commands = { --- @setting commands will trigger only when command prefix is given
|
||||||
['dev']={'chat-bot.not-real-dev'},
|
['dev'] = {'chat-bot.not-real-dev'},
|
||||||
['blame']=function(player)
|
['blame'] = function(player)
|
||||||
local names = {'Cooldude2606','arty714','badgamernl', 'mark9064', 'aldldl', 'Drahc_pro',player.name}
|
local names = {'Cooldude2606', 'arty714', 'badgamernl', 'mark9064', 'aldldl', 'Drahc_pro', player.name}
|
||||||
for _,next_player in pairs(game.connected_players) do
|
for _, next_player in pairs(game.connected_players) do
|
||||||
names[#names + 1] = next_player.name
|
names[#names + 1] = next_player.name
|
||||||
end
|
end
|
||||||
return {'chat-bot.blame',table.get_random_dictionary_entry(names)}
|
return {'chat-bot.blame', table.get_random_dictionary_entry(names)}
|
||||||
end,
|
end,
|
||||||
['magic']={'chat-bot.magic'},
|
['magic'] = {'chat-bot.magic'},
|
||||||
['aids']={'chat-bot.aids'},
|
['aids'] = {'chat-bot.aids'},
|
||||||
['riot']={'chat-bot.riot'},
|
['riot'] = {'chat-bot.riot'},
|
||||||
['lenny']={'chat-bot.lenny'},
|
['lenny'] = {'chat-bot.lenny'},
|
||||||
['hodor']=function()
|
['hodor'] = function()
|
||||||
local options = {'?','.','!','!!!'}
|
local options = {'?', '.', '!', '!!!'}
|
||||||
return {'chat-bot.hodor',table.get_random_dictionary_entry(options)}
|
return {'chat-bot.hodor', table.get_random_dictionary_entry(options)}
|
||||||
end,
|
end,
|
||||||
['evolution']=function()
|
['evolution'] = function()
|
||||||
return {'chat-bot.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)}
|
return {'chat-bot.current-evolution', string.format('%.2f', game.forces['enemy'].evolution_factor)}
|
||||||
end,
|
end,
|
||||||
['makepopcorn']=function(player)
|
['makepopcorn'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.get-popcorn-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-popcorn-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.get-popcorn-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-popcorn-2', player.name}})
|
||||||
end,
|
end,
|
||||||
['passsomesnaps']=function(player)
|
['passsomesnaps'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.get-snaps-1'}})
|
Async(async_message, player, {'chat-bot.reply', {'chat-bot.get-snaps-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.get-snaps-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-snaps-2', player.name}})
|
||||||
Async.wait(timeout*(math.random()+0.5),async_message,player,{'chat-bot.reply',{'chat-bot.get-snaps-3',player.name}})
|
Async.wait(timeout*(math.random()+0.5), async_message, true, {'chat-bot.reply', {'chat-bot.get-snaps-3', player.name}})
|
||||||
end,
|
end,
|
||||||
['makecocktail']=function(player)
|
['makecocktail'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.get-cocktail-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-cocktail-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.get-cocktail-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-cocktail-2', player.name}})
|
||||||
Async.wait(timeout*(math.random()+0.5),async_message,player,{'chat-bot.reply',{'chat-bot.get-cocktail-3',player.name}})
|
Async.wait(timeout*(math.random()+0.5), async_message, true, {'chat-bot.reply', {'chat-bot.get-cocktail-3', player.name}})
|
||||||
end,
|
end,
|
||||||
['makecoffee']=function(player)
|
['makecoffee'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.make-coffee-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.make-coffee-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.make-coffee-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.make-coffee-2', player.name}})
|
||||||
end,
|
end,
|
||||||
['orderpizza']=function(player)
|
['orderpizza'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.order-pizza-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.order-pizza-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.order-pizza-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.order-pizza-2', player.name}})
|
||||||
Async.wait(timeout*(math.random()+0.5),async_message,player,{'chat-bot.reply',{'chat-bot.order-pizza-3',player.name}})
|
Async.wait(timeout*(math.random()+0.5), async_message, true, {'chat-bot.reply', {'chat-bot.order-pizza-3', player.name}})
|
||||||
end,
|
end,
|
||||||
['maketea']=function(player)
|
['maketea'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.make-tea-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.make-tea-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.make-tea-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.make-tea-2', player.name}})
|
||||||
end,
|
end,
|
||||||
['meadplease']=function(player)
|
['meadplease'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.get-mead-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-mead-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.get-mead-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-mead-2', player.name}})
|
||||||
end,
|
end,
|
||||||
['passabeer']=function(player)
|
['passabeer'] = function(player)
|
||||||
local timeout = math.floor(180*(math.random()+0.5))
|
local timeout = math.floor(180*(math.random()+0.5))
|
||||||
Async(async_message,player,{'chat-bot.reply',{'chat-bot.get-beer-1'}})
|
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-beer-1'}})
|
||||||
Async.wait(timeout,async_message,player,{'chat-bot.reply',{'chat-bot.get-beer-2',player.name}})
|
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-beer-2', player.name}})
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ see ./expcore/commands.lua for more details
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
|
|
||||||
-- luacheck:ignore 212/player
|
-- luacheck:ignore 212/player
|
||||||
Commands.add_parse('boolean',function(input, player)
|
Commands.add_parse('boolean',function(input, player)
|
||||||
@@ -94,7 +93,7 @@ end)
|
|||||||
|
|
||||||
Commands.add_parse('player',function(input, player, reject)
|
Commands.add_parse('player',function(input, player, reject)
|
||||||
if not input then return end -- nil check
|
if not input then return end -- nil check
|
||||||
local input_player = Game.get_player_from_any(input)
|
local input_player = game.players[input]
|
||||||
if not input_player then
|
if not input_player then
|
||||||
return reject{'expcore-commands.reject-player',input}
|
return reject{'expcore-commands.reject-player',input}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ end)
|
|||||||
Commands.add_parse('player-role-online',function(input, player, reject)
|
Commands.add_parse('player-role-online',function(input, player, reject)
|
||||||
local input_player = Commands.parse('player-role',input, player, reject)
|
local input_player = Commands.parse('player-role',input, player, reject)
|
||||||
if not input_player then return end -- nil check
|
if not input_player then return end -- nil check
|
||||||
return Commands.parse('player-online',input_player, player, reject)
|
return Commands.parse('player-online',input_player.name, player, reject)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Commands.add_parse('player-role-alive',function(input, player, reject)
|
Commands.add_parse('player-role-alive',function(input, player, reject)
|
||||||
local input_player = Commands.parse('player-role',input, player, reject)
|
local input_player = Commands.parse('player-role',input, player, reject)
|
||||||
if not input_player then return end -- nil check
|
if not input_player then return end -- nil check
|
||||||
return Commands.parse('player-alive',input_player, player, reject)
|
return Commands.parse('player-alive',input_player.name, player, reject)
|
||||||
end)
|
end)
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
-- @config Permission-Groups
|
-- @config Permission-Groups
|
||||||
|
|
||||||
--local Event = require 'utils.event' -- @dep utils.event
|
--local Event = require 'utils.event' -- @dep utils.event
|
||||||
--local Game = require 'utils.game' -- @dep utils.game
|
|
||||||
local Permission_Groups = require 'expcore.permission_groups' --- @dep expcore.permission_groups
|
local Permission_Groups = require 'expcore.permission_groups' --- @dep expcore.permission_groups
|
||||||
|
|
||||||
Permission_Groups.new_group('Admin')
|
Permission_Groups.new_group('Admin')
|
||||||
@@ -120,17 +119,17 @@ local function assign_group(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Event.add(defines.events.on_player_joined_game,function(event)
|
Event.add(defines.events.on_player_joined_game,function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
assign_group(player)
|
assign_group(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Event.add(defines.events.on_player_promoted,function(event)
|
Event.add(defines.events.on_player_promoted,function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
assign_group(player)
|
assign_group(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Event.add(defines.events.on_player_demoted,function(event)
|
Event.add(defines.events.on_player_demoted,function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
assign_group(player)
|
assign_group(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Reports = require 'modules.control.reports' --- @dep modules.control.reports
|
local Reports = require 'modules.control.reports' --- @dep modules.control.reports
|
||||||
local Warnings = require 'modules.control.warnings' --- @dep modules.control.warnings
|
local Warnings = require 'modules.control.warnings' --- @dep modules.control.warnings
|
||||||
local Jail = require 'modules.control.jail' --- @dep modules.control.jail
|
local Jail = require 'modules.control.jail' --- @dep modules.control.jail
|
||||||
@@ -31,7 +30,7 @@ end
|
|||||||
-- gets the action player and a coloured name for the action to be used on
|
-- gets the action player and a coloured name for the action to be used on
|
||||||
local function get_action_player_name(player)
|
local function get_action_player_name(player)
|
||||||
local selected_player_name = SelectedPlayer:get(player)
|
local selected_player_name = SelectedPlayer:get(player)
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
local selected_player_color = format_chat_player_name(selected_player)
|
local selected_player_color = format_chat_player_name(selected_player)
|
||||||
return selected_player_name, selected_player_color
|
return selected_player_name, selected_player_color
|
||||||
end
|
end
|
||||||
@@ -64,7 +63,7 @@ end
|
|||||||
local goto_player = new_button('utility/export',{'player-list.goto-player'})
|
local goto_player = new_button('utility/export',{'player-list.goto-player'})
|
||||||
:on_click(function(player)
|
:on_click(function(player)
|
||||||
local selected_player_name = get_action_player_name(player)
|
local selected_player_name = get_action_player_name(player)
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
if not player.character or not selected_player.character then
|
if not player.character or not selected_player.character then
|
||||||
player.print({'expcore-commands.reject-player-alive'},Colors.orange_red)
|
player.print({'expcore-commands.reject-player-alive'},Colors.orange_red)
|
||||||
else
|
else
|
||||||
@@ -77,7 +76,7 @@ end)
|
|||||||
local bring_player = new_button('utility/import',{'player-list.bring-player'})
|
local bring_player = new_button('utility/import',{'player-list.bring-player'})
|
||||||
:on_click(function(player)
|
:on_click(function(player)
|
||||||
local selected_player_name = get_action_player_name(player)
|
local selected_player_name = get_action_player_name(player)
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
if not player.character or not selected_player.character then
|
if not player.character or not selected_player.character then
|
||||||
player.print({'expcore-commands.reject-player-alive'},Colors.orange_red)
|
player.print({'expcore-commands.reject-player-alive'},Colors.orange_red)
|
||||||
else
|
else
|
||||||
@@ -90,7 +89,7 @@ end)
|
|||||||
local kill_player = new_button('utility/too_far',{'player-list.kill-player'})
|
local kill_player = new_button('utility/too_far',{'player-list.kill-player'})
|
||||||
:on_click(function(player)
|
:on_click(function(player)
|
||||||
local selected_player_name = get_action_player_name(player)
|
local selected_player_name = get_action_player_name(player)
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
if selected_player.character then
|
if selected_player.character then
|
||||||
selected_player.character.die()
|
selected_player.character.die()
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -101,16 +101,18 @@ end
|
|||||||
|
|
||||||
--[[-- Gets the status of the given server
|
--[[-- Gets the status of the given server
|
||||||
@tparam string server_id The internal server if for the server you want the status of
|
@tparam string server_id The internal server if for the server you want the status of
|
||||||
@treturn string The status of the given server, one of: Online, Modded, Protected, Offline
|
@tparam boolean raw When true Current will not be returned as status but rather the raw status for the server
|
||||||
|
@treturn string The status of the given server, one of: Online, Modded, Protected, Current, Offline
|
||||||
|
|
||||||
@usage-- Get the status of the given server
|
@usage-- Get the status of the given server
|
||||||
local status = External.get_server_status('eu-01')
|
local status = External.get_server_status('eu-01')
|
||||||
|
|
||||||
]]
|
]]
|
||||||
function External.get_server_status(server_id)
|
function External.get_server_status(server_id, raw)
|
||||||
assert(var, 'No external data was found, use External.valid() to ensure external data exists.')
|
assert(var, 'No external data was found, use External.valid() to ensure external data exists.')
|
||||||
local servers = assert(var.status, 'No server status was found, please ensure that the external service is running')
|
local servers = assert(var.status, 'No server status was found, please ensure that the external service is running')
|
||||||
return servers[server_id]
|
local current = assert(ext.current, 'No current id was found, please ensure that the external service is running')
|
||||||
|
return not raw and server_id == current and 'Current' or servers[server_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-- Gets the ups of the current server
|
--[[-- Gets the ups of the current server
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ servers-d7=This is our event server, we try to run events at least once per week
|
|||||||
servers-8=S8 T̷-̶s̶-̴:̷
|
servers-8=S8 T̷-̶s̶-̴:̷
|
||||||
servers-d8=N̵o̴ ̶o̷-̶e̵ ̴k̸n̷-̶w̵s̸ ̴w̷h̷a̶-̶ ̷h̴a̴p̷p̴e̷n̷s̸ ̷o̶n̴ ̷t̶h̴-̶s̶ ̷s̷e̶r̸v̸e̴r̷,̶ ̸i̸t̴ ̷m̶-̸g̴h̶t̷ ̸n̸-̶t̵ ̷e̴v̸e̸n̶t̷ ̵-̷x̴i̵s̶t̸.̸
|
servers-d8=N̵o̴ ̶o̷-̶e̵ ̴k̸n̷-̶w̵s̸ ̴w̷h̷a̶-̶ ̷h̴a̴p̷p̴e̷n̷s̸ ̷o̶n̴ ̷t̶h̴-̶s̶ ̷s̷e̶r̸v̸e̴r̷,̶ ̸i̸t̴ ̷m̶-̸g̴h̶t̷ ̸n̸-̶t̵ ̷e̴v̸e̸n̶t̷ ̵-̷x̴i̵s̶t̸.̸
|
||||||
servers-connect-Offline=Server is currently offline
|
servers-connect-Offline=Server is currently offline
|
||||||
|
servers-connect-Current=This is your current server
|
||||||
servers-connect-Version=Server is on a different version: __1__
|
servers-connect-Version=Server is on a different version: __1__
|
||||||
servers-connect-Password=Server requires a password
|
servers-connect-Password=Server requires a password
|
||||||
servers-connect-Modded=Server requires mods to be downloaded
|
servers-connect-Modded=Server requires mods to be downloaded
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
-- @addon Advanced-Start
|
-- @addon Advanced-Start
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local config = require 'config.advanced_start' --- @dep config.advanced_start
|
local config = require 'config.advanced_start' --- @dep 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)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
-- game init settings
|
-- game init settings
|
||||||
if event.player_index == 1 then
|
if event.player_index == 1 then
|
||||||
player.force.friendly_fire = config.friendly_fire
|
player.force.friendly_fire = config.friendly_fire
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ local send_text = Game.print_player_floating_text -- (player_index, text, color)
|
|||||||
|
|
||||||
Event.add(defines.events.on_console_chat, function(event)
|
Event.add(defines.events.on_console_chat, function(event)
|
||||||
if not event.player_index or event.player_index < 1 then return end
|
if not event.player_index or event.player_index < 1 then return end
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
-- Some basic sanity checks
|
-- Some basic sanity checks
|
||||||
if not player then return end
|
if not player then return end
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
--- Adds auto replies to chat messages; aswell as chat commands
|
--- Adds auto replies to chat messages; as well as chat commands
|
||||||
-- @addon Chat-Reply
|
-- @addon Chat-Reply
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local config = require 'config.chat_reply' --- @dep config.chat_reply
|
local config = require 'config.chat_reply' --- @dep config.chat_reply
|
||||||
|
|
||||||
Event.add(defines.events.on_console_chat, function(event)
|
Event.add(defines.events.on_console_chat, function(event)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
if not player_index or player_index < 1 then return end
|
if not player_index or player_index < 1 then return end
|
||||||
local player = Game.get_player_by_index(player_index)
|
local player = game.players[player_index]
|
||||||
local message = event.message:lower():gsub("%s+", "")
|
local message = event.message:lower():gsub("%s+", "")
|
||||||
local allowed = true
|
local allowed = true
|
||||||
if config.command_admin_only and not player.admin then allowed = false end
|
if config.command_admin_only and not player.admin then allowed = false end
|
||||||
@@ -18,16 +17,15 @@ Event.add(defines.events.on_console_chat, function(event)
|
|||||||
local prefix = config.command_prefix
|
local prefix = config.command_prefix
|
||||||
for key_word, reply in pairs(config.messages) do
|
for key_word, reply in pairs(config.messages) do
|
||||||
if message:find(key_word) then
|
if message:find(key_word) then
|
||||||
|
local is_command = message:find(prefix..key_word)
|
||||||
if type(reply) == 'function' then
|
if type(reply) == 'function' then
|
||||||
reply = reply(player)
|
reply = reply(player, is_command)
|
||||||
end
|
end
|
||||||
|
|
||||||
if message:find(prefix..key_word) then
|
if is_command and allowed then
|
||||||
if allowed then
|
game.print{'chat-bot.reply', reply}
|
||||||
game.print{'chat-bot.reply', reply}
|
elseif is_command then
|
||||||
else
|
player.print{'chat-bot.disallow'}
|
||||||
player.print{'chat-bot.disallow'}
|
|
||||||
end
|
|
||||||
elseif not allowed then
|
elseif not allowed then
|
||||||
player.print{'chat-bot.reply', reply}
|
player.print{'chat-bot.reply', reply}
|
||||||
end
|
end
|
||||||
@@ -39,7 +37,7 @@ Event.add(defines.events.on_console_chat, function(event)
|
|||||||
for key_word, reply in pairs(config.commands) do
|
for key_word, reply in pairs(config.commands) do
|
||||||
if message:find(prefix..key_word) then
|
if message:find(prefix..key_word) then
|
||||||
if type(reply) == 'function' then
|
if type(reply) == 'function' then
|
||||||
reply = reply(player)
|
reply = reply(player, true)
|
||||||
|
|
||||||
if reply then
|
if reply then
|
||||||
game.print{'chat-bot.reply', reply}
|
game.print{'chat-bot.reply', reply}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
local Global = require 'utils.global' --- @dep utils.global
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Task = require 'utils.task' --- @dep utils.task
|
local Task = require 'utils.task' --- @dep utils.task
|
||||||
local Token = require 'utils.token' --- @dep utils.token
|
local Token = require 'utils.token' --- @dep utils.token
|
||||||
local config = require 'config.compilatron' --- @dep config.compilatron
|
local config = require 'config.compilatron' --- @dep config.compilatron
|
||||||
@@ -95,7 +94,7 @@ end
|
|||||||
-- When the first player is created this will create all compilatrons that are resisted in the config
|
-- When the first player is created this will create all compilatrons that are resisted in the config
|
||||||
Event.add(defines.events.on_player_created, function(event)
|
Event.add(defines.events.on_player_created, function(event)
|
||||||
if event.player_index ~= 1 then return end
|
if event.player_index ~= 1 then return end
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
for location in pairs(locations) do
|
for location in pairs(locations) do
|
||||||
Public.spawn_compilatron(player.surface, location)
|
Public.spawn_compilatron(player.surface, location)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
-- @addon Death-Logger
|
-- @addon Death-Logger
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
local Global = require 'utils.global' --- @dep utils.global
|
||||||
local config = require 'config.death_logger' --- @dep config.death_logger
|
local config = require 'config.death_logger' --- @dep config.death_logger
|
||||||
local format_time, move_items = _C.format_time, _C.move_items --- @dep expcore.common
|
local format_time, move_items = _C.format_time, _C.move_items --- @dep expcore.common
|
||||||
@@ -17,7 +16,7 @@ end)
|
|||||||
|
|
||||||
--- Creates a new death marker and saves it to the given death
|
--- Creates a new death marker and saves it to the given death
|
||||||
local function create_map_tag(death)
|
local function create_map_tag(death)
|
||||||
local player = Game.get_player_from_any(death.player_name)
|
local player = game.players[death.player_name]
|
||||||
local message = player.name..' died'
|
local message = player.name..' died'
|
||||||
if config.include_time_of_death then
|
if config.include_time_of_death then
|
||||||
local time = format_time(death.time_of_death, {hours=true, minutes=true, string=true})
|
local time = format_time(death.time_of_death, {hours=true, minutes=true, string=true})
|
||||||
@@ -59,7 +58,7 @@ end
|
|||||||
|
|
||||||
-- when a player dies a new death is added to the records and a map marker is made
|
-- when a player dies a new death is added to the records and a map marker is made
|
||||||
Event.add(defines.events.on_player_died, function(event)
|
Event.add(defines.events.on_player_died, function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
local corpse = player.surface.find_entity('character-corpse', player.position)
|
local corpse = player.surface.find_entity('character-corpse', player.position)
|
||||||
if config.use_chests_as_bodies then
|
if config.use_chests_as_bodies then
|
||||||
local items = corpse.get_inventory(defines.inventory.character_corpse).get_contents()
|
local items = corpse.get_inventory(defines.inventory.character_corpse).get_contents()
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
-- @addon Discord-Alerts
|
-- @addon Discord-Alerts
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
||||||
local write_json, format_time = _C.write_json, _C.format_time --- @dep expcore.common
|
local write_json, format_time = _C.write_json, _C.format_time --- @dep expcore.common
|
||||||
local config = require 'config.discord_alerts' --- @dep config.discord_alerts
|
local config = require 'config.discord_alerts' --- @dep config.discord_alerts
|
||||||
|
|
||||||
local function get_player_name(event)
|
local function get_player_name(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
return player.name, event.by_player_name
|
return player.name, event.by_player_name
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -32,8 +31,8 @@ local function emit_event(args)
|
|||||||
color = to_hex(color)
|
color = to_hex(color)
|
||||||
end
|
end
|
||||||
|
|
||||||
local tick = args.tick or 0
|
local tick = args.tick or game.tick
|
||||||
local tick_formated = format_time(tick, {hours = true, minutes = true, string = true, long = true})
|
local tick_formatted = format_time(tick, {days = true, hours = true, minutes = true, string = true, long = true})
|
||||||
|
|
||||||
local players_online = 0
|
local players_online = 0
|
||||||
local admins_online = 0
|
local admins_online = 0
|
||||||
@@ -47,7 +46,7 @@ local function emit_event(args)
|
|||||||
local done = {title=true, color=true, description=true}
|
local done = {title=true, color=true, description=true}
|
||||||
local fields = {{
|
local fields = {{
|
||||||
name='Server Details',
|
name='Server Details',
|
||||||
value=string.format('Server name: ${serverName} Players: %d Admins: %d Time: %s', players_online, admins_online, tick_formated)
|
value=string.format('Server: ${serverName} Time: %s\nTotal: %d Online: %d Admins: %d', tick_formatted, #game.players, players_online, admins_online)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for key, value in pairs(args) do
|
for key, value in pairs(args) do
|
||||||
@@ -86,9 +85,9 @@ if config.player_reports then
|
|||||||
title='Report',
|
title='Report',
|
||||||
description='A player was reported',
|
description='A player was reported',
|
||||||
color=Colors.yellow,
|
color=Colors.yellow,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name,
|
['By']='<inline>'..by_player_name,
|
||||||
['Reason:']=event.reason
|
['Reason']=event.reason
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(Reports.events.on_report_removed, function(event)
|
Event.add(Reports.events.on_report_removed, function(event)
|
||||||
@@ -98,9 +97,9 @@ if config.player_reports then
|
|||||||
title='Reports Removed',
|
title='Reports Removed',
|
||||||
description='A player has a report removed',
|
description='A player has a report removed',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..event.removed_by_name,
|
['By']='<inline>'..event.removed_by_name,
|
||||||
['Amount:']='<inline>'..event.batch_count
|
['Amount']='<inline>'..event.batch_count
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -114,9 +113,9 @@ if config.player_warnings then
|
|||||||
title='Warning',
|
title='Warning',
|
||||||
description='A player has been given a warning',
|
description='A player has been given a warning',
|
||||||
color=Colors.yellow,
|
color=Colors.yellow,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name,
|
['By']='<inline>'..by_player_name,
|
||||||
['Reason:']=event.reason
|
['Reason']=event.reason
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(Warnings.events.on_warning_removed, function(event)
|
Event.add(Warnings.events.on_warning_removed, function(event)
|
||||||
@@ -126,9 +125,9 @@ if config.player_warnings then
|
|||||||
title='Warnings Removed',
|
title='Warnings Removed',
|
||||||
description='A player has a warning removed',
|
description='A player has a warning removed',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..event.removed_by_name,
|
['By']='<inline>'..event.removed_by_name,
|
||||||
['Amount:']='<inline>'..event.batch_count
|
['Amount']='<inline>'..event.batch_count
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -142,9 +141,9 @@ if config.player_jail then
|
|||||||
title='Jail',
|
title='Jail',
|
||||||
description='A player has been jailed',
|
description='A player has been jailed',
|
||||||
color=Colors.yellow,
|
color=Colors.yellow,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name,
|
['By']='<inline>'..by_player_name,
|
||||||
['Reason:']=event.reason
|
['Reason']=event.reason
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(Jail.events.on_player_unjailed, function(event)
|
Event.add(Jail.events.on_player_unjailed, function(event)
|
||||||
@@ -153,8 +152,8 @@ if config.player_jail then
|
|||||||
title='Unjail',
|
title='Unjail',
|
||||||
description='A player has been unjailed',
|
description='A player has been unjailed',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name
|
['By']='<inline>'..by_player_name
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -168,9 +167,9 @@ if config.player_temp_ban then
|
|||||||
title='Temp Ban',
|
title='Temp Ban',
|
||||||
description='A player has been temp banned',
|
description='A player has been temp banned',
|
||||||
color=Colors.red,
|
color=Colors.red,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name,
|
['By']='<inline>'..by_player_name,
|
||||||
['Reason:']=event.reason
|
['Reason']=event.reason
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(Jail.events.on_player_untemp_banned, function(event)
|
Event.add(Jail.events.on_player_untemp_banned, function(event)
|
||||||
@@ -179,8 +178,8 @@ if config.player_temp_ban then
|
|||||||
title='Temp Ban Removed',
|
title='Temp Ban Removed',
|
||||||
description='A player has been untemp banned',
|
description='A player has been untemp banned',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name
|
['By']='<inline>'..by_player_name
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -189,26 +188,26 @@ end
|
|||||||
if config.player_bans then
|
if config.player_bans then
|
||||||
Event.add(defines.events.on_player_banned, function(event)
|
Event.add(defines.events.on_player_banned, function(event)
|
||||||
if event.by_player then
|
if event.by_player then
|
||||||
local by_player = Game.get_player_by_index(event.by_player)
|
local by_player = game.players[event.by_player]
|
||||||
emit_event{
|
emit_event{
|
||||||
title='Banned',
|
title='Banned',
|
||||||
description='A player has been banned',
|
description='A player has been banned',
|
||||||
color=Colors.red,
|
color=Colors.red,
|
||||||
['Player:']='<inline>'..event.player_name,
|
['Player']='<inline>'..event.player_name,
|
||||||
['By:']='<inline>'..by_player.name,
|
['By']='<inline>'..by_player.name,
|
||||||
['Reason:']=event.reason
|
['Reason']=event.reason
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
Event.add(defines.events.on_player_unbanned, function(event)
|
Event.add(defines.events.on_player_unbanned, function(event)
|
||||||
if event.by_player then
|
if event.by_player then
|
||||||
local by_player = Game.get_player_by_index(event.by_player)
|
local by_player = game.players[event.by_player]
|
||||||
emit_event{
|
emit_event{
|
||||||
title='Un-Banned',
|
title='Un-Banned',
|
||||||
description='A player has been un-banned',
|
description='A player has been un-banned',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..event.player_name,
|
['Player']='<inline>'..event.player_name,
|
||||||
['By:']='<inline>'..by_player.name
|
['By']='<inline>'..by_player.name
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -222,7 +221,7 @@ if config.player_mutes then
|
|||||||
title='Muted',
|
title='Muted',
|
||||||
description='A player has been muted',
|
description='A player has been muted',
|
||||||
color=Colors.yellow,
|
color=Colors.yellow,
|
||||||
['Player:']='<inline>'..player_name
|
['Player']='<inline>'..player_name
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(defines.events.on_player_unmuted, function(event)
|
Event.add(defines.events.on_player_unmuted, function(event)
|
||||||
@@ -231,7 +230,7 @@ if config.player_mutes then
|
|||||||
title='Un-Muted',
|
title='Un-Muted',
|
||||||
description='A player has been un-muted',
|
description='A player has been un-muted',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name
|
['Player']='<inline>'..player_name
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -241,14 +240,14 @@ if config.player_kicks then
|
|||||||
Event.add(defines.events.on_player_kicked, function(event)
|
Event.add(defines.events.on_player_kicked, function(event)
|
||||||
if event.by_player then
|
if event.by_player then
|
||||||
local player_name = get_player_name(event)
|
local player_name = get_player_name(event)
|
||||||
local by_player = Game.get_player_by_index(event.by_player)
|
local by_player = game.players[event.by_player]
|
||||||
emit_event{
|
emit_event{
|
||||||
title='Kick',
|
title='Kick',
|
||||||
description='A player has been kicked',
|
description='A player has been kicked',
|
||||||
color=Colors.orange,
|
color=Colors.orange,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player.name,
|
['By']='<inline>'..by_player.name,
|
||||||
['Reason:']=event.reason
|
['Reason']=event.reason
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -262,7 +261,7 @@ if config.player_promotes then
|
|||||||
title='Promote',
|
title='Promote',
|
||||||
description='A player has been promoted',
|
description='A player has been promoted',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name
|
['Player']='<inline>'..player_name
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(defines.events.on_player_demoted, function(event)
|
Event.add(defines.events.on_player_demoted, function(event)
|
||||||
@@ -271,7 +270,7 @@ if config.player_promotes then
|
|||||||
title='Demote',
|
title='Demote',
|
||||||
description='A player has been demoted',
|
description='A player has been demoted',
|
||||||
color=Colors.yellow,
|
color=Colors.yellow,
|
||||||
['Player:']='<inline>'..player_name
|
['Player']='<inline>'..player_name
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -285,8 +284,8 @@ Event.add(defines.events.on_console_command, function(event)
|
|||||||
title=event.command:gsub('^%l', string.upper),
|
title=event.command:gsub('^%l', string.upper),
|
||||||
description='/'..event.command..' was used',
|
description='/'..event.command..' was used',
|
||||||
color=Colors.grey,
|
color=Colors.grey,
|
||||||
['By:']='<inline>'..player_name,
|
['By']='<inline>'..player_name,
|
||||||
['Details:'] = event.parameters ~= '' and event.parameters or nil
|
['Details'] = event.parameters ~= '' and event.parameters or nil
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
-- @addon Scorched-Earth
|
-- @addon Scorched-Earth
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
local Global = require 'utils.global' --- @dep utils.global
|
||||||
local print_grid_value, clear_flying_text = _C.print_grid_value, _C.clear_flying_text --- @dep expcore.common
|
local print_grid_value, clear_flying_text = _C.print_grid_value, _C.clear_flying_text --- @dep expcore.common
|
||||||
local config = require 'config.scorched_earth' --- @dep config.scorched_earth
|
local config = require 'config.scorched_earth' --- @dep config.scorched_earth
|
||||||
@@ -94,7 +93,7 @@ end
|
|||||||
|
|
||||||
-- When the player changes position the tile will have a chance to downgrade, debug check is here
|
-- When the player changes position the tile will have a chance to downgrade, debug check is here
|
||||||
Event.add(defines.events.on_player_changed_position, function(event)
|
Event.add(defines.events.on_player_changed_position, function(event)
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
local surface = player.surface
|
local surface = player.surface
|
||||||
local position = player.position
|
local position = player.position
|
||||||
local strength = get_tile_strength(surface, position)
|
local strength = get_tile_strength(surface, position)
|
||||||
@@ -133,7 +132,7 @@ end)
|
|||||||
|
|
||||||
-- Used as a way to access the global table
|
-- Used as a way to access the global table
|
||||||
return function(player_name, state)
|
return function(player_name, state)
|
||||||
local player = Game.get_player_from_any(player_name)
|
local player = game.players[player_name]
|
||||||
clear_flying_text(player.surface)
|
clear_flying_text(player.surface)
|
||||||
debug_players[player_name] = state
|
debug_players[player_name] = state
|
||||||
end
|
end
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
local Global = require 'utils.global' --- @dep utils.global
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local config = require 'config.spawn_area' --- @dep config.spawn_area
|
local config = require 'config.spawn_area' --- @dep config.spawn_area
|
||||||
local tiles = config.tiles
|
local tiles = config.tiles
|
||||||
local entities = config.entities
|
local entities = config.entities
|
||||||
@@ -134,7 +133,7 @@ end)
|
|||||||
|
|
||||||
Event.add(defines.events.on_player_created, function(event)
|
Event.add(defines.events.on_player_created, function(event)
|
||||||
if event.player_index ~= 1 then return end
|
if event.player_index ~= 1 then return end
|
||||||
local player = Game.get_player_by_index(event.player_index)
|
local player = game.players[event.player_index]
|
||||||
local p = {x=0, y=0}
|
local p = {x=0, y=0}
|
||||||
local s = player.surface
|
local s = player.surface
|
||||||
spawn_base(s, p)
|
spawn_base(s, p)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
-- @addon Tree-Decon
|
-- @addon Tree-Decon
|
||||||
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
local Global = require 'utils.global' --- @dep utils.global
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ Event.add(defines.events.on_marked_for_deconstruction, function(event)
|
|||||||
-- Check which type of decon a player is allowed
|
-- Check which type of decon a player is allowed
|
||||||
local index = event.player_index
|
local index = event.player_index
|
||||||
if chache[index] == nil then
|
if chache[index] == nil then
|
||||||
local player = Game.get_player_by_index(index)
|
local player = game.players[index]
|
||||||
if Roles.player_allowed(player, 'fast-tree-decon') then chache[index] = 'fast'
|
if Roles.player_allowed(player, 'fast-tree-decon') then chache[index] = 'fast'
|
||||||
elseif Roles.player_allowed(player, 'standard-decon') then chache[index] = 'standard'
|
elseif Roles.player_allowed(player, 'standard-decon') then chache[index] = 'standard'
|
||||||
else chache[index] = player.force end
|
else chache[index] = player.force end
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ require 'config.expcore.command_role_parse'
|
|||||||
-- @command clear-inventory
|
-- @command clear-inventory
|
||||||
-- @tparam LuaPlayer player the player to clear the inventory of
|
-- @tparam LuaPlayer player the player to clear the inventory of
|
||||||
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')
|
||||||
:add_alias('clear-inv', 'move-inventory', 'move-inv')
|
:add_alias('clear-inv', 'move-inventory', 'move-inv')
|
||||||
:register(function(_, player)
|
:register(function(_, player)
|
||||||
local inv = player.get_main_inventory()
|
local inv = player.get_main_inventory()
|
||||||
|
if not inv then
|
||||||
|
return Commands.error{'expcore-commands.reject-player-alive'}
|
||||||
|
end
|
||||||
move_items(inv.get_contents())
|
move_items(inv.get_contents())
|
||||||
inv.clear()
|
inv.clear()
|
||||||
end)
|
end)
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local Datastore = require 'expcore.datastore' --- @dep expcore.datastore
|
local Datastore = require 'expcore.datastore' --- @dep expcore.datastore
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local config = require 'config.gui.player_list_actions' --- @dep config.gui.player_list_actions
|
local config = require 'config.gui.player_list_actions' --- @dep config.gui.player_list_actions
|
||||||
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
||||||
@@ -115,7 +114,7 @@ Gui.element(function(event_trigger, parent, player_data)
|
|||||||
end)
|
end)
|
||||||
:on_click(function(player, element, event)
|
:on_click(function(player, element, event)
|
||||||
local selected_player_name = element.caption
|
local selected_player_name = element.caption
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
if event.button == defines.mouse_button_type.left then
|
if event.button == defines.mouse_button_type.left then
|
||||||
-- LMB will open the map to the selected player
|
-- LMB will open the map to the selected player
|
||||||
local position = selected_player.position
|
local position = selected_player.position
|
||||||
@@ -177,7 +176,7 @@ local function update_action_bar(element)
|
|||||||
element.visible = false
|
element.visible = false
|
||||||
|
|
||||||
else
|
else
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
if not selected_player.connected then
|
if not selected_player.connected then
|
||||||
-- If the player is offline then reest stores
|
-- If the player is offline then reest stores
|
||||||
element.visible = false
|
element.visible = false
|
||||||
@@ -357,7 +356,7 @@ end)
|
|||||||
|
|
||||||
--- When a player leaves only remove they entry
|
--- When a player leaves only remove they entry
|
||||||
Event.add(defines.events.on_player_left_game, function(event)
|
Event.add(defines.events.on_player_left_game, function(event)
|
||||||
local remove_player = Game.get_player_by_index(event.player_index)
|
local remove_player = game.players[event.player_index]
|
||||||
for _, player in pairs(game.connected_players) do
|
for _, player in pairs(game.connected_players) do
|
||||||
local frame = Gui.get_left_element(player, player_list_container)
|
local frame = Gui.get_left_element(player, player_list_container)
|
||||||
local scroll_table = frame.container.scroll.table
|
local scroll_table = frame.container.scroll.table
|
||||||
@@ -390,7 +389,7 @@ Event.add(Roles.events.on_role_unassigned, redraw_player_list)
|
|||||||
|
|
||||||
--- When the action player is changed the action bar will update
|
--- When the action player is changed the action bar will update
|
||||||
SelectedPlayer:on_update(function(player_name, selected_player)
|
SelectedPlayer:on_update(function(player_name, selected_player)
|
||||||
local player = Game.get_player_from_any(player_name)
|
local player = game.players[player_name]
|
||||||
local frame = Gui.get_left_element(player, player_list_container)
|
local frame = Gui.get_left_element(player, player_list_container)
|
||||||
local scroll_table = frame.container.scroll.table
|
local scroll_table = frame.container.scroll.table
|
||||||
update_action_bar(frame.container.action_bar)
|
update_action_bar(frame.container.action_bar)
|
||||||
@@ -410,13 +409,13 @@ end)
|
|||||||
|
|
||||||
--- When the action name is changed the reason input will update
|
--- When the action name is changed the reason input will update
|
||||||
SelectedAction:on_update(function(player_name, selected_action)
|
SelectedAction:on_update(function(player_name, selected_action)
|
||||||
local player = Game.get_player_from_any(player_name)
|
local player = game.players[player_name]
|
||||||
local frame = Gui.get_left_element(player, player_list_container)
|
local frame = Gui.get_left_element(player, player_list_container)
|
||||||
local element = frame.container.reason_bar
|
local element = frame.container.reason_bar
|
||||||
if selected_action then
|
if selected_action then
|
||||||
-- if there is a new value then check the player is still online
|
-- if there is a new value then check the player is still online
|
||||||
local selected_player_name = SelectedPlayer:get(player_name)
|
local selected_player_name = SelectedPlayer:get(player_name)
|
||||||
local selected_player = Game.get_player_from_any(selected_player_name)
|
local selected_player = game.players[selected_player_name]
|
||||||
if selected_player.connected then
|
if selected_player.connected then
|
||||||
element.visible = true
|
element.visible = true
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ Gui.element{
|
|||||||
-- @element join_server
|
-- @element join_server
|
||||||
local join_server =
|
local join_server =
|
||||||
Gui.element(function(event_trigger, parent, server_id, wrong_version)
|
Gui.element(function(event_trigger, parent, server_id, wrong_version)
|
||||||
local status = wrong_version and 'Version' or External.get_server_status(server_id) or 'Offline'
|
local status = External.get_server_status(server_id) or 'Offline'
|
||||||
|
if wrong_version then status = 'Version' end
|
||||||
local flow = parent.add{ name = server_id, type = 'flow' }
|
local flow = parent.add{ name = server_id, type = 'flow' }
|
||||||
local button = flow.add{
|
local button = flow.add{
|
||||||
name = event_trigger,
|
name = event_trigger,
|
||||||
@@ -88,7 +89,7 @@ Gui.element(function(event_trigger, parent, server_id, wrong_version)
|
|||||||
tooltip = {'readme.servers-connect-'..status, wrong_version}
|
tooltip = {'readme.servers-connect-'..status, wrong_version}
|
||||||
}
|
}
|
||||||
|
|
||||||
if status == 'Offline' then
|
if status == 'Offline' or status == 'Current' then
|
||||||
button.enabled = false
|
button.enabled = false
|
||||||
button.sprite = 'utility/circuit_network_panel_black'
|
button.sprite = 'utility/circuit_network_panel_black'
|
||||||
elseif status == 'Version' then
|
elseif status == 'Version' then
|
||||||
|
|||||||
@@ -1,64 +1,39 @@
|
|||||||
local Global = require 'utils.global' --- @dep utils.global
|
|
||||||
local Color = require 'utils.color_presets' --- @dep utils.color_presets
|
|
||||||
local pairs = pairs
|
|
||||||
|
|
||||||
|
local Color = require 'utils.color_presets' --- @dep utils.color_presets
|
||||||
local Game = {}
|
local Game = {}
|
||||||
|
|
||||||
local bad_name_players = {}
|
--[[ Note to readers
|
||||||
Global.register(
|
Game.get_player_from_name was removed because game.players[name] works without any edge cases
|
||||||
bad_name_players,
|
always true: game.players[name].name == name
|
||||||
function(tbl)
|
|
||||||
bad_name_players = tbl
|
Game.get_player_by_index was added originally as a workaround for the following edge case:
|
||||||
end
|
player with index of 5 and name of "Cooldude2606"
|
||||||
)
|
player with index of 10 and name of "5"
|
||||||
|
game.players[5].name == "5"
|
||||||
|
|
||||||
|
Discovered the following logic:
|
||||||
|
all keys are first converted to string and search against player names
|
||||||
|
if this fails it attempts to convert it to a number and search against player indexes
|
||||||
|
sometimes fails: game.players[index].index == index
|
||||||
|
|
||||||
|
Game.get_player_by_index was removed after the above logic was corrected to the following:
|
||||||
|
when a key is a number it is searched against player indexes, and only their indexes
|
||||||
|
when a key is a string it is searched against player names, and then against their indexes
|
||||||
|
always true: game.players[name].name == name; game.players[index].index == index
|
||||||
|
|
||||||
--[[
|
|
||||||
Due to a bug in the Factorio api the following expression isn't guaranteed to be true.
|
|
||||||
game.players[player.index] == player
|
|
||||||
get_player_by_index(index) will always return the correct player.
|
|
||||||
When looking up players by name or iterating through all players use game.players instead.
|
|
||||||
]]
|
]]
|
||||||
function Game.get_player_by_index(index)
|
|
||||||
local p = game.players[index]
|
|
||||||
|
|
||||||
if not p then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
if p.index == index then
|
|
||||||
return p
|
|
||||||
end
|
|
||||||
|
|
||||||
p = bad_name_players[index]
|
|
||||||
if p then
|
|
||||||
if p.valid then
|
|
||||||
return p
|
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(game.players) do
|
|
||||||
if k == index then
|
|
||||||
bad_name_players[index] = v
|
|
||||||
return v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a valid LuaPlayer if given a number, string, or LuaPlayer. Returns nil otherwise.
|
--- Returns a valid LuaPlayer if given a number, string, or LuaPlayer. Returns nil otherwise.
|
||||||
-- obj <number|string|LuaPlayer>
|
-- obj <number|string|LuaPlayer>
|
||||||
function Game.get_player_from_any(obj)
|
function Game.get_player_from_any(obj)
|
||||||
local o_type = type(obj)
|
local o_type, p = type(obj)
|
||||||
local p
|
if o_type == 'table' then
|
||||||
if o_type == 'number' then
|
p = obj
|
||||||
p = Game.get_player_by_index(obj)
|
elseif o_type == 'string' or o_type == 'number' then
|
||||||
elseif o_type == 'string' then
|
|
||||||
p = game.players[obj]
|
p = game.players[obj]
|
||||||
elseif o_type == 'table' and obj.valid and obj.is_player() then
|
|
||||||
return obj
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if p and p.valid then
|
if p and p.valid and p.is_player() then
|
||||||
return p
|
return p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -95,16 +70,18 @@ function Game.print_floating_text(surface, position, text, color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Creates a floating text entity at the player location with the specified color in {r, g, b} format.
|
Creates a floating text entity at the player location with the specified color and offset.
|
||||||
Example: "+10 iron" or "-10 coins"
|
Example: "+10 iron" or "-10 coins"
|
||||||
|
|
||||||
@param text String to display
|
@param text String to display
|
||||||
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
||||||
|
@param x_offset number the x offset for the floating text
|
||||||
|
@param y_offset number the y offset for the floating text
|
||||||
|
|
||||||
@return the created entity
|
@return the created entity
|
||||||
]]
|
]]
|
||||||
function Game.print_player_floating_text_position(player_index, text, color, x_offset, y_offset)
|
function Game.print_player_floating_text_position(player, text, color, x_offset, y_offset)
|
||||||
local player = Game.get_player_by_index(player_index)
|
player = Game.get_player_from_any(player)
|
||||||
if not player or not player.valid then
|
if not player or not player.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -113,8 +90,17 @@ function Game.print_player_floating_text_position(player_index, text, color, x_o
|
|||||||
return Game.print_floating_text(player.surface, {x = position.x + x_offset, y = position.y + y_offset}, text, color)
|
return Game.print_floating_text(player.surface, {x = position.x + x_offset, y = position.y + y_offset}, text, color)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Game.print_player_floating_text(player_index, text, color)
|
--[[
|
||||||
Game.print_player_floating_text_position(player_index, text, color, 0, -1.5)
|
Creates a floating text entity at the player location with the specified color in {r, g, b} format.
|
||||||
|
Example: "+10 iron" or "-10 coins"
|
||||||
|
|
||||||
|
@param text String to display
|
||||||
|
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
||||||
|
|
||||||
|
@return the created entity
|
||||||
|
]]
|
||||||
|
function Game.print_player_floating_text(player, text, color)
|
||||||
|
Game.print_player_floating_text_position(player, text, color, 0, -1.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Game
|
return Game
|
||||||
Reference in New Issue
Block a user