Update player kill tracking logic and increment version to 0.1.9
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -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": [
|
||||
|
||||
23
control.lua
23
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
|
||||
|
||||
Reference in New Issue
Block a user