Merge branch 'master' of git://github.com/BTAxis/naev into testmission
[naev.git] / docs / ai / examples / scan.lua
blob988a59c95afccb05698bcd8ce4874186689584aa
1 --[[
2 -- typical usage would be:
3 -- ai.pushtask(0, "scan", ai.rndpilot())
4 --]]
6 function scan ()
7 target = ai.targetid()
8 if not ai.exists(target) then
9 ai.poptask()
10 return
11 end
12 dir = ai.face(target)
13 dist = ai.dist( ai.pos(target) )
14 if dir < 10 and dist > 300 then
15 ai.accel()
16 elseif dist < 300 then
17 -- scan the target
18 ai.poptask()
19 end
20 end