Skip to content

Commit 3cf7d09

Browse files
committed
doc: Clarify on_script_reloaded behavior.
1 parent c355a34 commit 3cf7d09

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/src/ScriptingReference/core-callbacks.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ end
3636

3737
This will be called twice: right before and after a script is reloaded.
3838

39-
The first parameter `save` informs you whether it is time to save a value or restore it.
39+
The first parameter `save` informs whether it is time to save a value or restore it.
4040

41-
Before the reload, it is called with one argument: `true`. After the script is reloaded, it is called with two parameters: the first is `false` and the second is value returned from before.
41+
Before the script reload, `on_script_reloaded` is called with two arguments:
42+
`true`, `nil`. The value returned is kept. After the script reload,
43+
`on_script_reloaded` is called with two arguments: `false` and the value
44+
returned from the preceding call.
4245

4346
```lua
4447
mode = 1
@@ -52,3 +55,5 @@ function on_script_reloaded(save, value)
5255
end
5356
end
5457
```
58+
59+
Using `on_script_reloaded` one can make a script reload event not disrupt the current script state.

0 commit comments

Comments
 (0)