|
@@ -138,7 +138,7 @@ end
|
|
The script code above is written in the Lua language. There are a few things to note about the code:
|
|
The script code above is written in the Lua language. There are a few things to note about the code:
|
|
|
|
|
|
- Defold reserves a set of built in callback *functions* that are called during the lifetime of a script component. These are *not* methods but plain functions. The runtime passes a reference to the current script component instance through the parameter `self`. The `self` reference is used to store instance data.
|
|
- Defold reserves a set of built in callback *functions* that are called during the lifetime of a script component. These are *not* methods but plain functions. The runtime passes a reference to the current script component instance through the parameter `self`. The `self` reference is used to store instance data.
|
|
-- Lua table literals are written surrounded with curly braces. Table entries can be key/value pairs (`{x = 10, y = 20}`), nested Lua tables (`{{a = 1}, {b = 2}}`) or other data types.
|
|
|
|
|
|
+- Lua table literals are written surrounded with curly braces. Table entries can be key/value pairs (`{x = 10, y = 20}`), nested Lua tables (`{ {a = 1}, {b = 2} a}`) or other data types.
|
|
- The `self` reference can be used as a Lua table that you can store data in. Just use the dot notation as you would with any other table: `self.data = "value"`. The reference is valid throughout the lifetime of the script, in this case from game start until you quit it.
|
|
- The `self` reference can be used as a Lua table that you can store data in. Just use the dot notation as you would with any other table: `self.data = "value"`. The reference is valid throughout the lifetime of the script, in this case from game start until you quit it.
|
|
|
|
|
|
If you didn't understand any of the above, don't worry about it. Just tag along, experiment and give it time---you will get it eventually.
|
|
If you didn't understand any of the above, don't worry about it. Just tag along, experiment and give it time---you will get it eventually.
|