Author Topic: Lua scripting in Eufloria - reference  (Read 171453 times)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Lua scripting in Eufloria - reference
« on: July 19, 2009, 06:48:14 PM »
Thread for lua script command reference

Currently existing commands

Function prototypereturn typeDescription
GameRunning()boolreturns true if the game is still running
AddAsteroid(x, y)AsteroidAdds an asteroid to the game at the given coordinates during setup.
AddAsteroidWithAttribs(x, y, energy, strength, speed)AsteroidAdds an asteroid with the given attributes at the given x,y location, during setup.
GetAsteroid(id)AsteroidGet a specific asteroid. Asteroid ID starts at zero and goes up by one with each asteroid created. All of the GetAsteroid functions may return nil if you pass in an invalid ID, so ideally you will check the return value if you are at all uncertain.
GetRandomAsteroid()AsteroidGet any asteroid in the current game, at random.
GetRandomRangeAsteroid(start, end)AsteroidGet a random asteroid from the given range of IDs (start is inclusive, end is exclusive, so e.g. a range of (4, 10) would select a random asteroid from the asteroids with IDs of 4, 5, 6, 7, 8, and 9)
GetRandomEmptyAsteroid()AsteroidGet a random asteroid in the game that is empty (that is, it has no trees or seedlings on it and is owned by the grey team)
GetRandomRangeEmptyAsteroid(start, end)AsteroidGet an empty asteroid from the given range of asteroid IDs.
GetGameTime()numberReturns a real number in seconds showing the time the current game has been running.
MessageBox(string message)nilPops up a message box with an OK button and the given message.
AddAsteroidRing(int numAsteroids, float x, float y, float centreRadius, float beltWidth)nilAdds an asteroid ring containing numAsteroids asteroids, centred around coordinates (x, y), with radius centreRadius, and spreading asteroids out over a ring thickness of beltWidth game units.
GetDialogActive()boolreturns whether there is an active dialog on the screen (from MessageBox).
Pause()nilPauses the game (without popping up the pause menu).
Unpause()nilUnpauses the game (without removing the pause menu if it is active)
GetNumInactiveFactionsnumberReturns the number of currently inactive factions.
GetFirstInactiveFactionIDnumberReturns the number of the first faction number which is 'dead', i.e. has no asteroids.
GetRandomInactiveFactionIDnumberGets a random dead faction and returns its id number.
Quit(bool win)nilStops the game and returns to the main menu. Set the parameter to true if the game was won, false if not.
GetEmpire(int faction)EmpireGets the empire with the given ID.
GetAI(int faction)AI or nilGets the AI with the given ID. can return nil, e.g. if you ask for team 1 (the player) the function will return nil as the player has no AI.
SetBackdropColor / SetBackdropColournilSet the level colour (r, g, b values from 0 - 255)
SetVignetteAlphanilSet the darkness of the vignette (value from 0 - 255)
printnil
SetDysonTreeButtonAvailable(bool available)nilSets the availability of this button.
SetDefenseTreeButtonAvailable(bool available)nilSets the availability of this button.
SetFlowerDefenseButtonAvailable(bool available)nilSets the availability of this button.
SetFlowerSeederButtonAvailable(bool available)nilSets the availability of this button.
SetTreeInfoAvailable(bool available)nilSets the availability of this information on the info panel.
SetEnemyInfoAvailable(bool available)nilSets the availability of this information on the info panel.
SetCoreInfoAvailable(bool available)nilSets the availability of this information on the info panel.
SetAttribsInfoAvailable(bool available)nilSets the availability of this information on the info panel.
SetCameraPosition(float x, float y)nilSets the camera's position, without causing it to smoothly transition.
SetCameraTarget(float x, float y)nilSets the camera target, causing it to smoothly move from the current location to the new target.
SetCameraPositionToAsteroidID(int id)nilSets the camera's position to that of the given asteroid's ID, without causing it to smoothly transition. Will do nothing if the asteroid does not exist.
SetCameraTargetToAsteroidID(int id)nilSets the camera target position to that of the given asteroid's ID, causing it to smoothly move from the current location to the new target.
SetCameraZoom(float zoom)nilSets the camera zoom. The camera will smoothly zoom to the given value.
SetCameraZoomNow(float zoom)nilSets the camera zoom bypassing any smooth transition.
GetNumFactionsintHow many factions are there? This one will tell you.
UnlockArenaLevel(int level)voidUnlock an arena level (pass in 1 to unlock the first arena, 2 for the second etc)
DrawLine(x1,y1,x2,y2,r1,g1,b1,a1,r2,g2,b2,a2,thickness)void(all parameters floating point) Draws a line from (x1,y1) to (x2,y2) with starting colour (r1,g1,b1,a1) and ending colour (r2,g2,b2,a2) where colour values are from 0 to 1. use alpha <1 (e.g. 0.99) rather than 1 in general.
DrawTexLine(int id, x1,y1,x2,y2,r1,g1,b1,a1,r2,g2,b2,a2,thickness)voidAs for DrawLine except applies a texture (see below for id indexes)
DrawSprite(int id, x,y, r,g,b,a, size)voidDraws sprite of size size and index id at (x,y) in colour (r,g,b,a).
IsOnScreen(x,y, radius)boolreturns true if the object at x,y with radius radius would be on the screen at the time of drawing.
GetLODAlpha(int LOD)floatreturns the alpha of the given LOD (0,1,2). LOD 2 is the most zoomed-in; LOD 0 is the farthest zoomed-out.
GetCameraScale()floatreturns the current scale of the camera. Divide a value by this to get a size in pixels on-screen to pass to draw functions.
SaveStats(string filename)e.g. SaveStats("myfile.bin") - saves out the current game stats to the given file
LoadStats(string filename)e.g. LoadStats("myfile.bin") - loads myfile.bin into the current stats register
GetCameraX()floatGet camera's x position
GetCameraY()floatGet camera's y position
GetCameraZoom()floatGets the camera zoom - warning this value is different from the value passed in from SetCameraZoom for arcane and ridiculous reasons... the formula is (0.05f + ((float)(Zoom * Zoom * Math.Sign(Zoom)) / 10)) where Zoom is the value you passed in
« Last Edit: June 14, 2010, 06:44:10 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Globals reference
« Reply #1 on: July 19, 2009, 11:07:31 PM »
All accessible from lua. They are floats or ints. Try not to put floating point numbers into int vars... I have put the type after the var name.

