From 1e736c89ab43fcc06e1bf20c480c0cb83dc5a4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Grie=C3=9Fhaber?= Date: Fri, 2 Jan 2026 22:08:41 +0100 Subject: [PATCH] Update player kill tracking logic and increment version to 0.1.9 --- .vscode/settings.json | 2 +- control.lua | 23 +++++++++++------------ info.json | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fc17c31..d4784a5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "Lua.workspace.userThirdParty": [ - "c:\\Users\\jangr\\AppData\\Roaming\\Code\\User\\workspaceStorage\\ebd0abbb61655c51088fab51f622e068\\justarandomgeek.factoriomod-debug\\sumneko-3rd" + "c:\\Users\\jangr\\AppData\\Roaming\\Code\\User\\workspaceStorage\\340ead7f10d9ae8505ebc6dec42b1e88\\justarandomgeek.factoriomod-debug\\sumneko-3rd" ], "Lua.workspace.checkThirdParty": "ApplyInMemory", "factorio.versions": [ diff --git a/control.lua b/control.lua index e2a0442..0c4f6ae 100644 --- a/control.lua +++ b/control.lua @@ -134,20 +134,19 @@ end) script.on_event(defines.events.on_player_died, function(event) - if event.cause and event.cause.player~=nil then + if event.cause and event.cause.type == "character" then + local killer = event.cause.player + if killer then + local killer_index = killer.index + local victim_index = event.player_index + log(("Player ID %d killed player ID %d"):format(killer_index,victim_index)) - local killer = event.cause.player - if not killer then return end - local killer_index = killer.index + storage.playerKillCount[killer_index] = + storage.playerKillCount[killer_index] or {} - local victim_index = event.player_index - log(("Player ID %d killed player ID %d"):format(killer_index,victim_index)) - - storage.playerKillCount[killer_index] = - storage.playerKillCount[killer_index] or {} - - storage.playerKillCount[killer_index][victim_index] = - (storage.playerKillCount[killer_index][victim_index] or 0) + 1 + storage.playerKillCount[killer_index][victim_index] = + (storage.playerKillCount[killer_index][victim_index] or 0) + 1 + end end storage.playerDeathCount[event.player_index] = (storage.playerDeathCount[event.player_index] or 0) + 1 diff --git a/info.json b/info.json index 184c11d..fea4eeb 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "factorio-metrics-exporter", - "version": "0.1.8", + "version": "0.1.9", "title": "Prometheus Metrics Exporter", "author": "Jan Grießhaber", "contact": "jan@griesshaber.systems",