Yeah, there's a few things wrong there.
Your LevelSetup() code:
LevelLogic() is more broken.
Your LevelLogic() code:
[spoiler][code]function LevelSetup() -- Hier zijn de asteriods --
--add asteroids here. For now, let's say that you have added four asteroids (with ids 0, 1, 2, 3) and want asteroids 0 and 2 to be 'unstable'
-- 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(20)
-- 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:AddSeedlings(15)
-- Asteroid 2
a = AddAsteroidWithAttribs(3000,0, 0.3,0.3,0.3)
a.TreeCap = 2
a:SetRadius(450)
a.SendDistance = 2500
-- Asteroid 3
a = AddAsteroidWithAttribs(4000,0, 0.3,0.3,0.3)
a.TreeCap = 2
a:SetRadius(450)
a.SendDistance = 2500
end
LevelSetup() is perfectly ok, although you might want to add globals to it, like your how many asteroids and empires you want, so I'd change your LevelSteup() to be:
function LevelSetup()
Globals.G.EnemyFactionsMin (minimum number of enemy empires)
Globals.G.EnemyFactionsMax (maximum number of enemy empires)
Globals.G.Asteroids (total number of asteroids)
--add your asteroids here
end
LevelLogic() is a little more broken.
Your code:
function LevelLogic()
--in this example, the energy of asteroid 2 changes to a random value between 0 and 1, roughly every second,
--and the speed of asteroid 0 changes to a random value between 0.5 and 0.75 roughly every 3 seconds.
Roid0UnstableTimer = GetGameTime(10) + 3
Roid2UnstableTimer = GetGameTime(10) + 1
-- everything until the next comment must be inside a loop that will never stop until the level ends, like while GameRunning() do...end.
if GetGameTime() >= Roid0UnstableTimer then
GetAsteroid(2):SetSpeed(math.random(50, 75)/100)
Roid0UnstableTimer = GetGameTime() + 1
end
if GetGameTime() >= Roid2UnstableTimer then
GetAsteroid(2):SetEnergy(math.random())
Roid2UnstableTimer = GetGameTime() + 1
end
--this is the next comment. Carry on as normal. put eveything else here.
This should really be something like:
function LevelLogic()
while GameRunning() do
--in this example, the energy of asteroid 2 changes to a random value between 0 and 1, roughly every second,
--and the speed of asteroid 0 changes to a random value between 0.5 and 0.75 roughly every 3 seconds.
Roid0UnstableTimer = GetGameTime() + 3
Roid2UnstableTimer = GetGameTime() + 1
-- everything until the next comment must be inside a loop that will never stop until the level ends, like while GameRunning() do...end.
if GetGameTime() >= Roid0UnstableTimer then
GetAsteroid(2):SetSpeed(math.random(50, 75)/100)
Roid0UnstableTimer = GetGameTime() + 3
end
if GetGameTime() >= Roid2UnstableTimer then
GetAsteroid(2):SetEnergy(math.random())
Roid2UnstableTimer = GetGameTime() + 1
end
--this is the next comment. Carry on as normal. put everything else here.
end
An explanation:
GetGameTime() cannot have anything in the brackets. In your code GetGameTime(10) was invalid. Assuming you want to have asteroid 0 change every 10 seconds, you would use Roid0UnstableTimer = GetGameTime() + 10.
In the if...then statement, you would also use Roid0UnstableTimer = GetGameTime() + 10.
Also, you wrote it so that there was nothing to say when to check if the time should be checked. Eufloria would never evaluate if GetGameTime >=10, so the asteroid would not change. Placing it in a while GameRunning() do block meant that it would be checking nearly all the time.
In case that doesn't make sense, I'll make a template thingy and post it.
EDIT:
HERE IT IS[/code]