Camera vars
Globals.Camera.ViewSupplement (float)

Flower vars
Globals.Flowers.GrowTime (float)
Globals.Flowers.MinSpeed (float)
Globals.Flowers.MaxSpeed (float)
Globals.Flowers.SpeedPower (float)
Globals.Flowers.MinHealth (int)
Globals.Flowers.MaxHealth (int)
Globals.Flowers.HealthPower (float)
Globals.Flowers.Available (int) - sets whether or not flowers will grow (0 = won't grow, anything else = will grow)

Mine vars
Globals.Mines.GrowTime (float)
Globals.Mines.MinSpeed (float)
Globals.Mines.MaxSpeed (float)
Globals.Mines.SpeedPower (float)
Globals.Mines.MinHealth (int)
Globals.Mines.MaxHealth (int)
Globals.Mines.HealthPower (float)
Globals.Mines.NumberOfLasers (int)
Globals.Mines.LaserPowerMin (float)
Globals.Mines.LaserPowerMax (float)
Globals.Mines.LaserPowerRule (float)
Globals.Mines.ExplosionPowerMin (float)
Globals.Mines.ExplosionPowerMax (float)
Globals.Mines.ExplosionPowerRule (float)
Globals.Mines.ExplosionRadiusMin   (float)
Globals.Mines.ExplosionRadiusMax (float)
Globals.Mines.ExplosionRadiusPower  (float)
Globals.Mines.LaserRange  (float)

Missile vars
Globals.Missiles.AmmoAvailable1 (int)
Globals.Missiles.AmmoAvailable2  (int)
Globals.Missiles.AmmoAvailable3  (int)
Globals.Missiles.AmmoAvailable4  (int)
Globals.Missiles.DamageMin  (float)
Globals.Missiles.DamageMax (float)
Globals.Missiles.DamagePowerRule (float)
Globals.Missiles.RadiusMin  (float)
Globals.Missiles.RadiusMax (float)
Globals.Missiles.RadiusPowerRule (float)
Globals.Missiles.SpeedMin  (float)
Globals.Missiles.SpeedMax (float)
Globals.Missiles.SpeedPowerRule  (float)
Globals.Missiles.TriggerDistance  (float)
Globals.Missiles.ReloadMin (float)
Globals.Missiles.ReloadMax (float)
Globals.Missiles.ReloadPowerRule (float)
Globals.Missiles.TurnRate  (float)
Globals.Missiles.LaunchDuration (float)
Globals.Missiles.CheckTimer  (float)

Seedling vars
Globals.Agents.MaxSpeed   (float)
Globals.Agents.MinSpeed  (float)
Globals.Agents.SpeedPower  (float)
Globals.Agents.WanderAttackTime  (float)
Globals.Agents.AttackRepeatTime  (float)
Globals.Agents.MinDamage  (float)
Globals.Agents.MaxDamage (float)
Globals.Agents.DamagePower (float)
Globals.Agents.MinAltitude  (float)
Globals.Agents.MaxAltitude (float)
Globals.Agents.AttackDist   (float)
Globals.Agents.BomVolume  (int)
Globals.Agents.MinHealth  (int)
Globals.Agents.MaxHealth (int)
Globals.Agents.HealthPower  (float)
Globals.Agents.RegenRate (float)
Globals.Agents.NoseLengthMin  (float)
Globals.Agents.NoseLengthMax (float)
Globals.Agents.TurnRate (float)
Globals.Agents.AttackTravellerMultiplier (float)
Globals.Agents.AttackAgentDistanceSuper (float)
Globals.Agents.AttackRepeatTimeSuper (float)
Globals.Agents.SendThresholdEnergy (float)
Globals.Agents.SendThresholdStrength (float)
Globals.Agents.SendThresholdSpeed (float)

Asteroid vars
Globals.Asteroids.MaxVolume (int)
Globals.Asteroids.TakeoverVolume (int)
Globals.Asteroids.MaxTrees (int)
Globals.Asteroids.MinRadius (float)
Globals.Asteroids.MaxRadius (float)
Globals.Asteroids.RadiusPowerRule (float)
Globals.Asteroids.SizeFromEnergy (float)
Globals.Asteroids.SizeFromStrength (float)
Globals.Asteroids.SizeFromSpeed (float)
Globals.Asteroids.AttributeMinimum (float)
Globals.Asteroids.AttributeDivisions (int)
Globals.Asteroids.SendVolume (int)
Globals.Asteroids.AsteroidSelectRadius (int)
Globals.Asteroids.MinSendDistance (float)
Globals.Asteroids.MaxSendDistance (float)
Globals.Asteroids.SendPowerRule (float)
Globals.Asteroids.MinCoreHealth (float)
Globals.Asteroids.MaxCoreHealth (float)
Globals.Asteroids.CoreHealthPower (float)
Globals.Asteroids.SeedlingCap  (int)
Globals.Asteroids.SpawnCap (int)

Dyson tree vars
Globals.Structures.TreeCost  (int)
Globals.Structures.MinHealth  (float)
Globals.Structures.MaxHealth  (float)
Globals.Structures.HealthPower  (float)
Globals.Structures.RegenRate  (float)
Globals.Structures.LevelTime1 (float)
Globals.Structures.LevelTime2  (float)
Globals.Structures.LevelTime3 (float)
Globals.Structures.LevelTime4  (float)
Globals.Structures.SpawnTime1 (float)
Globals.Structures.SpawnTime2 (float)
Globals.Structures.SpawnTime3 (float)
Globals.Structures.SpawnTime4 (float)
Globals.Structures.SoundVolume (float)
Globals.Structures.MinSoundTime (float)
Globals.Structures.MaxSoundTime (float)
Globals.Structures.MaxDamage   (float)
Globals.Structures.MinDamage  (float)
Globals.Structures.DamagePower  (float)
Globals.Structures.FlowerProbability (float)
Globals.Structures.RootSpeed (float) - affects all roots in the game

Defense tree vars
Globals.StructuresDefense.TreeCost (int)
Globals.StructuresDefense.MinHealth (float)
Globals.StructuresDefense.MaxHealth (float)
Globals.StructuresDefense.HealthPower (float)
Globals.StructuresDefense.RegenRate (float)
Globals.StructuresDefense.LevelTime1  (float)
Globals.StructuresDefense.LevelTime2  (float)
Globals.StructuresDefense.LevelTime3  (float)
Globals.StructuresDefense.LevelTime4  (float)
Globals.StructuresDefense.SpawnTime1  (float)
Globals.StructuresDefense.SpawnTime2  (float)
Globals.StructuresDefense.SpawnTime3  (float)
Globals.StructuresDefense.SpawnTime4  (float)
Globals.StructuresDefense.MaxDamage (float)
Globals.StructuresDefense.MinDamage (float)
Globals.StructuresDefense.DamagePower (float)

AI stuff
Globals.AI.MinDecisionTime (float)
Globals.AI.MaxDecisionTime (float)
Globals.AI.GraceTimer (int)

Program vars - try not to change these yourself :)
Globals.P.ToolTipWait (float)
Globals.P.ToolTipWaitUI (float)
Globals.P.AutoHide (int)
Globals.P.FullScreen (int)
Globals.P.SeenHelp (int)
Globals.P.FontSize (float)
Globals.P.BGFade (float)
Globals.P.PlayerColour  (int)

