mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
print player deaths to discord
This commit is contained in:
parent
36d165afe1
commit
da904702ca
@ -695,7 +695,7 @@ Event.add(Public.events.on_server_started, set_scenario_version)
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
@ -707,7 +707,7 @@ Event.add(
|
||||
Event.add(
|
||||
defines.events.on_player_left_game,
|
||||
function(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
@ -716,4 +716,35 @@ Event.add(
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_died,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local cause = event.cause
|
||||
|
||||
local message = {discord_bold_tag, player.name}
|
||||
if cause and cause.valid then
|
||||
message[#message + 1] = ' was killed by '
|
||||
|
||||
local name = cause.name
|
||||
if name == 'player' then
|
||||
name = cause.player.name
|
||||
end
|
||||
|
||||
message[#message + 1] = name
|
||||
message[#message + 1] = '.'
|
||||
else
|
||||
message[#message + 1] = ' has died.'
|
||||
end
|
||||
|
||||
message = concat(message)
|
||||
raw_print(message)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
|
Loading…
Reference in New Issue
Block a user