Skip to content

Commit

Permalink
Make MapVariableStorage concurrent-safe #6
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJosh9000 committed May 8, 2023
1 parent 8767399 commit 1e3c0c9
Show file tree
Hide file tree
Showing 5 changed files with 475 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ commands to the handler.

## Usage

1. Compile your `.yarn` file. You can probably get the compiled output from a
1. Compile your `.yarn` file. You can probably get the compiled output from a
Unity project, or you can compile without using Unity with a tool like the
[Yarn Spinner Console](https://github.com/YarnSpinnerTool/YarnSpinner-Console):

Expand Down Expand Up @@ -75,7 +75,7 @@ commands to the handler.
return choice, nil
}

// ... and also the other methods.
// ... and also the other methods.
// Alternatively you can embed yarn.FakeDialogueHandler in your handler.
```

Expand All @@ -85,9 +85,9 @@ commands to the handler.

```go
package main

import "github.com/DrJosh9000/yarn"

func main() {
// Load the files (error handling omitted for brevity):
program, stringTable, _ := yarn.LoadFiles("Example.yarn.yarnc", "Example.yarn.csv", "en-AU")
Expand All @@ -99,7 +99,7 @@ commands to the handler.
vm := &yarn.VirtualMachine{
Program: program,
Handler: myHandler,
Vars: make(yarn.MapVariableStorage), // or your own VariableStorage implementation
Vars: yarn.NewMapVariableStorage(), // or your own VariableStorage implementation
FuncMap: yarn.FuncMap{ // this is optional
"last_value": func(x ...interface{}) interface{} {
return x[len(x)-1]
Expand Down Expand Up @@ -168,7 +168,7 @@ func (m *MyHandler) setWaiting(w bool) {
func (m *MyHandler) Line(line yarn.Line) error {
text, _ := m.stringTable.Render(line)
m.dialogueDisplay.Show(text)

// Go into waiting-for-player-input state
m.setWaiting(true)

Expand Down
Loading

0 comments on commit 1e3c0c9

Please sign in to comment.