mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-28 03:57:22 +02:00
Fix broken stuff
This commit is contained in:
parent
474347231a
commit
604ba247ab
@ -111,7 +111,7 @@ local artillery_target_entities = {
|
||||
'car',
|
||||
'radar',
|
||||
'lab',
|
||||
'furnace',
|
||||
'stone-furnace',
|
||||
'locomotive',
|
||||
'cargo-wagon',
|
||||
'fluid-wagon',
|
||||
@ -120,7 +120,7 @@ local artillery_target_entities = {
|
||||
'laser-turret',
|
||||
'gun-turret',
|
||||
'flamethrower-turret',
|
||||
'silo',
|
||||
'rocket-silo',
|
||||
'spidertron'
|
||||
}
|
||||
|
||||
|
@ -677,9 +677,17 @@ local function construct_doors(car)
|
||||
for _, x in pairs({ area.left_top.x - 1.5, area.right_bottom.x + 1.5 }) do
|
||||
local p = { x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) }
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 1 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y - 1 } } }, true)
|
||||
else
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y - 0.5 } } }, true)
|
||||
end
|
||||
local e =
|
||||
surface.create_entity(
|
||||
|
@ -484,9 +484,17 @@ local function construct_wagon_doors(icw, wagon)
|
||||
for _, x in pairs({ area.left_top.x - 1.5, area.right_bottom.x + 1.5 }) do
|
||||
local p = { x = x, y = area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5) }
|
||||
if p.x < 0 then
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x + 0.5, y = p.y - 1 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y - 1 } } }, true)
|
||||
else
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 0.5, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x, y = p.y - 0.5 } } }, true)
|
||||
surface.set_tiles({ { name = main_tile_name, position = { x = p.x - 1, y = p.y - 0.5 } } }, true)
|
||||
end
|
||||
local e =
|
||||
surface.create_entity(
|
||||
|
@ -8,8 +8,8 @@ local this = {
|
||||
settings = {
|
||||
is_enabled = false,
|
||||
offline_players_surface_removal = false,
|
||||
active_surface_index = nil, -- needs to be set else this will fail
|
||||
required_online_time = 18000, -- nearest prime to 5 minutes in ticks
|
||||
active_surface_index = nil, -- needs to be set else this will fail
|
||||
required_online_time = 18000, -- nearest prime to 5 minutes in ticks
|
||||
clear_player_after_tick = 108000 -- nearest prime to 30 minutes in ticks
|
||||
},
|
||||
offline_players = {}
|
||||
@ -17,7 +17,7 @@ local this = {
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -43,8 +43,6 @@ function Public.dump_expired_players()
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
if #this.offline_players > 0 then
|
||||
for i = 1, #this.offline_players, 1 do
|
||||
if this.offline_players[i] and this.offline_players[i].index then
|
||||
@ -54,8 +52,11 @@ function Public.dump_expired_players()
|
||||
remove(this.offline_players, i)
|
||||
else
|
||||
if this.offline_players[i].tick < tick then
|
||||
local name = this.offline_players[i].name
|
||||
player_inv[1] = target.get_inventory(defines.inventory.character_main)
|
||||
local player_inv = {}
|
||||
local items = {}
|
||||
|
||||
local name = target.name
|
||||
player_inv[1] = target.get_main_inventory()
|
||||
player_inv[2] = target.get_inventory(defines.inventory.character_armor)
|
||||
player_inv[3] = target.get_inventory(defines.inventory.character_guns)
|
||||
player_inv[4] = target.get_inventory(defines.inventory.character_ammo)
|
||||
@ -64,25 +65,32 @@ function Public.dump_expired_players()
|
||||
Event.raise(this.events.remove_surface, { target = target })
|
||||
end
|
||||
|
||||
if target.get_item_count() == 0 then -- if the player has zero items, don't do anything
|
||||
local found_items = false
|
||||
for index = 1, 5, 1 do
|
||||
if player_inv[index] and player_inv[index].valid and player_inv[index].get_item_count() ~= 0 then
|
||||
found_items = true
|
||||
end
|
||||
end
|
||||
|
||||
if not found_items then -- if the player has zero items, don't do anything
|
||||
remove(this.offline_players, i)
|
||||
goto final
|
||||
end
|
||||
|
||||
local pos = game.forces.player.get_spawn_position(surface)
|
||||
local e =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'character',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
if not e or not e.valid then
|
||||
break
|
||||
end
|
||||
|
||||
local inv = e.get_inventory(defines.inventory.character_main)
|
||||
local inv = e.get_main_inventory()
|
||||
if not inv then
|
||||
break
|
||||
end
|
||||
@ -90,9 +98,9 @@ function Public.dump_expired_players()
|
||||
---@diagnostic disable-next-line: assign-type-mismatch
|
||||
e.character_inventory_slots_bonus = #player_inv[1]
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
if player_inv[ii] and player_inv[ii].valid then
|
||||
for iii = 1, #player_inv[ii], 1 do
|
||||
if player_inv[ii][iii].valid then
|
||||
if player_inv[ii][iii] and player_inv[ii][iii].valid then
|
||||
insert(items, player_inv[ii][iii])
|
||||
end
|
||||
end
|
||||
@ -117,7 +125,7 @@ function Public.dump_expired_players()
|
||||
end
|
||||
|
||||
for ii = 1, 5, 1 do
|
||||
if player_inv[ii].valid then
|
||||
if player_inv[ii] and player_inv[ii].valid then
|
||||
player_inv[ii].clear()
|
||||
end
|
||||
end
|
||||
@ -184,7 +192,7 @@ Event.on_nth_tick(tick_frequency, Public.dump_expired_players)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_pre_player_left_game,
|
||||
function(event)
|
||||
function (event)
|
||||
if not this.settings.is_enabled then
|
||||
return
|
||||
end
|
||||
|
@ -164,16 +164,21 @@ local function zoom_to_pos(event)
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
local player = event.player
|
||||
local element = event.element
|
||||
local target = Gui.get_data(element)
|
||||
local data = Gui.get_data(element)
|
||||
if not data then return end
|
||||
|
||||
if not target or not target.valid then
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
|
||||
if target.character ~= nil then target = target.character end
|
||||
player.centered_on = target
|
||||
player.set_controller({
|
||||
type = defines.controllers.remote,
|
||||
position = data.position,
|
||||
surface = player.surface,
|
||||
zoom = 4
|
||||
})
|
||||
end
|
||||
|
||||
local close_alert = Public.close_alert
|
||||
@ -290,7 +295,7 @@ function Public.alert_all_players_location(player, message, color, duration)
|
||||
style = 'slot_button'
|
||||
}
|
||||
|
||||
Gui.set_data(sprite, player)
|
||||
Gui.set_data(sprite, player.position)
|
||||
|
||||
local label =
|
||||
container.add {
|
||||
|
@ -583,6 +583,25 @@ function Public:callback(func)
|
||||
end
|
||||
end
|
||||
|
||||
local directions = {
|
||||
[0] = 'defines.direction.north',
|
||||
[1] = 'defines.direction.northnortheast',
|
||||
[2] = 'defines.direction.northeast',
|
||||
[3] = 'defines.direction.eastnortheast',
|
||||
[4] = 'defines.direction.east',
|
||||
[5] = 'defines.direction.eastsoutheast',
|
||||
[6] = 'defines.direction.southeast',
|
||||
[7] = 'defines.direction.southsoutheast',
|
||||
[8] = 'defines.direction.south',
|
||||
[9] = 'defines.direction.southsouthwest',
|
||||
[10] = 'defines.direction.southwest',
|
||||
[11] = 'defines.direction.westsouthwest',
|
||||
[12] = 'defines.direction.west',
|
||||
[13] = 'defines.direction.westnorthwest',
|
||||
[14] = 'defines.direction.northwest',
|
||||
[15] = 'defines.direction.northnorthwest',
|
||||
}
|
||||
|
||||
Public.new('get', 'Hover over an object to get its name.')
|
||||
:require_admin()
|
||||
:add_parameter('die', true, 'string')
|
||||
@ -602,7 +621,7 @@ Public.new('get', 'Hover over an object to get its name.')
|
||||
player.print('[color=orange]Name:[/color] ' .. entity.name)
|
||||
player.print('[color=orange]Type:[/color] ' .. entity.type)
|
||||
player.print('[color=orange]Force:[/color] ' .. entity.force.name)
|
||||
player.print('[color=orange]Direction:[/color] ' .. entity.direction)
|
||||
player.print('[color=orange]Direction:[/color] ' .. entity.direction .. ' (' .. directions[entity.direction] .. ')')
|
||||
player.print('[color=orange]Destructible:[/color] ' .. (entity.destructible and 'true' or 'false'))
|
||||
player.print('[color=orange]Minable:[/color] ' .. (entity.minable and 'true' or 'false'))
|
||||
player.print('[color=orange]Unit Number:[/color] ' .. (entity.unit_number or 'nil'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user