Game vars
Globals.G.EnemyFactionsMin (int)
Globals.G.EnemyFactionsMax (int)
Globals.G.BeltRadius (int)
Globals.G.BeltWidth  (int)
Globals.G.Asteroids  (int)
Globals.G.MinAsteroidSeparation (int)
Globals.G.StartingSeedlings (int)
Globals.G.StartingSeedlingsPlayer  (int)
Globals.G.MaxAsteroidNeighbourDist (int)
Globals.G.GreysProbability (float)
Globals.G.GreysMin (int)
Globals.G.GreysMax (int)
« Last Edit: September 26, 2009, 05:08:29 AM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
What goes in the Lua file?
« Reply #2 on: July 19, 2009, 11:07:52 PM »
function LevelSetup()
Called once at the start of the game - use it to set up asteroids and stuff.
Example:
(click to show/hide)

function LevelLogic()
Called as a coroutine. Put in while loops with coroutine.yield() in them to hold up your script.
Example:
(click to show/hide)

function LevelDraw()
Optional. Called every time the game draws to the screen. Fill it with your lovely drawing code. Check the script examples thread for an example.

function OnAsteroidTaken(id, owner)
This is optional but if defined will be called whenever an asteroid changes hands. Use it to check for specific asteroids being taken over by specific teams, or whatever you like.
(click to show/hide)


function OnAsteroidRevealed(id, owner)
This is optional but if defined will be called whenever an asteroid is revealed to an owner. So when you discover an asteroid, this will be called with the id of the asteroid and owner 1, for example.
(click to show/hide)
« Last Edit: March 24, 2010, 11:12:22 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Documentation of Asteroids and Empires
« Reply #3 on: July 26, 2009, 08:50:16 PM »
Let's say you have an Asteroid called a. To call functions on a, you use the colon like so
Code: [Select]
a:AddTrees(1,2)and to set fields you use the dot like so
Code: [Select]
a.Owner = 3
These are the most important functions and fields available to you as a scripter (there are tons more but listing them all would take ages and confuse people):

