Gamedev:UnitDefs: Difference between revisions
m →Data Types: note that y is up |
add tags up to energymake (inclusive) |
||
| Line 19: | Line 19: | ||
==Details== | ==Details== | ||
There follows a comprehensive list of the tags available, their data type, default value and a brief description of what they do. Bear in mind that the source code linked above is the ultimate reference when dealing with these tags. | There follows a comprehensive list of the tags available, their data type, default value and a brief description of what they do. Bear in mind that the source code linked above is the ultimate reference when dealing with these tags. In lua tables keys (i.e. the tags) should be lower case, here they are represented in camelCase for readability. In your files you may use the <code>lowerkeys</code> function on your final table to ensure the keys are properly cased. | ||
===General=== | ===General=== | ||
* '''<code>name</code>''' - type: <code>string</code> - default: <code>""</code> | |||
: This is simply the name of the unit as it appears to the player. | |||
* '''<code>description</code>''' - type: <code>string</code> - default: <code>name</code> | |||
: This is the tooltip description of the unit seen by the player. It defaults to the <code>name</code> of the unit. | |||
* '''<code>buildPic</code>''' - type: <code>string</code> - default: <code>""</code> | |||
: The filename of of the image to be used as the build picture. | |||
===Resources=== | ===Resources=== | ||
* '''<code>metalStorage</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the metal resource storage the unit contributes. | |||
* '''<code>energyStorage</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the energy resource storage the unit contributes. | |||
* '''<code>extractsMetal</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the metal resource the unit extracts from the ground. The amount extracted depends on the metal map defined in the map itself. Works only for structures. | |||
* '''<code>windGenerator</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures. | |||
* '''<code>tidalGenerator</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the energy resource the unit generates which is dependant on the maps tidal power. Clearly, this only works on water structures. | |||
* '''<code>metalUse</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the metal resource the unit consumes per game 'tick'. | |||
* '''<code>energyUse</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the energy resource the unit consumes per game 'tick'. | |||
* '''<code>metalMake</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the metal resource the unit generates unconditionally per game 'tick'. | |||
* '''<code>energyMake</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the energy resource the unit generates unconditionally per game 'tick'. | |||
* '''<code>makesMetal</code>''' - type: <code>float</code> - default: <code>0.0</code> | |||
: The amount of the energy resource the unit turns into the metal resource per game 'tick'. | |||
===Sensors=== | |||
===Commands=== | ===Commands=== | ||
===Builder=== | ===Builder=== | ||
===Movement=== | ===Movement=== | ||
===Flanking=== | ===Flanking=== | ||
===Aircraft=== | ===Aircraft=== | ||
===Transports=== | ===Transports=== | ||
===Categories=== | ===Categories=== | ||
===Decals=== | ===Decals=== | ||
===Collision Volumes=== | ===Collision Volumes=== | ||
===Weapons=== | ===Weapons=== | ||
===Other=== | ===Other=== | ||
* '''<code>decoyFor</code>''' - type: <code>string</code> - default: <code>""</code> | |||
: The unitdef name (not human <code>name</code>) which this unit is a decoy for. | |||
===Custom Params=== | ===Custom Params=== | ||
Revision as of 19:06, 11 June 2011
Location
UnitDef files are .lua files stored in the Units/ directory of a Spring Game.
Purpose
UnitDef files have one purpose; to define the properties of units. They are the main description file for what attributes your unit should have and how it should behave.
Source
The engine source code which loads the tags from these files is viewable here:
https://github.com/spring/spring/blob/master/rts/Sim/Units/UnitDef.cpp
Data Types
Tags may be one of the following data types:
int- An integer numberfloat- A number with decimals.bool- A value which can betrueorfalse.string- Text, or more precisely a string of alphanumeric characters.float[3]- A vector, with threefloatcomponents, representing x, y and z axes (y is 'up').
Details
There follows a comprehensive list of the tags available, their data type, default value and a brief description of what they do. Bear in mind that the source code linked above is the ultimate reference when dealing with these tags. In lua tables keys (i.e. the tags) should be lower case, here they are represented in camelCase for readability. In your files you may use the lowerkeys function on your final table to ensure the keys are properly cased.
General
name- type:string- default:""
- This is simply the name of the unit as it appears to the player.
description- type:string- default:name
- This is the tooltip description of the unit seen by the player. It defaults to the
nameof the unit.
buildPic- type:string- default:""
- The filename of of the image to be used as the build picture.
Resources
metalStorage- type:float- default:0.0
- The amount of the metal resource storage the unit contributes.
energyStorage- type:float- default:0.0
- The amount of the energy resource storage the unit contributes.
extractsMetal- type:float- default:0.0
- The amount of the metal resource the unit extracts from the ground. The amount extracted depends on the metal map defined in the map itself. Works only for structures.
windGenerator- type:float- default:0.0
- The amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures.
tidalGenerator- type:float- default:0.0
- The amount of the energy resource the unit generates which is dependant on the maps tidal power. Clearly, this only works on water structures.
metalUse- type:float- default:0.0
- The amount of the metal resource the unit consumes per game 'tick'.
energyUse- type:float- default:0.0
- The amount of the energy resource the unit consumes per game 'tick'.
metalMake- type:float- default:0.0
- The amount of the metal resource the unit generates unconditionally per game 'tick'.
energyMake- type:float- default:0.0
- The amount of the energy resource the unit generates unconditionally per game 'tick'.
makesMetal- type:float- default:0.0
- The amount of the energy resource the unit turns into the metal resource per game 'tick'.
Sensors
Commands
Builder
Movement
Flanking
Aircraft
Transports
Categories
Decals
Collision Volumes
Weapons
Other
decoyFor- type:string- default:""
- The unitdef name (not human
name) which this unit is a decoy for.