201 | | Lua is the scripting language we use in our levels. At the beginning of the file templates for spaceships, the hud and more are loaded. |
202 | | |
203 | | == Triggers == |
204 | | |
205 | | == Events == |
| 201 | Lua is the scripting language we use in our levels. At the beginning of the file templates for spaceships, the hud and more are loaded. What lua does is in fact editing the XML file before the level is loaded. (that's why you cannot rely on the line numbers displayed when an error occurs. |
| 202 | |
| 203 | What lua can do: |
| 204 | * load external skripts: for example the cuboid spacestation. |
| 205 | {{{ |
| 206 | #!xml <?lua |
| 207 | dofile("includes/CuboidSpaceStation.lua") |
| 208 | ?> |
| 209 | <!-- First, the skript has to be included. --> |
| 210 | |
| 211 | <!-- Usage: Creates a modular space station --> |
| 212 | <StaticEntity scale=1 position="4650,5350,-11050" name=base visible=true active=true yaw=60> |
| 213 | <attached> |
| 214 | <?lua |
| 215 | createSpaceStationPar(9851,2,1,2,1,2,1,100) |
| 216 | ?> |
| 217 | </attached> |
| 218 | </StaticEntity> |
| 219 | }}} |
| 220 | |
| 221 | * {{{ |
| 222 | #!xml <?lua |
| 223 | for i = 1, 10, 1 do |
| 224 | ?> |
| 225 | |
| 226 | <?lua end ?> |
| 227 | <!-- A for loop. the index i starts from 1, is increased up to 10 by adding +1. --> |
| 228 | }}} |
| 229 | |
| 230 | * <?lua print(math.random() * 10 + 5) ?> |
| 231 | |
| 232 | |
| 233 | == Triggers && Events== |
| 234 | Example: ../data/levels/events.oxw |
| 235 | |