Asteroids
Function nameReturn valueDescription
MoveBy(float, float)nilMoves the asteroid by the given offset.
MoveTo(float, float)nilMoves the asteroid to the given position.
GetNumSeedlings()intCounts the number of seedlings present at the asteroid.
GetNumSeedlings(int faction)intCounts the number of seedlings present at the asteroid belonging to the given faction/empire.
GetNumSeedlingsExcluding(int faction)intCounts the number of seedlings present at the asteroid, excluding seedlings from the given faction.
GetNumFlowers(int faction)intCounts the number of flowers present at the asteroid belonging to the given faction/empire.
GetNumMines(int faction)intCounts the number of mines present at the asteroid belonging to the given faction/empire.
GetFlower(int faction)FlowerGets one of the flowers of the given faction present on the asteroid. Will return nil if there are none available.
GetMine(int faction)MineGets one of the mines of the given faction present on the asteroid. Will return nil if there are none available.
GetNumTrees()intCounts the number of trees present at the asteroid.
GetNumDysonTrees()intCounts the number of these trees present at the asteroid.
GetNumDefenseTrees()intCounts the number of these trees present at the asteroid.
FreeSlots()intReturns how many places for trees are left here.
AvailableStructureSpace()boolTells you if there is space for any trees here.
SetRadius(float radius)nilSet the radius of the asteroid. Probably best not to call this after level setup.
SendSeedlingsToTarget(int faction, int number, Asteroid asteroid)intAttempt to send number seedlings from faction faction to asteroid asteroid.
CanAddSeedling(int faction)boolCheck to see if faction faction can add any seedlings to this asteroid.
CanSpawnSeedling(int faction)boolCheck to see if faction faction can spawn any seedlings on this asteroid.
AddDysonTree()StructureAttempt to add a Dyson tree to the asteroid; if nothing can be done (all tree slots are taken) the function does nothing and returns nil. Otherwise the function returns a Structure, which is the base type of the trees in Dyson.
AddDefenseTree()StructureSee above.
PlantDysonTree(int faction)StructureAttempt to plant a Dyson tree using the seedlings present at the asteroid; if nothing can be done (all tree slots are taken, or there are not enough seedlings or the asteroi is owned by some other faction than team 0 or the given faction) the function does nothing and returns nil. Otherwise the function returns a Structure, which is the base type of the trees in Dyson.
PlantDefenseTree(int faction)StructureSee above.
ChangeOwner(int faction)nilInstantly transfers ownership of the asteroid to the given team.
GetSendDistance()floatInstantly transfers ownership of the asteroid to the given team.
IsBarren()boolInforms of the asteroid's barren status (barren is when team 0 (the greys) is the owner and there are no trees).
AddSeedlings(int numberToAdd)nilAdds numberToAdd seedlings to the asteroid of the current asteroid owner's team.
AddSuperSeedlings(int numberToAdd)nilAdds numberToAdd enhanced seedlings to the asteroid of the current asteroid owner's team.
AddSeedlings(int numberToAdd, int faction, float energy, float strength, float speed)nilAdds numberToAdd seedlings to the asteroid of the given team and with the given attributes.
AddSuperSeedlings(int numberToAdd, int faction, float energy, float strength, float speed)nilAdds numberToAdd enhanced seedlings to the asteroid of the given team and with the given attributes.
RemoveSeedlings(int faction, int numberToRemove)nilRemoves numberToAdd seedlings at random from the asteroid of the given owner's team.
AddFlower()FlowerAdds a flower of the asteroid's owners type to the asteroid. May return nil if there are too many flowers in the game.
AddFlower(int faction)FlowerAdds a flower of the given faction type to the asteroid.
AddMine()MineAdds a mine of the asteroid's owners type to the asteroid. May return nil if there are too many mines in the game.
AddMine(int faction)MineAdds a mine of the given faction type to the asteroid.
AddTrees(int dyson, int defense)nilAdd the given number of trees to the asteroid.
SetGraceTime(float gracetime)nilSets the grace time for the current owner of the asteroid - stops the owner's AI from doing anything with the asteroid while the grace timer is still above 0.
SetFlowerProbability(float probability)nilOverride the probability (0 = no chance -> 1 = guaranteed) of flowers being grown on trees planted on this asteroid. Will also affect any trees currently planted here - if they are currently not going to grow a flower (as this is decided when they are created), they will "roll the die" again to see if they will grow a flower.
GetRandomDefenseTree() and
GetRandomDefenseTree(bool ignoreEnhance)
Structure or nilThis gets a random defense tree. If you send in false as the parameter, it will choose a tree without a flower already planted on it. If no tree is suitable the function returns nil.
GetRandomDysonTree() and
GetRandomDysonTree(bool ignoreEnhance)
Structure or nilThis gets a random dyson tree. If you send in false as the parameter, it will choose a tree without a flower already planted on it. If no tree is suitable the function returns nil.
GetRandomTree() and
GetRandomTree(bool ignoreEnhance)
Structure or nilThis gets a random tree. If you send in false as the parameter, it will choose a tree without a flower already planted on it. If no tree is suitable the function returns nil.
Field nameTypeDescription
IDintThe ID of the asteroid, corresponding to when it was created in the level setup. Do not edit this value unless you want trouble.
MoveableboolCan the game move the asteroid around during setup to make sure it isn't too close / far away from other asteroids? This field will have no effect after level setup.
NamestringThe name of the asteroid. You can name your asteroids if you like.
SeedlingCapintSet the maximum number of seedlings allowed on an asteroid.
SpawnCapintSet the number of seedlings at an asteroid before Dyson trees stop producing seedlings.
TreeCapintSet the maximum number of trees allowed on an asteroid.
CoreHealthintSet the asteroid's core health.
MaxCoreHealthintSet the asteroid's maximum core health.
SendDistancefloatSet the asteroid's sending distance.

Trees
Function nameReturn valueDescription
LevelUp()nilLevel the tree up. If called during setup the tree will start the game with a fully grown root and at the next level up. Call it multiple times have the tree at higher levels.
SetFlowerProbability(float probability)nilOverride the probability (0 = no chance -> 1 = guaranteed) of flowers being grown on a tree. The tree will "roll the die" again to see if it will grow a flower.
AddFlower()Flower/Mine or nilIf the tree is a dyson tree this will add a Flower. If the tree is a Defense tree it will add a Mine. If the tree already has a flower or mine this will return nil.
Field nameTypeDescription
EnhancedboolSets the tree to have been enhanced (to make super seedlings).

