Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
class_name TableEntry
|
|
|
|
|
|
extends RefCounted
|
|
|
|
|
|
## One possible result on a table. An entry may pipe into other tables, and on a
|
|
|
|
|
|
## ranged (dice) table it covers a span of die values such as 01–30.
|
|
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
const MAX_PIPE_COUNT := 99
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## Most times an expression pipe count (such as "@terms") may roll.
|
|
|
|
|
|
const MAX_EXPR_COUNT := 10000
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var id: String = ""
|
|
|
|
|
|
var text: String = ""
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## Optional longer description (may contain BBCode).
|
|
|
|
|
|
var details: String = ""
|
|
|
|
|
|
## Relative chance on a plain table; also the number of copies in card mode.
|
|
|
|
|
|
## 0 means it never comes up. Ignored on ranged tables.
|
|
|
|
|
|
var weight: int = 1
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## Effect statements run when this entry is chosen (see Effects), before its
|
|
|
|
|
|
## text expands and its pipes follow. "" for none.
|
|
|
|
|
|
var effects: String = ""
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## IDs of the tables this entry rolls on next (unique; one pipe per target).
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var pipes: Array[String] = []
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## target table id -> how many times to roll it (missing = 1): an int, or a
|
|
|
|
|
|
## String expression such as "@terms" or "1d3" evaluated when the pipe runs.
|
2026-11-08 12:11:43 -06:00
|
|
|
|
var pipe_count: Dictionary = {}
|
|
|
|
|
|
## target table id -> variable name to save the result under (missing = none).
|
|
|
|
|
|
var pipe_save: Dictionary = {}
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## target table id -> condition expression: the pipe runs only when it's true
|
|
|
|
|
|
## (docs/LOGIC.md, Conditional pipes). Missing = always.
|
|
|
|
|
|
var pipe_when: Dictionary = {}
|
|
|
|
|
|
## target table id -> true: the pipe runs only when none of this entry's
|
|
|
|
|
|
## conditional pipes did. Ignored while the pipe has a condition.
|
|
|
|
|
|
var pipe_otherwise: Dictionary = {}
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## target table id -> {input name: expression}: values passed to the target
|
|
|
|
|
|
## card's inputs (docs/PLAIN.md §4.2), worked out in the entry's snapshot.
|
|
|
|
|
|
## Missing = none.
|
|
|
|
|
|
var pipe_with: Dictionary = {}
|
2026-11-10 18:20:46 -06:00
|
|
|
|
## target table id -> the thread's own colour "#hex" (missing = the theme's).
|
|
|
|
|
|
var pipe_color: Dictionary = {}
|
2026-11-10 19:02:46 -06:00
|
|
|
|
## The Book page this result is linked to ("" = none). Its text and details
|
|
|
|
|
|
## follow the page (TowerBoard.sync_page).
|
|
|
|
|
|
var page: String = ""
|
2026-11-10 19:06:55 -06:00
|
|
|
|
## target table id -> how repeated rolls combine: "sum", "max", "min" or
|
|
|
|
|
|
## "choose" (RollCombine). Missing = keep every roll.
|
|
|
|
|
|
var pipe_combine: Dictionary = {}
|
2026-11-10 19:10:11 -06:00
|
|
|
|
## target table id -> true: the roll waits before following this thread until
|
|
|
|
|
|
## the player continues (Roller.OP_PAUSE). Missing = no pause.
|
|
|
|
|
|
var pipe_pause: Dictionary = {}
|
2026-11-10 19:12:06 -06:00
|
|
|
|
## Choice options: what picking this costs (RollCosts): a value name and an
|
|
|
|
|
|
## amount (an expression). "" = free.
|
|
|
|
|
|
var cost_value: String = ""
|
|
|
|
|
|
var cost_amount: String = ""
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## Router cards: this case's condition. "" is the Otherwise case (always
|
|
|
|
|
|
## matches). Ignored on other kinds.
|
|
|
|
|
|
var when: String = ""
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
## Pick choices: the option is offered (in the pop-up and to Random) only when
|
|
|
|
|
|
## this expression is true when the card is reached. "" means always.
|
|
|
|
|
|
var show_if: String = ""
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var has_range: bool = false
|
|
|
|
|
|
var range_lo: int = 1
|
|
|
|
|
|
var range_hi: int = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init(p_id: String = "", p_text: String = "") -> void:
|
|
|
|
|
|
id = p_id
|
|
|
|
|
|
text = p_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## How many die faces this entry covers. Plain entries cover exactly one.
|
|
|
|
|
|
func span() -> int:
|
|
|
|
|
|
return range_hi - range_lo + 1 if has_range else 1
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## How many times the pipe to `target` rolls. An expression count reads as 1
|
|
|
|
|
|
## here; see count_expr() and count_value().
|
2026-11-08 12:11:43 -06:00
|
|
|
|
func count_for(target: String) -> int:
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
var c: Variant = pipe_count.get(target, 1)
|
|
|
|
|
|
if c is String:
|
|
|
|
|
|
return 1
|
|
|
|
|
|
return clampi(int(c), 1, MAX_PIPE_COUNT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The pipe's count expression, or "" when the count is a plain number.
|
|
|
|
|
|
func count_expr(target: String) -> String:
|
|
|
|
|
|
var c: Variant = pipe_count.get(target, 1)
|
|
|
|
|
|
return c if c is String else ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The count as typed: "3", or the expression ("@terms").
|
|
|
|
|
|
func count_text(target: String) -> String:
|
|
|
|
|
|
var e := count_expr(target)
|
|
|
|
|
|
return e if e != "" else str(count_for(target))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## How many times the pipe rolls in this roll: a plain count, or the
|
|
|
|
|
|
## expression evaluated now (0 and up; errors give 0). `log` (optional) gets an
|
|
|
|
|
|
## error line when the expression fails.
|
|
|
|
|
|
func count_value(target: String, ctx: RollContext, log: Array = []) -> int:
|
|
|
|
|
|
var e := count_expr(target)
|
|
|
|
|
|
if e == "":
|
|
|
|
|
|
return count_for(target)
|
|
|
|
|
|
var r := Expr.evaluate(e, ctx)
|
|
|
|
|
|
if r["error"] != "":
|
2026-11-10 18:24:23 -06:00
|
|
|
|
log.append({"text": "Thread count %s: %s" % [e, r["error"]], "error": true})
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
return 0
|
|
|
|
|
|
return clampi(Expr.as_int(r, 0), 0, MAX_EXPR_COUNT)
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Variable name the pipe to `target` saves into, or "".
|
|
|
|
|
|
func save_for(target: String) -> String:
|
|
|
|
|
|
return str(pipe_save.get(target, ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## Sets the count: an int (clamped 1..99), or a String that is either a whole
|
|
|
|
|
|
## number or an expression.
|
|
|
|
|
|
func set_pipe_count(target: String, n: Variant) -> void:
|
|
|
|
|
|
if n is String:
|
|
|
|
|
|
var s := (n as String).strip_edges()
|
|
|
|
|
|
if s == "" or s.is_valid_int():
|
|
|
|
|
|
n = s.to_int() if s != "" else 1
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_count[target] = s
|
|
|
|
|
|
return
|
|
|
|
|
|
if n is float:
|
|
|
|
|
|
n = int(n)
|
|
|
|
|
|
var k := clampi(int(n), 1, MAX_PIPE_COUNT)
|
|
|
|
|
|
if k == 1:
|
2026-11-08 12:11:43 -06:00
|
|
|
|
pipe_count.erase(target)
|
|
|
|
|
|
else:
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
pipe_count[target] = k
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## The pipe's condition, or "".
|
|
|
|
|
|
func when_for(target: String) -> String:
|
|
|
|
|
|
return str(pipe_when.get(target, ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## True when the pipe is an "otherwise" pipe (and has no condition).
|
|
|
|
|
|
func is_otherwise(target: String) -> bool:
|
|
|
|
|
|
return bool(pipe_otherwise.get(target, false)) and when_for(target) == ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## True when the pipe has a condition or is an otherwise pipe.
|
|
|
|
|
|
func is_conditional(target: String) -> bool:
|
|
|
|
|
|
return when_for(target) != "" or is_otherwise(target)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Sets the pipe's condition ("" for none). A condition clears "otherwise".
|
|
|
|
|
|
func set_pipe_when(target: String, expr: String) -> void:
|
|
|
|
|
|
expr = expr.strip_edges()
|
|
|
|
|
|
if expr == "":
|
|
|
|
|
|
pipe_when.erase(target)
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_when[target] = expr
|
|
|
|
|
|
pipe_otherwise.erase(target)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func set_pipe_otherwise(target: String, on: bool) -> void:
|
|
|
|
|
|
if on and when_for(target) == "":
|
|
|
|
|
|
pipe_otherwise[target] = true
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_otherwise.erase(target)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## True when any of this entry's pipes has a condition or is an otherwise pipe.
|
|
|
|
|
|
func has_conditional_pipes() -> bool:
|
|
|
|
|
|
for p in pipes:
|
|
|
|
|
|
if is_conditional(p):
|
|
|
|
|
|
return true
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## The pipe's input values: {input name: expression}, or {} (a copy).
|
|
|
|
|
|
func with_for(target: String) -> Dictionary:
|
|
|
|
|
|
var w: Variant = pipe_with.get(target)
|
|
|
|
|
|
return (w as Dictionary).duplicate() if w is Dictionary else {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Sets the pipe's input values ({} for none). Names are trimmed (a leading
|
|
|
|
|
|
## "@" dropped); empty names and empty expressions are left out; numbers
|
|
|
|
|
|
## become expression text.
|
|
|
|
|
|
func set_pipe_with(target: String, values: Variant) -> void:
|
|
|
|
|
|
var clean := {}
|
|
|
|
|
|
if values is Dictionary:
|
|
|
|
|
|
for k: Variant in values:
|
|
|
|
|
|
var nm := str(k).strip_edges().trim_prefix("@")
|
|
|
|
|
|
var ex := RollTable.expr_text(values[k], "").strip_edges()
|
|
|
|
|
|
if nm != "" and ex != "":
|
|
|
|
|
|
clean[nm] = ex
|
|
|
|
|
|
if clean.is_empty():
|
|
|
|
|
|
pipe_with.erase(target)
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_with[target] = clean
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
func set_pipe_save(target: String, name: String) -> void:
|
|
|
|
|
|
name = name.strip_edges()
|
|
|
|
|
|
if name == "":
|
|
|
|
|
|
pipe_save.erase(target)
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_save[target] = name
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## Adds a pipe if it isn't there already. `count` is an int or an expression.
|
|
|
|
|
|
func add_pipe(target: String, count: Variant = 1, save_as: String = "") -> void:
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if not pipes.has(target):
|
|
|
|
|
|
pipes.append(target)
|
|
|
|
|
|
set_pipe_count(target, count)
|
|
|
|
|
|
set_pipe_save(target, save_as)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 19:06:55 -06:00
|
|
|
|
## How a thread's repeated rolls combine (RollCombine.MODES).
|
|
|
|
|
|
func combine_for(target: String) -> String:
|
|
|
|
|
|
return str(pipe_combine.get(target, "all"))
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## Removes a pipe along with its options.
|
|
|
|
|
|
func remove_pipe(target: String) -> void:
|
|
|
|
|
|
pipes.erase(target)
|
|
|
|
|
|
pipe_count.erase(target)
|
|
|
|
|
|
pipe_save.erase(target)
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
pipe_when.erase(target)
|
|
|
|
|
|
pipe_otherwise.erase(target)
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
pipe_with.erase(target)
|
2026-11-10 18:20:46 -06:00
|
|
|
|
pipe_color.erase(target)
|
2026-11-10 19:06:55 -06:00
|
|
|
|
pipe_combine.erase(target)
|
2026-11-10 19:10:11 -06:00
|
|
|
|
pipe_pause.erase(target)
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func to_dict() -> Dictionary:
|
|
|
|
|
|
var d := {"id": id, "text": text}
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if details != "":
|
|
|
|
|
|
d["details"] = details
|
|
|
|
|
|
if weight != 1:
|
|
|
|
|
|
d["weight"] = weight
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
if effects != "":
|
|
|
|
|
|
d["effects"] = effects
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
if when.strip_edges() != "":
|
|
|
|
|
|
d["when"] = when.strip_edges()
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
if show_if.strip_edges() != "":
|
|
|
|
|
|
d["show_if"] = show_if.strip_edges()
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
if not pipes.is_empty():
|
2026-11-08 12:11:43 -06:00
|
|
|
|
var list: Array = []
|
|
|
|
|
|
for p in pipes:
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
var expr := count_expr(p)
|
2026-11-08 12:11:43 -06:00
|
|
|
|
var n := count_for(p)
|
|
|
|
|
|
var s := save_for(p)
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
var w := when_for(p)
|
|
|
|
|
|
var other := is_otherwise(p)
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
var wv: Variant = pipe_with.get(p)
|
2026-11-10 18:20:46 -06:00
|
|
|
|
var col := str(pipe_color.get(p, ""))
|
2026-11-10 19:06:55 -06:00
|
|
|
|
var comb := combine_for(p)
|
2026-11-10 19:10:11 -06:00
|
|
|
|
var paused := pipe_pause.has(p)
|
|
|
|
|
|
if expr == "" and n == 1 and s == "" and w == "" and not other and wv == null and col == "" and comb == "all" and not paused:
|
2026-11-08 12:11:43 -06:00
|
|
|
|
list.append(p)
|
|
|
|
|
|
else:
|
|
|
|
|
|
var po := {"table": p}
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
if expr != "":
|
|
|
|
|
|
po["count"] = expr
|
|
|
|
|
|
elif n != 1:
|
2026-11-08 12:11:43 -06:00
|
|
|
|
po["count"] = n
|
|
|
|
|
|
if s != "":
|
|
|
|
|
|
po["save_as"] = s
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
if w != "":
|
|
|
|
|
|
po["when"] = w
|
|
|
|
|
|
elif other:
|
|
|
|
|
|
po["otherwise"] = true
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
if wv is Dictionary and not (wv as Dictionary).is_empty():
|
|
|
|
|
|
po["with"] = (wv as Dictionary).duplicate()
|
2026-11-10 18:20:46 -06:00
|
|
|
|
if col != "":
|
|
|
|
|
|
po["color"] = col
|
2026-11-10 19:06:55 -06:00
|
|
|
|
if comb != "all":
|
|
|
|
|
|
po["combine"] = comb
|
2026-11-10 19:10:11 -06:00
|
|
|
|
if paused:
|
|
|
|
|
|
po["pause"] = true
|
2026-11-08 12:11:43 -06:00
|
|
|
|
list.append(po)
|
|
|
|
|
|
d["pipes"] = list
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
if has_range:
|
|
|
|
|
|
d["range"] = [range_lo, range_hi]
|
2026-11-10 19:02:46 -06:00
|
|
|
|
if page != "":
|
|
|
|
|
|
d["page"] = page
|
2026-11-10 19:12:06 -06:00
|
|
|
|
if cost_value.strip_edges() != "":
|
|
|
|
|
|
d["cost"] = {"value": cost_value.strip_edges(), "amount": cost_amount.strip_edges()}
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func from_dict(d: Dictionary) -> TableEntry:
|
|
|
|
|
|
var e := TableEntry.new(str(d.get("id", "")), str(d.get("text", "")))
|
2026-11-08 12:11:43 -06:00
|
|
|
|
e.details = str(d.get("details", ""))
|
|
|
|
|
|
e.weight = maxi(0, int(d.get("weight", 1)))
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
e.effects = str(d.get("effects", ""))
|
2026-11-10 19:02:46 -06:00
|
|
|
|
e.page = str(d.get("page", ""))
|
2026-11-10 19:12:06 -06:00
|
|
|
|
var cost: Variant = d.get("cost")
|
|
|
|
|
|
if cost is Dictionary:
|
|
|
|
|
|
e.cost_value = str(cost.get("value", ""))
|
|
|
|
|
|
e.cost_amount = str(cost.get("amount", ""))
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
e.when = str(d.get("when", "")).strip_edges() if d.get("when") != null else ""
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
e.show_if = str(d.get("show_if", "")).strip_edges() if d.get("show_if") != null else ""
|
2026-11-08 12:11:43 -06:00
|
|
|
|
for p: Variant in d.get("pipes", []):
|
|
|
|
|
|
if p is Dictionary:
|
|
|
|
|
|
var target := str(p.get("table", ""))
|
|
|
|
|
|
if target != "":
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
var c: Variant = p.get("count", 1)
|
|
|
|
|
|
e.add_pipe(target, c if c is String else int(c), str(p.get("save_as", "")))
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
e.set_pipe_when(target, str(p.get("when", "")) if p.get("when") != null else "")
|
|
|
|
|
|
e.set_pipe_otherwise(target, bool(p.get("otherwise", false)))
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
if p.get("with") is Dictionary:
|
|
|
|
|
|
e.set_pipe_with(target, p["with"])
|
2026-11-10 18:20:46 -06:00
|
|
|
|
if str(p.get("color", "")) != "":
|
|
|
|
|
|
e.pipe_color[target] = str(p["color"])
|
2026-11-10 19:06:55 -06:00
|
|
|
|
if RollCombine.MODES.has(str(p.get("combine", "all"))) and str(p.get("combine", "all")) != "all":
|
|
|
|
|
|
e.pipe_combine[target] = str(p["combine"])
|
2026-11-10 19:10:11 -06:00
|
|
|
|
if bool(p.get("pause", false)):
|
|
|
|
|
|
e.pipe_pause[target] = true
|
2026-11-08 12:11:43 -06:00
|
|
|
|
elif str(p) != "":
|
|
|
|
|
|
e.add_pipe(str(p))
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var r: Variant = d.get("range")
|
|
|
|
|
|
if r is Array and r.size() == 2:
|
|
|
|
|
|
e.has_range = true
|
|
|
|
|
|
e.range_lo = int(r[0])
|
|
|
|
|
|
e.range_hi = int(r[1])
|
|
|
|
|
|
return e
|