mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Updated lua basics (markdown)
parent
b8adc3351b
commit
cb40adb9a9
1 changed files with 2 additions and 1 deletions
|
@ -39,7 +39,8 @@ Look for tutorials. Lua 5.1 to 5.4 all equally apply since the core language has
|
||||||
- There are no bit operations. You need to shoehorn something out of multiplications, divisions, and math.floor(). Luckily for Aquaria modding you will most likely never need bit operations. (Lua 5.2 has bit ops but we're stuck on 5.1, yay)
|
- There are no bit operations. You need to shoehorn something out of multiplications, divisions, and math.floor(). Luckily for Aquaria modding you will most likely never need bit operations. (Lua 5.2 has bit ops but we're stuck on 5.1, yay)
|
||||||
- Functions can return multiple values:
|
- Functions can return multiple values:
|
||||||
- `local x, y, z = entity_getPosition(e)` sets x, y to numbers and z to *nil*, because `entity_getPosition()` returns (only) 2 values.
|
- `local x, y, z = entity_getPosition(e)` sets x, y to numbers and z to *nil*, because `entity_getPosition()` returns (only) 2 values.
|
||||||
- If the result of a function call _ends_ a parameter list, all return values are forwarded as call parameters: `entity_setPosition(e, node_getPosition(node))`
|
- If the last parameter to a function call is the result of another function call, all return values are forwarded as call parameters:<br /> `entity_setPosition(e, node_getPosition(node))` (This forwards x, y as `node_getPosition()` returns 2 values)
|
||||||
|
- Lua has no idea how many parameters a function is going to take. Missing function parameters are passed as **nil**, extraneous ones are ignored. This can lead to mistakes like this:<br /> `entity_scale(me, 2)` causes an entity to visually disappear.<br />Why? Because `entity_scale(entity, scaleX, scaleY, ...)` takes more than 2 parameters (most of which are optional); scaleY is passed as **nil**, which is silently converted to 0 on the C++ side. And a scale factor of 0 on one axis makes an object appear infinitely thin, so it's not drawn.
|
||||||
|
|
||||||
### Aquaria-specific things:
|
### Aquaria-specific things:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue