mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Merge pull request #1171 from Refactorio/fish_munchers
Added fish consumed to player_stats and crash site awards
This commit is contained in:
commit
6aa3fc3a71
@ -28,6 +28,7 @@ local player_spawners_killed_name = 'player-spawners-killed'
|
||||
local player_total_kills_name = 'player-total-kills'
|
||||
local player_turrets_killed_name = 'player-turrets-killed'
|
||||
local player_entities_built_name = 'player_entities_built'
|
||||
local player_fish_eaten_name = 'player_fish_eaten'
|
||||
|
||||
ScoreTracker.register(rocks_smashed_name, {'player_stats.rocks_smashed'}, '[img=entity.rock-huge]')
|
||||
ScoreTracker.register(trees_cut_down_name, {'player_stats.trees_cut_down'}, '[img=entity.tree-02]')
|
||||
@ -49,6 +50,7 @@ ScoreTracker.register(player_spawners_killed_name, {'player_stats.player_spawner
|
||||
ScoreTracker.register(player_turrets_killed_name, {'player_stats.player_turrets_killed'})
|
||||
ScoreTracker.register(player_total_kills_name, {'player_stats.player_total_kills'})
|
||||
ScoreTracker.register(player_entities_built_name, {'player_stats.player_entities_built'})
|
||||
ScoreTracker.register(player_fish_eaten_name, {'player_stats.player_fish_eaten'})
|
||||
|
||||
local train_kill_causes = {
|
||||
['locomotive'] = true,
|
||||
@ -282,6 +284,15 @@ local function rocket_launched(event)
|
||||
change_for_global(satellites_launched_name, 1)
|
||||
end
|
||||
|
||||
local function capsule_used(event)
|
||||
local item = event.item
|
||||
|
||||
if not item or not item.valid or item.name ~= 'raw-fish' then
|
||||
return
|
||||
end
|
||||
|
||||
change_for_player(event.player_index, player_fish_eaten_name, 1)
|
||||
end
|
||||
local function tick()
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if (p.afk_time < 30 or p.walking_state.walking) and p.vehicle == nil then
|
||||
@ -309,6 +320,7 @@ Event.add(defines.events.on_built_entity, player_built_entity)
|
||||
Event.add(defines.events.on_robot_built_entity, robot_built_entity)
|
||||
Event.add(defines.events.on_entity_died, entity_died)
|
||||
Event.add(defines.events.on_rocket_launched, rocket_launched)
|
||||
Event.add(defines.events.on_player_used_capsule, capsule_used)
|
||||
|
||||
Event.on_nth_tick(62, tick)
|
||||
|
||||
@ -332,7 +344,8 @@ local Public = {
|
||||
player_spawners_killed_name = player_spawners_killed_name,
|
||||
player_total_kills_name = player_total_kills_name,
|
||||
player_turrets_killed_name = player_turrets_killed_name,
|
||||
player_entities_built_name = player_entities_built_name
|
||||
player_entities_built_name = player_entities_built_name,
|
||||
player_fish_eaten_name = player_fish_eaten_name
|
||||
}
|
||||
|
||||
-- Returns a dictionary of cause_name -> count
|
||||
|
@ -123,6 +123,7 @@ function Public.control(config)
|
||||
coins_earned = ScoreTracker.get_for_player(p.index, PlayerStats.coins_earned_name),
|
||||
entities_built = ScoreTracker.get_for_player(p.index,PlayerStats.player_entities_built_name),
|
||||
entities_crafted = ScoreTracker.get_for_player(p.index,PlayerStats.player_items_crafted_name),
|
||||
fish_eaten = ScoreTracker.get_for_player(p.index,PlayerStats.player_fish_eaten_name),
|
||||
time_played = p.online_time
|
||||
}
|
||||
end
|
||||
@ -149,7 +150,8 @@ function Public.control(config)
|
||||
['entities_built'] = {value = 0, player = ""},
|
||||
['entities_crafted'] = {value = 0, player = ""},
|
||||
['distance_walked'] = {value = 0, player = ""},
|
||||
['coins_earned'] = {value = 0, player = ""}
|
||||
['coins_earned'] = {value = 0, player = ""},
|
||||
['fish_eaten'] = {value = 0, player = ""}
|
||||
}
|
||||
|
||||
for k, v in pairs(statistics.player_data) do
|
||||
@ -193,6 +195,10 @@ function Public.control(config)
|
||||
awards.coins_earned.value = v.coins_earned
|
||||
awards.coins_earned.player = v.name
|
||||
end
|
||||
if v.fish_eaten > awards.fish_eaten.value then
|
||||
awards.fish_eaten.value = v.fish_eaten
|
||||
awards.fish_eaten.player = v.name
|
||||
end
|
||||
end
|
||||
|
||||
local time_string = Core.format_time(game.ticks_played)
|
||||
@ -215,9 +221,10 @@ function Public.control(config)
|
||||
.. 'Most time played: '..awards.time_played.player..' ('..Core.format_time(awards.time_played.value)..')\\n'
|
||||
.. 'Furthest walked: '..awards.distance_walked.player..' ('..math.floor(awards.distance_walked.value)..')\\n'
|
||||
.. 'Most coins earned: '..awards.coins_earned.player..' ('..awards.coins_earned.value..')\\n'
|
||||
.. 'Seafood lover: '..awards.fish_eaten.player..' ('..awards.fish_eaten.value..' fish eaten)\\n'
|
||||
)
|
||||
else
|
||||
Server.to_discord_named_embed(map_promotion_channel, 'Crash Site map failed!\\n\\n'
|
||||
Server.to_discord_named_embed(map_promotion_channel, 'Crash Site map failed!\\n\\n'
|
||||
.. 'Statistics:\\n'
|
||||
.. 'Map time: '..time_string..'\\n'
|
||||
.. 'Total kills: '..statistics.biters_killed..'\\n'
|
||||
|
Loading…
Reference in New Issue
Block a user