Modified the code to have tabs instead of spaces, and added some additional comments such as Asteroid ID numbers.
Haven't spotted the problem yet though. :>
function LevelSetup()
SetBackdropColour(200,200,200)
--Custom Story Mode Created by: Tomfloria
--Wouldn't have been possible without help from: Annikk.exe, Aino, Pilchard123
--iOS installation tutorial can be found here: http://www.dyson-game.com/smf/index.php?topic=1541.0
--Big thanks to the creaters of Eufloria, without them I wouldn't have done this.
--Contact me at Thomasbiggin@gmail.com
Globals():Get("Asteroids"):Set("RadiusPowerRule",4)
Globals():Get("Asteroids"):Set("SizeFromEnergy",530)
Globals():Get("Asteroids"):Set("SizeFromStrength",530)
Globals():Get("Asteroids"):Set("SizeFromSpeed",540)
Globals():Get("Asteroids"):Set("MinCoreHealth",75)
Globals():Get("Asteroids"):Set("MaxCoreHealth",350)
Globals():Get("Asteroids"):Set("CoreHealthPowerRule",2.5)
Globals():Get("Asteroids"):Set("MinSendDistance",3500)
Globals():Get("Asteroids"):Set("MaxSendDistance",5500)
Globals():Get("Asteroids"):Set("SendPowerRule",2.0)
Globals():Get("Asteroids"):Set("SpawnCap", 20)
Globals():Get("Structures"):Set("LevelDuration1",15)
Globals():Get("Structures"):Set("LevelDuration2",30)
Globals():Get("Structures"):Set("LevelDuration3",60)
Globals():Get("Structures"):Set("LevelDuration4",100)
Globals():Get("Structures"):Set("SpawnTime1",15)
Globals():Get("Structures"):Set("SpawnTime2",12)
Globals():Get("Structures"):Set("SpawnTime3",10)
Globals():Get("Structures"):Set("SpawnTime4",8)
Globals():Get("Flowers"):Set("Available",0)
Globals():Get("Game"):Set("GreysProbability",0)
--FIRST PATH TO PUZZLE--
-- ID 0
a = AddAsteroidWithAttribs(0,0, 0.0,0.0,0.5)
a.Owner = 1
--a:AddSeedlings(1)
a:SetRadius(180)
a.TreeCap = 0
a:Reveal(1)
-- ID 1
a = AddAsteroidWithAttribs(100,-600, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 2
a = AddAsteroidWithAttribs(-1000,-2300, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 3
a = AddAsteroidWithAttribs(200,-4000, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 4
a = AddAsteroidWithAttribs(3000,-3500, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 5
a = AddAsteroidWithAttribs(3000,-1300, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 6
a = AddAsteroidWithAttribs(4000,1000, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 7
a = AddAsteroidWithAttribs(6000,-1000, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 8
a = AddAsteroidWithAttribs(8000,-3500, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- ID 9
a = AddAsteroidWithAttribs(8500,-5500, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:AddSeedlings(1)
a:Reveal(1)
-- ID 10
a = AddAsteroidWithAttribs(8500,-7500, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Hide(1)
--END OF PATH TO PUZZLE--
--START OF PUZZLE--THE PRATROLERS
--MIDDLE ASTEROID--11
a = AddAsteroidWithAttribs(8500,-13000, math.random(2,5) / 10,math.random(2,5) / 10,math.random(2,5) / 10)
a.Owner = 1
a:SetRadius(300)
a.Moveable = false
a:Hide(1)
--BOTTOM ASTEROID--12
a = AddAsteroidWithAttribs(8500,-10000, 1,1,0.3)
a.Owner = 1
a.TreeCap = 0
a.Moveable = false
a:SetRadius(200)
a:Hide(1)
--BOTTOM LEFT ASTEROID--13
a = AddAsteroidWithAttribs(6500,-11000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--LEFT ASTEROID--14
a = AddAsteroidWithAttribs(5500,-13000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--TOP LEFT ASTEROID--15
a = AddAsteroidWithAttribs(6500,-15000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--TOP ASTEROID--16
a = AddAsteroidWithAttribs(8500,-16000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--TOP RIGHT ASTEROID--17
a = AddAsteroidWithAttribs(10500,-15000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--RIGHT ASTEROID--18
a = AddAsteroidWithAttribs(11500,-13000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--BOTTOM RIGHT ASTEROID--19
a = AddAsteroidWithAttribs(10500,-11000, 1,1,0.3)
a.Owner = 0
a.TreeCap = 0
a:AddSeedlings(100)
a.Moveable = false
a:SetGraceTime(999999)
a:SetRadius(200)
a:Hide(1)
--END OF PUZZLE 1--
--SECOND PATH TO PUZZLE 2 - ID 20
a = AddAsteroidWithAttribs(10500,-19000, 1,1,0.3)
a.Owner = 1
a:SetRadius(math.random(150,400))
a.TreeCap = 0
a.Moveable = false
a.SendDistance = 100
a:Reveal(1)
-- Disable buttons
SetDysonTreeButtonAvailable(false)
SetDefenseTreeButtonAvailable(false)
SetFlowerDefenseButtonAvailable(false)
SetFlowerSeederButtonAvailable(false)
SetTerraformingButtonAvailable(false)
SetBeaconButtonAvailable(false)
if IsiOS() then
SetEnemyInfoAvailable(true)
SetCoreInfoAvailable(true)
SetAttribsInfoAvailable(true)
SetSpeedSwitchAvailable(true)
SetSendModeScoutAvailable(true)
SetSendModeUnitsSelectorAvailable(true)
SetSendModeButtonAvailable(true)
SetSendModeHoldAvailable(true)
SetSendModeDragAvailable(true)
else
SetTreeInfoAvailable(true)
SetEnemyInfoAvailable(true)
SetCoreInfoAvailable(true)
SetAttribsInfoAvailable(true)
end
SetCameraPosition(0,0)
end
function LevelLogic()
StartLevelLogic()
Lives = 10
Puzzle = 0
startroid = {}
startroid[1] = GetAsteroid(9)
startroid[2] = GetAsteroid(9)
GetAsteroid(16).Owner = 1
GetAsteroid(16):Hide(1)
while GameRunning() do
if Puzzle == 1 then
WaitReal(10)
GetAsteroid(12):SendSeedlingsToTarget(0,100,GetAsteroid(13))
GetAsteroid(13):SendSeedlingsToTarget(0,100,GetAsteroid(14))
GetAsteroid(14):SendSeedlingsToTarget(0,100,GetAsteroid(15))
GetAsteroid(15):SendSeedlingsToTarget(0,100,GetAsteroid(16))
GetAsteroid(16):SendSeedlingsToTarget(0,100,GetAsteroid(17))
GetAsteroid(17):SendSeedlingsToTarget(0,100,GetAsteroid(18))
GetAsteroid(18):SendSeedlingsToTarget(0,100,GetAsteroid(19))
GetAsteroid(19):SendSeedlingsToTarget(0,100,GetAsteroid(12))
end
CheckConditions()
coroutine.yield()
end
end
function CheckConditions()
if gameFinished then
return
end
if GetEmpire(0).NumDysonTrees == 0 and GetEmpire(0).NumSeedlings == 0 then
GameOver(true, "")
Message("You successfully protected the Captured Seedlings.~Well Done", true, 1.0, "Centre")
WaitMessage(false)
WaitDialog()
Quit(true)
end
LivesCheck()
if GetEmpire(1).NumSeedlings == 0 and Lives == 1 then
Lives = 0
GameOver(false, "")
Message("Unfortunately you have failed to complete the tasks.", true, 1.0, "Centre")
WaitMessage(false)
WaitDialog()
Quit(false)
end
end
function LivesCheck()
if GetEmpire(1).NumSeedlings == 0 and Lives == 10 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 9 seedlings left.", true, 1.0, "Centre")
Lives = 9
end
if Lives == 9 then
if GetEmpire(1).NumSeedlings == 0 then
startroid[CheckPoint]:AddSeedlings(1)
end
Message("You have 8 seedlings left.", true, 1.0, "Centre")
Lives = 8
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 8 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 7 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 7
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 7 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 6 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 6
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 6 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 5 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 5
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 5 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 4 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 4
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 4 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 3 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 3
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 3 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 2 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 2
end
if GetEmpire(1).NumSeedlings == 0 and Lives == 2 then
startroid[CheckPoint]:AddSeedlings(1)
Message("You have 1 seedlings left.", true, 1.0, "Centre")
WaitReal(4)
Lives = 1
end
end
function OnAsteroidRevealed(id, owner)
if id == 10 then
Puzzle = 1
GetAsteroid(11):Reveal(1)
GetAsteroid(12):Reveal(1)
GetAsteroid(13):Reveal(1)
GetAsteroid(14):Reveal(1)
GetAsteroid(15):Reveal(1)
GetAsteroid(16):Reveal(1)
GetAsteroid(17):Reveal(1)
GetAsteroid(18):Reveal(1)
GetAsteroid(19):Reveal(1)
CheckPoint = 1
end
end