From 2d967438cb6f29a80a5c5a570e94f99430afe13d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 15 Mar 2018 18:58:20 +0000 Subject: [PATCH] Added Body Markers --- StandAlone/body-marker.lua | 25 +++++++++++++++++++++++++ StandAlone/load.lua | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 StandAlone/body-marker.lua diff --git a/StandAlone/body-marker.lua b/StandAlone/body-marker.lua new file mode 100644 index 00000000..3f71db82 --- /dev/null +++ b/StandAlone/body-marker.lua @@ -0,0 +1,25 @@ +-- made by cooldude - this just adds a marker to the map which is removed when the body is removed + +Event.register(defines.events.on_player_died, function(event) + local player = game.players[event.player_index] + local tag = player.force.add_chart_tag(player.surface,{ + position=player.position, + text='Death: '..player.name..' ('..tick_to_display_format(event.tick)..')' + }) + if not global.corpses then global.corpses = {} end + table.insert(global.corpses,tag) +end) + +Event.register(defines.events.on_tick, function(event) + if (game.tick%3600) ~= 0 then return end + if not global.corpses then global.corpses = {} end + for key,tag in pairs(global.corpses) do + if not tag.valid then global.corpses[key] = nil return end + if not tag.target then + local o = tag.position + local entity = tag.surface.find_entities_filtered{area={{o.x-1,o.y-1},{o.x+1,o.y+1}},name='character-corpse'} + if entity[1] then tag.target = entity[1] end + end + if not tag.target or not tag.target.valid then tag.destroy() global.corpses[key] = nil return end + end +end) \ No newline at end of file diff --git a/StandAlone/load.lua b/StandAlone/load.lua index 6c8b3923..12e896b4 100644 --- a/StandAlone/load.lua +++ b/StandAlone/load.lua @@ -18,4 +18,5 @@ require('colours') require('health') require('spawn') require('starting-items') ---require('paths') -- takes up too much file size \ No newline at end of file +--require('paths') -- takes up too much file size +require('body-marker') \ No newline at end of file