I have noticed that when the character is mining an entity, it finishes mining one tick faster than when it should based on the `mining_speed` and `mining_time` but only for some combinations of `mining_speed` and `mine_time`.
I have measured some combinations of `mining_speed` and `mine_time` but failed to notice a pattern.
measurements: https://docs.google.com/spreadsheets/d/ ... sp=sharing
I suspect inaccurate float representation and then a round down at the end but I am not sure.
I know that this is probably only problem for me because I'm trying to predict the mine times so if it is not worth developer time to fix this It would be awesome if someone noticed the pattern when the mine action takes one tick less.
code used for measurements:
Code: Select all
local last = false
local start = 0
script.on_event(defines.events.on_tick, function()
---@type LuaPlayer
local player = game.players[1]
local now = player.mining_state.mining
if now ~= last then
if now then -- started mining
start = game.tick
local prototype = player.selected.prototype
local mining_time = prototype.mineable_properties.mining_time
local player_prototype = game.entity_prototypes['character']
local mining_speed = player_prototype.mining_speed
local prediction = (mining_time / mining_speed) * 60
game.print('prediction: ' .. prediction ..
' mining_time: ' .. mining_time ..
' mining_speed: ' .. mining_speed
)
else -- stopped mining
game.print('actual time: ' .. (game.tick - start) - 1)
-- minus one because on the current tick the entity is already gone
end
end
last = now
end)