Eufloria > Eufloria Classic Mods
LUA problem
(1/1)
njursten:
I wanted to try making a level for this great game, but ran into some problems. To see what happened in the level from the very start I wanted to make all the asteroids visible. After creating the asteroids I tried running the following code.
--- Code: --- id = 0
while GetAsteroid(id) ~= nil do
GetAsteroid(id):Reveal(1)
id = id + 1
end
--- End code ---
However, the not equal to nil check doesn't seem to work. The id reaches a value not used and I get a "index was out of range" error. I also tried adding "if GetAsteroid(id) == nil then break end" inside the loop, but that didn't help either. An explicit loop from 0 up to the last index works without problems.
Alex:
I can fix it to return nil if the id is out of range, yeah. Will add it to the list :)
njursten:
Thanks! Either that or a function that returns the current number of existing asteroids.
Hm, I just now saw the Globals.G.Asteroids variable. Doesn't seem to be the number of added asteroids, though. What's it for?
Alex:
I think it used to, but it was for the XML stuff.
njursten:
I had some trouble with an asteroid ring being added with some preset values unless I added one myself. Setting Globals.G.Asteroids to 0 prevented this from happening, so apparently it still has some function. :)
Navigation
[0] Message Index
Go to full version