mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-26 03:52:00 +02:00
added nil check to walk_distance_on_second() #51
This commit is contained in:
parent
05d24c94c3
commit
eae8ab39db
@ -4,10 +4,12 @@ function walk_distance_on_second()
|
||||
local d_y = 0
|
||||
for _,v in pairs(game.players) do
|
||||
if (v.afk_time < 30 or v.walking_state.walking) and v.vehicle == nil then
|
||||
d_x = last_positions[v.name].x - v.position.x
|
||||
d_y = last_positions[v.name].y - v.position.y
|
||||
global.scenario.variables.player_walk_distances[v.name] = global.scenario.variables.player_walk_distances[v.name] + math.sqrt(d_x*d_x + d_y*d_y)
|
||||
global.scenario.variables.player_positions[v.name] = v.position
|
||||
if last_positions[v.name] then
|
||||
d_x = last_positions[v.name].x - v.position.x
|
||||
d_y = last_positions[v.name].y - v.position.y
|
||||
global.scenario.variables.player_walk_distances[v.name] = global.scenario.variables.player_walk_distances[v.name] + math.sqrt(d_x*d_x + d_y*d_y)
|
||||
global.scenario.variables.player_positions[v.name] = v.position
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user