a:AddMine(faction)
a:AddMine(1)
-- Asteroid 0
a = AddAsteroidWithAttribs(200,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 5
a:SetRadius(650)
a:AddSeedlings(400)
a:AddMine(1)
s = a:AddDysonTree()
a.Moveable = False
-- Up here you need to add your asteroids.
function LevelLogic() --holds code to run during the game
-- I'd use a timer to send waves of seedlings to the no-man's-land (no-seed's-land?) asteroid, otherwise the game will crash due to too many seedlings. I know, I've been there, though it's more annoying than anything
-- and it stops you playing the level. So, a timer.
timer = GetGameTime() + 30 -- this declares a variable named 'timer' (you could call it 'monkey', or 'frank', or 'MyNeighbourWhoIsCalledJoeBloggsHasAMassiveWartOnTheEndOfHisNoseAndItLooksReallyFunny', or whatever you want) that is 30 seconds after the current game's time.
--As this will run once, at the very start of the level, it will be 30, unless it is changed.
while GameRunning() do -- while the game is running...
if GetGameTime() >= then --check if the game has been running for a number of seconds that is higher than the number given to the varible 'timer'(or 'MyNeighbourWhoIsCalledJoeBloggsHasAMassiveWartOnTheEndOfHisNoseAndItLooksReallyFunny', if that's what makes you happy)
-- if it has, then...do something
GetAsteroid(0):AddSeedlings(100) --your code
GetAsteroid(1):AddSeedlings(100) --your code
GetAsteroid(0):SendSeedlingsToTarget(2,100,GetAsteroid(2)) --your code
GetAsteroid(1):SendSeedlingsToTarget(3,100,GetAsteroid(2)) --your code
timer = GetGameTime() + 30 --resets the timer, to thirty more than the game time.
end --end the check
coroutine.yield() --return control to something else, ready to be picked up again later if there is a need.
end --end the loop
end
-- Up here you need to add your asteroids.
function LevelLogic() --holds code to run during the game
timer = GetGameTime() + 30
while GameRunning() do -- while the game is running...
if GetGameTime() >= timer then
if GetAsteroid(2):GetNumSeedlings(2) < 50 then
GetAsteroid(0):AddSeedlings(100)
GetAsteroid(0):SendSeedlingsToTarget(2,100,GetAsteroid(2))
end
if GetAsteroid(2):GetNumSeedlings(3) < 50 then
GetAsteroid(1):AddSeedlings(100)
GetAsteroid(1):SendSeedlingsToTarget(3,100,GetAsteroid(2))
end
timer = GetGameTime() + 30
end
coroutine.yield()
end
end
The coroutine.yield() still confuses me though. Once I think I've figured out it's use I see it in another place used for something similar but different. Can you explain it's whole use? Like what the program does when it hits that line?
[..] I don't know how to make those spoiler boxesWell, if nothing else, then I can at least add the following to a dev thread:
*A clever loop with correct syntax goes here*
while GameRunning() do
GetAsteroid(1):SendSeedlingsToTarget(1,2,GetAsteroid(0))
coroutine.yield()
end
for i = 0,20 do
GetAsteroid(0):AddSeedlings(i)
end
edit: also how can you make it send a laser mine to an asteroid?
fluffysbeautifulmine = GetAsteroid(0):GetMine(2)
fluffysbeautifulmine:SendTo(GetAsteroid(1))
Also another question, can you instantly add seedlings to an asteroid of one empire that is controlled by another? Example: Asteroid 1 is owned by empire 1, can you add 10 seedlings of empire 2 to asteroid 1? Or can they only be put on asteroids owned by that empire?
-- Asteroid 0
a = AddAsteroidWithAttribs(500,500, 0.5,0.6,0.4)
a.Owner = 1
a.TreeCap = 5
a:SetRadius(350)
a:AddSeedlings(200)
s = a:AddDysonTree()
a.Moveable = False
GetAsteroid(0):AddSeedlings(300,2,0.3,0.2,0.1)