You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/manuals/script.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ Defold executes Lua scripts as part of the engine lifecycle and exposes the life
32
32
`self` is a userdata object that acts like a Lua table but you can't iterate over it with `pairs()` or `ipairs()` and you can't print it using `pprint()`.
33
33
:::
34
34
35
-
####`init(self)`
35
+
##### init(self)
36
36
Called when the component is initialized.
37
37
38
38
```lua
@@ -43,7 +43,7 @@ function init(self)
43
43
end
44
44
```
45
45
46
-
####`final(self)`
46
+
##### final(self)
47
47
Called when the component is deleted. This is useful for cleaning up purposes, for instance if you have spawned game objects that should be deleted when the component is deleted.
48
48
49
49
```lua
@@ -54,7 +54,7 @@ function final(self)
54
54
end
55
55
```
56
56
57
-
####`update(self, dt)`
57
+
##### update(self, dt)
58
58
Called once each frame. `dt` contains the delta time since the last frame.
59
59
60
60
```lua
@@ -63,7 +63,7 @@ function update(self, dt)
63
63
end
64
64
```
65
65
66
-
####`fixed_update(self, dt)`
66
+
##### fixed_update(self, dt)
67
67
Frame-rate independent update. `dt` contains the delta time since the last update. This function is called when `engine.fixed_update_frequency` is enabled (!= 0). Useful when you wish to manipulate physics objects at regular intervals to achieve a stable physics simulation when `physics.use_fixed_timestep` is enabled in *game.project*.
When messages are sent to the script component through [`msg.post()`](/ref/msg#msg.post) the engine calls this function of the receiver component. Learn [more about message passing](/manuals/message-passing).
77
77
78
78
```lua
@@ -83,7 +83,7 @@ function on_message(self, message_id, message, sender)
83
83
end
84
84
```
85
85
86
-
####`on_input(self, action_id, action)`
86
+
##### on_input(self, action_id, action)
87
87
If this component has acquired input focus (see [`acquire_input_focus`](/ref/go/#acquire_input_focus)) the engine calls this function when input is registered. Learn [more about input handling](/manuals/input).
88
88
89
89
```lua
@@ -94,7 +94,7 @@ function on_input(self, action_id, action)
94
94
end
95
95
```
96
96
97
-
####`on_reload(self)`
97
+
##### on_reload(self)
98
98
This function is called when the script is reloaded through the hot reload editor function (<kbd>Edit ▸ Reload Resource</kbd>). It is very useful for debugging, testing and tweaking purposes. Learn [more about hot-reload](/manuals/hot-reload).
0 commit comments