EmptyEpsilon Scripting Reference
This is the EmptyEpsilon script reference for this version of EmptyEpsilon.
By no means this is a guide to help you scripting, you should check emptyepsilon.org for the guide on scripting. As well as check the already existing scenario and ship data files on how to get started.
Some of the types in the parameters:
- ScriptSimpleCallback / function: Note that the callback function must reference something global, otherwise you get an error like "??[convert<ScriptSimpleCallback>::param] Upvalue 1 of function is not a table...". Use e.g. `math.abs(0) -- Provides global context for SeriousProton` to do nothing.
- EAlertLevel: "Normal", "YELLOW ALERT", "RED ALERT" (
playerSpaceship.cpp
)
- ECrewPosition: "Helms", "Weapons", "Engineering", "Science", "Relay", "Tactical", "Engineering+", "Operations", "Single", "DamageControl", "PowerManagement", "Database", "AltRelay", "CommsOnly", "ShipLog", (
playerInfo.cpp
)
- EMissileSizes: "small", "medium", "large"
- EMissileWeapons: "Homing", "Nuke", "Mine", "EMP", "HVLI" (
spaceship.cpp
)
- EScannedState: "notscanned", "friendorfoeidentified", "simplescan", "fullscan" (
spaceObject.h
)
- ESystem: "reactor", "beamweapons", "missilesystem", "maneuver", "impulse", "warp", "jumpdrive", "frontshield", "rearshield"
- Factions: "Independent", "Kraylor", "Arlenians", "Exuari", "Ghosts", "Ktlitans", "TSN", "USN", "CUF" (
factionInfo.lua
)
- Color: A string that can either be a hex color code (#rrggbb), three comma seperated rgb integers (rrr,ggg,bbb) or one of the following: "black", "white", "red", "green", "blue", "yellow", "magenta" or "cyan". Invalid values default to white.
Note that most SpaceObject
s directly switch to fully scanned, only SpaceShips
s go through all the states.
Functions
- number random(number min_value, number max_value)
- Generate a random floating point number between the min and max value. Includes min and max as possible values.
(Floating point numbers are factional numbers, so 1.5, 2.333333, 3.141) - number irandom(number min_value, number max_value)
- Generate a random integer number between the min and max value. Includes min and max as possible values.
(Integer numbers are whole numbers, so 1, 2, 3, 5, 1400) - string traceback()
- Returns a string containing a list of function calls up to the current point.
useful for debugging and error reporting. - destroyScript()
- Destroy this script instance. Note that the script will keep running till the end of the current script call.
- addGMMessage(string message)
- shows a message on the GM screen
- addGMFunction(string name, ScriptSimpleCallback callback)
- Add a function that can be called from the GM console. This can be used to create helper scripts for the GM.
Or to give the GM console certain control over the scenario. - removeGMFunction(string name)
- Remove a function from the GM console
- clearGMFunctions()
- Remove all the GM functions from the GM console.
- SpaceObject[] getGMSelection()
- Returns an list of objects that the GM currently has selected.
- onGMClick(ScriptSimpleCallback callback)
- Register a callback function that is called when the gm clicks on the background of their screen.
Example 1: onGMClick(function(x,y) print(x,y) end) -- print the x and y when clicked.
Example 2: onGMClick(nil) -- resets to no function being called on clicks - setCommsMessage(string message)
- Sets the message/reply shown to the comms officer.
Not setting the message leads to "no reply" (when trying to open comms)
or a dialog with the message "?" (in a reply). - addCommsReply(string message, ScriptSimpleCallback callback)
- Add an reply option for communications.
Within the callback function, `comms_source` and `comms_target` are available.
Deprecated: In a CommsScript, `player` can be used for `comms_source`.
(In a CommsFunction, only `comms_source` is provided.)
Instead of using the globals, the callback function can take two parameters.
Example: addCommsReply(message, function(comms_source, comms_target) ... end) - commsSwitchToGM()
- Use this function from a communication callback function to switch the current
communication from scripted to a GM based chat. - FactionInfo getFactionInfo(string faction_name)
- Get a reference to a FactionInfo object, which can be used to modify faction to faction states.
- string getSectorName(number x, number y)
- Return the sector name for the point with coordinates (x, y). Compare SpaceObject:getSectorName().
- number x, number y sectorToXY(string sector_name)
- Convert a sector name to x,y coordinates for the top-left of the sector
sectorToXY("A0") sectorToXY("zz-23") sectorToXY("BA12") - victory(string faction_name)
- Called with a faction name as parameter, sets a certain faction as victor and ends the game.
(The GM can unpause the game, but the scenario with its update function is destroyed.) - globalMessage(string message, number timeout=nil)
- Show a global message on the main screens of all active player ships.
The message is shown for 5 sec; new messages replace the old immediately. - setBanner(string banner)
- Show a scrolling banner containing this text on the cinematic and top down views.
- number getScenarioTime()
- Return the elapsed time of the scenario.
- PlayerSpaceship getPlayerShip(number index)
- Return the player's ship, use -1 to get the first active player ship.
- PlayerSpaceship[] getActivePlayerShips()
- Return a list of active player ships.
- SpaceObject[] getObjectsInRadius(number x, number y, number radius)
- Return a list of all space objects at the x,y location within a certain radius.
- SpaceObject[] getAllObjects()
- Return a list of all space objects. (Use with care, this could return a very long list which could slow down the game when called every update)
- string getScenarioVariation()
- Returns the currently used scenario variation.
Deprecated: Scenario settings are the replacement - string getScenarioSetting(string key)
- Returns a scenario setting, or an empty string if the setting is not found.
- string getGameLanguage()
- Returns the language as the string set in game preferences under language key
- setScenario(string script_name, string variation_name=nil)
- Change the current scenario to a different one.
- shutdownGame()
- Shutdown the game.
Calling this function will close the game. Mainly useful for a headless server setup. - pauseGame()
- Pause the game
Calling this function will pause the game. Mainly useful for a headless server setup. - unpauseGame()
- Pause the game
Calling this function will pause the game. Mainly useful for a headless server setup. As the scenario functions are not called when paused. - playSoundFile(string filename)
- Play a sound file on the server. Will work with any file supported by SFML (.wav, .ogg, .flac)
Note that the sound is only played on the server. Not on any of the clients. - EScanningComplexity getScanningComplexity()
- Get the scanning complexity setting
- number getHackingDifficulty()
- Get the hacking difficulty setting (returns an integer between 0 and 3)
- EHackingGames getHackingGames()
- Get the hacking games setting
- boolean areBeamShieldFrequenciesUsed()
- returns if the "Beam/Shield Frequencies" setting is enabled
- boolean isPerSystemDamageUsed()
- returns if the "Per-System Damage" setting is enabled
- boolean isTacticalRadarAllowed()
- returns if the "Tactical Radar" setting is enabled
- boolean isLongRangeRadarAllowed()
- returns if the "Long Range Radar" setting is enabled
- onNewPlayerShip(ScriptSimpleCallback callback)
- Register a callback function that is called when a new ship is created (on the ship selection screen or with the constructor in a lua script).
This callback function is called with the newly created ship as the only parameter. - allowNewPlayerShips(boolean allow)
- Set if the server is allowed to create new player ships from the ship creation screen.
- string getEEVersion()
- Get a string with the current version number, like "20191231"
- ScienceDatabase queryScienceDatabaseById(number id)
- Return a ScienceDatabase entry by its unique multiplayer_id.
Returns nil if no entry is found.
Example: local mine_db = queryScienceDatabaseById(4); - ScienceDatabase queryScienceDatabase(string path...)
- finds a ScienceDatabase entry by its case-insensitive name. You have to give the full path to the entry by using multiple arguments.
Returns nil if no entry is found.
e.g. local mine_db = queryScienceDatabase("Natural", "Mine") - ScienceDatabase[] getScienceDatabases()
- get all ScienceDatabases that do not have a parent. Use getEntries() or getEntryByName() to navigate.
- require(string filename)
- Run the script with the given filename in the same context as the current running script.
- string _(string text, string default=nil)
- Translate the given string with the user configured language.
- ScriptStorage getScriptStorage()
- Expose the ScriptStorage object, which can save and load key-value pairs
These key-value pairs are permanently stored and survive server restarts.
Returns a ScriptStorage object; see also ScriptStorage.get() and .set().
Example: storage = getScriptStorage();
FactionInfo
- FactionInfo FactionInfo:setName(string name)
- Returns the object it was called on.
- FactionInfo FactionInfo:setLocaleName(string name)
- Returns the object it was called on.
- FactionInfo FactionInfo:setGMColor(number r, number g, number b)
- Returns the object it was called on.
- FactionInfo FactionInfo:setDescription(string description)
- Returns the object it was called on.
- FactionInfo FactionInfo:setEnemy(FactionInfo other)
- Returns the object it was called on.
- FactionInfo FactionInfo:setFriendly(FactionInfo other)
- Returns the object it was called on.
- boolean FactionInfo:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- FactionInfo FactionInfo:destroy()
- Removes this object from the game.
Returns the object it was called on. - FactionInfo:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
ModelData
- ModelData ModelData:setName(string name)
- Returns the object it was called on.
- ModelData ModelData:setMesh(string mesh_name)
- Returns the object it was called on.
- ModelData ModelData:setTexture(string texture_name)
- Returns the object it was called on.
- ModelData ModelData:setSpecular(string specular_texture_name)
- Returns the object it was called on.
- ModelData ModelData:setIllumination(string illumination_texture_name)
- Returns the object it was called on.
- ModelData ModelData:setRenderOffset(number mesh_offset_x, number mesh_offset_y, number mesh_offset_z)
- Returns the object it was called on.
- ModelData ModelData:setScale(number scale)
- Returns the object it was called on.
- ModelData ModelData:setRadius(number radius)
- Returns the object it was called on.
- ModelData ModelData:setCollisionBox(number collision_box_x, number collision_box_y)
- Returns the object it was called on.
- ModelData ModelData:addBeamPosition(number position_x, number position_y, number position_z)
- Returns the object it was called on.
- ModelData ModelData:addTubePosition(number position_x, number position_y, number position_z)
- Returns the object it was called on.
- ModelData ModelData:addEngineEmitor(number position_x, number position_y, number position_z, number color_r, number color_g, number color_b, number scale)
- Returns the object it was called on.
- ModelData ModelData:addEngineEmitter(number position_x, number position_y, number position_z, number color_r, number color_g, number color_b, number scale)
- Returns the object it was called on.
- boolean ModelData:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- ModelData ModelData:destroy()
- Removes this object from the game.
Returns the object it was called on. - ModelData:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
ScienceDatabase
- ScienceDatabase ScienceDatabase:setName(string name)
- Returns the object it was called on.
- string ScienceDatabase:getName()
- number ScienceDatabase:getId()
- number ScienceDatabase:getParentId()
- ScienceDatabase ScienceDatabase:addEntry(string name)
- ScienceDatabase ScienceDatabase:getEntryByName(string name)
- returns a child entry by its case-insensitive name
- ScienceDatabase[] ScienceDatabase:getEntries()
- returns a table of all child entries in arbitrary order
- boolean ScienceDatabase:hasEntries()
- returns true if this entry has child entries
- ScienceDatabase ScienceDatabase:addKeyValue(string key, string value)
- add a new key-value pair in the center column of the database
Returns the object it was called on. - ScienceDatabase ScienceDatabase:setKeyValue(string key, string value)
- if an entry with this key exists already, its value will be changed. If not, the pair is created.
Returns the object it was called on. - string ScienceDatabase:getKeyValue(string key)
- get the value of the key value-pair with the given key. returns empty string when key does not exist.
- table ScienceDatabase:getKeyValues()
- get all the key value pairs as a table. Warning: if there are duplicate keys only appear once with the last value.
- ScienceDatabase ScienceDatabase:removeKey(string key)
- remove all key value pairs with the case-insensitive key value name
Returns the object it was called on. - ScienceDatabase ScienceDatabase:setLongDescription(string text)
- Returns the object it was called on.
- string ScienceDatabase:getLongDescription()
- ScienceDatabase ScienceDatabase:setImage(string path)
- Returns the object it was called on.
- string ScienceDatabase:getImage()
- ScienceDatabase ScienceDatabase:setModelDataName(string model_data_name)
- Returns the object it was called on.
- boolean ScienceDatabase:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- ScienceDatabase ScienceDatabase:destroy()
- Removes this object from the game.
Returns the object it was called on. - ScienceDatabase:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
Script
Object which can be used to create and run another script.
Other scripts have their own lifetime, update and init functions.
Scripts can destroy themselves (destroyScript()), or be destroyed by the main script.
Example: local script = Script():run("script.lua"); script:destroy();
- boolean Script:run(string filename)
- Run a script with a certain filename
- Script Script:setVariable(string variable_name, string value)
- Set a global variable in this script instance, this variable can be accessed in the main script.
Returns the object it was called on. - boolean Script:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- Script Script:destroy()
- Removes this object from the game.
Returns the object it was called on. - Script:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
ScriptStorage
- string ScriptStorage:get(string key)
- Get a value from persistent script storage.
Requires the key as a string.
Returns the value as a JSON string.
Returns nothing if the key is not found.
Example: storage = getScriptStorage()
storage:get('key') - ScriptStorage ScriptStorage:set(string key, string value)
- Set a value in persistent script storage.
Requires the key and value as strings.
Creates scriptstorage.json if it doesn't exist.
Example: storage = getScriptStorage()
storage:set('key', 'value')
Returns the object it was called on. - boolean ScriptStorage:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- ScriptStorage ScriptStorage:destroy()
- Removes this object from the game.
Returns the object it was called on. - ScriptStorage:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
ShipTemplate
ShipTemplates are created when EmptyEpsilon is started.
And used to fill the ship starting statistics, and other information.
- ShipTemplate ShipTemplate:setName(string name)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setLocaleName(string name)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setClass(string class_name, string sub_class_name)
- Set the class name, and subclass name for the ship. Used to divide ships into different classes.
Returns the object it was called on. - ShipTemplate ShipTemplate:setDescription(string description)
- Set the description shown for this ship in the science database.
Returns the object it was called on. - ShipTemplate ShipTemplate:setType(TemplateType type)
- Sets the type of template. Defaults to normal ships, so then it does not need to be set.
Example: template:setType("ship"), template:setType("playership"), template:setType("station")
Returns the object it was called on. - ShipTemplate ShipTemplate:hidden()
- Hides this template from GM creation features and science database.
Hidden templates exists mainly for backwards compatibility of scripts.
Returns the object it was called on. - ShipTemplate ShipTemplate:setDefaultAI(string default_ai_name)
- Set the default AI behaviour. EE has 3 types of AI coded into the game right now: "default", "fighter", "missilevolley"
Returns the object it was called on. - ShipTemplate ShipTemplate:setModel(string model_name)
- Set the 3D model to be used for this template. The model referers to data set in the model_data.lua file.
Returns the object it was called on. - ShipTemplate ShipTemplate:setDockClasses(string classes...)
- Supply a list of ship classes that can be docked to this ship. setDockClasses("Starfighter") will allow all small starfighter type ships to dock with this ship.
(Same as setExternalDockClasses)
Returns the object it was called on. - ShipTemplate ShipTemplate:setExternalDockClasses(string classes...)
- Supply a list of ship classes that can be docked to this ship. setExternalDockClasses("Starfighter") will allow all small starfighter type ships to dock with this ship.
External docking will keep the ship attached to the side of this ship.
Returns the object it was called on. - ShipTemplate ShipTemplate:setInternalDockClasses(string classes...)
- Supply a list of ship classes that can be docked to this ship. setInternalDockClasses("Starfighter") will allow all small starfighter type ships to dock with this ship.
Internal docking will hide the docked ship inside the other ship.
Returns the object it was called on. - ShipTemplate ShipTemplate:setEnergyStorage(number energy_amount)
- Set the amount of energy available for this ship. Note that only player ships use energy. So setting this for anything else is useless.
Returns the object it was called on. - ShipTemplate ShipTemplate:setRepairCrewCount(number amount)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setBeam(number index, number arc, number direction, number range, number cycle_time, number damage)
- Setup a beam weapon.
Returns the object it was called on. - ShipTemplate ShipTemplate:setBeamWeapon(number index, number arc, number direction, number range, number cycle_time, number damage)
- Setup a beam weapon.
Returns the object it was called on. - ShipTemplate ShipTemplate:setBeamWeaponTurret(number index, number arc, number direction, number rotation_rate)
- Setup a beam's turret.
Returns the object it was called on. - ShipTemplate ShipTemplate:setBeamTexture(number index, string texture)
- Setup a beam weapon texture
Returns the object it was called on. - ShipTemplate ShipTemplate:setBeamWeaponEnergyPerFire(number index, number energy)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setBeamWeaponHeatPerFire(number index, number heat)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setTubes(number amount, number load_time)
- Set the amount of missile tubes, limited to a maximum of 16.
Returns the object it was called on. - ShipTemplate ShipTemplate:setTubeLoadTime(number index, number load_time)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:weaponTubeAllowMissle(number index, EMissileWeapons type)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:weaponTubeDisallowMissle(number index, EMissileWeapons type)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setWeaponTubeExclusiveFor(number index, EMissileWeapons type)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setTubeDirection(number index, number direction)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setTubeSize(number index, EMissileSizes size)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setHull(number amount)
- Set the amount of starting hull
Returns the object it was called on. - ShipTemplate ShipTemplate:setShields(number values...)
- Set the shield levels, amount of parameters defines the amount of shields. (Up to a maximum of 8 shields)
Example: setShieldData(400) setShieldData(100, 80) setShieldData(100, 50, 50)
Returns the object it was called on. - ShipTemplate ShipTemplate:setSpeed(number impulse, number turn, number acceleration, number reverse_speed=nil, number reverse_acceleration=nil)
- Set the impulse speed, rotation speed and impulse acceleration for this ship.
Optional fourth and fifth arguments are reverse speed and reverse acceeleration.
If not explicitely set, reverse speed and reverse acceleration are set to forward speed and acceleration
Compare SpaceShip:setImpulseMaxSpeed, :setRotationMaxSpeed, :setAcceleration.
Returns the object it was called on. - ShipTemplate ShipTemplate:setCombatManeuver(number boost, number strafe)
- Sets the combat maneuver power of this ship.
Returns the object it was called on. - ShipTemplate ShipTemplate:setWarpSpeed(number warp)
- Set the warp speed for warp level 1 for this ship. Setting this will indicate that this ship has a warpdrive. (normal value is 1000)
Returns the object it was called on. - ShipTemplate ShipTemplate:setSharesEnergyWithDocked(boolean enabled)
- Set if this ship shares energy with docked ships. Example: template:setSharesEnergyWithDocked(false)
Returns the object it was called on. - ShipTemplate ShipTemplate:setRepairDocked(boolean enabled)
- Set if this ship repairs docked ships. Example: template:setRepairDocked(false)
Returns the object it was called on. - ShipTemplate ShipTemplate:setRestocksScanProbes(boolean enabled)
- Set if this ship restocks scan probes on docked ships. Example: template:setRestocksScanProbes(false)
Returns the object it was called on. - ShipTemplate ShipTemplate:setRestocksMissilesDocked(boolean enabled)
- Set if this ship restores missiles on docked cpuships. Example template:setRestocksMissilesDocked(false)
Returns the object it was called on. - ShipTemplate ShipTemplate:setJumpDrive(boolean enabled)
- Set if this ship has a jump drive. Example: template:setJumpDrive(true)
Returns the object it was called on. - ShipTemplate ShipTemplate:setJumpDriveRange(number min, number max)
- Set this ship's minimum and maximum jump drive distances.
Example: template:setJumpDrive(5000.0, 50000.0)
Returns the object it was called on. - ShipTemplate ShipTemplate:setCloaking(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setWeaponStorage(EMissileWeapons weapon, number amount)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:addRoom(number position_x, number position_y, number size_x, number size_y)
- Add an empty room to a ship template.
Rooms are shown on the engineering and damcon screens.
If a system room isn't accessible via other rooms connected by doors, that system
might not be repairable.
Rooms are placed on an integer x/y grid. The minimum size for a room is 1x1.
Accepts four parameters: the room's x coordinate, y coordinate, width, and height.
Example: template:addRoom(1, 2, 3, 4)
Returns the object it was called on. - ShipTemplate ShipTemplate:addRoomSystem(number position_x, number position_y, number size_x, number size_y, ESystem system)
- Add a room containing a ship system to a ship template.
Rooms are shown on the engineering and damcon screens.
If a system doesn't have a room, or repair crews can't reach a system's room, it
might not be repairable.
Accepts five parameters: the room's x coordinate, y coordinate, width, height, and
the ship system as the string equivalent of an ESystem value.
Example: template:addRoomSystem(1, 2, 3, 4, "Reactor")
Returns the object it was called on. - ShipTemplate ShipTemplate:addDoor(number position_x, number position_y, boolean horizontal)
- Add a door between rooms in a ship template.
Rooms are shown on the engineering and damcon screens.
If a system room doesn't have a door connecting it to other rooms, repair crews
might not be able to reach it for repairs.
Accepts three parameters: the door's x coordinate, y coordinate, and a Boolean
value for whether it's horizontal (true) or vertical (false).
Example: template:addDoor(2, 2, false)
Returns the object it was called on. - ShipTemplate ShipTemplate:setRadarTrace(string trace)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setLongRangeRadarRange(number range)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setShortRangeRadarRange(number range)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setImpulseSoundFile(string sound)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setCanScan(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setCanHack(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setCanDock(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setCanCombatManeuver(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setCanSelfDestruct(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:setCanLaunchProbe(boolean enabled)
- Returns the object it was called on.
- ShipTemplate ShipTemplate:copy(string new_name)
- Return a new template with the given name, which is an exact copy of this template.
Used to make easy variations of templates. - boolean ShipTemplate:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- ShipTemplate ShipTemplate:destroy()
- Removes this object from the game.
Returns the object it was called on. - ShipTemplate:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
SpaceObject
SpaceObject is the base for every object which can be seen in space.
General properties can read and set for each object.
Each object has a position, rotation, and collision shape.
- SpaceObject SpaceObject:setPosition(number v_x, number v_y)
- Sets this object's position on the map, in meters from the origin.
Requires two numeric values.
Example: obj:setPosition(x, y)
Returns the object it was called on. - number x, number y SpaceObject:getPosition()
- Gets this object's position on the map.
Returns x, y as meters from the origin.
Example: local x, y = obj:getPosition() - SpaceObject SpaceObject:setRotation(number angle)
- Sets this object's absolute rotation, in degrees.
Unlike setHeading, a value of 0 points to the right of the map.
The value can also be unbounded; it can be negative, or greater than
360 degrees.
Requires a numeric value.
Example: obj:setRotation(270)
Returns the object it was called on. - number SpaceObject:getRotation()
- Gets this object's absolute rotation.
setHeading and setRotation do not change the target heading of
PlayerSpaceships; use PlayerSpaceship's commandTargetRotation.
Returns a value in degrees.
Example: local rotation = obj:getRotation() - SpaceObject SpaceObject:setHeading(number heading)
- Sets this object's heading, in degrees ranging from 0 to 360.
Unlike setRotation, a value of 0 points to the top of the map.
Values that are negative or greater than 360 are are converted to values
within that range.
setHeading and setRotation do not change the target heading of
PlayerSpaceships; use PlayerSpaceship's commandTargetRotation.
Requires a numeric value.
Example: obj:setHeading(0)
Returns the object it was called on. - number SpaceObject:getHeading()
- Gets this object's heading, in degrees ranging from 0 to 360.
Returns a value in degrees.
Example: local heading = obj:getHeading(0) - number x, number y SpaceObject:getVelocity()
- Gets this object's directional velocity within 2D space.
Returns a pair of values x, y which are relative x, y coordinates from current position (2D velocity vector).
Example: local vx, vy = obj:getVelocity() - number SpaceObject:getAngularVelocity()
- Gets this object's rotational velocity within 2D space.
Returns a value in degrees/second.
Example: local angular_velocity = obj:getAngularVelocity() - SpaceObject SpaceObject:setFaction(string faction_name)
- Sets the faction to which this object belongs, by faction name.
Factions are defined by the FactionInfo() function, and default
factions are defined in scripts/factionInfo.lua.
Requires a faction name string as input.
Example: obj:setFaction("Human Navy")
Returns the object it was called on. - string SpaceObject:getFaction()
- Gets the name of the faction to which this object belongs.
Example: local faction = obj:getFaction() - string SpaceObject:getLocaleFaction()
- Gets the localized name of the faction to which this object belongs, for displaying to the players.
Example: local faction = obj:getLocaleFaction() - SpaceObject SpaceObject:setFactionId(number faction_id)
- Sets the faction to which this object belongs, by the faction's index
in the faction list.
Requires the index of a faction in the faction list.
Example: local faction_id = obj:getFactionId()
Returns the object it was called on. - number SpaceObject:getFactionId()
- Gets the faction list index for the faction to which this object
belongs. Can be used in combination with setFactionId() to ensure that
two objects have the same faction.
Example: other:setFactionId(obj:getFactionId()) - boolean SpaceObject:isEnemy(SpaceObject obj)
- Gets the friend-or-foe status of the parameter's faction relative to
this object's faction.
Requires a SpaceObject.
Returns true if the parameter's faction is hostile to this object's.
Example: local is_enemy = obj:isEnemy() - boolean SpaceObject:isFriendly(SpaceObject obj)
- Requires a SpaceObject.
Returns true if the parameter's faction is friendly to this object's.
If an object is neither friendly nor enemy, it is neutral.
Example: local is_friendly = obj:isFriendly() - SpaceObject SpaceObject:setCommsScript(string script_name)
- Sets the communications script used when this object is hailed.
Accepts the filename of a Lua script as a string, or can be set to an
empty string to disable comms with this object.
In the script, `comms_source` (or `player`, deprecated) (PlayerSpaceship)
and `comms_target` (SpaceObject) are available.
Compare `setCommsFunction`.
Examples:
obj:setCommsScript("")
obj:setCommsScript("comms_custom_script.lua")
Defaults:
"comms_station.lua" (in `spaceStation.cpp`)
"comms_ship.lua" (in `cpuShip.cpp`)
Call `setCommsMessage` once and `addCommsReply` zero or more times in each dialogue.
Returns the object it was called on. - SpaceObject SpaceObject:setCommsFunction(ScriptSimpleCallback callback)
- Defines a callback function to use when handling hails, in lieu of any
current or default comms script.
For a detailed example, see scenario_53_escape.lua.
Requires a function to call back to when hailed.
The globals `comms_source` (PlayerSpaceship)
and `comms_target` (SpaceObject) are made available in the scenario script.
(Note: They remain as globals. As usual, such globals are not accessible in required files.)
Compare `setCommsScript`.
Example: obj:setCommsFunction(commsStation)
where commsStation is a function
calling `setCommsMessage` once and `addCommsReply` zero or more times.
Instead of using the globals, the callback can take two parameters.
Example: obj:setCommsFunction(function(comms_source, comms_target) ... end)
Returns the object it was called on. - SpaceObject SpaceObject:setCallSign(string new_callsign)
- Set this object's callsign. Objects are assigned random callsigns at
creation; this function overrides that default.
Requires a string value.
Example: obj:setCallSign("Epsilon")
Returns the object it was called on. - boolean SpaceObject:sendCommsMessage(PlayerSpaceship target, string message)
- Hails a PlayerSpaceship from this object. The players' comms station is
notified and can accept or deny the hail. If the hail is answered, the
specified message is displayed to the player.
Returns true when the hail is accepted.
Returns false when the target player cannot be hailed right now, for
example because it's already communicating with something else.
A message will be logged in the comms log about this.
Requires a target option and message. The message can be an empty
string.
Example: obj:sendCommsMessage(player, "Prepare to die") - boolean SpaceObject:sendCommsMessageNoLog(PlayerSpaceship target, string message)
- Hails a PlayerSpaceship from this object. The players' comms station is
notified and can accept or deny the hail. If the hail is answered, the
specified message is displayed to the player.
Returns true when the hail is accepted.
Returns false when the target player cannot be hailed right now, for
example because it's already communicating with something else.
Requires a target option and message. The message can be an empty
string.
Example: obj:sendCommsMessageNoLog(player, "Prepare to die") - boolean SpaceObject:openCommsTo(PlayerSpaceship target)
- As sendCommsMessage, but sends an empty string as the message. This will call the object's comms function.
Example: obj:openCommsTo(player) - string SpaceObject:getCallSign()
- Gets this object's callsign.
Returns a string.
Example: local callsign = obj:getCallSign() - boolean SpaceObject:areEnemiesInRange(number range)
- Gets whether any objects from a hostile faction are within a specific
radius of this object, in meters.
Requires a numeric value for the radius.
Returns true if hostiles are in range.
Example: obj:areEnemiesInRange(5000) - SpaceObject[] SpaceObject:getObjectsInRange(number range)
- Gets any objects within a specific radius of this object, in meters.
Requires a numeric value for the radius.
Returns a list of SpaceObjects within range.
Example: for _, obj_in_range in ipairs(obj:getObjectsInRange(5000)) ... - SpaceObject SpaceObject:setReputationPoints(number amount)
- Sets this object's faction reputation to the specified amount.
Requires a numeric value.
Example: obj:setReputationPoints(1000)
Returns the object it was called on. - boolean SpaceObject:takeReputationPoints(number amount)
- Deduct a specified amount of faction reputation points from this object.
Requires a numeric value.
Returns true if there are enough points to deduct the specified amount.
Returns false if there are not enough points, and does not deduct any.
Example: local took_reputation = obj:takeReputationPoints(1000) - SpaceObject SpaceObject:addReputationPoints(number amount)
- Adds a specified amount of faction reputation points to this object.
Requires a numeric value.
Example: obj:addReputationPoints(1000)
Returns the object it was called on. - string SpaceObject:getSectorName()
- Gets the name of the map sector, such as "A4", where this object is
located.
Returns a string value.
Example: obj:getSectorName() - number SpaceObject:getReputationPoints()
- Gets this object's current faction reputation points.
Returns an integer value.
Example: local reputation = obj:getReputationPoints(); - SpaceObject SpaceObject:takeDamage(number damage_amount, DamageInfo info)
- Deals a specific amount of a specific type of damage to this object.
Requires a numeric value for the damage amount, and accepts an optional
DamageInfo type.
The DamageInfo parameter can be empty, or a string that indicates
whether to deal the default "energy" damage, "kinetic" damage, or "emp"
damage, and can optionally be followed by the location of the damage's
origin (for instance, to damage the correct shield on ships).
SpaceObjects by default do not implement damage, instead leaving it to
be overridden by specialized subclasses.
Examples:
amount, type, x, y
obj:takeDamage(20, "emp", 1000, 0)
obj:takeDamage(20)
Returns the object it was called on. - SpaceObject SpaceObject:setDescriptions(string unscanned_description, string scanned_description)
- Sets this object's description in unscanned and scanned states. These
descriptions are displayed when this object is targeted from a ship's
Science station.
Requires two string values, one for the descriptions when unscanned
and another for when it has been scanned.
Example:
obj:setDescriptions([[A refitted Atlantis X23...]], [[It's a trap!]])
Returns the object it was called on. - SpaceObject SpaceObject:setDescription(string description)
- As setDescriptions, but sets the same description for both unscanned
and scanned states.
Requires a string value.
Example: obj:setDescription([[A refitted Atlantis X23 for more ...]])
Returns the object it was called on. - SpaceObject SpaceObject:setDescriptionForScanState(EScannedState state, string description)
- Sets a description for a specific EScannedState. String equivalents for
EScannedState are defined in the convert<EScannedState> function of
src/spaceObjects/spaceObject.cpp.
Requires a string-equivalent EScannedState and a string description.
Example:
obj:setDescriptionForScanState("friendorfoeidentified", [[This...]])
Returns the object it was called on. - string SpaceObject:getDescription(EScannedState state)
- Gets this object's description.
Accepts an optional string-equivalent EScannedState.
Returns a string.
Examples:
obj:getDescription()
obj:getDescription("friendorfoeidentified") - SpaceObject SpaceObject:setRadarSignatureInfo(number grav, number elec, number bio)
- Sets this object's radar signature, which creates noise on the Science
station's raw radar signal ring.
Certain SpaceObject types might modify their signatures using this value
as a baseline. Default values also depend on the SpaceObject type.
Requires numeric values ranging from 0.0 to 1.0 for the gravitational,
electrical, and biological radar bands.
Example: obj:setRadarSignatureInfo(0.0, 0.5, 1.0)
Returns the object it was called on. - number SpaceObject:getRadarSignatureGravity()
- Gets this object's component values from its radar signature.
Returns a numeric value between 0.0 and 1.0; larger and negative values
are possible, but currently have no visual effect on the bands.
Examples:
local grav_band = obj:getRadarSignatureGravity()
local elec_band = obj:getRadarSignatureElectrical()
local bio_band = obj:getRadarSignatureBiological() - number SpaceObject:getRadarSignatureElectrical()
- number SpaceObject:getRadarSignatureBiological()
- SpaceObject SpaceObject:setScanningParameters(number complexity, number depth)
- Sets this object's scanning complexity (number of bars in the scanning
minigame) and depth (number of scanning minigames to complete).
Also clears the scanned state.
Requires two integer values.
Example: obj:setScanningParameters(2, 3)
Returns the object it was called on. - number SpaceObject:scanningComplexity(SpaceObject target)
- Gets the scanning complexity for the parameter object.
Requires a SpaceObject.
Returns an integer value.
Example: local scan_complexity = obj:scanningComplexity(obj) - number SpaceObject:scanningChannelDepth(SpaceObject target)
- Gets the scanning depth for the parameter object.
Requires a SpaceObject.
Returns an integer value.
Example: local scan_depth = obj:scanningChannelDepth(obj) - SpaceObject SpaceObject:setScanned(boolean scanned)
- Sets whether all factions consider this object as having been scanned.
Requires a boolean value. If false, all factions treat this object as
unscanned; if true, all factions treat this object as fully scanned.
Example: obj:setScanned(true)
Returns the object it was called on. - boolean SpaceObject:isScanned()
- [DEPRECATED]
Gets whether this object has been scanned.
Use isScannedBy or isScannedByFaction instead. - boolean SpaceObject:isScannedBy(SpaceObject obj)
- Gets whether the parameter object has successfully scanned this object.
Requires a SpaceObject.
Returns a boolean value.
Example: obj:isScannedBy(other) - SpaceObject SpaceObject:setScannedByFaction(string faction_name, boolean scanned)
- Sets whether a specific faction considers this object as having been
scanned.
Requires a faction name string value and a boolean value.
Example: obj:setScannedByFaction("Human Navy", false)
Returns the object it was called on. - boolean SpaceObject:isScannedByFaction(string faction)
- Gets whether the parameter faction has successfully scanned this object.
Requires a faction name string value.
Returns a boolean value.
Example: obj:isScannedByFaction("Human Navy") - SpaceObject SpaceObject:onDestroyed(ScriptSimpleCallback callback)
- Returns the object it was called on.
- boolean SpaceObject:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- SpaceObject SpaceObject:destroy()
- Removes this object from the game.
Returns the object it was called on. - SpaceObject:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end
Artifact
An artifact.
Can be used for mission scripting.
Subclass of:
SpaceObject- Artifact Artifact:setModel(string name)
- Set the 3D model used for this artifact.
Example: setModel("artifact6"), setModel("shield_generator"), setModel("ammo_box").
Check model_data.lua for all possible options.
Returns the object it was called on. - Artifact Artifact:explode()
- Have this object explode with a visual explosion. The Artifact is destroyed by this action.
Returns the object it was called on. - Artifact Artifact:allowPickup(boolean allow)
- Set if this artifact can be picked up or not. When it is picked up, this artifact will be destroyed.
Returns the object it was called on. - Artifact Artifact:onCollision(ScriptSimpleCallback callback)
- Set a function that will be called every tick when a SpaceObject is
colliding with the artifact.
Passes the artifact and colliding SpaceObject.
Example:
artifact:onCollision(function(artifact, collider) print("Collision occurred") end)
Returns the object it was called on. - Artifact Artifact:onPlayerCollision(ScriptSimpleCallback callback)
- Set a function that will be called every tick when a PlayerSpaceship is
colliding with the artifact.
Passes the artifact and colliding PlayerSpaceship.
Example:
artifact:onCollision(function(artifact, player) print("Collision occurred") end)
Returns the object it was called on. - Artifact Artifact:onPickUp(ScriptSimpleCallback callback)
- Set a function that will be called once when a PlayerSpaceship collides
with the artifact while allowPickup is enabled. The artifact is
subsequently destroyed.
Passes the artifact and colliding PlayerSpaceship.
Example:
artifact:onPickUp(function(artifact, player) print("Artifact retrieved") end)
Returns the object it was called on. - Artifact Artifact:onPickup(ScriptSimpleCallback callback)
- Alias of onPickUp.
Returns the object it was called on. - Artifact Artifact:setSpin(number spin=0.0)
- Let the artifact rotate. For reference, normal asteroids in the game have spins between 0.1 and 0.8.
Returns the object it was called on. - Artifact Artifact:setRadarTraceIcon(string icon)
- Set the icon to be used for this artifact on the radar.
For example, artifact:setRadarTraceIcon("arrow.png") will show an arrow instead of a dot for this artifact.
Returns the object it was called on. - Artifact Artifact:setRadarTraceScale(number scale)
- Scales the radar trace. Setting to 0 restores to standard autoscaling.
Setting to 1 is needed for mimicking ship traces.
Returns the object it was called on. - Artifact Artifact:setRadarTraceColor(number r, number g, number b)
- Sets the color of the radar trace.
Example: 255,200,100 for mimicking asteroids.
Returns the object it was called on.
Asteroid
An asteroid in space. Which you can fly into and hit. Will do damage.
Subclass of:
SpaceObject- Asteroid Asteroid:setSize(number size)
- Set the radius of this asteroid
The default radius for an asteroid is between 110 and 130
Example: Asteroid():setSize(50)
Returns the object it was called on. - number Asteroid:getSize()
- Gets the current radius of this asteroid
Example: local size=Asteroid():getSize()
BeamEffect
BeamEffect is a beam weapon fire effect that will fade after 1 seond
Example: BeamEffect():setSource(player, 0, 0, 0):setTarget(enemy_ship, 0, 0)
Subclass of:
SpaceObject- BeamEffect BeamEffect:setSource(SpaceObject source, number offset_x, number offset_y, number offset_z)
- Returns the object it was called on.
- BeamEffect BeamEffect:setTarget(SpaceObject target, number hitLocation_x, number hitLocation_y)
- Returns the object it was called on.
- BeamEffect BeamEffect:setTexture(string texture)
- Returns the object it was called on.
- BeamEffect BeamEffect:setBeamFireSound(string sound)
- Returns the object it was called on.
- BeamEffect BeamEffect:setBeamFireSoundPower(number power)
- Returns the object it was called on.
- BeamEffect BeamEffect:setDuration(number duration)
- Returns the object it was called on.
- BeamEffect BeamEffect:setRing(boolean ring)
- Returns the object it was called on.
BlackHole
A blackhole has a 5km radius where it pulls in all near objects. At the center of the black hole everything gets a lot of damage.
Which will lead to the eventual destruction of said object.
Subclass of:
SpaceObject
ElectricExplosionEffect
ElectricExplosionEffect is a visible electrical explosion, as seen from EMP missiles
Example: ElectricExplosionEffect():setPosition(500,5000):setSize(20)
Subclass of:
SpaceObject- ElectricExplosionEffect ElectricExplosionEffect:setSize(number size)
- Returns the object it was called on.
- ElectricExplosionEffect ElectricExplosionEffect:setOnRadar(boolean on_radar)
- Returns the object it was called on.
ExplosionEffect
ExplosionEffect is a visible explosion, like from nukes, missiles, ship destruction, etc
Example: ExplosionEffect():setPosition(500,5000):setSize(20)
Subclass of:
SpaceObject- ExplosionEffect ExplosionEffect:setSize(number size)
- Returns the object it was called on.
- ExplosionEffect ExplosionEffect:setOnRadar(boolean on_radar)
- Returns the object it was called on.
MissileWeapon
Base class for every missile (mines are not missiles)
You cannot create a missile in script with this class, use derived classes
like HomingMissile, HVLI etc.
Subclass of:
SpaceObject- SpaceObject MissileWeapon:getOwner()
- Get the missile's owner's object.
- SpaceObject MissileWeapon:getTarget()
- Get the missile's target object.
- MissileWeapon MissileWeapon:setTarget(SpaceObject target)
- Must be an existing target, else does nothing. It does not check if really targetable or not.
Returns the object it was called on. - number MissileWeapon:getLifetime()
- Lifetime is a number in seconds
- MissileWeapon MissileWeapon:setLifetime(number lifetime)
- Lifetime is a number in seconds
Returns the object it was called on. - EMissileSizes MissileWeapon:getMissileSize()
- Set the missile size as for tube size.
Valid sizes: see EMissileSizes - MissileWeapon MissileWeapon:setMissileSize(EMissileSizes missile_size)
- Get the missile size as for tube size.
Valid sizes: see EMissileSizes
Returns the object it was called on.
Nebula
Nebulae block long-range radar in a 5U range.
Subclass of:
SpaceObject
Planet
A planet.
Subclass of:
SpaceObject- Planet Planet:setPlanetAtmosphereColor(number r, number g, number b)
- Returns the object it was called on.
- Planet Planet:setPlanetAtmosphereTexture(string texture_name)
- Returns the object it was called on.
- Planet Planet:setPlanetSurfaceTexture(string texture_name)
- Returns the object it was called on.
- Planet Planet:setPlanetCloudTexture(string texture_name)
- Returns the object it was called on.
- number Planet:getPlanetRadius()
- Planet Planet:setPlanetRadius(number size)
- Returns the object it was called on.
- number Planet:getCollisionSize()
- Planet Planet:setPlanetCloudRadius(number size)
- Returns the object it was called on.
- Planet Planet:setDistanceFromMovementPlane(number distance_from_movement_plane)
- Returns the object it was called on.
- Planet Planet:setAxialRotationTime(number time)
- Returns the object it was called on.
- Planet Planet:setOrbit(SpaceObject target, number orbit_time)
- Returns the object it was called on.
ScanProbe
A scan probe.
Subclass of:
SpaceObject- ScanProbe ScanProbe:setSpeed(number probe_speed)
- Set the probe's speed. A value of 1000 = 1U/second.
Probes move at a fixed rate of speed and ignore physics.
Requires a float value. The default vaule is 1000.
Example: probe:setSpeed(2000)
Returns the object it was called on. - number ScanProbe:getSpeed()
- Get the probe's speed. A value of 1000 = 1U/second.
Returns a float value.
Example: local speed = probe:getSpeed() - ScanProbe ScanProbe:setLifetime(number lifetime)
- Set the probe's remaining lifetime, in seconds.
The default initial lifetime is 10 minutes.
Example: probe:setLifetime(60 * 5)
Returns the object it was called on. - number ScanProbe:getLifetime()
- Get the probe's remaining lifetime.
Example: local lifetime = probe:getLifetime() - ScanProbe ScanProbe:setTarget(number target_x, number target_y)
- Set the probe's target coordinates.
Example: probe:setTarget(1000, 5000)
Returns the object it was called on. - number x, number y ScanProbe:getTarget()
- Get the probe's target coordinates.
Example: local targetX, targetY = probe:getTarget() - ScanProbe ScanProbe:setOwner(SpaceObject owner)
- Set the probe's owner SpaceObject.
Requires a SpaceObject.
Example: probe:setOwner(owner_ship)
Returns the object it was called on. - SpaceObject ScanProbe:getOwner()
- Get the probe's owner SpaceObject.
Example: local owner_ship = probe:getOwner() - ScanProbe ScanProbe:onArrival(ScriptSimpleCallback callback)
- Callback when the probe arrives to its target coordinates.
Passes the probe and position as arguments to the callback.
Example: probe:onArrival(probeArrived)
Returns the object it was called on. - ScanProbe ScanProbe:onExpiration(ScriptSimpleCallback callback)
- Callback when the probe's lifetime expires.
Passes the probe as an argument to the callback.
Example: probe:onExpiration(probeExpired)
Returns the object it was called on. - ScanProbe ScanProbe:onDestruction(ScriptSimpleCallback callback)
- Callback when the probe is destroyed by damage.
Passes the probe and instigator as arguments to the callback.
Example: probe:onDestruction(probeDestroyed)
Returns the object it was called on.
ShipTemplateBasedObject
Subclass of:
SpaceObject- ShipTemplateBasedObject ShipTemplateBasedObject:setTemplate(string template_name)
- Set the template to be used for this ship or station. Templates define hull/shields/looks etc.
Examples:
CpuShip():setTemplate("Phobos T3")
PlayerSpaceship():setTemplate("Phobos M3P")
SpaceStation():setTemplate("Large Station")
WARNING: Using a string that is not a valid template name lets the game crash! This is case-sensitive.
See `scripts/shipTemplates.lua` for the existing templates.
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setShipTemplate(string template_name)
- [Depricated]
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setTypeName(string type_name)
- Set the class name of this object. Normally the class name is copied from the template name (Ex "Cruiser") but you can override it with this function.
Returns the object it was called on. - string ShipTemplateBasedObject:getTypeName()
- number ShipTemplateBasedObject:getHull()
- Get the current amount of hull
- number ShipTemplateBasedObject:getHullMax()
- Get the maximum hull value
- ShipTemplateBasedObject ShipTemplateBasedObject:setHull(number amount)
- Set the current hull value, note that setting this to 0 does not destroy the station.
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setHullMax(number amount)
- Set the maximum amount of hull for this station. Stations never repair hull damage, so this only effects the percentage displays
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setCanBeDestroyed(boolean enabled)
- Set whether the object can be destroyed.
Requires a Boolean value.
Example: ship:setCanBeDestroyed(true)
Returns the object it was called on. - boolean ShipTemplateBasedObject:getCanBeDestroyed()
- Get whether the object can be destroyed.
Returns a Boolean value.
Example: ship:getCanBeDestroyed() - number ShipTemplateBasedObject:getShieldLevel(number index)
- Get the specified shield's current level.
Requires an integer index value.
Returns a float value.
Example to get shield level on front shields of a ship with two shields:
ship:getShieldLevel(0)
Rear shields: ship:getShieldLevel(1) - number ShipTemplateBasedObject:getShieldCount()
- Get the number of shields on this object.
For example, a ship with 1 shield count has a single shield covering
all angles, a ship with 2 covers front and back, etc.
Returns an integer count.
Example: ship:getShieldCount() - number ShipTemplateBasedObject:getShieldMax(number index)
- Get the maxium shield level.
- ShipTemplateBasedObject ShipTemplateBasedObject:setShields(number amounts...)
- Set the current amount of shields.
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setShieldsMax(number amounts...)
- Set the maximum shield level, amount of parameters defines the amount of shields. (Up to a maximum of 8 shields). Note that this does low the current shield level when the max becomes lower, but it does not increase the shield level.
A seperate call to setShield is needed for that.
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setRadarTrace(string trace)
- Set the icon to be used for this object on the radar.
For example, station:setRadarTrace("arrow.png") will show an arrow instead of a dot for this station.
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setImpulseSoundFile(string sound)
- Set the sound file to be used for this object's impulse engines.
Requires a string for a filename relative to the resources path.
Example: setImpulseSoundFile("engine.wav")
Returns the object it was called on. - boolean ShipTemplateBasedObject:getShieldsActive()
- Are the shields online or not. Currently always returns true except for player ships, as only players can turn off shields.
- boolean ShipTemplateBasedObject:getSharesEnergyWithDocked()
- ShipTemplateBasedObject ShipTemplateBasedObject:setSharesEnergyWithDocked(boolean enabled)
- Returns the object it was called on.
- boolean ShipTemplateBasedObject:getRepairDocked()
- ShipTemplateBasedObject ShipTemplateBasedObject:setRepairDocked(boolean enabled)
- Returns the object it was called on.
- boolean ShipTemplateBasedObject:getRestocksScanProbes()
- ShipTemplateBasedObject ShipTemplateBasedObject:setRestocksScanProbes(boolean enabled)
- Returns the object it was called on.
- boolean ShipTemplateBasedObject:getRestocksMissilesDocked()
- ShipTemplateBasedObject ShipTemplateBasedObject:setRestocksMissilesDocked(boolean enabled)
- Returns the object it was called on.
- number ShipTemplateBasedObject:getLongRangeRadarRange()
- number ShipTemplateBasedObject:getShortRangeRadarRange()
- ShipTemplateBasedObject ShipTemplateBasedObject:setLongRangeRadarRange(number range)
- Returns the object it was called on.
- ShipTemplateBasedObject ShipTemplateBasedObject:setShortRangeRadarRange(number range)
- Returns the object it was called on.
- number ShipTemplateBasedObject:getFrontShield()
- [Depricated]
- number ShipTemplateBasedObject:getFrontShieldMax()
- [Depricated]
- ShipTemplateBasedObject ShipTemplateBasedObject:setFrontShield(number amount)
- [Depricated]
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setFrontShieldMax(number amount)
- [Depricated]
Returns the object it was called on. - number ShipTemplateBasedObject:getRearShield()
- [Depricated]
- number ShipTemplateBasedObject:getRearShieldMax()
- [Depricated]
- ShipTemplateBasedObject ShipTemplateBasedObject:setRearShield(number amount)
- [Depricated]
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:setRearShieldMax(number amount)
- [Depricated]
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:onTakingDamage(ScriptSimpleCallback callback)
- Set a function that will be called if the object is taking damage.
First argument given to the function will be the object taking damage, the second the instigator SpaceObject (or nil).
Returns the object it was called on. - ShipTemplateBasedObject ShipTemplateBasedObject:onDestruction(ScriptSimpleCallback callback)
- Set a function that will be called if the object is destroyed by taking damage.
First argument given to the function will be the object taking damage, the second the instigator SpaceObject that gave the final blow (or nil).
Returns the object it was called on.
SpaceShip
Subclass of:
ShipTemplateBasedObject- boolean SpaceShip:isFriendOrFoeIdentified()
- [DEPRECATED]
- boolean SpaceShip:isFullyScanned()
- [DEPRECATED]
- boolean SpaceShip:isFriendOrFoeIdentifiedBy(SpaceObject other)
- boolean SpaceShip:isFullyScannedBy(SpaceObject other)
- boolean SpaceShip:isFriendOrFoeIdentifiedByFaction(number faction_id)
- boolean SpaceShip:isFullyScannedByFaction(number faction_id)
- boolean SpaceShip:isDocked(SpaceObject target)
- SpaceObject SpaceShip:getDockedWith()
- EDockingState SpaceShip:getDockingState()
- SpaceObject SpaceShip:getTarget()
- Returns gets this ship target.
For example enemy targetted by player ship's weapons. - number SpaceShip:getWeaponStorage(EMissileWeapons weapon)
- number SpaceShip:getWeaponStorageMax(EMissileWeapons weapon)
- SpaceShip SpaceShip:setWeaponStorage(EMissileWeapons weapon, number amount)
- Returns the object it was called on.
- SpaceShip SpaceShip:setWeaponStorageMax(EMissileWeapons weapon, number amount)
- Returns the object it was called on.
- number SpaceShip:getShieldsFrequency()
- SpaceShip SpaceShip:setShieldsFrequency(number freq)
- Returns the object it was called on.
- number SpaceShip:getBeamFrequency()
- number SpaceShip:getMaxEnergy()
- SpaceShip SpaceShip:setMaxEnergy(number amount)
- Returns the object it was called on.
- number SpaceShip:getEnergy()
- SpaceShip SpaceShip:setEnergy(number amount)
- Returns the object it was called on.
- boolean SpaceShip:hasSystem(ESystem system)
- number SpaceShip:getSystemHackedLevel(ESystem system)
- SpaceShip SpaceShip:setSystemHackedLevel(ESystem system, number hacked_level)
- Returns the object it was called on.
- number SpaceShip:getSystemHealth(ESystem system)
- SpaceShip SpaceShip:setSystemHealth(ESystem system, number health)
- Returns the object it was called on.
- number SpaceShip:getSystemHealthMax(ESystem system)
- SpaceShip SpaceShip:setSystemHealthMax(ESystem system, number health_max)
- Returns the object it was called on.
- number SpaceShip:getSystemHeat(ESystem system)
- SpaceShip SpaceShip:setSystemHeat(ESystem system, number heat)
- Returns the object it was called on.
- number SpaceShip:getSystemHeatRate(ESystem system)
- SpaceShip SpaceShip:setSystemHeatRate(ESystem system, number rate)
- Returns the object it was called on.
- number SpaceShip:getSystemPower(ESystem system)
- SpaceShip SpaceShip:setSystemPower(ESystem system, number power)
- Returns the object it was called on.
- number SpaceShip:getSystemPowerRate(ESystem system)
- SpaceShip SpaceShip:setSystemPowerRate(ESystem system, number rate)
- Returns the object it was called on.
- number SpaceShip:getSystemPowerFactor(ESystem system)
- SpaceShip SpaceShip:setSystemPowerFactor(ESystem system, number factor)
- Returns the object it was called on.
- number SpaceShip:getSystemCoolant(ESystem system)
- SpaceShip SpaceShip:setSystemCoolant(ESystem system, number coolant)
- Returns the object it was called on.
- number SpaceShip:getSystemCoolantRate(ESystem system)
- SpaceShip SpaceShip:setSystemCoolantRate(ESystem system, number rate)
- Returns the object it was called on.
- Speeds SpaceShip:getImpulseMaxSpeed()
- Get multiple results, first one is forward speed and second one is reverse speed.
ex : forward,reverse = getImpulseMaxSpeed() (you can also use select or _ to get only reverse speed)
You can also only get forward speed, reverse speed will just be discarded :
forward = getImpulseMaxSpeed() - SpaceShip SpaceShip:setImpulseMaxSpeed(number forward_speed, number reverse_speed=nil)
- Sets max speed.
If called with only one argument, sets forward and reverse speed to equal values.
If called with two arguments, first one is forward speed and second one is reverse speed.
Returns the object it was called on. - number SpaceShip:getRotationMaxSpeed()
- SpaceShip SpaceShip:setRotationMaxSpeed(number speed)
- Returns the object it was called on.
- Speeds SpaceShip:getAcceleration()
- Get multiple resulsts, first one is forward acceleration and second one is reverse acceleration.
ex : forward, reverse = getAcceleration (you can also use select or _ to get only reverse speed)
You can also only get forward speed, reverse speed will just be discarded :
forward = getAcceleration() - SpaceShip SpaceShip:setAcceleration(number acceleration, number reverse_acceleration=nil)
- Sets acceleration.
If called with one argument, sets forward and reverse acceleration to equal values.
If called with two arguments, first one is forward acceleration and second one is reverse acceleration.
Returns the object it was called on. - SpaceShip SpaceShip:setCombatManeuver(number boost, number strafe)
- Returns the object it was called on.
- boolean SpaceShip:hasJumpDrive()
- SpaceShip SpaceShip:setJumpDrive(boolean has_jump)
- Returns the object it was called on.
- SpaceShip SpaceShip:setJumpDriveRange(number min, number max)
- Returns the object it was called on.
- SpaceShip SpaceShip:setJumpDriveCharge(number charge)
- sets the current jump range charged.
ships will be able to jump when this is equal to their max jump drive range.
Example ship:setJumpDriveCharge(50000)
Returns the object it was called on. - number SpaceShip:getJumpDriveCharge()
- returns the current amount of jump charged.
Example ship:getJumpDriveCharge() - number SpaceShip:getJumpDelay()
- boolean SpaceShip:hasWarpDrive()
- SpaceShip SpaceShip:setWarpDrive(boolean has_warp)
- Returns the object it was called on.
- SpaceShip SpaceShip:setWarpSpeed(number speed)
- Set the warp speed for this ship's warp level 1.
Setting this is equivalent to also setting setWarpDrive(true).
If a value isn't specified in the ship template, the default is 1000.
Requires a numeric value.
Example: ship:setWarpSpeed(500);
Returns the object it was called on. - number SpaceShip:getWarpSpeed()
- number SpaceShip:getBeamWeaponArc(number index)
- number SpaceShip:getBeamWeaponDirection(number index)
- number SpaceShip:getBeamWeaponRange(number index)
- number SpaceShip:getBeamWeaponTurretArc(number index)
- number SpaceShip:getBeamWeaponTurretDirection(number index)
- number SpaceShip:getBeamWeaponCycleTime(number index)
- number SpaceShip:getBeamWeaponDamage(number index)
- number SpaceShip:getBeamWeaponEnergyPerFire(number index)
- number SpaceShip:getBeamWeaponHeatPerFire(number index)
- SpaceShip SpaceShip:setBeamWeapon(number index, number arc, number direction, number range, number cycle_time, number damage)
- Returns the object it was called on.
- SpaceShip SpaceShip:setBeamWeaponTurret(number index, number arc, number direction, number rotation_rate)
- Returns the object it was called on.
- SpaceShip SpaceShip:setBeamWeaponTexture(number index, string texture)
- Returns the object it was called on.
- SpaceShip SpaceShip:setBeamWeaponEnergyPerFire(number index, number energy)
- Returns the object it was called on.
- SpaceShip SpaceShip:setBeamWeaponHeatPerFire(number index, number heat)
- Returns the object it was called on.
- SpaceShip SpaceShip:setBeamWeaponArcColor(number index, number r, number g, number b, number fire_r, number fire_g, number fire_b)
- Returns the object it was called on.
- SpaceShip SpaceShip:setBeamWeaponDamageType(number index, EDamageType type)
- Returns the object it was called on.
- SpaceShip SpaceShip:setWeaponTubeCount(number amount)
- Returns the object it was called on.
- number SpaceShip:getWeaponTubeCount()
- EMissileWeapons SpaceShip:getWeaponTubeLoadType(number index)
- SpaceShip SpaceShip:weaponTubeAllowMissle(number index, EMissileWeapons type)
- Returns the object it was called on.
- SpaceShip SpaceShip:weaponTubeDisallowMissle(number index, EMissileWeapons type)
- Returns the object it was called on.
- SpaceShip SpaceShip:setWeaponTubeExclusiveFor(number index, EMissileWeapons type)
- Returns the object it was called on.
- SpaceShip SpaceShip:setWeaponTubeDirection(number index, number direction)
- Returns the object it was called on.
- SpaceShip SpaceShip:setTubeSize(number index, EMissileSizes size)
- Set the tube size
Example: ship:setTubeSize(0,"small")
Valid Sizes: "small" "medium" "large"
Returns the object it was called on. - EMissileSizes SpaceShip:getTubeSize(number index)
- Returns the size of the tube
Example: local size = ship:getTubeSize(0) - number SpaceShip:getTubeLoadTime(number index)
- SpaceShip SpaceShip:setTubeLoadTime(number index, number time)
- Returns the object it was called on.
- SpaceShip SpaceShip:setRadarTrace(string trace)
- Set the icon to be used for this ship on the radar.
For example, ship:setRadarTrace("blip.png") will show a dot instead of an arrow for this ship.
Note: Icon is only shown after scanning, before the ship is scanned it is always shown as an arrow.
Returns the object it was called on. - number SpaceShip:getDynamicRadarSignatureGravity()
- Get the dynamic radar signature values for each component band.
Returns a float.
Example: obj:getDynamicRadarSignatureGravity() - number SpaceShip:getDynamicRadarSignatureElectrical()
- number SpaceShip:getDynamicRadarSignatureBiological()
- SpaceShip SpaceShip:addBroadcast(number threshold, string message)
- Returns the object it was called on.
- SpaceShip SpaceShip:setScanState(EScannedState scanned)
- Set the scan state of this ship for every faction.
Returns the object it was called on. - SpaceShip SpaceShip:setScanStateByFaction(string faction_name, EScannedState scanned)
- Set the scane state of this ship for a particular faction.
Returns the object it was called on.
CpuShip
CpuShips are AI controlled ships.
They can get different orders.
Example: CpuShip():setTemplate("Fighter"):setPosition(random(-10000, 10000), random(0, 3000)):setFaction("Human Navy"):orderRoaming():setScanned(true)
Subclass of:
SpaceShip- CpuShip CpuShip:setAI(string new_ai)
- Switch the AI to a different state. AI state can be set per ship,
defined in the shipTemplate, or left to "default". AI state is distinct
from orders, and determines the AI's tactics and responses in combat.
Valid values are "default", "missileVolley", "fighter", and "evasion".
"missileVolley" prefers lining up missile attacks from long range.
"fighter" prefers attacking at close range with strafing maneuvers.
"evasion" maintains distance from enemy weapons and evades attacks.
Example: enemy:setAI("fighter")
Returns the object it was called on. - CpuShip CpuShip:orderIdle()
- Order this ship to hold the current position. Do nothing; don't attack.
Orders are distinct from AI state, and determines what the ship's
current objectives.
Example: enemy:orderIdle()
Returns the object it was called on. - CpuShip CpuShip:orderRoaming()
- Order this ship to roam and engage at will, without a specific target.
Example: enemy:orderRoaming()
Returns the object it was called on. - CpuShip CpuShip:orderRetreat(SpaceObject object)
- Order this ship to dock at [order_target] to re-stock missiles and
repair its hull. If neccessary, roam to locate a dockable target.
Continue roaming after repairs and re-stocking, or if no dockable
target is found.
Requires a target ShipTemplateBasedObject that supports docking.
Example: enemy:orderRetreat(spaceStation)
Returns the object it was called on. - CpuShip CpuShip:orderStandGround()
- Order this ship to hold the current position. Do not retreat, and
attack nearby targets.
Example: enemy:orderStandGround()
Returns the object it was called on. - CpuShip CpuShip:orderDefendLocation(number position_x, number position_y)
- Order this ship to defend [order_target_location] against enemies that
get too close.
Requires x,y coordinates to defend.
Example: enemy:orderDefendLocation(500, 1000)
Returns the object it was called on. - CpuShip CpuShip:orderDefendTarget(SpaceObject object)
- Order this ship to defend [order_target] against enemies that get too
close. Default to AI_Roaming if the defense target is destroyed.
Requires a SpaceObject to defend.
Example: enemy:orderDefendTarget(enemy2)
Returns the object it was called on. - CpuShip CpuShip:orderFlyFormation(SpaceObject object, number offset_x, number offset_y)
- Order this ship to follow [order_target] from a specified distance, and
to use [order_target]'s target if one is selected.
Requires a SpaceObject to serve as the formation's flight leader, and a
float value for the offset distance to maintain.
Example: enemy:orderFlyFormation(enemy2, 500)
Returns the object it was called on. - CpuShip CpuShip:orderFlyTowards(number target_x, number target_y)
- Order this ship to move towards [order_target_location] and attack
enemies that get too close during transit. Disengage from combat and
continue towards the destination if enemies are too distant.
Requires x,y coordinates to move towards.
Example: enemy:orderFlyTowards(500, 1000)
Returns the object it was called on. - CpuShip CpuShip:orderFlyTowardsBlind(number target_x, number target_y)
- Order this ship to move towards [order_target_location] while ignoring
all enemies. Don't attack.
Requires x,y coordinates to move towards.
Example: enemy:orderFlyTowardsBlind(500, 1000)
Returns the object it was called on. - CpuShip CpuShip:orderAttack(SpaceObject object)
- Order this ship to attack the specified [order_target].
Requires a SpaceObject to attack.
Example: enemy:orderAttack(player)
Returns the object it was called on. - CpuShip CpuShip:orderDock(SpaceObject object)
- Order this ship to dock with the specified target, if possible.
Requires a dockable SpaceObject to dock with.
Example: enemy:orderDock(spaceStation)
Returns the object it was called on. - EAIOrder CpuShip:getOrder()
- Get this ship's current orders.
Returns a string representation of the ship's current EAIOrder value.
Example: local ship_orders = enemy:getOrder() - number x, number y CpuShip:getOrderTargetLocation()
- Get the target location of this ship's current orders.
Returns the targeted x,y coordinates, or 0,0 if not defined.
Example: local x, y = enemy:getOrderTargetLocation() - SpaceObject CpuShip:getOrderTarget()
- Get the target SpaceObject of this ship's current orders.
Returns the targeted SpaceObject.
Example: local target = enemy:getOrderTarget()
PlayerSpaceship
Subclass of:
SpaceShip- number x, number y PlayerSpaceship:getWaypoint(number index)
- Returns the sf::Vector2f of a specific waypoint set by this ship.
Takes the index of the waypoint as its parameter. - number PlayerSpaceship:getWaypointCount()
- Returns the total number of this ship's active waypoints.
- EAlertLevel PlayerSpaceship:getAlertLevel()
- Returns the ship's EAlertLevel.
- PlayerSpaceship PlayerSpaceship:setShieldsActive(boolean active)
- Sets whether this ship's shields are raised or lowered.
Takes a Boolean value.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:addToShipLog(string message, Color color)
- Adds a message to the ship's log. Takes a string as the message and a
color.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:transferPlayersToShip(PlayerSpaceship other_ship)
- Move all players connected to this ship to the same stations on a
different PlayerSpaceship. If the target isn't a PlayerSpaceship, this
function does nothing.
This can be used in scenarios to change the crew's ship.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:transferPlayersAtPositionToShip(ECrewPosition position, PlayerSpaceship other_ship)
- Transfers only the crew members who fill a specific station to another
PlayerSpaceship.
Returns the object it was called on. - boolean PlayerSpaceship:hasPlayerAtPosition(ECrewPosition position)
- Returns true if a station is occupied by a player, and false if not.
- boolean PlayerSpaceship:isCommsInactive()
- boolean PlayerSpaceship:isCommsOpening()
- boolean PlayerSpaceship:isCommsBeingHailed()
- boolean PlayerSpaceship:isCommsBeingHailedByGM()
- boolean PlayerSpaceship:isCommsFailed()
- boolean PlayerSpaceship:isCommsBroken()
- boolean PlayerSpaceship:isCommsClosed()
- boolean PlayerSpaceship:isCommsChatOpen()
- boolean PlayerSpaceship:isCommsChatOpenToGM()
- boolean PlayerSpaceship:isCommsChatOpenToPlayer()
- boolean PlayerSpaceship:isCommsScriptOpen()
- PlayerSpaceship PlayerSpaceship:setEnergyLevel(number amount)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:setEnergyLevelMax(number amount)
- Returns the object it was called on.
- number PlayerSpaceship:getEnergyLevel()
- number PlayerSpaceship:getEnergyLevelMax()
- number PlayerSpaceship:getEnergyShieldUsePerSecond()
- PlayerSpaceship PlayerSpaceship:setEnergyShieldUsePerSecond(number rate)
- Returns the object it was called on.
- number PlayerSpaceship:getEnergyWarpPerSecond()
- PlayerSpaceship PlayerSpaceship:setEnergyWarpPerSecond(number rate)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:setMaxCoolant(number coolant)
- Set the maximum coolant available to engineering. Default is 10.
Returns the object it was called on. - number PlayerSpaceship:getMaxCoolant()
- PlayerSpaceship PlayerSpaceship:setScanProbeCount(number amount)
- Returns the object it was called on.
- number PlayerSpaceship:getScanProbeCount()
- PlayerSpaceship PlayerSpaceship:setMaxScanProbeCount(number amount)
- Returns the object it was called on.
- number PlayerSpaceship:getMaxScanProbeCount()
- PlayerSpaceship PlayerSpaceship:addCustomButton(ECrewPosition position, string name, string caption, ScriptSimpleCallback callback, number order=nil)
- add a custom Button to the according station. Use order to sort (shared with custom info).
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:addCustomInfo(ECrewPosition position, string name, string caption, number order=nil)
- add a custom Info Label to the according station. Use order to sort (shared with custom button).
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:addCustomMessage(ECrewPosition position, string name, string caption)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:addCustomMessageWithCallback(ECrewPosition position, string name, string caption, ScriptSimpleCallback callback)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:removeCustom(string name)
- Returns the object it was called on.
- ESystem PlayerSpaceship:getBeamSystemTarget()
- Gets what part (hull, shields,... ) will be targeted on enemy, returns index to ESystem, -1 is hull.
- string PlayerSpaceship:getBeamSystemTargetName()
- Gets the name (content of ESystem) of the target system, instead of the ID
- PlayerSpaceship PlayerSpaceship:commandTargetRotation(number target)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandImpulse(number target)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandWarp(number target)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandJump(number distance)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetTarget(SpaceObject target)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandLoadTube(number tubeNumber, EMissileWeapons missileType)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandUnloadTube(number tubeNumber)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandFireTube(number tubeNumber, number missile_target_angle)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandFireTubeAtTarget(number tubeNumber, SpaceObject target)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetShields(boolean enabled)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandMainScreenSetting(EMainScreenSetting mainScreen)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandMainScreenOverlay(EMainScreenOverlay mainScreen)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandScan(SpaceObject object)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetSystemPowerRequest(ESystem system, number power_level)
- Set power of the system to e.g. 1.5 ("150 percent")
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:commandSetSystemCoolantRequest(ESystem system, number coolant_level)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandDock(SpaceObject station)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandUndock()
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandAbortDock()
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandOpenTextComm(SpaceObject obj)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandCloseTextComm()
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandAnswerCommHail(boolean awnser)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSendComm(number index)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSendCommPlayer(string message)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetAutoRepair(boolean enabled)
- Command repair crews to automatically move to damaged subsystems.
is command on ships to require less player interaction, especially
when combined with setAutoCoolant/auto_coolant_enabled.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:commandSetBeamFrequency(number frequency)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetBeamSystemTarget(ESystem system)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetShieldFrequency(number frequency)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandAddWaypoint(number position_x, number position_y)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandRemoveWaypoint(number index)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandMoveWaypoint(number index, number position_x, number position_y)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandActivateSelfDestruct()
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandCancelSelfDestruct()
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandConfirmDestructCode(number index, number code)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandCombatManeuverBoost(number amount)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandLaunchProbe(number target_position_x, number target_position_y)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:commandSetScienceLink(ScanProbe probe)
- Command the science screen to link to the given ScanProbe object.
This is equivalent of selecting a probe on Relay and clicking
"Link to Science".
Example: player:commandSetScienceLink(probeObject)
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:commandClearScienceLink()
- Command the science screen to clear its link to any ScanProbe object.
This is equivalent to clicking "Link to Science" on Relay when a link
is already active.
Example: player:commandClearScienceLink()
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:commandSetAlertLevel(EAlertLevel level)
- Returns the object it was called on.
- number PlayerSpaceship:getRepairCrewCount()
- Return the number of Engineering repair crews on the ship.
- PlayerSpaceship PlayerSpaceship:setRepairCrewCount(number amount)
- Set the total number of Engineering repair crews. If this value is less
than the number of repair crews, this function removes repair crews.
If the value is greater, it adds new repair crews at random locations.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:setAutoCoolant(boolean active)
- Sets whether automatic coolant distribution is enabled. This sets the
amount of coolant proportionally to the amount of heat in that system.
Use this command on ships to require less player interaction, especially
when combined with commandSetAutoRepair/auto_repair_enabled.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:setControlCode(string code)
- Set a password to join the ship.
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:onProbeLaunch(ScriptSimpleCallback callback)
- Callback when this ship launches a probe.
Passes the launching PlayerSpaceship and launched ScanProbe.
Example:
player:onProbeLaunch(function (player, probe)
print("Probe " .. probe:getCallSign() .. " launched from ship " .. player:getCallSign())
end)
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:onProbeLink(ScriptSimpleCallback callback)
- Callback when this ship links a probe to the Science screen.
Passes the PlayerShip and linked ScanProbe.
Example:
player:onProbeLink(function (player, probe)
print("Probe " .. probe:getCallSign() .. " linked to Science on ship " .. player:getCallSign())
end)
Returns the object it was called on. - PlayerSpaceship PlayerSpaceship:onProbeUnlink(ScriptSimpleCallback callback)
- Callback when this ship unlinks a probe on the Science screen.
Passes the PlayerShip and previously linked ScanProbe.
Does _not_ fire when the probe is destroyed or expires;
see ScanProbe:onDestruction() and ScanProbe:onExpiration().
Example:
player:onProbeUnlink(function (player, probe)
print("Probe " .. probe:getCallSign() .. " unlinked from Science on ship " .. player:getCallSign())
end)
Returns the object it was called on. - number PlayerSpaceship:getLongRangeRadarRange()
- number PlayerSpaceship:getShortRangeRadarRange()
- PlayerSpaceship PlayerSpaceship:setLongRangeRadarRange(number range)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:setShortRangeRadarRange(number range)
- Returns the object it was called on.
- PlayerSpaceship PlayerSpaceship:setCanScan(boolean enabled)
- Set whether the object can scan other objects.
Requires a Boolean value.
Example: ship:setCanScan(true)
Returns the object it was called on. - boolean PlayerSpaceship:getCanScan()
- Get whether the object can scan other objects.
Returns a Boolean value.
Example: ship:getCanScan() - PlayerSpaceship PlayerSpaceship:setCanHack(boolean enabled)
- Set whether the object can hack other objects.
Requires a Boolean value.
Example: ship:setCanHack(true)
Returns the object it was called on. - boolean PlayerSpaceship:getCanHack()
- Get whether the object can hack other objects.
Returns a Boolean value.
Example: ship:getCanHack() - PlayerSpaceship PlayerSpaceship:setCanDock(boolean enabled)
- Set whether the object can dock with other objects.
Requires a Boolean value.
Example: ship:setCanDock(true)
Returns the object it was called on. - boolean PlayerSpaceship:getCanDock()
- Get whether the object can dock with other objects.
Returns a Boolean value.
Example: ship:getCanDock() - PlayerSpaceship PlayerSpaceship:setCanCombatManeuver(boolean enabled)
- Set whether the object can perform combat maneuvers.
Requires a Boolean value.
Example: ship:setCanCombatManeuver(true)
Returns the object it was called on. - boolean PlayerSpaceship:getCanCombatManeuver()
- Get whether the object can perform combat maneuvers.
Returns a Boolean value.
Example: ship:getCanCombatManeuver() - PlayerSpaceship PlayerSpaceship:setCanSelfDestruct(boolean enabled)
- Set whether the object can self destruct.
Requires a Boolean value.
Example: ship:setCanSelfDestruct(true)
Returns the object it was called on. - boolean PlayerSpaceship:getCanSelfDestruct()
- Get whether the object can self destruct.
This returns false if self destruct size and damage are both 0, even if
you set setCanSelfDestruct(true).
Returns a Boolean value.
Example: ship:getCanSelfDestruct() - PlayerSpaceship PlayerSpaceship:setCanLaunchProbe(boolean enabled)
- Set whether the object can launch probes.
Requires a Boolean value.
Example: ship:setCanLaunchProbe(true)
Returns the object it was called on. - boolean PlayerSpaceship:getCanLaunchProbe()
- Get whether the object can launch probes.
Returns a Boolean value.
Example: ship:getCanLaunchProbe() - PlayerSpaceship PlayerSpaceship:setSelfDestructDamage(number amount)
- Set the amount of damage done by self destruction.
Requires a float; the value used is randomized +/- 33%.
Example: ship:setSelfDestructDamage(150)
Returns the object it was called on. - number PlayerSpaceship:getSelfDestructDamage()
- Get the amount of damage done by self destruction.
Returns a float.
Example: ship:getSelfDestructDamage() - PlayerSpaceship PlayerSpaceship:setSelfDestructSize(number size)
- Set the size of the explosion created by self destruction.
Requires a float.
Example: ship:setSelfDestructSize(1500)
Returns the object it was called on. - number PlayerSpaceship:getSelfDestructSize()
- Get the size of the explosion created by self destruction.
Returns a float.
Example: ship:getSelfDestructSize()
SupplyDrop
A supply drop.
Subclass of:
SpaceObject- SupplyDrop SupplyDrop:setEnergy(number amount)
- Returns the object it was called on.
- SupplyDrop SupplyDrop:setWeaponStorage(EMissileWeapons weapon, number amount)
- Returns the object it was called on.
- SupplyDrop SupplyDrop:onPickUp(ScriptSimpleCallback callback)
- Set a function that will be called if a player picks up the supply drop.
First argument given to the function will be the supply drop, the second the player.
Returns the object it was called on.
VisualAsteroid
An asteroid in space. Outside of hit range, just for visuals.
Subclass of:
SpaceObject- VisualAsteroid VisualAsteroid:setSize(number size)
- Set the radius of this asteroid
The default radius for an VisualAsteroid is between 110 and 130
Example: VisualAsteroid():setSize(50)
Returns the object it was called on. - number VisualAsteroid:getSize()
- Gets the current radius of this asteroid
Example: local size=VisualAsteroid():getSize()
WarpJammer
A warp jammer.
Subclass of:
SpaceObject- number WarpJammer:getRange()
- Gets jamming range (circle with jammer in the middle inside which no warp/jump will be possible).
- WarpJammer WarpJammer:setRange(number range)
- Sets jamming range (circle with jammer in the middle inside which no warp/jump will be possible).
Returns the object it was called on. - number WarpJammer:getHull()
- Gets current hull of warpJammer.
- WarpJammer WarpJammer:setHull(number hull)
- Sets current hull of warpJammer.
Returns the object it was called on. - WarpJammer WarpJammer:onTakingDamage(ScriptSimpleCallback callback)
- Set a function that will be called if the warp jammer is taking damage.
First argument given to the function will be the warp jammer, the second the instigator SpaceObject (or nil).
Returns the object it was called on. - WarpJammer WarpJammer:onDestruction(ScriptSimpleCallback callback)
- Set a function that will be called if the warp jammer is destroyed by taking damage.
First argument given to the function will be the warp jammer, the second the instigator SpaceObject that gave the final blow (or nil).
Returns the object it was called on.
WormHole
A wormhole object that drags objects toward it like a black hole, and then
teleports them to another point when they reach its center.
Subclass of:
SpaceObject- WormHole WormHole:setTargetPosition(number v_x, number v_y)
- Set the target of this wormhole
Returns the object it was called on. - number x, number y WormHole:getTargetPosition()
- WormHole WormHole:onTeleportation(ScriptSimpleCallback callback)
- Set a function that will be called if a SpaceObject is teleported.
First argument given to the function will be the WormHole, the second the SpaceObject that has been teleported.
Returns the object it was called on.
Zone
A zone area
Subclass of:
SpaceObject- Zone Zone:setPoints(number points_x, number points_y...)
- Set corners of n-gon to x_1, y_1, x_2, y_2, ..., x_n, y_n.
Recall that x goes right and y goes down.
Example: zone = Zone():setPoints(2000, 0, 0, 3000, -2000, 0)
Returns the object it was called on. - Zone Zone:setColor(number r, number g, number b)
- Example: zone:setColor(255, 140, 0)
Returns the object it was called on. - Zone Zone:setLabel(string label)
- Returns the object it was called on.
- string Zone:getLabel()
- boolean Zone:isInside(SpaceObject obj)
TutorialGame
The TutorialGame object is normally never created.
And it only used to setup the special tutorial level.
It contains functions to assist in explaining the game, but do not work outside of the tutorial.
- TutorialGame TutorialGame:setPlayerShip(PlayerSpaceship ship)
- Returns the object it was called on.
- TutorialGame TutorialGame:switchViewToMainScreen()
- Returns the object it was called on.
- TutorialGame TutorialGame:switchViewToTactical()
- Returns the object it was called on.
- TutorialGame TutorialGame:switchViewToLongRange()
- Returns the object it was called on.
- TutorialGame TutorialGame:switchViewToScreen(number n)
- Returns the object it was called on.
- TutorialGame TutorialGame:showMessage(string message, boolean show_next)
- Returns the object it was called on.
- TutorialGame TutorialGame:setMessageToTopPosition()
- Returns the object it was called on.
- TutorialGame TutorialGame:setMessageToBottomPosition()
- Returns the object it was called on.
- TutorialGame TutorialGame:onNext(ScriptSimpleCallback callback)
- Returns the object it was called on.
- TutorialGame TutorialGame:finish()
- Returns the object it was called on.
- boolean TutorialGame:isValid()
- Check if this is still looking at a valid object. Returns false when the objects that this variable references is destroyed.
- TutorialGame TutorialGame:destroy()
- Removes this object from the game.
Returns the object it was called on. - TutorialGame:typeName
- Returns the class name of this object, this is not a function, but a direct member: if object.typeName == "Mine" then print("MINE!") end