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

0 Members and 1 Guest are viewing this topic.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Lua scripting in Eufloria - reference
« on: July 19, 2009, 10:48:14 AM »
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, 10:44:10 AM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Globals reference
« Reply #1 on: July 19, 2009, 03: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 25, 2009, 09:08:29 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
What goes in the Lua file?
« Reply #2 on: July 19, 2009, 03: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, 04:12:22 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Documentation of Asteroids and Empires
« Reply #3 on: July 26, 2009, 12: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, 03:17:24 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Scripting in Lua
« Reply #4 on: August 08, 2009, 03: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, 03: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: 4
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #6 on: February 10, 2010, 07:56:09 AM »
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 10, 2010, 07:09:34 PM »
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 10, 2010, 10:31:59 PM »
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: 4
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #9 on: February 10, 2010, 11:37:11 PM »
I'm not that hardcore :<

jhchrist

  • Guest
Re: Lua scripting in Eufloria - reference
« Reply #10 on: February 11, 2010, 12: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, 02:30:48 AM by jhchrist »

annikk.exe

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

Nice job dude :>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Lua scripting in Eufloria - reference
« Reply #12 on: February 11, 2010, 11:13:17 AM »
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, 03: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: 4
  • Posts: 1,809
Re: Lua scripting in Eufloria - reference
« Reply #14 on: May 16, 2010, 04:04:26 AM »
We're not sure, unfortunately.. :>