Skip to content

Commit 543cd11

Browse files
Fix readme and authoring routes pages
1 parent d91d312 commit 543cd11

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Included are:
6060
- Any%
6161
- B-side
6262
- C-side
63-
- Icons (chapters, berry, and celeste mountain) for use as split icons
64-
For each of these the `.lss` file can be imported directly into LiveSplit One and the corresponding `.json` files can
65-
be loaded into SwiftSplit.
63+
64+
## Authoring your own routes
65+
See [Authoring Routes](authoring_routes.md)
6666

SwiftSplit/CelesteSplitter.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,18 @@ class RouteEvent {
310310
var event: String
311311

312312
init?(from jsonString: String) {
313-
if jsonString.prefix(1) == "#" {
314-
return nil
315-
}
316313
guard let match = RouteEvent.pattern.firstMatch(in: jsonString, options: [], range: NSRange(jsonString.startIndex..<jsonString.endIndex, in: jsonString)) else {
317314
return nil
318315
}
319316
silent = match.range(at: 1).location != NSNotFound
320-
if let eventRange = Range(match.range(at: 2), in: jsonString) {
321-
event = String(jsonString[eventRange]).lowercased(with: nil)
322-
} else {
317+
guard let eventRange = Range(match.range(at: 2), in: jsonString) else {
323318
return nil
324319
}
320+
let event = String(jsonString[eventRange])
321+
if event.isEmpty {
322+
return nil
323+
}
324+
self.event = event
325325
}
326326

327327
init(silent: Bool, event: String) {

authoring_routes.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Route JSON
1+
# Authoring routes
2+
3+
## Route JSON
24
Routes are configured using a JSON file and use "events" generated by SwiftSplit.
35

46
Here's an example for Old Site Any%:
57
```json
68
{
79
"useFileTime": false,
8-
"reset": "reset chapter",
10+
"reset": "leave chapter",
911
"route": [
1012
"enter chapter 2 # Start",
1113
"d8 > d3 # - Mirror",
@@ -27,15 +29,21 @@ Events are triggered when SwiftSplit observes a change in the game state, which
2729
single event may have multiple variants, generally with differing levels of specificity (e.g. `leave chapter`,
2830
`leave chapter 1`, and `leave a-side 1`).
2931

32+
SwiftSplit has an "Event Stream" panel that displays events as they are triggered, which can be useful when creating
33+
route files. (You can copy the text out of the panel to paste directly into the route file).
34+
3035
Note that the *exact* text of an event is important. Spaces and capitalization have to match, with a couple additions:
31-
- Whitespace *around* an event doesn't matter. (e.g. `"leave chapter"` is equivalent to `" leave chapter "`)
36+
37+
- Whitespace *around* an event is ignored. (e.g. `"leave chapter"` is equivalent to `" leave chapter "`)
3238
- Inserting an exclamation point (`!`) at the beginning of an event will cause that event to be "silent" and not trigger
3339
a split. This can be useful for situations like [expected resets](#expected-resets).
3440
- Anything after `#` will be trimmed off. This can be useful for explaining events.
35-
- If after applying the previous two rules the event is empty, it's simply ignored. (e.g. `! # comment` will be ignored)
41+
- If after applying the previous rules the event is empty, it's simply ignored. (e.g. `! # comment` will be ignored)
3642

37-
SwiftSplit has an "Event Stream" panel that displays events as they are triggered, which can be useful when creating
38-
route files. (You can copy the text out of the panel to paste directly into the route file).
43+
Bringing this together, `" ! d8 > d3# other stuff "` is a valid event, and translates to a silent transition from
44+
`d8` to `d3`.
45+
46+
## Event list
3947

4048
### Chapter start/end events
4149
- `leave chapter` - Triggered when leaving any chapter (either by restarting the chapter, returning to the map, or
@@ -81,10 +89,10 @@ route files. (You can copy the text out of the panel to paste directly into the
8189
## Return to Map & Save and Quit
8290

8391
Without the proper route file, both of these count as resetting a chapter. It's impossible for SwiftSplit to tell the
84-
difference between a reset, return to map, or save and quit. To get around this, you can define in your route where
85-
leaving the chapter is *expected.*
92+
difference between a restart, return to map, or save and quit. To get around this, you can define in your route where
93+
leaving the chapter is *expected.* Unless you're triggering a split there, the event should be marked as silent.
8694

87-
Here's what the reset for the 1A might look like:
95+
Here's what the reset for the 1A heart might look like:
8896
```json
8997
"route": [
9098
"enter chapter 1 # Start",
@@ -101,8 +109,8 @@ leave the chapter *you can not automatically reset the run.* Any attempt to rest
101109
progressing through the route. By putting the collect heart event before the leave chapter event we make sure that
102110
SwiftSplit only starts waiting for the leave event right before we do it.
103111

104-
For restarting after collecting berries you'd want to have two events: one when you enter the room you'll save and quit
105-
in, and the next when you collect the berry:
112+
For restarting after collecting berries you'll probably want to have two events: one when you enter the room you'll
113+
save and quit in, and the next when you collect the berry
106114

107115
```json
108116
"route": [

0 commit comments

Comments
 (0)