Flower/Mine
Function nameReturn valueDescription
GrowToMax()nilThe flower will immediately grow to full age, ready to be plucked.
Pluck()nilThe flower or mine will detatch itself from its tree, if it is attached.
SendTo(Asteroid destination)nilAttempt to send the flower/mine to the destination asteroid.
Plant(Structure tree)boolPlant the flower on the given tree, returns false if it couldn't plant.
PlantOnRandomTree()boolPlant the flower on a random tree, returns false if it couldn't plant.
PlantOnRandomDysonTree()boolPlant the flower on a random dyson tree, returns false if it couldn't plant.
PlantOnRandomDefenseTree()boolPlant the flower on a random defense tree, returns false if it couldn't plant.
Field nameTypeDescription


Empires
Function nameReturn valueDescription
GetRandomAsteroid()Asteroid.
GetNumOwnedAsteroids()intHow many asteroids the empire owns
GetNumVisibleAsteroids()intHow many asteroids the empire knows about
OwnsAsteroidID(int id)boolreturns true if the empire currently owns asteroid with given id.
Field nameTypeDescription
NumSeedlingsint.
NumTreesint.
NumDysonTreesint.
NumDefenseTreesint.
Defeatedboolset by the game to true when the empire has been defeated.


AIs - AIs are also Empires, so you can also call/set anything in the above Empire reference on any AI you might have around. e.g. num = GetAI(3).NumSeedlings
Function nameReturn valueDescription
...
Field nameTypeDescription
MinScoutTimefloatscout timer - how often will we check to scout.
MaxScoutTimefloatThe timer is set to a random value between the min and max values.
MinScoutableArmyintwon't scout from asteroids with this number or fewer seedlings.
MinBattleAnalysisTimefloatTime between periodic checks. When this timer runs out, an analysis of battles in progress is conducted. Various values below are then taken in to account to govern the AI's decisions depending on the battle's progression.
MaxBattleAnalysisTimefloatThe timer is set to a random value between the min and max values.
Cowardicefloat (0-1)chances of retreating a battle we are losing.
BattleSavvyfloat (0-1)chances of picking a battle for a valuable asteroid - don't put this at 1 or the AI will only look at one asteroid at a time!
RecognisableThreatProportionfloat (0-1)enemy army size relative to ours before it's considered a threat.
ReinforcementGreedfloat (0-1)proportion of existing forces elsewhere to send in aid of battle.
AidEnthusiasmfloat (0-1)how much to overshoot the battle rating when sending aid, to allow for inbound enemy forces, estimate errors, travel time, wanting to win, etc.
MinExpansionTimefloatExpand the empire. Expansion won't happen if seedling numbers are below a certain value
MaxExpansionTimefloatThe timer is set to a random value between the min and max values.
MinExpansionForceintThis should be at least the cost of a tree.
ExpandToValuableAsteroidChancefloat (0-1)likelihood of choosing a more valuable asteroid to expand to.
GreedyExpansionfloat (0-1)likelihood of sending all/most of the seedlings to expand.
ExpandBlindfloat (0-1)likelihood of expanding to asteroids that haven't been scouted yet.
MinAttackTimefloatTime between checks for vulnerable nearby asteroids that can be attacked.
MaxAttackTimefloatThe timer is set to a random value between the min and max values.
MinPlantTimefloatTime between checks for suitable locations for planting trees.
MaxPlantTimefloatThe timer is set to a random value between the min and max values.
MinFlowerTimefloatTime between checks that cause the AI to pluck, plant and send flowers.
MaxFlowerTimefloatThe timer is set to a random value between the min and max values.
MinGatherTimefloatTime between AI logic used to gather armies on asteroids, and send them to take over enemy asteroids too.
MaxGatherTimefloatThe timer is set to a random value between the min and max values.
MinTotalSeedlingsintthe minimum number of seedlings allowed in the empire. if the actual number is below this then the AI will stop expanding and planting trees.
MinTotalAddPerAsteroidintadds this number on to the above minimum, per asteroid in the empire.






General game entities - these functions can be used on most anything in the game (seedlings, trees, asteroids, etc)
Function nameReturn valueDescription
Hide(int faction)nilHides the entity from the given faction.
Reveal(int faction)nilReveals the entity to the given faction.
IsVisible(int faction)boolTells if the entity is visible to the given faction.
SetVisible(int faction, bool visible)nilSets whether the entity can be seen by the given faction.
IsVisible()boolTells if the entity is visible to the game (i.e. will it render if it comes onscreen).
Die()nilDeactivate the entity and do whatever else happens when it dies.
SetEnergy(float energy)nilSet the energy attribute of the entity from 0.0 to 1.0
SetStrength(float strength)nilSet the strength attribute of the entity from 0.0 to 1.0
SetSpeed(float speed)nilSet the speed attribute of the entity from 0.0 to 1.0
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 nameTypeDescription
CurrentEnergyfloatCurrent hit points of the entity.
MaxEnergyfloatMax hitpoints of the entity.
PositionVector3Position 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.
« Last Edit: August 31, 2010, 11:17:24 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Scripting in Lua
« Reply #4 on: August 08, 2009, 11:30:22 PM »
For reference, here are some standard Lua reference pages online:

Programming in Lua

If you are new to Lua and especiialy if you are new to scripting, at least read the Expressions and Statements sections, preferably also read the Types section, Functions, and Iterators.

Also available is the rather terse and academic official Lua reference.

jhchrist

  • Guest
Re: Lua scripting in Eufloria - reference
« Reply #5 on: February 10, 2010, 11:19:43 AM »
Quote
These are the most important functions and fields available to you as a scripter (there are tons more but listing them all would take ages and confuse people):

