diff --git a/api/behaviors.lua b/api/behaviors.lua index d5c4ec8..42d1c6c 100644 --- a/api/behaviors.lua +++ b/api/behaviors.lua @@ -12,7 +12,18 @@ local floor = math.floor local pi = math.pi local sin = math.sin local rad = math.rad -local random = math.random + +-- fix for negative coordinates +local function random(a,b) + if b == nil then + return math.random(a) + elseif a < b then + return math.random(a,b) + else + return math.random(b,a) + end +end + local function diff(a, b) -- Get difference between 2 angles return atan2(sin(b - a), cos(b - a))