1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-17 21:08:08 +02:00

implemented debug outout and enable/disable for nuke_control.on_player_mined

This commit is contained in:
Valansch 2017-10-26 16:28:08 +02:00
parent 237eaf6c7d
commit 70a055a495
2 changed files with 29 additions and 11 deletions

View File

@ -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

View File

@ -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)