i am trying to make 100 seedlings appear at the moment i scout a planet using the
OnAsteroidRevealed function
function OnAsteroidRevealed(id, owner)
if id == 3 and owner == 0 then
GetAsteroid(3):AddSeedlings(100)
return
end
end
can someone tell me what i am doing wrong
BC wins
this is about how to get the 400 seedlings from your test lvl to move properly with the timer
first my whole lvl
function LevelSetup()
-- Set Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(1)
-- Asteroid 0 - starting asteroid
a = AddAsteroidWithAttribs(0,0, 0.99,0.99,0.99)
a.Owner = 1
a.TreeCap = 20
a:SetRadius(800)
a.SendDistance = 3000
a:AddSeedlings(150)
a.Moveable = false
-- Asteroid 1
a = AddAsteroidWithAttribs(2000,0, 0.4,0.6,0.5)
a.Owner = 2
a.TreeCap = 20
a:SetRadius(600)
a.SendDistance = 3000
a:AddSeedlings(100)
a.Moveable = false
-- Asteroid 2
a = AddAsteroidWithAttribs(2000,-2000, 0.9,0.9,0.78)
a.Owner = 2
a.TreeCap = 10
a:SetRadius(700)
a.SendDistance = 3000
a:AddSeedlings(100)
a.Moveable = false
end
function LevelLogic()
-- Greet the player
Timer = GetGameTime() + 5
while GetGameTime() < Timer do
coroutine.yield()
end
Pause()
MessageBox("Take the asteroid to the east to win. Don't lose yours.")
WaitDialog()
Unpause()
-- Add some enemies to Asteroid 1
Timer = GetGameTime() + 15
while GetGameTime() < Timer do
coroutine.yield()
end
-- Add some reinforcements
GetAsteroid(1):AddSeedlings(400)
Timer = GetGameTime() + 15
while GetGameTime() < Timer do
coroutine.yield()
end
GetAsteroid(1):SendSeedlingsToTarget(2,400,GetAsteroid(0))
-- Winning and Losing
gamewon = 0
while gamewon == 0 do
coroutine.yield()
end
if gamewon == 1 then
Pause()
MessageBox("You have won.")
WaitDialog()
Unpause()
Quit(true)
end
if gamewon == 2 then
Pause()
MessageBox("You have lost.")
WaitDialog()
Unpause()
Quit(false)
end
end
function OnAsteroidTaken(id, owner)
if id == 1 and owner == 1 then
gamewon = 1
return
end
if id == 0 and owner == 2 then
gamewon = 2
return
end
end
and here's the timer bit
-- Add some enemies to Asteroid 1
Timer = GetGameTime() + 15
while GetGameTime() < Timer do
coroutine.yield()
end
-- Add some reinforcements
GetAsteroid(1):AddSeedlings(400)
Timer = GetGameTime() + 15
while GetGameTime() < Timer do
coroutine.yield()
end
GetAsteroid(1):SendSeedlingsToTarget(2,400,GetAsteroid(0))
An alternative way to write that is:
Timer = GetGameTime() + 15
If GetGameTime() >= Timer then
GetAsteroid(1):AddSeedlings(400)
Timer = Timer + 15
end
If GetGameTime() >= Timer then
GetAsteroid(1):SendSeedlingsToTarget(2,400,GetAsteroid(0))
end
use this:
Challenger = GetAsteroid(0).Owner
Owner = Challenger
while GameRunning() do
Challenger = GetAsteroid(7).Owner
if Challenger ~= Owner then
Owner = Challenger
GetAsteroid(7)SendDistance = 5000
end
coroutine.yield()
end
This will go into effect every time a new player takes the asteroid