Skip to content

Commit

Permalink
feat(flame_jenny): Public access to variables to allow load/save (#2689)
Browse files Browse the repository at this point in the history
Allows direct access to the variables in the VariableStorage class in jenny (via YarnProject.variables.variables).

This enables a user to implement a save game feature to save the variables and later restore them.
  • Loading branch information
projectitis authored Aug 28, 2023
1 parent a1cb9a0 commit 1485f84
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/other_modules/jenny/runtime/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ FunctionStorage <function_storage.md>
MarkupAttribute <markup_attribute.md>
Node <node.md>
UserDefinedCommand <user_defined_command.md>
VariableStorage <variable_storage.md>
YarnProject <yarn_project.md>
```
7 changes: 7 additions & 0 deletions doc/other_modules/jenny/runtime/variable_storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# VariableStorage

```{dartdoc}
:package: jenny
:symbol: VariableStorage
:file: src/variable_storage.dart
```
7 changes: 7 additions & 0 deletions doc/other_modules/jenny/runtime/yarn_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ final yarn = YarnProject()
**trueValues**, **falseValues** `Set<String>`
: The strings that can be recognized as `true`/`false` values respectively.

**variables** `VariableStorage`
: The [container][VariableStorage] for all variables declared and manipulated in your yarn scripts.
This is also used for maintaining the visit counts for nodes that the user has visited. To
implement a 'save game' feature it is possible to save the variables from
`VariableStorage.variables` and later restore them again.


## Methods

Expand All @@ -92,3 +98,4 @@ final yarn = YarnProject()
[CommandStorage]: command_storage.md
[FunctionStorage]: function_storage.md
[Node]: node.md
[VariableStorage]: variable_storage.md
2 changes: 0 additions & 2 deletions packages/flame_jenny/jenny/lib/src/variable_storage.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:jenny/src/errors.dart';
import 'package:jenny/src/structure/expressions/expression.dart';
import 'package:jenny/src/structure/expressions/variables.dart';
import 'package:meta/meta.dart';

class VariableStorage {
@protected
final Map<String, dynamic> variables = <String, dynamic>{};

int get length => variables.length;
Expand Down

0 comments on commit 1485f84

Please sign in to comment.