1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-05-13 21:56:29 +02:00

Mining Thief History

This commit is contained in:
MewMew 2018-12-02 06:39:54 +01:00
parent 0c1c15009e
commit 56cea737cd
2 changed files with 39 additions and 1 deletions

View File

@ -150,6 +150,31 @@ local function on_entity_died(event)
global.friendly_fire_history[#global.friendly_fire_history + 1] = str
end
--Mining Thieves History
local blacklisted_types = {
["transport-belt"] = true,
["inserter"] = true
}
local function on_player_mined_entity(event)
if not event.entity.last_user then return end
local player = game.players[event.player_index]
if event.entity.last_user.name == player.name then return end
if event.entity.force.name ~= player.force.name then return end
if blacklisted_types[event.entity.type] then return end
if not global.mining_history then global.mining_history = {} end
if #global.mining_history > 999 then global.mining_history = {} end
local str = player.name .. " mined "
str = str .. event.entity.name
str = str .. " at X:"
str = str .. math.floor(event.entity.position.x)
str = str .. " Y:"
str = str .. math.floor(event.entity.position.y)
global.mining_history[#global.mining_history + 1] = str
end
local function on_gui_opened(event)
if not event.entity then return end
if event.entity.name ~= "character-corpse" then return end
@ -169,6 +194,7 @@ local function on_pre_player_mined_item(event)
end
end
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_built_entity, on_built_entity)
event.add(defines.events.on_console_command, on_console_command)

View File

@ -234,7 +234,7 @@ local function create_admin_panel(player)
local l = frame.add({type = "label", caption = "----------------------------------------------"})
end
local t = frame.add({type = "table", column_count = 3})
local t = frame.add({type = "table", column_count = 4})
if global.friendly_fire_history then
local tt = t.add({type = "table", column_count = 1})
@ -248,6 +248,18 @@ local function create_admin_panel(player)
end
end
if global.mining_history then
local tt = t.add({type = "table", column_count = 1})
local l = tt.add({type = "label", caption = "Mining History:"})
l.style.font = "default-listbox"
l.style.font_color = { r=0.98, g=0.66, b=0.22}
local scroll_pane = tt.add({ type = "scroll-pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"})
scroll_pane.style.maximal_height = 160
for i = #global.mining_history, 1, -1 do
scroll_pane.add({type = "label", caption = global.mining_history[i]})
end
end
if global.landfill_history then
local tt = t.add({type = "table", column_count = 1})
local l = tt.add({type = "label", caption = "Landfill History:"})