Skip to content

Commit

Permalink
Site changes [skip-ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
defold-services committed Jan 26, 2025
1 parent c94d87f commit d136845
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manuals/gui-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To control the logic of your GUI and animate nodes you use Lua scripts. GUI scri

To add a script to a GUI, first create a GUI script file by <kbd>right clicking</kbd> a location in the *Assets* browser and selecting <kbd>New ▸ Gui Script</kbd> from the popup context menu.

The editor automatically opens the new script file. It is based on a template and comes equipped with empty lifetime functions, just like game object scripts:
The editor automatically opens the new script file. It is based on a template and comes equipped with empty lifecycle functions, just like game object scripts:

```lua
function init(self)
Expand Down
14 changes: 7 additions & 7 deletions manuals/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Defold executes Lua scripts as part of the engine lifecycle and exposes the life
`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()`.
</div>

#### `init(self)`
##### init(self)
Called when the component is initialized.

```lua
Expand All @@ -47,7 +47,7 @@ function init(self)
end
```

#### `final(self)`
##### final(self)
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.

```lua
Expand All @@ -58,7 +58,7 @@ function final(self)
end
```

#### `update(self, dt)`
##### update(self, dt)
Called once each frame. `dt` contains the delta time since the last frame.

```lua
Expand All @@ -67,7 +67,7 @@ function update(self, dt)
end
```

#### `fixed_update(self, dt)`
##### fixed_update(self, dt)
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*.

```lua
Expand All @@ -76,7 +76,7 @@ function fixed_update(self, dt)
end
```

#### `on_message(self, message_id, message, sender)`
##### on_message(self, message_id, message, sender)
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).

```lua
Expand All @@ -87,7 +87,7 @@ function on_message(self, message_id, message, sender)
end
```

#### `on_input(self, action_id, action)`
##### on_input(self, action_id, action)
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).

```lua
Expand All @@ -98,7 +98,7 @@ function on_input(self, action_id, action)
end
```

#### `on_reload(self)`
##### on_reload(self)
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).

```lua
Expand Down

0 comments on commit d136845

Please sign in to comment.