Hey Terrial, awesome to see someone else making levels. :>
I'll see if I can cover some of the questions asked too, even though Pilchard already did a sterling job. :>
*A clever loop with correct syntax goes here*
Here are two different types of loops:While
This is usually used to continually run stuff. Generally you would use this within Function LevelLogic().Syntax:
So for example:
while GameRunning() do
The "coroutine.yield()" bit is necessary to close off a while loop. If you forget to add it, the level will not load.
I think of it as being synonymous with "end", when it comes to this type of loop.For
This can be used in LevelSetup or LevelLogic, or anywhere else for that matter. It creates a "ticker" variable, and runs through the loop a specified number of times. Each time it goes through the loop, the "ticker" is incremented by one, and then when it reaches the specified number, the loop ends.Syntax:
Here is an example of a For loop in action:
for i = 0,20 do
So in this example, we are saying run the loop 20 times, and on each occasion, add a number of seedlings to Asteroid 0 that is equal to whichever loop number we are on. So the game would add 0 seedlings, then 1 seedling, then 2 seedlings, then 3, and so on, until eventually i
reaches 20, it adds 20 seedlings, and the loop ends.
edit: also how can you make it send a laser mine to an asteroid?
When we refer to asteroids in our scripts, the way we do it is by assigning a variable to represent them.
You can assign the variable in a couple of different ways, here's the easiest:
Suppose Asteroid 0 has a mine belonging to empire 2, and you want it to travel to Asteroid 1.
fluffysbeautifulmine = GetAsteroid(0):GetMine(2)
There is only one mine at Asteroid 0, so that code will select it and from now on we can refer to it as fluffysbeautifulmine
Next lets send it to the neighbouring asteroid:
In that line, we told Fluffy's Beautiful Mine to start the journey toward Asteroid 1.
Also another question, can you instantly add seedlings to an asteroid of one empire that is controlled by another? Example: Asteroid 1 is owned by empire 1, can you add 10 seedlings of empire 2 to asteroid 1? Or can they only be put on asteroids owned by that empire?
You can. :>
Consider the following code:
-- Asteroid 0
a = AddAsteroidWithAttribs(500,500, 0.5,0.6,0.4)
a.Owner = 1
a.TreeCap = 5
s = a:AddDysonTree()
a.Moveable = False
We gave ourselves an asteroid, a tree, and 200 seedlings.
Now lets make some enemies on the same asteroid:
This line will put seedlings onto Asteroid 0. There will be 300 of them, belonging to Empire 2, and they will have energy 0.3, strength 0.2, and speed 0.1
So you can expect that as soon as the level starts, this asteroid will be the site of a massive battle!
I would ultimately expect the player seedlings to win, as their stats are so much better than those belonging to Empire 2.
Let us know how you get on. :>