diff --git a/locale/gen_combined/dimentions.lua b/locale/gen_combined/dimentions.lua index db8d9de5..738e1161 100644 --- a/locale/gen_combined/dimentions.lua +++ b/locale/gen_combined/dimentions.lua @@ -14,6 +14,7 @@ global.magic_chests = {} global.last_tp = {} global.teleport_cooldown = 3 +global.portal_radius = 2.5 local function get_nice_surface_name(surface) @@ -45,7 +46,7 @@ end local function teleport_nearby_players(portal) for _,player in pairs(game.players) do if player.connected and player.surface == portal.source then - if distance(portal.position, player.position) < 2.5 then + if distance(portal.position, player.position) < global.portal_radius then if not global.last_tp[player.name] or global.last_tp[player.name] + global.teleport_cooldown * 60 < game.tick then player.teleport(portal.target, portal.target_surface) global.last_tp[player.name] = game.tick diff --git a/nuke_control.lua b/nuke_control.lua index 9c62ddb7..62937df6 100644 --- a/nuke_control.lua +++ b/nuke_control.lua @@ -29,18 +29,35 @@ local function on_player_deconstructed_area(event) end end -local init = true +local function log_on_player_mined_entity(str, event) + game.write_file("on_plalyer_mined_entity_debug", game.tick .. " (" .. game.players[event.player_index].name .. ") " .. str .. "\n", true, 1) +end + +global.on_player_mined_item_enabled = true +global.on_player_mined_item_init = true + local function on_player_mined_item(event) - if init then - game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration on force toggle - init = false - end - if event.entity.force.name ~= "enemy" and event.entity.force.name ~= "neutral" and event.entity.name ~= "entity-ghost" then - local entity_name = event.entity.name - if entity_name == "pipe-to-ground" then entity_name = "pipe" end - local ghost = event.entity.surface.create_entity{name = "entity-ghost", position = event.entity.position, inner_name = entity_name, expires = false, force = "enemy", direction = event.entity.direction} - ghost.last_user = event.player_index + log_on_player_mined_entity("nuke_control.on_player_mined_item: entry", event) + if global.on_player_mined_item_enabled then + log_on_player_mined_entity("nuke_control.on_player_mined_item: enabled", event) + if global.on_player_mined_item_init then + log_on_player_mined_entity("nuke_control.on_player_mined_item: init", event) + game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration on force toggle + global.on_player_mined_item_init = false + end + local entity = event.entity + if entity.force.name ~= "enemy" and entity.force.name ~= "neutral" and entity.name ~= "entity-ghost" and entity.type ~= "logistic-robot" and entity.type ~= "construction-robot" then + log_on_player_mined_entity("nuke_control.on_player_mined_item: in body", event) + local entity_name = entity.name + if entity_name == "pipe-to-ground" then entity_name = "pipe" end + log_on_player_mined_entity("nuke_control.on_player_mined_item: before ghost placement", event) + local ghost = event.entity.surface.create_entity{name = "entity-ghost", position = event.entity.position, inner_name = entity_name, expires = false, force = "enemy", direction = event.entity.direction} + log_on_player_mined_entity("nuke_control.on_player_mined_item: ghost placed", event) + ghost.last_user = event.player_index + log_on_player_mined_entity("nuke_control.on_player_mined_item: last user set", event) + end end + log_on_player_mined_entity("nuke_control.on_player_mined_item: exit", event) end Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed)