Yo dude i followed your tuts and that and was wanting to know if you could fix my code cause i keep getting random errors but i cannot see the prob thanksCode: [Select]function LevelSetup()
-- Set shiz
SetBackdropColour(0,0,0)
SetCameraZoomNow(9)
-- Set Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(2)
-- My Roid
a = AddAsteroidWithAttribs(0,0, 0.8,0.8,0.8)
a.Owner = 1
a.TreeCap = 5
a:SetRadius(700)
a.SendDistance = 4000
a:AddSeedlings(150)
a.Moveable = false
GenerateLevel()
end
function GenerateLevel()
InitArrays()
for i = 0,math.random(6,10) do
RandomiseAttributes(i)
PlaceRoids(i)
end
function InitArrays()
energy = {}
strength = {}
speed = {}
radius = {}
senddist = {}
treecaptcha = {}
seeds = {}
x = {}
y = {}
end
function RandomiseAttributes(RoidID)
energy[RoidID] = math.random(1,10) / 10 + 0.1
strength[RoidID] = math.random(1,10) / 10 + 0.1
speed[RoidID] = math.random(1,10) / 10 + 0.1
treecaptcha[RoidID] = math.random(2,4)
radius[RoidID] = math.random (100,450)
senddist[RoidID] = radius * 10
seeds[RoidID] = math.random(20,30)
x[RoidID] = math.random(-5000,5000)
y[RoidID] = math.random(-5000,5000)
end
function PlaceRoid(RoidID)
a = AddAsteroidWithAttribs(x[RoidID],y[RoidID],energy[RoidID],strength[RoidID],speed[RoidID])
a.Owner = 0
a.TreeCap = treecaptcha[RoidID]
a.radius = radius[RoidID]
a.AddSeedlings = seeds[RoidID]
a.SendDistance = senddist[RoidID]
a.Moveable = true
end
end
function LevelLogic()
-- Objective Msg
Timer = GetGameTime() + 2
while GetGameTime() < Timer do
coroutine.yield()
end
Pause()
MessageBox("Take over the whole galaxy to win. Good Luck.")
WaitDialog()
Unpause()
-- Send timed Attack
Timer = GetGameTime() + 13
while GetGameTime() < Timer do
coroutine.yield()
end
GetAsteroid(2):AddSeedlings(20)
GetAsteroid(2):SendSeedlingsToTarget(0,200,GetAsteroid(0))
while GameRunning() do
-- Win condition
if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(3):GetNumOwnedAsteroids() == 0 and GetEmpire(0):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have won")
WaitDialog()
Unpause()
Quit(true)
end
-- lose condition
if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have lost")
WaitDialog()
Unpause()
Quit(false)
end
coroutine.yield()
end
end
function LevelSetup()
-- Set shiz
SetBackdropColour(0,0,0)
SetCameraZoomNow(9)
-- Set Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(2)
-- My Roid
a = AddAsteroidWithAttribs(0,0, 0.8,0.8,0.8)
a.Owner = 1
a.TreeCap = 5
a:SetRadius(700)
a.SendDistance = 4000
a:AddSeedlings(150)
a.Moveable = false
GenerateLevel()
end
function GenerateLevel()
InitArrays()
for i = 0,math.random(6,10) do
RandomiseAttributes(i)
PlaceRoid(i)
end
end
function InitArrays()
energy = {}
strength = {}
speed = {}
radius = {}
senddist = {}
treecaptcha = {}
seeds = {}
x = {}
y = {}
end
function RandomiseAttributes(RoidID)
energy[RoidID] = math.random(1,10) / 10 + 0.1
strength[RoidID] = math.random(1,10) / 10 + 0.1
speed[RoidID] = math.random(1,10) / 10 + 0.1
treecaptcha[RoidID] = math.random(2,4)
radius[RoidID] = math.random (100,450)
senddist[RoidID] = radius[RoidID] * 10
seeds[RoidID] = math.random(20,30)
x[RoidID] = math.random(-5000,5000)
y[RoidID] = math.random(-5000,5000)
end
function PlaceRoid(RoidID)
a = AddAsteroidWithAttribs(x[RoidID],y[RoidID],energy[RoidID],strength[RoidID],speed[RoidID])
a.Owner = 0
a.TreeCap = treecaptcha[RoidID]
a:SetRadius(radius[RoidID])
a:AddSeedlings(seeds[RoidID])
a.SendDistance = senddist[RoidID]
a.Moveable = true
end
function LevelLogic()
-- Objective Msg
Timer = GetGameTime() + 2
while GetGameTime() < Timer do
coroutine.yield()
end
Pause()
MessageBox("Take over the whole galaxy to win. Good Luck.")
WaitDialog()
Unpause()
-- Send timed Attack
Timer = GetGameTime() + 13
while GetGameTime() < Timer do
coroutine.yield()
end
GetAsteroid(2):AddSeedlings(20)
GetAsteroid(2):SendSeedlingsToTarget(0,200,GetAsteroid(0))
while GameRunning() do
-- Win condition
if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(3):GetNumOwnedAsteroids() == 0 and GetEmpire(0):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have won")
WaitDialog()
Unpause()
Quit(true)
end
-- lose condition
if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have lost")
WaitDialog()
Unpause()
Quit(false)
end
coroutine.yield()
end
end
function LevelSetup()
-- Set shiz
SetBackdropColour(0,0,0)
SetCameraZoomNow(9)
-- Set Global Values
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(2)
Globals.Asteroids.SeedlingCap=(500)
Globals.Asteroids.SpawnCap=(2000)
-- My Roid
a = AddAsteroidWithAttribs(0,0, 0.8,0.8,0.8)
a.Owner = 1
a.TreeCap = 5
a:SetRadius(700)
a.SendDistance = 4000
a:AddSeedlings(150)
a.Moveable = false
a = AddAsteroidWithAttribs(15000,0, 0.8,0.8,0.8)
a.Owner = 2
a.TreeCap = 5
a:SetRadius(700)
a.SendDistance = 4000
a:AddSeedlings(150)
a.Moveable = false
GenerateLevel()
end
function GenerateLevel()
InitArrays()
for i = 2,math.random(15,40) do
RandomiseAttributes(i)
PlaceRoid(i)
end
end
function InitArrays()
energy = {}
strength = {}
speed = {}
radius = {}
senddist = {}
treecaptcha = {}
owner = {}
seeds = {}
x = {}
y = {}
end
function RandomiseAttributes(RoidID)
energy[RoidID] = math.random(1,10) / 10 + 0.1
strength[RoidID] = math.random(1,10) / 10 + 0.1
speed[RoidID] = math.random(1,10) / 10 + 0.1
owner[RoidID] = 0
treecaptcha[RoidID] = math.random(2,4)
radius[RoidID] = math.random (200,600)
senddist[RoidID] = radius[RoidID] * 10
seeds[RoidID] = math.random(0,5)
x[RoidID] = math.random(0,13000)
y[RoidID] = math.random(-10000,10000)
if radius[RoidID] > 500 then
seeds[RoidID] = 20
end
end
function PlaceRoid(RoidID)
a = AddAsteroidWithAttribs(x[RoidID],y[RoidID],energy[RoidID],strength[RoidID],speed[RoidID])
a.Owner = owner[RoidID]
a.TreeCap = treecaptcha[RoidID]
a:SetRadius(radius[RoidID])
a:AddSeedlings(seeds[RoidID])
a.SendDistance = senddist[RoidID]
a.Moveable = true
end
function LevelLogic()
-- Objective Msg
Timer = GetGameTime() + 2
while GetGameTime() < Timer do
coroutine.yield()
end
Pause()
MessageBox("Take over the whole galaxy to win. Good Luck.")
WaitDialog()
Unpause()
-- Send timed Attack
--Timer = GetGameTime() + 10
--while GetGameTime() < Timer do
-- coroutine.yield()
--end
-- Pause()
-- MessageBox("Incomming")
-- WaitDialog()
-- Unpause()
-- GetEmpire(1):SendSeedlingsToTarget(0,100,GetAsteroid(0))
while GameRunning() do
-- Win condition
if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(0):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have won")
WaitDialog()
Unpause()
Quit(true)
end
-- lose condition
if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have lost")
WaitDialog()
Unpause()
Quit(false)
end
coroutine.yield()
end
end
Here:Code: [Select]function LevelSetup()
-- Set shiz
SetBackdropColour(0,0,0)
SetCameraZoomNow(9)
-- Set Global Values
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(2)
Globals.Asteroids.SeedlingCap=(500)
Globals.Asteroids.SpawnCap=(2000)
-- My Roid
a = AddAsteroidWithAttribs(0,0, 0.8,0.8,0.8)
a.Owner = 1
a.TreeCap = 5
a:SetRadius(700)
a.SendDistance = 4000
a:AddSeedlings(150)
a.Moveable = false
a = AddAsteroidWithAttribs(15000,0, 0.8,0.8,0.8)
a.Owner = 2
a.TreeCap = 5
a:SetRadius(700)
a.SendDistance = 4000
a:AddSeedlings(150)
a.Moveable = false
GenerateLevel()
end
function GenerateLevel()
InitArrays()
for i = 2,math.random(15,40) do
RandomiseAttributes(i)
PlaceRoid(i)
end
end
function InitArrays()
energy = {}
strength = {}
speed = {}
radius = {}
senddist = {}
treecaptcha = {}
owner = {}
seeds = {}
x = {}
y = {}
end
function RandomiseAttributes(RoidID)
energy[RoidID] = math.random(1,10) / 10 + 0.1
strength[RoidID] = math.random(1,10) / 10 + 0.1
speed[RoidID] = math.random(1,10) / 10 + 0.1
owner[RoidID] = 0
treecaptcha[RoidID] = math.random(2,4)
radius[RoidID] = math.random (200,600)
senddist[RoidID] = radius[RoidID] * 10
seeds[RoidID] = math.random(0,5)
x[RoidID] = math.random(0,13000)
y[RoidID] = math.random(-10000,10000)
if radius[RoidID] > 500 then
seeds[RoidID] = 20
end
end
function PlaceRoid(RoidID)
a = AddAsteroidWithAttribs(x[RoidID],y[RoidID],energy[RoidID],strength[RoidID],speed[RoidID])
a.Owner = owner[RoidID]
a.TreeCap = treecaptcha[RoidID]
a:SetRadius(radius[RoidID])
a:AddSeedlings(seeds[RoidID])
a.SendDistance = senddist[RoidID]
a.Moveable = true
end
function LevelLogic()
-- Objective Msg
Timer = GetGameTime() + 2
while GetGameTime() < Timer do
coroutine.yield()
end
Pause()
MessageBox("Take over the whole galaxy to win. Good Luck.")
WaitDialog()
Unpause()
-- Send timed Attack
--Timer = GetGameTime() + 10
--while GetGameTime() < Timer do
-- coroutine.yield()
--end
-- Pause()
-- MessageBox("Incomming")
-- WaitDialog()
-- Unpause()
-- GetEmpire(1):SendSeedlingsToTarget(0,100,GetAsteroid(0))
while GameRunning() do
-- Win condition
if GetEmpire(2):GetNumOwnedAsteroids() == 0 and GetEmpire(0):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have won")
WaitDialog()
Unpause()
Quit(true)
end
-- lose condition
if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
Pause()
MessageBox("You have lost")
WaitDialog()
Unpause()
Quit(false)
end
coroutine.yield()
end
end
and try to put it in a code box, because thoose emoticons I had to fix up :P
The map looks great BTW, I'd love to beta-test it :)
Good job, Good luck coding more :P
Treecap limit? there is no real limit, is there?
GetAsteroid(0).TreeCap = 5
for i = 0,numberofasteroids do
GetAsteroid(i).TreeCap = math.random(1,5)
end
i tried making all grays attack an asteroid but failed how would i do that?
GetAsteroid(3):SendSeedlingsToTarget(0,1000,GetAsteroid(5))
for i = 0,numberofasteroids do
GetAsteroid(i):SendSeedlingsToTarget(0,1000,GetAsteroid(3))
end
Actually, a 'common error messages' section to annikk's bugfixing guide could be useful. Want me to try to write one?
any news on this?
ReinforcementsAllowed = false
CommandoCenterAllowed = false
SetBackdropColour(166,146,150)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(0)
Globals.G.GreysProbability=0
-- Asteroid 0
a = AddAsteroidWithAttribs(-4002, -3992, 0.9,0.8,0.8)
a.Moveable = false
a.radius = 1009
a.Owner = 2
a:AddSeedlings(23)
a.SendDistance = 8394
-- Asteroid 1
a = AddAsteroidWithAttribs(-1048, -4562, 0.3,0.3,0.2)
a.Moveable = false
a.radius = 288
a.SendDistance = 2327
-- Asteroid 2
a = AddAsteroidWithAttribs(-1324, -2292, 0.2,0.3,0.3)
a.Moveable = false
a.radius = 272
a.SendDistance = 3473
-- Asteroid 3
a = AddAsteroidWithAttribs(-4707, -1426, 0.4,0.5,0.4)
a.Moveable = false
a.radius = 586
a.SendDistance = 2634
-- Asteroid 4
a = AddAsteroidWithAttribs(-7, 7, 0.6,0.6,0.5)
a.Moveable = false
a.Owner = 1
a:AddSeedlings(35)
a.radius = 301
a.SendDistance = 1802
-- Asteroid 5
a = AddAsteroidWithAttribs(-4005, 1012, 0.4,0.5,0.4)
a.Moveable = false
a.radius = 471
a.SendDistance = 2653
-- Asteroid 6
a = AddAsteroidWithAttribs(-957, 3012, 0.5,0.4,0.4)
a.Moveable = false
a.radius = 365
a.SendDistance = 4221
-- Asteroid 7
a = AddAsteroidWithAttribs(1640, 2205, 0.5,0.5,0,6)
a.Moveable = false
a.radius = 363
a.SendDistance = 2817
-- Asteroid 8
a = AddAsteroidWithAttribs(1713, -108, 0.5,0.8,0.5)
a.Moveable = false
a.radius = 384
a.SendDistance = 2487
SetFlowerDefenseButtonAvailable(false)
SetFlowerSeederButtonAvailable(false)
StartupText = "Stop n Fight"
StartupRed = 0.1
StartupGreen = 0.5
StartupBlue = 0.5
OpeningText = "We have encountered an obstacle in our race for the... Uhh, I never mentioned anything, ok! We have atleast encountered an asteroidbelt, would be nice to capture it!"
MapTime = nil
Win = "all"
AIType = "normal"
StartCondition = "Map03"
Condition = "Map03"
LostMessage = "Our enemy defeated us, try again!"
WinMessage = "They were piece of cake to conquer. Let's move on and hope we don't need to crush more enemies though!"
MapTime = nil
number = "here is some text"
GetAsteroid(number):AddSeedlings(10)