Skip to content

Commit

Permalink
Fix readme and authoring routes pages
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodewarrior committed Jun 20, 2021
1 parent d91d312 commit 543cd11
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Included are:
- Any%
- B-side
- C-side
- Icons (chapters, berry, and celeste mountain) for use as split icons
For each of these the `.lss` file can be imported directly into LiveSplit One and the corresponding `.json` files can
be loaded into SwiftSplit.

## Authoring your own routes
See [Authoring Routes](authoring_routes.md)

12 changes: 6 additions & 6 deletions SwiftSplit/CelesteSplitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,18 @@ class RouteEvent {
var event: String

init?(from jsonString: String) {
if jsonString.prefix(1) == "#" {
return nil
}
guard let match = RouteEvent.pattern.firstMatch(in: jsonString, options: [], range: NSRange(jsonString.startIndex..<jsonString.endIndex, in: jsonString)) else {
return nil
}
silent = match.range(at: 1).location != NSNotFound
if let eventRange = Range(match.range(at: 2), in: jsonString) {
event = String(jsonString[eventRange]).lowercased(with: nil)
} else {
guard let eventRange = Range(match.range(at: 2), in: jsonString) else {
return nil
}
let event = String(jsonString[eventRange])
if event.isEmpty {
return nil
}
self.event = event
}

init(silent: Bool, event: String) {
Expand Down
30 changes: 19 additions & 11 deletions authoring_routes.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Route JSON
# Authoring routes

## Route JSON
Routes are configured using a JSON file and use "events" generated by SwiftSplit.

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

SwiftSplit has an "Event Stream" panel that displays events as they are triggered, which can be useful when creating
route files. (You can copy the text out of the panel to paste directly into the route file).

Note that the *exact* text of an event is important. Spaces and capitalization have to match, with a couple additions:
- Whitespace *around* an event doesn't matter. (e.g. `"leave chapter"` is equivalent to `" leave chapter "`)

- Whitespace *around* an event is ignored. (e.g. `"leave chapter"` is equivalent to `" leave chapter "`)
- Inserting an exclamation point (`!`) at the beginning of an event will cause that event to be "silent" and not trigger
a split. This can be useful for situations like [expected resets](#expected-resets).
- Anything after `#` will be trimmed off. This can be useful for explaining events.
- If after applying the previous two rules the event is empty, it's simply ignored. (e.g. `! # comment` will be ignored)
- If after applying the previous rules the event is empty, it's simply ignored. (e.g. `! # comment` will be ignored)

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

## Event list

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

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

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

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

```json
"route": [
Expand Down

0 comments on commit 543cd11

Please sign in to comment.