The game always ends up crashing after about 30 seconds with the code at the bottom. Changing the Owner of the Asteroid to the computer player prevents the bug (With no tree's or tree-slots). Any idea's of how to prevent the bug? The map i'm working on requires enemy seedlings to be spawned onto player asteroids.
function LevelLogic()
while GameRunning() do
Timer = GetGameTime()
coroutine.yield()
if LoopTime < Timer then
GetAsteroid(0):AddSeedlings(1,2,1,1,1)
LoopTime = LoopTime + 1
end
end
end
That's the whole of the example level i made to show the bug.
function LevelSetup()
-- Set Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(0)
-- Asteroid 0 - starting asteroid
a = AddAsteroidWithAttribs(0,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 1
a:SetRadius(250)
a.SendDistance = 2500
a:AddSeedlings(90,1,1,1,1)
LoopTime = 0
end
function LevelLogic()
while GameRunning() do
Timer = GetGameTime()
if LoopTime < Timer then
GetAsteroid(0):AddSeedlings(1,2,1,1,1)
LoopTime = LoopTime + 1
end
coroutine.yield()
end
end
You can also induce the bug, by planting a tree onto a planet that does not belong to you. You can use the following code to explore that.
function LevelSetup()
-- Set Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(1)
Globals.AI.GraceTimer = (9999)
-- Asteroid 0 - starting asteroid
a = AddAsteroidWithAttribs(0,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 1
a:SetRadius(250)
a.SendDistance = 2500
a:AddSeedlings(90)
a = a:AddDysonTree()
a:LevelUp()
a:LevelUp()
a:LevelUp()
-- Asteroid 1
a = AddAsteroidWithAttribs(2000,0, 0.3,0.3,0.3)
a.Owner = 2
a.TreeCap = 2
a:SetRadius(450)
a.SendDistance = 2500
a:Reveal(1)
a:AddSeedlings(100)
end
function LevelLogic()
end
function LevelSetup()
-- Set Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(0)
-- Asteroid 0 - starting asteroid
a = AddAsteroidWithAttribs(0,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 1
a:SetRadius(250)
a.SendDistance = 2500
a:AddSeedlings(90,1,1,1,1)
LoopTime = 0
end
function LevelLogic()
while GameRunning() do
Timer = GetGameTime()
if LoopTime < Timer then
GetAsteroid(0):AddSeedlings(1,2,1,1,1)
LoopTime = LoopTime + 1
end
coroutine.yield()
end
end
Won't work. There isn't even a second empire, so that may be the problem.
EDIT: The second one gives me no trouble at all. Are you sure it causes the bug?