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.
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:
latch = false
timer = 6
While GameRunning() do
-- first, lets do the greeting.
if GetGameTime() > timer and latch == false then
latch = true
-- rest of the code goes here...
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. :>