EngiN33R

Additional auxiliary functions

May 27th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. function table.find(table, element)
  2.     for key, value in ipairs(table) do
  3.         if value == element then
  4.             return key
  5.         end
  6.     end
  7.     return nil
  8. end
  9.  
  10. function inRange(x,y,rx1,ry1,rx2,ry2) -- I think there's something wrong with this one, not sure tho
  11.     if (x>=rx1 and x<=rx2 and y>=ry1 and y<=ry2) then
  12.         return true
  13.     end
  14.     return false
  15. end
  16.  
  17. function csconvert(rot,x,y,factor)
  18.     if rot<-90 then rot=rot+360 end
  19.     local angle=math.rad(math.abs(rot+90))-math.pi
  20.     local cx=x+(math.cos(angle)*factor)
  21.     local cy=y+(math.sin(angle)*factor)
  22.     return cx,cy
  23. end
Advertisement
Add Comment
Please, Sign In to add comment