Eufloria > Eufloria Classic Mods

Lua scripting in Eufloria - reference

<< < (4/13) > >>

ulfn:
Using the time-honored method of trial-and-error I found the following fields for the Asteroid type:

FieldtypedescriptionpositionPositionThe position of the asteroid.radiusfloatThe radius of the asteroid.attribsAttributesAsteroid attributes (strength, energy, speed)
With the types

Position
Fieldtypexfloatyfloat
Attributes
Fieldtypestrengthfloatenergyfloatspeedfloat
The position and radius are really handy for instance for computing if one asteroid is reachable from another:
(click to show/hide)function Distance(From, To)
  local dx, dy

  dx = To.position.x - From.position.x
  dy = To.position.y - From.position.y
  return math.sqrt(dx*dx + dy*dy)
end

function Reachable(From, To)
  return Distance(From, To) <= From.SendDistance + To.radius
end

Edit: The attribs and radius are in jh's userdata list, but the position field isn't.

Alex:
Added to the list (these should be in and working in 2.05):
General game entities - these functions can be used on most anything in the game (seedlings, trees, asteroids, etc)
Function nameReturn valueDescriptionSetVisible(int faction, bool visible)nilSets whether the entity can be seen by the given faction.Regen(float time)niltells the entity to regenerate some of its energy. The parameter is delta time, so set it to e.g. 1 to regenerate a second's worth of energy. Normally this is called once a frame with the duration of the frame passed in.DistanceSquaredTo(Entity other)floatreturns the squared distance from the centre of this entity to the centre of the one you passed in.AttackedBy(Entity other)nilTells this entity that it was attacked by the one you pass in.AttackedBy(Entity other, float time)nilTells this entity that it was attacked by the one you pass in for 'time' seconds. Normally the second value is the frame duration.Field nameTypeDescriptionPositionVector3Position of the entity - access individual coords with capital letters e.g. entity.Position.X or entity.Position.Y.Radiusfloatradius of the entity.OnScreenbooltells you whether the entity is on the screen or not.ActiveboolTells whether the entity is still active. Set it to false to remove the entity from the game.

IDemon:
Alex truly a massive thank you for publishing all this for us it has been no end of help in developing my map editor thus far.

dragoonreas:
I was looking through the userdata structures list jhchrist posted and noticed the get_FacingAngle and get_Rotation functions for Asteroids. I'm assuming the FacingAngle parameter controls the absolute rotation of the asteroid, and the Rotation parameter controls how fast and in what direction the asteroid is spinning. Are these assumptions correct?

I tried using GetAsteroid(id).FacingAngle but it didn't seem to do anything. I might have been setting the facing angle using radians rather then degrees, which may explain why it didn't appear to have any affect if it's supposed to be set using degrees.

I also tried using GetAsteroid(id).Rotation but got an error saying there was no Set function for this parameter. Does this mean that the asteroid rotation (spin) isn't bound in Lua, or is there another way to set it?

Pilchard123:
Rotation doesn't work. I tried already, a while back.

Here's what Alex said:


--- Quote from: Alex on July 13, 2010, 01:40:45 AM ---...

for now, no rotating asteroids or even experiments with rotating asteroids - sorry!

--- End quote ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version