### Author Topic: Level help  (Read 2192 times)

0 Members and 1 Guest are viewing this topic.

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,794
##### Level help
« on: July 02, 2011, 02:57:40 PM »
I received a PM, here's what it says:

Quote
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 thanks

Code: [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()      endfunction GenerateLevel()   InitArrays()      for i = 0,math.random(6,10) do      RandomiseAttributes(i)      PlaceRoids(i)   endfunction InitArrays()   energy = {}   strength = {}   speed = {}   radius = {}   senddist = {}   treecaptcha = {}   seeds = {}   x = {}   y = {}endfunction 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)endfunction 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 = trueendendfunction 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()   endend`

Here's the problems I've spotted:

1.  There's no "end" to finish off the GenerateLevel() function.
2.  There's an extra, un-needed "end" at the end of the PlaceRoid() function.

Looks ok apart from that.. :>

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Level help
« Reply #1 on: July 02, 2011, 04:03:58 PM »
Looks a little OTT for a "followed your tuts" map - unless you already know how to use Lua, I'd just stick with something simple.

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,794
##### Re: Level help
« Reply #2 on: July 02, 2011, 04:45:17 PM »
It sounds like he followed all of them.. :>

It's mostly correct, just a few minor things.  Don't see why he shouldn't go for it.  :>

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Level help
« Reply #3 on: July 02, 2011, 05:03:42 PM »
Yeah, fair enough, but I just didn't want him/her to jump in too deep, too quick and give up right at the start.

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Level help
« Reply #4 on: July 02, 2011, 05:45:27 PM »
Here:

Code: [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()      endfunction GenerateLevel()   InitArrays()      for i = 0,math.random(6,10) do      RandomiseAttributes(i)      PlaceRoid(i)   endendfunction InitArrays()   energy = {}   strength = {}   speed = {}   radius = {}   senddist = {}   treecaptcha = {}   seeds = {}   x = {}   y = {}endfunction 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)endfunction 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 = trueendfunction 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()   endend`

#### kmercy

• Seedling
• Thank You
• -Given: 0
• Posts: 34
##### Re: Level help
« Reply #5 on: July 02, 2011, 06:20:58 PM »
Thanks guys just couldn't spot it was tired up all night etc

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Level help
« Reply #6 on: July 02, 2011, 06:45:53 PM »
Glad to help, you should make a topic, the more helpers, the higher are the possability to find the problems... I guess.

I must say, there were no coding errors, only names were written wrong and you sometimes used functions as fields
*All of thoose stuff are common, and deadly irritating!

Welcome aboard, btw

#### kmercy

• Seedling
• Thank You
• -Given: 0
• Posts: 34
##### Re: Level help
« Reply #7 on: July 03, 2011, 05:43:01 PM »
Causes this error

Attempt to yield across
metamethod\c-call boundary

Anyone know what the prob is?

Code:
(click to show/hide)
« Last Edit: July 03, 2011, 05:50:56 PM by kmercy »

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Level help
« Reply #8 on: July 03, 2011, 07:30:40 PM »
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()  endfunction GenerateLevel()   InitArrays()     for i = 2,math.random(15,40) do      RandomiseAttributes(i)      PlaceRoid(i)   endendfunction InitArrays()   energy = {}   strength = {}   speed = {}   radius = {}   senddist = {}   treecaptcha = {}   owner = {}   seeds = {}   x = {}   y = {}endfunction 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   endendfunction 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 = trueendfunction 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

The map looks great BTW, I'd love to beta-test it

Good job, Good luck coding more

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Level help
« Reply #9 on: July 03, 2011, 07:53:43 PM »
What exactly did that error mean? I've never seen it before.

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Level help
« Reply #10 on: July 03, 2011, 08:05:28 PM »
I got no real idea, but seems you ended the LevelLogic and left over some code underneath it, I guess thats the error

#### kmercy

• Seedling
• Thank You
• -Given: 0
• Posts: 34
##### Re: Level help
« Reply #11 on: July 03, 2011, 08:11:47 PM »
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()  endfunction GenerateLevel()   InitArrays()     for i = 2,math.random(15,40) do      RandomiseAttributes(i)      PlaceRoid(i)   endendfunction InitArrays()   energy = {}   strength = {}   speed = {}   radius = {}   senddist = {}   treecaptcha = {}   owner = {}   seeds = {}   x = {}   y = {}endfunction 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   endendfunction 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 = trueendfunction 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

The map looks great BTW, I'd love to beta-test it

Good job, Good luck coding more

Thanks i prob will release it once its done or get some beta testers

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 0
• Posts: 899
• Eufloria: Yes
##### Re: Level help
« Reply #12 on: July 03, 2011, 08:17:18 PM »
Actually, a 'common error messages' section to annikk's bugfixing guide could be useful. Want me to try to write one?

#### Aino

• Ent
• Thank You
• -Given: 1
• Posts: 1,483
• They'll eat you next!
• Eufloria: Yes
##### Re: Level help
« Reply #13 on: July 03, 2011, 08:23:22 PM »
Don't forget the painful Vector3f then

• Seedling
• Thank You
• -Given: 0