Advertisement
Guest User

Untitled

a guest
Mar 12th, 2011
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. function script.Create()
  2.     Spring.Echo ("MAGNET unit " .. unitID .. " was created!")
  3.     StartThread (magnet)
  4. end
  5.  
  6. function magnet ()
  7.     while (true) do
  8.         local x,y,z = Spring.GetUnitPosition (unitID)
  9.         nearunits=Spring.GetUnitsInSphere  (x,y,z, 200) or "nothing"
  10.         if (nearunits~="nothing") then     
  11.             for _, nearunitid in ipairs (nearunits) do
  12.                 if (nearunitid~=unitID) then
  13.                     Spring.AddUnitImpulse( nearunitid, 0, 0.5, 0)
  14.                 end
  15.             end
  16.         end    
  17.         Sleep (100)
  18.     end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement