mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
more rewrite
This commit is contained in:
parent
cb4bc47efe
commit
f51fcce509
@ -287,7 +287,7 @@ local column_builders = {
|
||||
create_data = function(player)
|
||||
local index = player.index
|
||||
return {
|
||||
fish_earnt = PlayerStats.get_fish_earned(index),
|
||||
fish_earned = PlayerStats.get_fish_earned(index),
|
||||
fish_spent = PlayerStats.get_fish_spent(index)
|
||||
}
|
||||
end,
|
||||
@ -300,7 +300,13 @@ local column_builders = {
|
||||
end
|
||||
end,
|
||||
draw_heading = function(parent)
|
||||
local label = parent.add {type = 'label', name = fish_heading_name, caption = 'Fish'}
|
||||
local label =
|
||||
parent.add {
|
||||
type = 'label',
|
||||
name = fish_heading_name,
|
||||
caption = 'Fish',
|
||||
tooltip = 'Fish earned / spent.'
|
||||
}
|
||||
local label_style = label.style
|
||||
apply_heading_style(label_style)
|
||||
label_style.width = 80
|
||||
@ -308,7 +314,7 @@ local column_builders = {
|
||||
return label
|
||||
end,
|
||||
draw_cell = function(parent, cell_data)
|
||||
local text = table.concat({cell_data.fish_earnt, '/', cell_data.fish_spent})
|
||||
local text = table.concat({cell_data.fish_earned, '/', cell_data.fish_spent})
|
||||
|
||||
local label = parent.add {type = 'label', name = fish_cell_name, caption = text}
|
||||
local label_style = label.style
|
||||
|
@ -66,6 +66,15 @@ local function player_died(event)
|
||||
causes[cause] = cause_count + 1
|
||||
end
|
||||
|
||||
local function picked_up_item(event)
|
||||
local stack = event.item_stack
|
||||
|
||||
if stack.name == 'raw-fish' then
|
||||
local player_index = event.player_index
|
||||
player_fish_earned[player_index] = player_fish_earned[player_index] + stack.count
|
||||
end
|
||||
end
|
||||
|
||||
local function tick()
|
||||
for _, p in ipairs(game.connected_players) do
|
||||
if (p.afk_time < 30 or p.walking_state.walking) and p.vehicle == nil then
|
||||
@ -84,6 +93,7 @@ end
|
||||
|
||||
Event.add(defines.events.on_player_created, player_created)
|
||||
Event.add(defines.events.on_player_died, player_died)
|
||||
Event.add(defines.events.on_picked_up_item, picked_up_item)
|
||||
Event.on_nth_tick(62, tick)
|
||||
|
||||
local Public = {}
|
||||
|
Loading…
Reference in New Issue
Block a user