If documenting the remaining functions would take too long, would it be possible for you to provide us with a list of the remaining functions without descriptions, so that we can at least experiment with them without having to try and guess their names?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #6 on: February 10, 2010, 03:56:09 PM »
I think it's probably a bit more complicated than simply copying and pasting a list over.  I know that Alex is extremely busy with various stuff right now, maybe in a month or so he will get time to make a nice list for us :>  I agree it would be cool to know what else it's possible to do..

njursten

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
Re: Lua scripting in Eufloria - reference
« Reply #7 on: February 11, 2010, 03:09:34 AM »
If you feel really hardcore you can extract all strings from the executable to try and find commands. How about the extremely useful function PlayWinSound? ;D

jhchrist

  • Guest
Re: Lua scripting in Eufloria - reference
« Reply #8 on: February 11, 2010, 06:31:59 AM »
Quote
If you feel really hardcore you can extract all strings from the executable to try and find commands.

I've already been doing this a little bit, but the trick is to find the functions which have lua bindings, too. For example, I want to move an asteroid, but none of the position-related function strings I can find seem to have lua bindings.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #9 on: February 11, 2010, 07:37:11 AM »
I'm not that hardcore :<

jhchrist

  • Guest
Re: Lua scripting in Eufloria - reference
« Reply #10 on: February 11, 2010, 08:17:59 AM »
Okay, so I've gone through the Eufloria.exe file and found a lot of function names that look familiar, so I'm going to assume that all of the functions which are bound in lua are in the executable.

I've attached the (formatted) list of function names which I found. I'm going to try using some of these in a game and see how it goes.

Edit: I have done some more digging, and I think I have a bit more worked out. Lua allows developers to create bindings to C/C++ data structures using something called the userdata datatype. Eufloria seems to have a few of these things defined, such as Eufloria.Music, Eufloria.Asteroid, and Eufloria.Attributes. These userdata types can have functions and parameters associated with them. I have attached a listing of the userdata structures as I understand them so far.
« Last Edit: February 11, 2010, 10:30:48 AM by jhchrist »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #11 on: February 11, 2010, 04:12:45 PM »
Awesome!! :D

Nice job dude :>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #12 on: February 11, 2010, 07:13:17 PM »
Nice work :D

I can bind in more lua stuff for later releases. Sorry I haven't given more detailed docs by now.

Imagamer

  • Guest
Re: Lua scripting in Eufloria - reference
« Reply #13 on: May 16, 2010, 11:20:33 AM »
If you have AI variables that determine how soon the AI performs a specific action, like MINPLANTTIME and MAXPLANTTIME, what does MINTICK and MAXTICK do now? Does it start the timer of the other AI variables?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #14 on: May 16, 2010, 12:04:26 PM »
We're not sure, unfortunately.. :>

ulfn

  • Guest
Re: Lua scripting in Eufloria - reference
« Reply #15 on: May 22, 2010, 02:26:26 AM »
Using the time-honored method of trial-and-error I found the following fields for the Asteroid type:

Fieldtypedescription
positionPositionThe position of the asteroid.
radiusfloatThe radius of the asteroid.
attribsAttributesAsteroid attributes (strength, energy, speed)

With the types

Position
Fieldtype
xfloat
yfloat

Attributes
Fieldtype
strengthfloat
energyfloat
speedfloat

