Skip to content

Commit

Permalink
AddCommandHandler now supports methods taking a string array as the l…
Browse files Browse the repository at this point in the history
…ast parameter
  • Loading branch information
desplesda committed Dec 11, 2024
1 parent fb75ce8 commit 237d5de
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 57 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added
- `DialogueRunner.AddCommandHandler` and `DialogueRunner.AddFunction` now validate that the provided names contain no spaces.
- `DialogueRunner.AddCommandHandler` now supports methods whose last parameter is an array of strings.
- This allows for commands with a variable list of parameters. For example, consider the following method:
```csharp
void LogStrings(int a, string[] remainder) {
Debug.Log($"a = {a}, remainder={string.Join(",", remainder)}");
}
```
This method can be registered as a Yarn command:
```csharp
dialogueRunner.AddCommandHandler<int, string[]>("my_command", LogStrings);
```
And called from Yarn Spinner:
```
// logs "a = 42, remainder=this,is,pretty,great"
<<my_command 42 this is pretty great>>
```
> [!NOTE]
> Array parameters are required to be string arrays, and are required to be the last parameter of the method.


### Changed

Expand Down
Loading

0 comments on commit 237d5de

Please sign in to comment.