[Add] Created an 'idle' task to run when idle for easy to change idle behaviours.
This commit is contained in:
parent
4af334e5e4
commit
76bea0092c
@ -55,14 +55,7 @@ function control()
|
||||
elseif task == "hyperspace" then
|
||||
ai.hyperspace() -- Try to hyperspace.
|
||||
else -- Get new task.
|
||||
planet = ai.landplanet()
|
||||
-- Planet must exist.
|
||||
if planet == nil or land_planet == false then
|
||||
ai.pushtask(0, "hyperspace")
|
||||
else
|
||||
ai.pushtask(0, "hyperspace")
|
||||
ai.pushtask(0, "land", planet)
|
||||
end
|
||||
idle()
|
||||
end
|
||||
end
|
||||
|
||||
@ -82,6 +75,18 @@ function attacked(attacker)
|
||||
end
|
||||
end
|
||||
|
||||
-- Default task to run when idle.
|
||||
function idle()
|
||||
planet = ai.landplanet()
|
||||
-- Planet must exist.
|
||||
if planet == nil or land_planet == false then
|
||||
ai.pushtask(0, "hyperspace")
|
||||
else
|
||||
ai.pushtask(0, "hyperspace")
|
||||
ai.pushtask(0, "land", planet)
|
||||
end
|
||||
end
|
||||
|
||||
function create()
|
||||
-- Empty stub.
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user