Author Topic: Calling all coders - please help me test Infected AI v2!  (Read 4533 times)

0 Members and 1 Guest are viewing this topic.

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 274
Re: Calling all coders - please help me test Infected AI v2!
« Reply #30 on: December 27, 2010, 01:21:31 AM »
ok, well,
the only reason why there is, i think, now 2 While loops going on is that- with just the one before my Greeting, and no End for that loop, it would repeat endlessly ingame, both intro messages, requiring Ctrl-Alt-Del again.
so i just used a 2nd loop after 'End'ing the greeting loop, and went from there.
if you've made it work with one loop i'd love to know how you didnt get the same repeating greeting problem i did?

as far as the rally code goes, i merely copied and pasted it into my code from where he has it in his example file, ie, before the end of levelsetup.
you're saying this this 1st part of the rallypoint code should be in between LevelSetup and LevelLogic, in its own little land somewhere?!if so, why?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #31 on: December 27, 2010, 01:46:50 AM »
ok, well,
the only reason why there is, i think, now 2 While loops going on is that- with just the one before my Greeting, and no End for that loop, it would repeat endlessly ingame, both intro messages, requiring Ctrl-Alt-Del again.
so i just used a 2nd loop after 'End'ing the greeting loop, and went from there.

You always need a "coroutine.yield() end" for each While loop.  The level won't load otherwise.
You really should only use While GameRunning() once.  The logic there is that the game is ALWAYS running, so the loop will be neverending.  Therefore, any code that appears after the coroutine.yield() end will never be run.


Quote
if you've made it work with one loop i'd love to know how you didnt get the same repeating greeting problem i did?

Yes, that is a problem isn't it.
We can say, "timer = 6", and then we can say if GetGameTime > timer then we can bring the messagebox up.
But the next frame, it's still more than timer... so another messagebox appears... then another, and another...

We need a "latch" to stop it.

The easiest way to build a latch is to use a "latch = false" variable.

Then you can do this:

Code: [Select]
latch = false
timer = 6

While GameRunning() do
-- first, lets do the greeting.
if GetGameTime() > timer and latch == false then
MessageBox("Welcome!")
latch = true
end

-- rest of the code goes here...

coroutine.yield()
end



Quote
as far as the rally code goes, i merely copied and pasted it into my code from where he has it in his example file, ie, before the end of levelsetup.
you're saying this this 1st part of the rallypoint code should be in between LevelSetup and LevelLogic, in its own little land somewhere?!if so, why?

Not all of it, but most of it.
Most of the code is actually seperate functions - as in, they are seperate from Function LevelSetup() and Function LevelLogic().
If you ever see "function", it means that it has to go in no man's land.  By convention, drawing stuff seems to go between LevelSetup and LevelLogic, wheras OnAsteroidTaken and any other asteroid-related ones go below LevelLogic.  I am not sure if it has to be this way or not, but it seems like a good standard so that everyone always knows where to find each section.  :>

I said some, but not all.  Some of the code goes inside Function LevelSetup() and some goes inside Function LevelLogic().
I actually ran into a problem on line 750 of the code I sent to you.  It's part of the Rally Point code.  It caused the While loop to stop (error message was revealed by pressing Tilde (`) to bring up the console).  I commented out the For loop in question and ran it again, and the AI aggressively expands and the two factions even fight over the large asteroid owned by the Greys :>
Maybe you could ask Pilchard to have a look at it for you.  In the mean time I'll PM you a copy of the code that I'm running right now so you can check it out.  :>
« Last Edit: December 27, 2010, 12:54:28 PM by annikk.exe »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #32 on: December 27, 2010, 11:07:22 AM »
Ah. That for loop is the only one in the RP code and kind of...makes it work. How does it break it, exactly?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #33 on: December 27, 2010, 12:51:06 PM »
It's detecting "numroids" as being incorrect, or something.  I forget the exact error message, but basically after a few seconds of game time, it crashes and brings up that error in the console.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #34 on: December 27, 2010, 01:15:13 PM »
Does the level have moving or created/destroyed asteroids? That might do it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #35 on: December 27, 2010, 02:00:43 PM »
I didn't see any.  The trouble is coming with this line:


Code: [Select]
for roidtocheck=0,numroids-42 do
Is that definitely the right way to declare the number of asteroids?
I would have thought "numroids" would be declared in the LevelSetup, and then simply referred to later.
In fact, "numroids" appears nowhere else in the code, so the reason it's crashing would seem to be because it's trying to treat a variable (numroids) as a number value, when it hasn't been declared and is therefore equal to nil.

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 274
Re: Calling all coders - please help me test Infected AI v2!
« Reply #36 on: December 27, 2010, 05:04:08 PM »
Does the level have moving or created/destroyed asteroids? That might do it.
no, all static roids. nothing fancy like movers in this one.

- also, im pleased they fight over the main 'grey' roid...that was part of my plan for the map...good :D

aws

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #37 on: December 27, 2010, 06:44:43 PM »
AH! That shouldn't be numroids-42, but numroids-1 Try that.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #38 on: December 27, 2010, 07:03:22 PM »
You still need to specify a value for "numroids" to begin with.  Otherwise its value will be "nil" (which is different from "0") and the game won't be able to carry out mathematics on it becuase it's "not a number", and so will stop working.

I think that AWS needs to put something like "numroids = 42" in his function LevelSetup.  The "-1" bit I presume is because you're starting a "for" loop on 0, but most coders will actually number their asteroids from 0.... so I'd suggest that the "-1" is actually unnecessary.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #39 on: December 27, 2010, 07:37:15 PM »
numroids isn't (read:shouldn't) be nil, I set it to 4 in the demo map. I might change it to use the IDs of the asteroids and put in your for loop too. *scripts*

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #40 on: December 27, 2010, 08:08:19 PM »
Well that is missing from the code AWS sent me.  In the level he sent, numroids is never declared.
I'm guessing this is at least part of the problem...

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 274
Re: Calling all coders - please help me test Infected AI v2!
« Reply #41 on: December 28, 2010, 05:12:59 PM »
hm... i was wondering if it should be an = sign rather than a - sign followed by the number of roids.
but still, where is the declared numroid code? im pretty sure i copied everything from pilchards code verbatum


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #42 on: December 28, 2010, 08:00:53 PM »
I would have thought that it should appear in function LevelSetup(), alongside the other rally point code.

Just declare the variable like this:

Code: [Select]
numroids = 42
Then in that for loop, you don't need "numroids - 1" or "numroids - 42".  You don't need to subtract anything from it, I think...


Alternatively you could strip out all the rally point code and just add the new version.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Calling all coders - please help me test Infected AI v2!
« Reply #43 on: December 28, 2010, 08:12:16 PM »
Unfortunately, you did in the old version - it worked on the number of 'roids, not IDs. The new version just needs to be copied over, with nothing done to it.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Calling all coders - please help me test Infected AI v2!
« Reply #44 on: December 28, 2010, 08:28:43 PM »
Sweet :>

By the way, maybe you should make more mention in your initial post of the fact that the code contains a bunch of functions which don't belong in either LevelSetup or LevelLogic, but rather in the area that lies between them.  The code AWS sent me seems to suggest that's something he was tripping up over.  All of the functions (eg function OnMouseLeftUpScreen(x,y)) were in his LevelSetup.