Guest User

Untitled

a guest
Apr 6th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. function widget:GetInfo()
  2. return {
  3. name = "Custom Unit Rings",
  4. desc = "Draws rings based upon customparams",
  5. author = "Some Asshole",
  6. date = "04/05/2012",
  7. license = "Public Domain",
  8. layer = 0,
  9. enabled = true -- loaded by default?
  10. }
  11. end
  12.  
  13. --[[Comments section (using block style comment for attention getter...ness]]--
  14.  
  15. --[[
  16. Contains 4 variables:
  17. ring1radius
  18. ring1color
  19. ring1thickness
  20. ring1ShowOnlySelected
  21.  
  22. ***To Be Continued...***
  23. ]]--
  24. local function explode(div,str)
  25. if (div=='') then return false end
  26. local pos,arr = 0,{}
  27. -- for each divider found
  28. for st,sp in function() return string.find(str,div,pos,true) end do
  29. table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
  30. pos = sp + 1 -- Jump past current divider
  31. end
  32. table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
  33. return arr
  34. end
  35.  
  36. function widget:DrawWorld()
  37. local units = Spring.GetAllUnits()
  38. for _,unitID in ipairs(units) do
  39. local x,y,z = Spring.GetUnitPosition(unitID)
  40. local unitDefID = Spring.GetUnitDefID(unitID)
  41. local ud = UnitDefs[unitDefID]
  42. local customParams = ud.customParams
  43.  
  44. -- ring 1
  45. if customParams.ring1radius then
  46. gl.Color(explode(',', customParams.ring1color))
  47. gl.LineWidth(customParams.ring1thickness)
  48. gl.DrawGroundCircle(x,y,z, customParams.ring1radius, 32)
  49. end
  50.  
  51. -- ring 2
  52. if customParams.ring2radius then
  53. gl.Color(explode(',', customParams.ring2color))
  54. gl.LineWidth(customParams.ring2thickness)
  55. gl.DrawGroundCircle(x,y,z,customParams.ring2radius, 32)
  56. end
  57. end
  58.  
  59. end
Advertisement
Add Comment
Please, Sign In to add comment