The position and radius are really handy for instance for computing if one asteroid is reachable from another:
(click to show/hide)

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

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #16 on: August 03, 2010, 05:47:48 AM »
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 valueDescription
SetVisible(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 nameTypeDescription
PositionVector3Position 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

  • Webdesigner/Developer and Magician
  • Shoot
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
Re: Lua scripting in Eufloria - reference
« Reply #17 on: August 03, 2010, 07:32:20 AM »
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

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #18 on: August 03, 2010, 09:18:59 PM »
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

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #19 on: August 03, 2010, 09:21:17 PM »
Rotation doesn't work. I tried already, a while back.

Here's what Alex said:

...

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

dragoonreas

  • Seedling
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #20 on: August 03, 2010, 09:46:22 PM »
That's a shame, spinning asteroids would have looked cool in the level I'm making. :(

I think the FacingAngle still retained the value I gave it though, so at least I won't have to create a separate array to store the angle values I'm using for my tree fractal algorithm. I'll also be making use of that new DistanceSquaredTo function in my algorithm too. :)

EDIT: Nope, the FacingAngle parameter stays at 0 no matter what you set it to. The DistanceSquaredTo function is also not working for me, as I get the following error message when I try to use it "Object reference not set to an instance of an object."
« Last Edit: August 04, 2010, 03:59:23 AM by dragoonreas »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #21 on: August 04, 2010, 11:00:47 PM »
You CAN rotate asteroids, but the trees and shrubbery and seedlings and everything else do not rotate with it.  Therefore because asteroids are circular, it effectively does nothing.

spywhere

  • Eufloria != Euroflia
  • Shoot
  • *
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 24
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #22 on: October 21, 2010, 10:21:39 PM »
Is "Globals.Flowers.MaxVolume" exist in the game?

I just make a commands database in my Tools and set default value as in the game and found that only one field is not used which is Globals.Flowers.MaxVolume

I use default.xml to set default value.

Thanks...

PS. Sorry for my bad English

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #23 on: October 28, 2010, 02:51:35 AM »
It does exist - it's used when flowers and mines are plucked, and for the flowers and mines loop sounds.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #24 on: December 21, 2010, 06:24:02 AM »
Alex, what does GetLeafColour(int) do?

I saw it in somebody's code.  I had no idea it was a command!  I gather it must be run on a tree.  What does it return?

If this could be used to check what colour a particular empire is, that would be very useful to me!

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #25 on: December 21, 2010, 09:21:08 PM »
It's a function in "Structure" (i.e. trees), takes an integer from 0 to 4 inclusive and returns a colour. Each team has 5 colours that represent it, and trees store an internal version of it so that when tree ownership changes, the leaves that it bears can smoothly change colour instead of changing immediately.

If you want to get a team colour... here's a tasty bit for you.
Code: [Select]
Game = luanet.import_type("Eufloria.ColonyGame");
team1red0 = Game.GetFactionColour(1,0)
team1red1 = Game.GetFactionColour(1,1)
team4red3 = Game.GetFactionColour(4,3)

luanet.import_type gives you access to a class type theoretically giving you the opportunity to create instances of this type as well, though I am not sure what it would mean to do this in many cases for Eufloria's classes.

GetFactionColour is a static function of ColonyGame so you only need the type to be able to access it, not the ColonyGame instance. Hence the code above assigns the type ColonyGame to the variable CG, and this makes available the static functions of that type.

The base game class (that handles the front end etc) is Eufloria.Game, and has a static instance called Eufloria.Game.Instance from which various things are available (including Game.Instance.ColonyGame if the game is running).

e.g.
Code: [Select]
Program = luanet.import_type("Eufloria.Game")
ProgramInstance = Program.Instance
Game = luanet.import_type("Eufloria.ColonyGame")
GameInstance = ProgramInstance.ColonyGame
if (GameInstance ~= nil) -- use some part of colonygame instance e.g. call ApplyDarkModeSettings()!

All very untested and unsupported I must hasted to add!





Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #26 on: December 21, 2010, 09:28:15 PM »
Can you set the colours with this too?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #27 on: December 21, 2010, 10:13:20 PM »
Even with just what Alex has given me, I could effectively "set" colours.  I could develop a script that checks what the colour is, and changes the asteroid to a different empire number if it's a colour I don't like.  :>

This is freaking awesome... if it works, this will finally give me the ability to produce maps that look exactly how I intend them to look, every time they are played.  :>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #28 on: December 21, 2010, 11:00:30 PM »
I don't think you can set them at the moment, maybe there's a way but as ColorF (the data returned by GetFactionColour) is a struct not a class, you don't get passed back a reference, so going GetFactionColour(1,4).R = 0.8 won't do anything. Same for GetLeafColour. The changing empire plan ought to work though. Just bear in mind that the leaf colours may not be close to any of the team colours if the asteroid was recently taken over.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #29 on: January 03, 2011, 07:15:15 AM »
I'm currently working on an extremely large and complicated level and I'm looking for ways to increase the FPS ingame.  I've already been able to make drastic improvements to some parts of the code by breaking out of loops early, using cheaper calculations to rule things out more quickly, avoiding math.sqrt wherever possible, trying to spot large inefficiencies in the looping structures, and so on.

I was wondering if you know if there are any Eufloria functions that are particularly expensive?  EG, does it cost more CPU cycles to draw a sprite, or a line?  Is "GetAsteroid" expensive?  What about "GetNumSeedlings"?  If there are any obvious cases where you can accomplish something in two different ways, and one is much cheaper than the other, I'd really like to know about them.. :>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #30 on: January 03, 2011, 09:44:22 AM »
Probably better to do this on a case-by-case basis. I don't know of any rotters in there that take more time than they ought, I'd have to take a look to see which are the most hefty.

I'll have a look in the thread now...

Avaguard

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 40
Re: Lua scripting in Eufloria - reference
« Reply #31 on: January 25, 2011, 03:38:33 AM »
heres 1 u can maybe add RevealAll() although maybe everyone already knew...........maybe i did something wrong just now :-\

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #32 on: January 25, 2011, 04:10:16 AM »
You could just do it this way:


Code: [Select]
for i = 0,numberofasteroidsinyourlevel do
GetAsteroid(i):Reveal(1)
end

:>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 15
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #33 on: January 30, 2011, 12:35:23 AM »
RevealAll() is a command that was added and should now work. I haven't updated this docs thread in ages, sorry.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #34 on: March 26, 2011, 08:37:33 AM »
Is there anyone that wants to make a writing program just for Eufloria? So it will recognize all these codes automatically instead of going up here just to figure out? :)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #35 on: March 27, 2011, 04:22:07 AM »
I'm working one one, I have been for a while now. Search for "EUCLiD". The uploaded one at the moment is rather basic, but will get maps done quick. EUCLiD 2 will be much more functional.


http://www.dyson-game.com/smf/index.php?topic=834.0 is the announcement thread, has a link to a download thread.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #36 on: March 27, 2011, 05:32:21 AM »
I would really like a coding window, and as I see it now, you are using some kind of Visual C... So you know what I mean maybe... If you use some kind of Visual C thingy...

What I meant was a nice program that was just like a notebook or notepad or whatever that recognizes parts of codes and show some examples of codes that looks a little alike...

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #37 on: March 27, 2011, 05:46:40 AM »
Ah. Try programmer's notepad, or notepad++

I'll probs put in a coding window to EUCLiD too.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #38 on: March 27, 2011, 10:39:23 AM »
I use notepad++ already :) What I am talking about is a way to not need to go in here and look after the thing you seek... Simply jsut either search for it in the program or it will pop up in a littl box when you write and you can choose from several(depends) built-in methods to put in...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #39 on: March 29, 2011, 01:50:38 AM »
Is there any way to GET the attribs of an entity? Like entity.attribs.speed?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #40 on: March 29, 2011, 06:45:49 AM »
Yes.

roidstrength = GetAsteroid(x).attribs.strength

For example :>

