minor code improvement
Posted: Sun Apr 27, 2014 7:53 pm
In
Using the builtin % operator, this can be rewritten in a more efficient and concise way:
I found the following code:game/modules/tome/data/timed_effects/physical.lua
Code: Select all
local normalize_direction = function(direction)
local pi2 = math.pi * 2
while direction > pi2 do
direction = direction - pi2
end
while direction < 0 do
direction = direction + pi2
end
return direction
end
Code: Select all
local normalize_direction = function(direction)
return direction % (2*math.pi)
end