mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-19 21:10:19 +02:00
Mtn: more fixes
This commit is contained in:
parent
8e8724a34e
commit
660391ecd3
@ -62,6 +62,9 @@ local function charge(player)
|
|||||||
if not player.character then
|
if not player.character then
|
||||||
return player.print(module_name .. 'It seems that you are not in the realm of living.', { color = Color.warning })
|
return player.print(module_name .. 'It seems that you are not in the realm of living.', { color = Color.warning })
|
||||||
end
|
end
|
||||||
|
if player.controller_type == defines.controllers.remote then
|
||||||
|
return player.print(module_name .. 'It seems that you are not in the realm of living.', { color = Color.warning })
|
||||||
|
end
|
||||||
local armor_inventory = player.get_inventory(defines.inventory.character_armor)
|
local armor_inventory = player.get_inventory(defines.inventory.character_armor)
|
||||||
if not armor_inventory.valid then
|
if not armor_inventory.valid then
|
||||||
return player.print(module_name .. 'No valid armor to charge was found.', { color = Color.warning })
|
return player.print(module_name .. 'No valid armor to charge was found.', { color = Color.warning })
|
||||||
|
@ -912,11 +912,17 @@ remove_boost_movement_speed_on_respawn =
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'v3_move_boost')
|
Modifiers.update_single_modifier(player, 'character_running_speed_modifier', 'v3_move_boost')
|
||||||
Modifiers.update_player_modifiers(player)
|
Modifiers.update_player_modifiers(player)
|
||||||
|
|
||||||
|
if not Public.is_task_done() then return end
|
||||||
player.print('Movement speed bonus removed!', { color = Color.info })
|
player.print('Movement speed bonus removed!', { color = Color.info })
|
||||||
local rpg_t = RPG.get_value_from_player(player.index)
|
local rpg_t = RPG.get_value_from_player(player.index)
|
||||||
|
if not rpg_t then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
rpg_t.has_boost_on_respawn = nil
|
rpg_t.has_boost_on_respawn = nil
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
22
maps/mountain_fortress_v3/icw/commands.lua
Normal file
22
maps/mountain_fortress_v3/icw/commands.lua
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
||||||
|
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||||
|
local Discord = require 'utils.discord_handler'
|
||||||
|
local Commands = require 'utils.commands'
|
||||||
|
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||||
|
|
||||||
|
Commands.new('icw_reconnect_train', 'Usable only for admins - reconnects all trains!')
|
||||||
|
:require_admin()
|
||||||
|
:require_validation()
|
||||||
|
:callback(
|
||||||
|
function (player)
|
||||||
|
local icw = ICW.get()
|
||||||
|
local suc = ICW_Func.reconstruct_all_trains(icw)
|
||||||
|
Discord.send_notification_raw(ICW.discord_name, player.name .. ' is reconnecting all trains via icw module.')
|
||||||
|
if suc then
|
||||||
|
player.print(mapkeeper .. 'All trains have been reconnected!')
|
||||||
|
else
|
||||||
|
player.print(mapkeeper .. 'Failed to reconnect all trains!')
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
)
|
@ -448,7 +448,7 @@ local function get_wagon_for_entity(icw, entity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local position = entity.position
|
local position = entity.position
|
||||||
for k, unit_number in pairs(train.wagons) do
|
for _, unit_number in pairs(train.wagons) do
|
||||||
local wagon = icw.wagons[unit_number]
|
local wagon = icw.wagons[unit_number]
|
||||||
if wagon then
|
if wagon then
|
||||||
local left_top = wagon.area.left_top
|
local left_top = wagon.area.left_top
|
||||||
@ -972,6 +972,7 @@ function Public.reconstruct_all_trains(icw)
|
|||||||
Public.construct_train(icw, locomotive, carriages)
|
Public.construct_train(icw, locomotive, carriages)
|
||||||
end
|
end
|
||||||
delete_empty_surfaces(icw)
|
delete_empty_surfaces(icw)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.item_transfer()
|
function Public.item_transfer()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'maps.mountain_fortress_v3.icw.commands'
|
||||||
|
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Functions = require 'maps.mountain_fortress_v3.icw.functions'
|
local Functions = require 'maps.mountain_fortress_v3.icw.functions'
|
||||||
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
||||||
|
@ -3,13 +3,16 @@ local Global = require 'utils.global'
|
|||||||
local this = {}
|
local this = {}
|
||||||
Global.register(
|
Global.register(
|
||||||
this,
|
this,
|
||||||
function(tbl)
|
function (tbl)
|
||||||
this = tbl
|
this = tbl
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local Public = {}
|
local Public = {}
|
||||||
|
|
||||||
|
local discord_name = 'Mtn Fortress'
|
||||||
|
Public.discord_name = discord_name
|
||||||
|
|
||||||
function Public.reset()
|
function Public.reset()
|
||||||
if this.surfaces then
|
if this.surfaces then
|
||||||
for _, surface in pairs(this.surfaces) do
|
for _, surface in pairs(this.surfaces) do
|
||||||
@ -39,10 +42,10 @@ function Public.reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.wagon_areas = {
|
this.wagon_areas = {
|
||||||
['cargo-wagon'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}},
|
['cargo-wagon'] = { left_top = { x = -40, y = 0 }, right_bottom = { x = 40, y = 100 } },
|
||||||
['artillery-wagon'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}},
|
['artillery-wagon'] = { left_top = { x = -40, y = 0 }, right_bottom = { x = 40, y = 100 } },
|
||||||
['fluid-wagon'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}},
|
['fluid-wagon'] = { left_top = { x = -40, y = 0 }, right_bottom = { x = 40, y = 100 } },
|
||||||
['locomotive'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}}
|
['locomotive'] = { left_top = { x = -40, y = 0 }, right_bottom = { x = 40, y = 100 } }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -795,7 +795,11 @@ Gui.on_click(
|
|||||||
end
|
end
|
||||||
local player = event.player
|
local player = event.player
|
||||||
if not player or not player.valid or not player.character then
|
if not player or not player.valid or not player.character then
|
||||||
return
|
return player.print(module_name .. 'It seems that you are not in the realm of living.', { color = Color.warning })
|
||||||
|
end
|
||||||
|
|
||||||
|
if player.controller_type == defines.controllers.remote then
|
||||||
|
return player.print(module_name .. 'It seems that you are not in the realm of living.', { color = Color.warning })
|
||||||
end
|
end
|
||||||
|
|
||||||
auto_stash(event.player, event)
|
auto_stash(event.player, event)
|
||||||
|
@ -375,6 +375,10 @@ function Public.remove_mana(player, mana_to_remove)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not Public.check_is_surface_valid(player) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not mana_to_remove then
|
if not mana_to_remove then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -425,6 +429,10 @@ function Public.update_mana(player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not Public.check_is_surface_valid(player) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not rpg_t then
|
if not rpg_t then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -527,6 +535,10 @@ function Public.update_health(player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not Public.check_is_surface_valid(player) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not rpg_t then
|
if not rpg_t then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1338,12 +1350,12 @@ function Public.check_is_surface_valid(player)
|
|||||||
local surface_name = Public.get('rpg_extra').surface_name
|
local surface_name = Public.get('rpg_extra').surface_name
|
||||||
if type(surface_name) == 'table' then
|
if type(surface_name) == 'table' then
|
||||||
for _, tbl_surface in pairs(surface_name) do
|
for _, tbl_surface in pairs(surface_name) do
|
||||||
if sub(player.surface.name, 0, #tbl_surface) == tbl_surface then
|
if sub(player.physical_surface.name, 0, #tbl_surface) == tbl_surface then
|
||||||
is_surface_valid = true
|
is_surface_valid = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if sub(player.surface.name, 0, #surface_name) ~= surface_name then
|
if sub(player.physical_surface.name, 0, #surface_name) ~= surface_name then
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
|
@ -749,6 +749,8 @@ local function on_player_crafted_item(event)
|
|||||||
local final_xp = recipe.energy * amount
|
local final_xp = recipe.energy * amount
|
||||||
|
|
||||||
local get_dex_modifier = Public.get_dex_modifier(player)
|
local get_dex_modifier = Public.get_dex_modifier(player)
|
||||||
|
if not get_dex_modifier then return end
|
||||||
|
|
||||||
if get_dex_modifier >= 10 then
|
if get_dex_modifier >= 10 then
|
||||||
local chance = Public.get_crafting_bonus_chance(player) * 10
|
local chance = Public.get_crafting_bonus_chance(player) * 10
|
||||||
local r = random(0, 1999)
|
local r = random(0, 1999)
|
||||||
|
@ -117,7 +117,7 @@ local function execute(event)
|
|||||||
player = game.get_player(event.player_index)
|
player = game.get_player(event.player_index)
|
||||||
else
|
else
|
||||||
player = {
|
player = {
|
||||||
name = 'Server',
|
name = '<server>',
|
||||||
position = { x = 0, y = 0 },
|
position = { x = 0, y = 0 },
|
||||||
surface = game.get_surface('nauvis'),
|
surface = game.get_surface('nauvis'),
|
||||||
force = game.forces.player,
|
force = game.forces.player,
|
||||||
@ -267,6 +267,18 @@ local function execute(event)
|
|||||||
handled_parameters[index] = player_data
|
handled_parameters[index] = player_data
|
||||||
index = index + 1
|
index = index + 1
|
||||||
end
|
end
|
||||||
|
if param_data.as_type == 'surface' and param ~= nil then
|
||||||
|
local surface_name = param
|
||||||
|
if type(surface_name) ~= 'string' then
|
||||||
|
return reject('Inputted value is not of type string. Valid values are: "string"')
|
||||||
|
end
|
||||||
|
local surface_data = game.get_surface(surface_name) --[[@type LuaSurface]]
|
||||||
|
if not surface_data then
|
||||||
|
return reject('Surface was not found.')
|
||||||
|
end
|
||||||
|
handled_parameters[index] = surface_data
|
||||||
|
index = index + 1
|
||||||
|
end
|
||||||
if param_data.as_type == 'player-online' and param ~= nil then
|
if param_data.as_type == 'player-online' and param ~= nil then
|
||||||
local player_name = param
|
local player_name = param
|
||||||
if type(player_name) ~= 'string' then
|
if type(player_name) ~= 'string' then
|
||||||
@ -345,7 +357,6 @@ local function execute(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Run the command callback if everything is validated
|
-- Run the command callback if everything is validated
|
||||||
handled_parameters[#handled_parameters + 1] = input_text
|
|
||||||
local callback = Task.get(command_data.callback)
|
local callback = Task.get(command_data.callback)
|
||||||
local success, err = pcall(callback, player, unpack(handled_parameters))
|
local success, err = pcall(callback, player, unpack(handled_parameters))
|
||||||
if internal_error(success, command_data.name, err) then
|
if internal_error(success, command_data.name, err) then
|
||||||
|
@ -10,6 +10,8 @@ local Gui = require 'utils.gui'
|
|||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
local Discord = require 'utils.discord_handler'
|
local Discord = require 'utils.discord_handler'
|
||||||
local Commands = require 'utils.commands'
|
local Commands = require 'utils.commands'
|
||||||
|
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||||
|
local Task = require 'utils.task_token'
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
@ -24,28 +26,191 @@ Global.register(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local Public = {
|
local Public = {}
|
||||||
}
|
|
||||||
|
|
||||||
local clear_corpse_button_name = Gui.uid_name()
|
local clear_corpse_button_name = Gui.uid_name()
|
||||||
|
local floor = math.floor
|
||||||
|
|
||||||
Commands.new('playtime', 'Fetches a player total playtime or nil.')
|
local clear_chunk_token =
|
||||||
|
Task.register(
|
||||||
|
function (event)
|
||||||
|
local chunk = event.chunk
|
||||||
|
if not chunk then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local surface = game.get_surface(event.surface_index)
|
||||||
|
if not surface or not surface.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if chunk and #chunk > 2 then
|
||||||
|
for _, c in pairs(chunk) do
|
||||||
|
surface.delete_chunk(c)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
surface.delete_chunk(chunk)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
local remove_offline_players_token =
|
||||||
|
Task.register(
|
||||||
|
function (event)
|
||||||
|
local list = event.list
|
||||||
|
if not list then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
game.remove_offline_players(list)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
local function tick_to_hours(t)
|
||||||
|
local seconds = t * 60
|
||||||
|
local minutes = floor((seconds) * 60)
|
||||||
|
return floor((minutes) * 60)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function hours_to_tick(t)
|
||||||
|
local seconds = t / 60
|
||||||
|
local minutes = floor((seconds) / 60)
|
||||||
|
return floor((minutes) / 60)
|
||||||
|
end
|
||||||
|
|
||||||
|
Commands.new('clear_all_enemies', 'Iterates over the current player surface and removes all generated enemies.')
|
||||||
|
:require_admin()
|
||||||
|
:require_validation("This will remove all enemies from the map.")
|
||||||
|
:add_parameter('surface', true, 'surface')
|
||||||
|
:add_parameter('force', true, 'string')
|
||||||
|
:callback(
|
||||||
|
function (player, surface_arg, force_arg)
|
||||||
|
local surface = surface_arg or player.surface
|
||||||
|
local force = force_arg or 'enemy'
|
||||||
|
local count = 0
|
||||||
|
for c in surface.get_chunks() do
|
||||||
|
for _, entity in pairs(surface.find_entities_filtered({ area = { { c.x * 32, c.y * 32 }, { c.x * 32 + 32, c.y * 32 + 32 } }, force = force })) do
|
||||||
|
if entity and entity.valid then
|
||||||
|
entity.destroy()
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if count == 0 then
|
||||||
|
player.print('No enemies to remove were found!')
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
game.print(mapkeeper .. ' ' .. player.name .. ' removed ' .. count .. ' enemies.')
|
||||||
|
Discord.send_notification_raw(nil, player.name .. ' removed ' .. count .. ' enemies.')
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
Commands.new('remove_chunks', 'Iterates over a surface and removes chunks that are charted but does not have any player entitie.')
|
||||||
|
:require_validation("This will remove all chunks that are charted but does not have any player entities.")
|
||||||
|
:require_admin()
|
||||||
|
:add_parameter('force', true, 'string')
|
||||||
|
:callback(
|
||||||
|
function (player, args)
|
||||||
|
local surface = player.surface
|
||||||
|
local chunks = surface.get_chunks()
|
||||||
|
local tick = 0
|
||||||
|
local force = args or player.force.name
|
||||||
|
|
||||||
|
local chunks_to_remove = {}
|
||||||
|
|
||||||
|
for chunk in chunks do
|
||||||
|
if surface.is_chunk_generated(chunk) then
|
||||||
|
local area = {
|
||||||
|
left_top = { chunk.area.left_top.x - 64, chunk.area.left_top.y - 64 },
|
||||||
|
right_bottom = { chunk.area.right_bottom.x + 64, chunk.area.right_bottom.y + 64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
local ents = surface.find_entities_filtered { area = area, force = { force } }
|
||||||
|
local total_count = #ents
|
||||||
|
|
||||||
|
if total_count <= 0 then
|
||||||
|
chunks_to_remove[#chunks_to_remove + 1] = chunk
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if chunks_to_remove and #chunks_to_remove >= 10 then
|
||||||
|
tick = tick + 2
|
||||||
|
Task.set_timeout_in_ticks(tick, clear_chunk_token,
|
||||||
|
{ chunk = chunks_to_remove, surface_index = surface.index })
|
||||||
|
|
||||||
|
chunks_to_remove = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
game.print(mapkeeper .. ' ' .. player.name .. ' scheduled ' .. surface.name .. ' for chunk removal.')
|
||||||
|
Discord.send_notification_raw(nil, player.name .. ' scheduled ' .. surface.name .. ' for chunk removal.')
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
Commands.new('remove_offline_players', 'Remove offline players.')
|
||||||
|
:require_validation("This will remove offline players that has not connected in the given hours.")
|
||||||
|
:add_parameter('hours', false, "number")
|
||||||
|
:require_admin()
|
||||||
|
:callback(
|
||||||
|
function (player, hours)
|
||||||
|
local surface = player.surface
|
||||||
|
local remove_players = {}
|
||||||
|
local tick = 0
|
||||||
|
local count = 0
|
||||||
|
local converted_hours = tick_to_hours(hours)
|
||||||
|
local converted_game_tick = hours_to_tick(game.tick)
|
||||||
|
|
||||||
|
if game.tick < converted_hours then
|
||||||
|
player.print('Cannot remove players that has not been offline for less than ' .. hours .. ' hours when the server has been running for ' .. converted_game_tick .. ' hours.')
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, p in pairs(game.players) do
|
||||||
|
if p.last_online < converted_hours then
|
||||||
|
count = count + 1
|
||||||
|
remove_players[#remove_players + 1] = p.name
|
||||||
|
|
||||||
|
if remove_players and #remove_players >= 10 then
|
||||||
|
tick = tick + 2
|
||||||
|
Task.set_timeout_in_ticks(tick, remove_offline_players_token,
|
||||||
|
{ list = remove_players })
|
||||||
|
|
||||||
|
remove_players = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local message = player.name .. ' scheduled ' .. surface.name .. ' for offline player removal of count: ' .. count .. '.'
|
||||||
|
game.print(mapkeeper .. ' ' .. message)
|
||||||
|
Discord.send_notification_raw(nil, message)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
Commands.new('playtime', 'Gets a single player total playtime or nil.')
|
||||||
:require_backend()
|
:require_backend()
|
||||||
:add_parameter('target', false, 'string')
|
:add_parameter('target', false, 'string')
|
||||||
:callback(
|
:callback(
|
||||||
function (player, target)
|
function (player, target)
|
||||||
Session.get_and_print_to_player(player, target)
|
Session.get_and_print_to_player(player, target)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
Commands.new('refresh', 'Reloads game script')
|
Commands.new('refresh', 'Reloads game script')
|
||||||
:require_admin()
|
:require_admin()
|
||||||
|
:require_validation("Running this command will freeze the server if run in multiplayer.")
|
||||||
|
:add_alias('reload')
|
||||||
:callback(
|
:callback(
|
||||||
function ()
|
function (player)
|
||||||
game.print('Reloading game script...', Color.warning)
|
game.print('Reloading game script...', Color.warning)
|
||||||
Server.to_discord_bold('Reloading game script...')
|
Server.to_discord_bold(player.name .. ' is reloading the game script.')
|
||||||
|
Discord.send_notification_raw(nil, player.name .. ' is reloading the game script.')
|
||||||
game.reload_script()
|
game.reload_script()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -75,6 +240,7 @@ Commands.new('spaghetti', 'Toggle between disabling bots.')
|
|||||||
force.technologies['worker-robots-speed-5'].enabled = false
|
force.technologies['worker-robots-speed-5'].enabled = false
|
||||||
force.technologies['worker-robots-speed-6'].enabled = false
|
force.technologies['worker-robots-speed-6'].enabled = false
|
||||||
this.spaghetti_enabled = true
|
this.spaghetti_enabled = true
|
||||||
|
return true
|
||||||
elseif args == 'false' then
|
elseif args == 'false' then
|
||||||
game.print('The world is no longer spaghett!', Color.yellow)
|
game.print('The world is no longer spaghett!', Color.yellow)
|
||||||
force.technologies['logistic-system'].enabled = true
|
force.technologies['logistic-system'].enabled = true
|
||||||
@ -93,7 +259,9 @@ Commands.new('spaghetti', 'Toggle between disabling bots.')
|
|||||||
force.technologies['worker-robots-speed-5'].enabled = true
|
force.technologies['worker-robots-speed-5'].enabled = true
|
||||||
force.technologies['worker-robots-speed-6'].enabled = true
|
force.technologies['worker-robots-speed-6'].enabled = true
|
||||||
this.spaghetti_enabled = false
|
this.spaghetti_enabled = false
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -106,7 +274,7 @@ Commands.new('generate_map', 'Pregenerates map.')
|
|||||||
local radius = args
|
local radius = args
|
||||||
local surface = player.surface
|
local surface = player.surface
|
||||||
if surface.is_chunk_generated({ radius, radius }) then
|
if surface.is_chunk_generated({ radius, radius }) then
|
||||||
player.print('Map generation done')
|
player.print('Map generation is already generated')
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
surface.request_to_generate_chunks({ 0, 0 }, radius)
|
surface.request_to_generate_chunks({ 0, 0 }, radius)
|
||||||
@ -115,6 +283,7 @@ Commands.new('generate_map', 'Pregenerates map.')
|
|||||||
pl.play_sound { path = 'utility/new_objective', volume_modifier = 1 }
|
pl.play_sound { path = 'utility/new_objective', volume_modifier = 1 }
|
||||||
end
|
end
|
||||||
player.print('Map generation done')
|
player.print('Map generation done')
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ local function vote_to_jail(player, offender, msg)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(offender) == 'table' then
|
if type(offender) == 'userdata' then
|
||||||
offender = offender.name
|
offender = offender.name
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ local function vote_to_free(player, offender)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(offender) == 'table' then
|
if type(offender) == 'userdata' then
|
||||||
offender = offender.name
|
offender = offender.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ local Game = {}
|
|||||||
local bad_name_players = {}
|
local bad_name_players = {}
|
||||||
Global.register(
|
Global.register(
|
||||||
bad_name_players,
|
bad_name_players,
|
||||||
function(tbl)
|
function (tbl)
|
||||||
bad_name_players = tbl
|
bad_name_players = tbl
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -53,7 +53,7 @@ function Game.get_player_from_any(obj)
|
|||||||
p = Game.get_player_by_index(obj)
|
p = Game.get_player_by_index(obj)
|
||||||
elseif o_type == 'string' 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
|
elseif o_type == 'userdata' and obj.valid and obj.is_player() then
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ function Game.player_print(str)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Game.get_player(mixed)
|
function Game.get_player(mixed)
|
||||||
if type(mixed) == 'table' then
|
if type(mixed) == 'userdata' then
|
||||||
if mixed.__self then
|
if mixed.__self then
|
||||||
return mixed and mixed.valid and mixed
|
return mixed and mixed.valid and mixed
|
||||||
elseif mixed.player_index then
|
elseif mixed.player_index then
|
||||||
@ -120,7 +120,7 @@ function Game.print_player_floating_text_position(player_index, text, color, x_o
|
|||||||
end
|
end
|
||||||
|
|
||||||
local position = player.position
|
local position = player.position
|
||||||
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)
|
function Game.print_player_floating_text(player_index, text, color)
|
||||||
|
@ -829,7 +829,7 @@ local function tick()
|
|||||||
local player_index = p.index
|
local player_index = p.index
|
||||||
local tbl = player_create_poll_data[player_index]
|
local tbl = player_create_poll_data[player_index]
|
||||||
if tbl then
|
if tbl then
|
||||||
for k, element in pairs(tbl) do
|
for _, element in pairs(tbl) do
|
||||||
if type(element) == 'table' then
|
if type(element) == 'table' then
|
||||||
if not element.valid then
|
if not element.valid then
|
||||||
player_create_poll_data[player_index] = nil
|
player_create_poll_data[player_index] = nil
|
||||||
|
@ -1148,11 +1148,10 @@ function Public.export_stats()
|
|||||||
|
|
||||||
}
|
}
|
||||||
for _, statName in pairs(statistics) do
|
for _, statName in pairs(statistics) do
|
||||||
flow_statistics[statName] = {
|
local surface_stats = flow_statistics[statName] or {}
|
||||||
[surface.name] = {
|
surface_stats[surface.name] = {
|
||||||
input = force[statName](surface).input_counts,
|
input = force[statName](surface).input_counts,
|
||||||
output = force[statName](surface).output_counts
|
output = force[statName](surface).output_counts
|
||||||
},
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user