".attribs.strength" should work for other entities too.  And of course you can call energy and speed, not just strength.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #41 on: March 29, 2011, 09:29:05 PM »
God -.- I have been close though, cause Lua is case sensitive?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #42 on: March 29, 2011, 09:33:50 PM »
Hmm,  not sure.. :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #43 on: March 29, 2011, 09:36:02 PM »
not working :/ Better check it closeluy then...

Code: [Select]
if GetAsteroid(i).attribs.energy > HighestEnergy then

HighestEnergy = GetAsteroid(i).attribs.energy

end

I get the error: invalid arguments to method call, the function is the AI... and I suspect the attrib part to be the fault...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #44 on: March 29, 2011, 09:42:53 PM »
Solved I think, I saw an error though, I was calling i when it wasn't in a for loop or the variable i was existing :) Changing now :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #45 on: March 31, 2011, 01:14:04 AM »
Any way to select each and every seed in the whole game?

Like:

Code: [Select]
for i = 1,NumSeedlings() do --NumSeedlings can be a variable by adding all the current seeds frome ach empire in the game, thats not the problem :)
if Agent(i) ~= nil then
x = Agent(i).position.X   --position.X is existing for all game enitites, so I guess that would work if you can call each and every agent alone :)
--make a variable containing x, if there is anything like this, is there then possible to track(if the seeds are on move) where they are going(asteroid wise)?
end
end

Now I am asking before I have experimented though... as usual -.-

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #46 on: March 31, 2011, 03:56:33 AM »
Just brainstorming, but here goes:

Get the number of empires, the number of asteroids, and the number of seedlings on each asteroid.

At EVERY roid, run a FOR loop for each empire, for the number of their seedlings on that roid. This loop would pick up a specific seedling, there is a way of doing this, but I'm not sure how just atm. Add this collected seedling to a variable.

This variable will hold all seedlings.


...


Maybe.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #47 on: March 31, 2011, 04:16:36 AM »
o.O...

Just do a for loop for all empires and NumSeedlings?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #48 on: March 31, 2011, 04:56:02 AM »
Or that, either way. Why did I not think of that?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #49 on: March 31, 2011, 06:46:11 PM »
I recall there is a way to access an inbuilt array of seedlings, organised per asteroid.  Can't remember offhand how to do it though.
If you make your own array and store the seedlings in it, you could then run commands on them even if they are mid-flight between two asteroids.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #50 on: March 31, 2011, 09:16:52 PM »
Thats exactly what I need for my save code, but now I need to know how to write into a file... IO crashes, so I don't know how...
« Last Edit: March 31, 2011, 09:47:02 PM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #51 on: April 03, 2011, 05:54:31 AM »
Is there any possibl way to find the Empire color? Like GetEmpire(faction).Colo(u)r

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #52 on: April 04, 2011, 02:57:14 AM »
GetLeafColour()

Ask Annikk about it, he was working with it a while ago.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #53 on: April 04, 2011, 07:29:06 PM »
I did not find an elegant solution to that.  My experiments with GetLeafColour() met with limited success.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #54 on: April 04, 2011, 09:32:10 PM »
Ok, I'll try and see :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #55 on: April 20, 2011, 05:14:19 PM »
Hmm, I need that Seedling/Agent thing again >.<

Anyone remember?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #56 on: May 05, 2011, 04:32:55 AM »
What is all of these?

Quote
DrawSprite Know that one
DrawLine
DrawEnergyLine
DrawBox
DrawCore
DrawTexturedLine2
DrawTexturedLine
DrawRoot
DrawPolyLine
DrawPolygon
DrawLineTest Guess it is jsut a test, so...

Are they usable, or? And if so, how do you use them(I know thay should either be in LevelDraw() or ScreenDraw(), but I am talking about the arguments it needs)?
« Last Edit: May 05, 2011, 05:41:02 AM by Aino »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #57 on: May 05, 2011, 05:35:01 AM »
Draw sprite draws...a sprite!

There's a list of them somewhere around, iirc.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 31
  • Posts: 1,527
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #58 on: May 05, 2011, 05:36:22 AM »
Lol, forgot to strikeout DrawSprite, I use it way to often to not know what it is :)

Edit: My 500th post :O

hitman271

  • Shoot
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
Re: Lua scripting in Eufloria - reference
« Reply #59 on: August 06, 2011, 01:50:44 AM »
Any word on DrawPolygon? Is there a way to determine a lua's functions arguments?!

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #60 on: August 06, 2011, 03:19:21 AM »
Oh, i made a draw polygon somewheres around. Want a link?

hitman271

  • Shoot
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
Re: Lua scripting in Eufloria - reference
« Reply #61 on: August 06, 2011, 10:54:41 AM »
Yes of course. Why doesn't this game have a proper wiki?

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: Lua scripting in Eufloria - reference
« Reply #62 on: August 06, 2011, 11:25:23 AM »
Regarding the GetFactionColor commands- Sometimes the values returned are spot-on to what they look like on the screen. Most of the time, unfortunately, they are not even close. I've spent many hours the last few weeks trying to use the colors returned to match Draw commands, and I'm convinced it is a hopeless pursuit. I thought perhaps it was a problem with the RGB values being switched around vs. the RBG values in some of the  Draw functions, but it turned out not to be the case. Weird.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Lua scripting in Eufloria - reference
« Reply #63 on: August 06, 2011, 09:22:28 PM »
http://www.dyson-game.com/smf/index.php?topic=1359.msg9403#msg9403

The arguments X and Y are arrays of the co-ordinates of the vetices.

BC wins

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
Re: Lua scripting in Eufloria - reference
« Reply #64 on: August 13, 2011, 06:37:23 AM »