BenchRegenerator
BenchRegenerator keeps a generator re-cooking the way a game that edits its world does. Every `every` seconds it sets the graph input named `input` on the Generator of the entity named `target`, stepping through `values` and starting over at the end. A value the generator has not
BenchRegenerator
BenchRegenerator keeps a generator re-cooking the way a game that edits its world does. Every
every seconds it sets the graph input named input on the Generator of the entity named
target, stepping through values and starting over at the end. A value the generator has not
held before is a new cook.
The bench_mixed scene uses it twice. BenchRocksReroll re-rolls the rock field on BenchRocks
(input = "seed", values = { 1 }, every = 2, stepping = true), and BenchValleyEdit edits the
valley on BenchValley (input = "cut", values = { -60 }, every = 5, stepping = true). With
stepping on, each of these counts up from its single value, so every re-cook is a new cook.
It looks up the target by name and reads that entity's Generator component.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
target | string | "" | The name of the entity whose Generator is re-cooked. |
input | string | "seed" | The graph input set on each re-cook. |
values | table | { 1, 2, 3, 4 } | The values the input steps through, in order, starting over at the end. |
every | number | 2 | Seconds between re-cooks. |
stepping | bool | false | Counts up from the last value once values is used up, so no value repeats and every re-cook is a cook the generator has not made before. |
All fields are Sync.
Lifecycle
update(dt): whileeveryis above 0, it addsdtto a timer. Each time the timer passesevery, it finds the first entity namedtarget, copies its Generator'sparams, setsparams[input]to the next value and assigns the copy back to the Generator'sparams.
The next value is the next entry of values. Past the last entry, with stepping on and a numeric
last entry, it is the last entry plus the number of steps taken past it; otherwise the sequence
starts again at the first entry.
Usage
local reroll = entity.spawn("BenchRocksReroll")
reroll.component.add("BenchRegenerator", {
target = "BenchRocks", input = "seed", values = { 1 }, every = 2, stepping = true,
})
Scoped to this part · feeds back into the world's score.