Skip to content

Commit eb83914

Browse files
docs: update function references and generated metadata
1 parent 4574215 commit eb83914

6 files changed

Lines changed: 25906 additions & 23 deletions

File tree

Tooling/scripts/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function buildEditorHtml(mediaPath, webview = false) {
4848
.replace("<!-- SER_TOOLING_BLOCKLY -->", `${scriptOpen}\n${blockly}\n</script>`)
4949
.replace(
5050
"<!-- SER_TOOLING_MANIFEST -->",
51-
`${scriptOpen}\nconst SER_TRUTH_TABLE = ${JSON.stringify(manifest)};\n</script>`
51+
`${scriptOpen}\nconst SER_TRUTH_TABLE = ${JSON.stringify(manifest, null, 2)};\n</script>`
5252
)
5353
.replace("<!-- SER_TOOLING_CORE -->", `${scriptOpen}\n${core}\n</script>`)
5454
.replace("<!-- SER_TOOLING_EDITOR -->", `${scriptOpen}\n${editor}\n</script>`);

VS Code Extension/out/ser-language.json

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@
593593
"argumentKind": "TextArgument",
594594
"mustBeProvided": true,
595595
"type": "Any text e.g. \"Hello, World!\"",
596-
"description": null,
596+
"description": "Has to be exactly 1 character long.",
597597
"defaultValue": null,
598598
"consumesRemainingValues": false,
599599
"syntax": "\"character\"",
@@ -666,7 +666,7 @@
666666
"errors": []
667667
},
668668
"Text.Slice": {
669-
"syntax": "Text.Slice \"text\" beginning_amount? end_amount",
669+
"syntax": "Text.Slice \"text\" beginning_amount? end_amount?",
670670
"description": "Slices off characters from beginning and end of a text value.",
671671
"subgroup": "Text",
672672
"essential": false,
@@ -707,12 +707,12 @@
707707
{
708708
"name": "end amount",
709709
"argumentKind": "IntArgument",
710-
"mustBeProvided": true,
710+
"mustBeProvided": false,
711711
"type": "A whole number bigger or equal 0",
712712
"description": "The amount of characters to remove from the end of the text.",
713-
"defaultValue": null,
713+
"defaultValue": "0",
714714
"consumesRemainingValues": false,
715-
"syntax": "end_amount",
715+
"syntax": "end_amount?",
716716
"enumValues": null,
717717
"enumDescription": null,
718718
"enumDescriptions": null,
@@ -1275,7 +1275,7 @@
12751275
"arguments": [
12761276
{
12771277
"name": "script to run",
1278-
"argumentKind": "CreatedScriptArgument",
1278+
"argumentKind": "FunctionScriptArgument",
12791279
"mustBeProvided": true,
12801280
"type": "Name of a script to create",
12811281
"description": null,
@@ -3361,6 +3361,48 @@
33613361
],
33623362
"errors": []
33633363
},
3364+
"SetPlayerIntercom": {
3365+
"syntax": "SetPlayerIntercom @players state",
3366+
"description": "Sets whether a player is using a global intercom.",
3367+
"subgroup": "Player",
3368+
"essential": false,
3369+
"additionalDescription": null,
3370+
"requiredFramework": null,
3371+
"returns": null,
3372+
"arguments": [
3373+
{
3374+
"name": "players",
3375+
"argumentKind": "PlayersArgument",
3376+
"mustBeProvided": true,
3377+
"type": "Player variable (e.g. @all, @classDPlayers)",
3378+
"description": null,
3379+
"defaultValue": null,
3380+
"consumesRemainingValues": false,
3381+
"syntax": "@players",
3382+
"enumValues": null,
3383+
"enumDescription": null,
3384+
"enumDescriptions": null,
3385+
"isEnumFlags": false,
3386+
"options": null
3387+
},
3388+
{
3389+
"name": "state",
3390+
"argumentKind": "BoolArgument",
3391+
"mustBeProvided": true,
3392+
"type": "bool (true or false) value",
3393+
"description": null,
3394+
"defaultValue": null,
3395+
"consumesRemainingValues": false,
3396+
"syntax": "state",
3397+
"enumValues": null,
3398+
"enumDescription": null,
3399+
"enumDescriptions": null,
3400+
"isEnumFlags": false,
3401+
"options": null
3402+
}
3403+
],
3404+
"errors": []
3405+
},
33643406
"SetRole": {
33653407
"syntax": "SetRole @players newRole spawnFlags? reason?",
33663408
"description": "Sets a role for players.",
@@ -4862,7 +4904,10 @@
48624904
]
48634905
}
48644906
],
4865-
"errors": []
4907+
"errors": [
4908+
"The starting number must not be greater than the ending number.",
4909+
"The requested integer range does not contain an integer."
4910+
]
48664911
},
48674912
"Round": {
48684913
"syntax": "Round number_to_round decimal_places?",
@@ -6233,7 +6278,7 @@
62336278
"description": "Gives an item to players.",
62346279
"subgroup": "Item",
62356280
"essential": true,
6236-
"additionalDescription": null,
6281+
"additionalDescription": "The return reference can be invalid if the player does not have enough space for the item. If adding multiple items, the reference will be for the last item added.",
62376282
"requiredFramework": null,
62386283
"returns": "reference to Item object",
62396284
"arguments": [
@@ -9416,8 +9461,8 @@
94169461
"name": "mode",
94179462
"argumentKind": "OptionsArgument",
94189463
"mustBeProvided": true,
9419-
"type": "One of the following options:\n > attacker\n > reciever",
9420-
"description": "Indicates whether the damage rule will be applied on all damage dealt by the attacker or on all damage received by the reciever.",
9464+
"type": "One of the following options:\n > attacker\n > receiver\n > reciever",
9465+
"description": "Indicates whether the damage rule will be applied on all damage dealt by the attacker or on all damage received by the receiver.",
94219466
"defaultValue": null,
94229467
"consumesRemainingValues": false,
94239468
"syntax": "mode",
@@ -9430,6 +9475,10 @@
94309475
"value": "attacker",
94319476
"description": ""
94329477
},
9478+
{
9479+
"value": "receiver",
9480+
"description": ""
9481+
},
94339482
{
94349483
"value": "reciever",
94359484
"description": ""
@@ -11264,7 +11313,7 @@
1126411313
},
1126511314
"Audio.Stop": {
1126611315
"syntax": "Audio.Stop \"speaker_name\"",
11267-
"description": "Plays a loaded audio clip from a created speaker.",
11316+
"description": "Stops all audio clips playing through a speaker.",
1126811317
"subgroup": "Audio",
1126911318
"essential": false,
1127011319
"additionalDescription": null,
@@ -15437,9 +15486,14 @@
1543715486
]
1543815487
},
1543915488
"Function": {
15440-
"syntax": "!-- Function",
15489+
"syntax": "!-- Function name",
1544115490
"description": "Requires this script to be executed only when required arguments are supplied.",
15442-
"inlineArgument": null,
15491+
"inlineArgument": {
15492+
"name": "name",
15493+
"description": "The unique name used to call this function with RunFunc.",
15494+
"required": false,
15495+
"example": "!-- Function HandleDoor"
15496+
},
1544315497
"arguments": [
1544415498
{
1544515499
"name": "argument",

VS Code Extension/out/visual-editor.html

Lines changed: 25750 additions & 1 deletion
Large diffs are not rendered by default.

docs/guides/flags-events-and-commands.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ version.
113113

114114
Prefer inline functions for new logic contained in one file.
115115

116+
Name each legacy function and call it by that name, including when the file
117+
contains other sections:
118+
119+
```ser
120+
!-- Function HandleDoor
121+
-- argument *door
122+
123+
LockDoor *door NoPower
124+
```
125+
126+
Use `RunFunc HandleDoor *door`. Function names are globally unique. Unnamed
127+
legacy functions remain callable by their file or section name.
128+
116129
Existing bindings reload their script before the next execution. After adding or
117130
removing bindings which cannot trigger yet, run `serreload` (or restart the round)
118131
and inspect `serstatus`.

docs/language/functions-scopes-and-errors.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ run Greet "Scientist"
3131
Inline `func`/`run` is different from the legacy `!-- Function` flag and
3232
`RunFunc` method used for cross-file compatibility.
3333

34+
Name a legacy function in its flag and call that name with `RunFunc`; the name
35+
is globally unique, so it works even when multiple function sections share a
36+
file:
37+
38+
```ser
39+
!-- Function HandleDoor
40+
-- argument *door
41+
42+
LockDoor *door NoPower
43+
```
44+
45+
Call it with `RunFunc HandleDoor *door`.
46+
3447
## Visibility and lifetime are different ideas
3548

3649
Words such as “local scope” and “function scope” are convenient shorthand, but

website/data/ser-truth-table.json

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@
12751275
"arguments": [
12761276
{
12771277
"name": "script to run",
1278-
"argumentKind": "CreatedScriptArgument",
1278+
"argumentKind": "FunctionScriptArgument",
12791279
"mustBeProvided": true,
12801280
"type": "Name of a script to create",
12811281
"description": null,
@@ -3361,6 +3361,48 @@
33613361
],
33623362
"errors": []
33633363
},
3364+
"SetPlayerIntercom": {
3365+
"syntax": "SetPlayerIntercom @players state",
3366+
"description": "Sets whether a player is using a global intercom.",
3367+
"subgroup": "Player",
3368+
"essential": false,
3369+
"additionalDescription": null,
3370+
"requiredFramework": null,
3371+
"returns": null,
3372+
"arguments": [
3373+
{
3374+
"name": "players",
3375+
"argumentKind": "PlayersArgument",
3376+
"mustBeProvided": true,
3377+
"type": "Player variable (e.g. @all, @classDPlayers)",
3378+
"description": null,
3379+
"defaultValue": null,
3380+
"consumesRemainingValues": false,
3381+
"syntax": "@players",
3382+
"enumValues": null,
3383+
"enumDescription": null,
3384+
"enumDescriptions": null,
3385+
"isEnumFlags": false,
3386+
"options": null
3387+
},
3388+
{
3389+
"name": "state",
3390+
"argumentKind": "BoolArgument",
3391+
"mustBeProvided": true,
3392+
"type": "bool (true or false) value",
3393+
"description": null,
3394+
"defaultValue": null,
3395+
"consumesRemainingValues": false,
3396+
"syntax": "state",
3397+
"enumValues": null,
3398+
"enumDescription": null,
3399+
"enumDescriptions": null,
3400+
"isEnumFlags": false,
3401+
"options": null
3402+
}
3403+
],
3404+
"errors": []
3405+
},
33643406
"SetRole": {
33653407
"syntax": "SetRole @players newRole spawnFlags? reason?",
33663408
"description": "Sets a role for players.",
@@ -4862,7 +4904,10 @@
48624904
]
48634905
}
48644906
],
4865-
"errors": []
4907+
"errors": [
4908+
"The starting number must not be greater than the ending number.",
4909+
"The requested integer range does not contain an integer."
4910+
]
48664911
},
48674912
"Round": {
48684913
"syntax": "Round number_to_round decimal_places?",
@@ -6233,7 +6278,7 @@
62336278
"description": "Gives an item to players.",
62346279
"subgroup": "Item",
62356280
"essential": true,
6236-
"additionalDescription": null,
6281+
"additionalDescription": "The return reference can be invalid if the player does not have enough space for the item. If adding multiple items, the reference will be for the last item added.",
62376282
"requiredFramework": null,
62386283
"returns": "reference to Item object",
62396284
"arguments": [
@@ -9416,8 +9461,8 @@
94169461
"name": "mode",
94179462
"argumentKind": "OptionsArgument",
94189463
"mustBeProvided": true,
9419-
"type": "One of the following options:\n > attacker\n > reciever",
9420-
"description": "Indicates whether the damage rule will be applied on all damage dealt by the attacker or on all damage received by the reciever.",
9464+
"type": "One of the following options:\n > attacker\n > receiver\n > reciever",
9465+
"description": "Indicates whether the damage rule will be applied on all damage dealt by the attacker or on all damage received by the receiver.",
94219466
"defaultValue": null,
94229467
"consumesRemainingValues": false,
94239468
"syntax": "mode",
@@ -9430,6 +9475,10 @@
94309475
"value": "attacker",
94319476
"description": ""
94329477
},
9478+
{
9479+
"value": "receiver",
9480+
"description": ""
9481+
},
94339482
{
94349483
"value": "reciever",
94359484
"description": ""
@@ -11264,7 +11313,7 @@
1126411313
},
1126511314
"Audio.Stop": {
1126611315
"syntax": "Audio.Stop \"speaker_name\"",
11267-
"description": "Plays a loaded audio clip from a created speaker.",
11316+
"description": "Stops all audio clips playing through a speaker.",
1126811317
"subgroup": "Audio",
1126911318
"essential": false,
1127011319
"additionalDescription": null,
@@ -15437,9 +15486,14 @@
1543715486
]
1543815487
},
1543915488
"Function": {
15440-
"syntax": "!-- Function",
15489+
"syntax": "!-- Function name",
1544115490
"description": "Requires this script to be executed only when required arguments are supplied.",
15442-
"inlineArgument": null,
15491+
"inlineArgument": {
15492+
"name": "name",
15493+
"description": "The unique name used to call this function with RunFunc.",
15494+
"required": false,
15495+
"example": "!-- Function HandleDoor"
15496+
},
1544315497
"arguments": [
1544415498
{
1544515499
"name": "argument",

0 commit comments

Comments
 (0)