Skip to content

Commit 844213d

Browse files
docs: expand release examples and reference coverage
1 parent 852992b commit 844213d

15 files changed

Lines changed: 152 additions & 77 deletions

Example Scripts/914Effects.ser

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Disabled by default: remove # from the filename to enable this script.
22
# this script applies different effects for players in SCP-914
33
# depending on the current setting of the knob
4+
# Requires SafeScripts: false so IsAllowed can change the 914 output in time.
45

56
!-- OnEvent ProcessingPlayer
67
-- require @evPlayer $evKnobSetting
@@ -31,4 +32,4 @@ elif $evKnobSetting is "Fine"
3132
elif $evKnobSetting is "VeryFine"
3233
GiveEffect @evPlayer MovementBoost 20s 10
3334
GiveEffect @evPlayer AntiScp207 10s
34-
end
35+
end

Example Scripts/chaosCoin.ser

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Disabled by default: remove # from the filename to enable this script.
22
# this script adds a fully functioning coin with custom behaviors
3+
# Requires SafeScripts: false so IsAllowed can cancel a coin flip in time.
34

45
!-- OnEvent FlippingCoin
56

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Disabled by default: remove # from the filename to enable this script.
2+
# Stops direct damage between players on the same team and tells the attacker why.
3+
# Environmental damage and self-damage are left unchanged.
4+
# Requires SafeScripts: false so IsAllowed can cancel the damage in time.
5+
6+
!-- OnEvent Hurting
7+
-- require @evPlayer @evAttacker
8+
9+
if {Overlapping @evPlayer @evAttacker}
10+
stop
11+
end
12+
13+
if {@evPlayer -> team} isnt {@evAttacker -> team}
14+
stop
15+
end
16+
17+
IsAllowed false
18+
Hint @evAttacker 3s "<color=#ffb86c>Friendly fire is disabled for your team.</color>"

Example Scripts/limitScp173Movement.ser

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Disabled by default: remove # from the filename to enable this script.
22
# this script limits when scp 173 can teleport
33
# depending on how many players are looking at him
4+
# Requires SafeScripts: false so IsAllowed can cancel the teleport in time.
45

56
!-- OnEvent Teleporting
67
-- require @evPlayer
@@ -39,4 +40,4 @@ wait {ToDuration {Random 1 $observerCount} seconds}
3940
SetPlayerData @evPlayer can_teleport true
4041

4142
# inform about the ability to move
42-
Hint @evPlayer 2s "<color=green><b>You can now move!</b></color>"
43+
Hint @evPlayer 2s "<color=green><b>You can now move!</b></color>"

Example Scripts/roundReport.ser

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Disabled by default: remove # from the filename to enable this script.
2+
# Sends a small Discord report after each round.
3+
# Create Custom Configs/round-report.yml inside the SER config directory:
4+
# webhook_url: "https://discord.com/api/webhooks/..."
5+
6+
!-- OnEvent RoundEnded
7+
-- require $evLeadingTeam
8+
9+
*settings = Config.Read "round-report"
10+
if {*settings -> isInvalid}
11+
Error "Round report was not sent. Create Custom Configs/round-report.yml and add webhook_url."
12+
stop
13+
end
14+
15+
$webhookUrl = Config.GetOption *settings "webhook_url" ""
16+
if {$webhookUrl -> length} is 0
17+
Error "Round report was not sent. Set webhook_url in Custom Configs/round-report.yml."
18+
stop
19+
end
20+
21+
$content = "Round ended. Leading team: {$evLeadingTeam}. Players online: {AmountOf @all}."
22+
*message = Discord.CreateMessage $content
23+
24+
attempt
25+
Discord.SendMessage $webhookUrl *message
26+
on_error with $message
27+
Error "Round report could not reach Discord: {$message}"
28+
end

VS Code Extension/out/ser-language.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7613,10 +7613,10 @@
76137613
},
76147614
"IsAllowed": {
76157615
"syntax": "IsAllowed isAllowed",
7616-
"description": "Sets whether or not the event is allowed to run.",
7616+
"description": "Allows or cancels the event that started this script.",
76177617
"subgroup": "Event",
76187618
"essential": false,
7619-
"additionalDescription": "In order for it to have any impact, the script in which the method is used must be triggered by an event, and that event must be cancellable.",
7619+
"additionalDescription": "This only works in a cancellable event, before any Wait or other pause. It cannot cancel the current event while SafeScripts is enabled because the safety pause lets the event continue first.",
76207620
"requiredFramework": null,
76217621
"returns": null,
76227622
"arguments": [

VS Code Extension/out/visual-editor.html

Lines changed: 46 additions & 45 deletions
Large diffs are not rendered by default.

docs/guides/examples.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ old releases.
1212
| Create a player command | [`selfHealCommand.ser`](../../Example%20Scripts/selfHealCommand.ser) |
1313
| Put several handlers in one file | [`multiSectionHandlers.ser`](../../Example%20Scripts/multiSectionHandlers.ser) |
1414
| Track round state | [`killStreak.ser`](../../Example%20Scripts/killStreak.ser) |
15+
| Block damage between teammates | [`friendlyFireGuard.ser`](../../Example%20Scripts/friendlyFireGuard.ser) |
16+
| Send a round result to Discord | [`roundReport.ser`](../../Example%20Scripts/roundReport.ser) |
1517
| Build a timed event | [`hotPotato.ser`](../../Example%20Scripts/hotPotato.ser) |
1618
| Store persistent-style data | [`coinTracker.ser`](../../Example%20Scripts/coinTracker.ser) |
1719
| Create custom roles | [`customRoles.ser`](../../Example%20Scripts/customRoles.ser) |

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,18 @@ end
8484
```
8585

8686
`IsAllowed false` changes the game event. `stop` prevents later SER
87-
instructions in this section from running.
87+
instructions in this section from running. Put `IsAllowed` before any `Wait` or
88+
other pause.
89+
90+
:::warning SafeScripts and event cancellation
91+
92+
`IsAllowed` cannot cancel the current event while SafeScripts is enabled. The
93+
safety pause lets the game continue the event before the script can change it.
94+
Keep SafeScripts enabled for general scripts. If a script must cancel an event,
95+
turn it off only after checking every active script for loops that can freeze the
96+
server.
97+
98+
:::
8899

89100
## ProjectMER events
90101

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ end
167167
```
168168

169169
Keep `attempt` blocks small so it is obvious which instruction failed.
170+
`attempt` handles errors caused by script input or game state. The `stop`
171+
keyword still stops the script, and an internal SER failure still receives an
172+
identifier in the server console instead of being hidden by `on_error`.
170173
Unexpected internal SER failures are presented with a short identifier; full
171174
technical details remain in the server console.
172175

0 commit comments

Comments
 (0)