Euflorium: The Eufloria Community

Eufloria => Eufloria Classic => Eufloria Classic Mods => Topic started by: njursten on November 17, 2009, 06:11:16 AM

Title: LUA problem
Post by: njursten on November 17, 2009, 06:11:16 AM
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: [Select]
   id = 0
   while GetAsteroid(id) ~= nil do
      GetAsteroid(id):Reveal(1)
      id = id + 1
   end

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.
Title: Re: LUA problem
Post by: Alex on November 17, 2009, 08:20:23 PM
I can fix it to return nil if the id is out of range, yeah. Will add it to the list :)
Title: Re: LUA problem
Post by: njursten on November 18, 2009, 05:08:59 AM
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?
Title: Re: LUA problem
Post by: Alex on November 18, 2009, 08:11:53 PM
I think it used to, but it was for the XML stuff.
Title: Re: LUA problem
Post by: njursten on November 20, 2009, 06:07:26 AM
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. :)