Skip to content

Commit

Permalink
Update README to include Singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
DevinPentecost authored May 5, 2019
1 parent 43d7e52 commit b0a10f7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/SeededRandomSequence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ func _ready():
print("Got Number: ", my_new_int)
```

## As a Singleton
There is a simple Singleton script included in this package, called SeededRandomSingleton. This Singleton simply creates and initializes a SeededRandomSequence object.
You can add this Singleton to your project via:

```
Project
└── Project Settings
└── AutoLoad
```

and selecting the SeededRandomSingleton.gd script. Assuming you named the Autoload `SeededRandomSingleton` then you can simply access it in your scripts like:

```
SeededRandomSingleton.sequence.reset(new_seed) #Optional, if you want to control the seed
var value = SeededRandomSingleton.sequence.next() #Grab the next value
print(value) #Print out the value
```

It's a very easy way to take advantage of the sequence without needing to pass around an object.

### Example Project
There is a provided Example Project in the repo. You can load it in Godot to see a simple GUI that allows you to set the seed, get the values, watch the state, and even save/load the JSON to show that it works!
The example is shown in the /lib/example/ folder.

0 comments on commit b0a10f7

Please sign in to comment.