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 TowerBoard
|
|
|
|
|
extends RefCounted
|
2026-11-08 12:11:26 -06:00
|
|
|
## A collection: every table on the board, plus loading and saving as JSON.
|
|
|
|
|
## Files carry a format_version; older versions are upgraded by migrate().
|
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
|
|
|
|
2026-11-08 12:11:26 -06:00
|
|
|
const SAVE_PATH := "user://board.json" # The single-board file of format version 1.
|
|
|
|
|
const FORMAT_VERSION := 2
|
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
|
|
|
|
|
|
|
|
static var _counter: int = 0
|
|
|
|
|
static var _salt: String = ""
|
|
|
|
|
|
2026-11-08 12:11:26 -06:00
|
|
|
## Stable slug used as the file name and as the key for local state.
|
|
|
|
|
var id: String = ""
|
|
|
|
|
## Display name; free to change.
|
|
|
|
|
var name: 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 tables: Array[RollTable] = []
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
## Group cards (frames around blocks of tables). Optional; a table is in at
|
|
|
|
|
## most one group. See TableGroup.
|
|
|
|
|
var groups: Array[TableGroup] = []
|
2026-11-10 19:02:46 -06:00
|
|
|
## The Book: reusable results (Pages) for this spread.
|
|
|
|
|
var book: Array[BookPage] = []
|
Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.
Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
|
|
|
## Pictures: id -> base64 data (BoardImages). Only used ones are saved.
|
|
|
|
|
var images: Dictionary = {}
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
static func new_id(prefix: String) -> String:
|
|
|
|
|
if _salt == "":
|
|
|
|
|
_salt = "%x" % (int(Time.get_unix_time_from_system()) % 0xfffff)
|
|
|
|
|
_counter += 1
|
|
|
|
|
return "%s%s_%d" % [prefix, _salt, _counter]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_table(id: String) -> RollTable:
|
|
|
|
|
for t in tables:
|
|
|
|
|
if t.id == id:
|
|
|
|
|
return t
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
## Removes a table, every pipe that pointed at it and its group membership.
|
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 remove_table(id: String) -> void:
|
|
|
|
|
for i in range(tables.size() - 1, -1, -1):
|
|
|
|
|
if tables[i].id == id:
|
|
|
|
|
tables.remove_at(i)
|
|
|
|
|
for t in tables:
|
|
|
|
|
for e in t.entries:
|
|
|
|
|
e.pipes.erase(id)
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
for g in groups:
|
|
|
|
|
g.members.erase(id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Groups ----------
|
|
|
|
|
|
|
|
|
|
func get_group(gid: String) -> TableGroup:
|
|
|
|
|
for g in groups:
|
|
|
|
|
if g.id == gid:
|
|
|
|
|
return g
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The group a table belongs to, or null.
|
|
|
|
|
func group_of(table_id: String) -> TableGroup:
|
|
|
|
|
for g in groups:
|
|
|
|
|
if g.members.has(table_id):
|
|
|
|
|
return g
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:47:05 -06:00
|
|
|
## True when the table is hidden inside a collapsed group (at any depth).
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
func is_hidden(table_id: String) -> bool:
|
|
|
|
|
var g := group_of(table_id)
|
2026-11-10 18:47:05 -06:00
|
|
|
while g != null:
|
|
|
|
|
if g.collapsed:
|
|
|
|
|
return true
|
|
|
|
|
g = get_group(g.parent)
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 19:02:46 -06:00
|
|
|
# ----- The Book (reusable results) -----
|
|
|
|
|
|
|
|
|
|
func book_list() -> Array:
|
|
|
|
|
var out: Array = []
|
|
|
|
|
for p in book:
|
|
|
|
|
out.append(p.to_dict())
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func load_book(src: Variant) -> void:
|
|
|
|
|
var pages: Array[BookPage] = []
|
|
|
|
|
if src is Array:
|
|
|
|
|
for v: Variant in src:
|
|
|
|
|
if v is Dictionary:
|
|
|
|
|
var p := BookPage.from_dict(v)
|
|
|
|
|
if p.id == "":
|
|
|
|
|
p.id = new_id("p")
|
|
|
|
|
pages.append(p)
|
|
|
|
|
book = pages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_page(pid: String) -> BookPage:
|
|
|
|
|
for p in book:
|
|
|
|
|
if p.id == pid:
|
|
|
|
|
return p
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.
Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
|
|
|
## The texture of a stored picture, or null.
|
|
|
|
|
func picture(id: String) -> Texture2D:
|
|
|
|
|
return BoardImages.texture(id, str(images.get(id, "")))
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 19:02:46 -06:00
|
|
|
func add_page(text: String, details: String = "") -> BookPage:
|
|
|
|
|
var p := BookPage.new()
|
|
|
|
|
p.id = new_id("p")
|
|
|
|
|
p.text = text
|
|
|
|
|
p.details = details
|
|
|
|
|
book.append(p)
|
|
|
|
|
return p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Deletes a page; results linked to it keep their text and become ordinary.
|
|
|
|
|
func remove_page(pid: String) -> void:
|
|
|
|
|
for t in tables:
|
|
|
|
|
for e in t.entries:
|
|
|
|
|
if e.page == pid:
|
|
|
|
|
e.page = ""
|
|
|
|
|
book = book.filter(func(p: BookPage) -> bool: return p.id != pid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Links a result to a page and copies the page's text and details onto it.
|
|
|
|
|
func link_page(e: TableEntry, pid: String) -> void:
|
|
|
|
|
var p := get_page(pid)
|
|
|
|
|
if p:
|
|
|
|
|
e.page = pid
|
|
|
|
|
e.text = p.text
|
|
|
|
|
e.details = p.details
|
Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.
Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
|
|
|
e.image = p.image
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Copies a page onto every result linked to it. Returns the tables touched.
|
|
|
|
|
func sync_page(pid: String) -> Array[String]:
|
|
|
|
|
var p := get_page(pid)
|
|
|
|
|
var touched: Array[String] = []
|
|
|
|
|
if p == null:
|
|
|
|
|
return touched
|
|
|
|
|
for t in tables:
|
|
|
|
|
for e in t.entries:
|
|
|
|
|
if e.page == pid:
|
|
|
|
|
e.text = p.text
|
|
|
|
|
e.details = p.details
|
Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.
Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
|
|
|
e.image = p.image
|
2026-11-10 19:02:46 -06:00
|
|
|
if not touched.has(t.id):
|
|
|
|
|
touched.append(t.id)
|
|
|
|
|
return touched
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## How many results are linked to a page.
|
|
|
|
|
func page_uses(pid: String) -> int:
|
|
|
|
|
var n := 0
|
|
|
|
|
for t in tables:
|
|
|
|
|
for e in t.entries:
|
|
|
|
|
if e.page == pid:
|
|
|
|
|
n += 1
|
|
|
|
|
return n
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:47:05 -06:00
|
|
|
# ----- Nested groups -----
|
|
|
|
|
|
|
|
|
|
func child_groups(gid: String) -> Array[TableGroup]:
|
|
|
|
|
var out: Array[TableGroup] = []
|
|
|
|
|
for g in groups:
|
|
|
|
|
if g.parent == gid and gid != "":
|
|
|
|
|
out.append(g)
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Every table inside a group, its inner groups' tables included.
|
|
|
|
|
func tables_in(gid: String) -> Array[String]:
|
|
|
|
|
var out: Array[String] = []
|
|
|
|
|
var g := get_group(gid)
|
|
|
|
|
if g == null:
|
|
|
|
|
return out
|
|
|
|
|
out.append_array(g.members)
|
|
|
|
|
for c in child_groups(gid):
|
|
|
|
|
out.append_array(tables_in(c.id))
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The group and every group inside it, outermost first.
|
|
|
|
|
func groups_in(gid: String) -> Array[TableGroup]:
|
|
|
|
|
var out: Array[TableGroup] = []
|
|
|
|
|
var g := get_group(gid)
|
|
|
|
|
if g == null:
|
|
|
|
|
return out
|
|
|
|
|
out.append(g)
|
|
|
|
|
for c in child_groups(gid):
|
|
|
|
|
out.append_array(groups_in(c.id))
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The outermost collapsed group around `g` (not `g` itself), or null when
|
|
|
|
|
## nothing around it is collapsed.
|
|
|
|
|
func hidden_by(g: TableGroup) -> TableGroup:
|
|
|
|
|
var out: TableGroup = null
|
|
|
|
|
var p := get_group(g.parent)
|
|
|
|
|
while p != null:
|
|
|
|
|
if p.collapsed:
|
|
|
|
|
out = p
|
|
|
|
|
p = get_group(p.parent)
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## How many groups `g` sits inside.
|
|
|
|
|
func depth_of(g: TableGroup) -> int:
|
|
|
|
|
var n := 0
|
|
|
|
|
var p := get_group(g.parent)
|
|
|
|
|
while p != null and n < groups.size():
|
|
|
|
|
n += 1
|
|
|
|
|
p = get_group(p.parent)
|
|
|
|
|
return n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Puts group `gid` inside `parent_id` ("" = the spread). False when that would
|
|
|
|
|
## put a group inside itself.
|
|
|
|
|
func set_group_parent(gid: String, parent_id: String) -> bool:
|
|
|
|
|
var g := get_group(gid)
|
|
|
|
|
if g == null:
|
|
|
|
|
return false
|
|
|
|
|
var p := get_group(parent_id)
|
|
|
|
|
while p != null:
|
|
|
|
|
if p.id == gid:
|
|
|
|
|
return false
|
|
|
|
|
p = get_group(p.parent)
|
|
|
|
|
g.parent = parent_id
|
|
|
|
|
return true
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Makes a group of the given tables (taking them out of any other group).
|
|
|
|
|
func add_group(gname: String, member_ids: Array, gid: String = "") -> TableGroup:
|
|
|
|
|
var g := TableGroup.new(gid if gid != "" else new_id("g"), gname)
|
|
|
|
|
groups.append(g)
|
|
|
|
|
for tid: Variant in member_ids:
|
|
|
|
|
add_to_group(str(tid), g.id)
|
|
|
|
|
return g
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Puts a table in a group, taking it out of its old one. False if either is missing.
|
|
|
|
|
func add_to_group(table_id: String, gid: String) -> bool:
|
|
|
|
|
var g := get_group(gid)
|
|
|
|
|
if g == null or get_table(table_id) == null:
|
|
|
|
|
return false
|
|
|
|
|
var old := group_of(table_id)
|
|
|
|
|
if old == g:
|
|
|
|
|
return true
|
|
|
|
|
if old:
|
|
|
|
|
old.members.erase(table_id)
|
|
|
|
|
g.members.append(table_id)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func remove_from_group(table_id: String) -> void:
|
|
|
|
|
var g := group_of(table_id)
|
|
|
|
|
if g:
|
|
|
|
|
g.members.erase(table_id)
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:47:05 -06:00
|
|
|
## Removes the group only; its cards and inner groups move up to the group
|
|
|
|
|
## around it (or onto the spread).
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
func ungroup(gid: String) -> void:
|
2026-11-10 18:47:05 -06:00
|
|
|
var g := get_group(gid)
|
|
|
|
|
if g == null:
|
|
|
|
|
return
|
|
|
|
|
var outer := get_group(g.parent)
|
|
|
|
|
for c in child_groups(gid):
|
|
|
|
|
c.parent = g.parent
|
|
|
|
|
if outer:
|
|
|
|
|
for tid in g.members:
|
|
|
|
|
if not outer.members.has(tid):
|
|
|
|
|
outer.members.append(tid)
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
for i in range(groups.size() - 1, -1, -1):
|
|
|
|
|
if groups[i].id == gid:
|
|
|
|
|
groups.remove_at(i)
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:47:05 -06:00
|
|
|
## Removes the group, its inner groups and every table in them. Returns the
|
|
|
|
|
## removed table ids.
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
func delete_group(gid: String) -> Array[String]:
|
|
|
|
|
var gone: Array[String] = []
|
2026-11-10 18:47:05 -06:00
|
|
|
if get_group(gid) == null:
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
return gone
|
2026-11-10 18:47:05 -06:00
|
|
|
gone.assign(tables_in(gid))
|
|
|
|
|
for inner in groups_in(gid):
|
|
|
|
|
groups.erase(inner)
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
for tid in gone:
|
|
|
|
|
remove_table(tid)
|
|
|
|
|
return gone
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:47:05 -06:00
|
|
|
## Moves a group's frame, its inner groups and every table in them by `delta`.
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
func move_group(gid: String, delta: Vector2) -> void:
|
2026-11-10 18:47:05 -06:00
|
|
|
for g in groups_in(gid):
|
|
|
|
|
g.position += delta
|
|
|
|
|
for tid in g.members:
|
|
|
|
|
var t := get_table(tid)
|
|
|
|
|
if t:
|
|
|
|
|
t.position += delta
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Drops members that aren't tables, keeps each table in its first group only,
|
|
|
|
|
## and gives groups unique ids. Empty groups are kept (they can be refilled).
|
|
|
|
|
func clean_groups() -> void:
|
|
|
|
|
var ids := {}
|
|
|
|
|
for t in tables:
|
|
|
|
|
ids[t.id] = true
|
|
|
|
|
var taken := {}
|
|
|
|
|
var gids := {}
|
|
|
|
|
for g in groups:
|
|
|
|
|
if g.id == "" or gids.has(g.id):
|
|
|
|
|
g.id = new_id("g")
|
|
|
|
|
gids[g.id] = true
|
|
|
|
|
var keep: Array[String] = []
|
|
|
|
|
for m in g.members:
|
|
|
|
|
if ids.has(m) and not taken.has(m):
|
|
|
|
|
taken[m] = true
|
|
|
|
|
keep.append(m)
|
|
|
|
|
g.members = keep
|
2026-11-10 18:47:05 -06:00
|
|
|
# Parents must exist and never loop back.
|
|
|
|
|
for g in groups:
|
|
|
|
|
if g.parent != "" and (not gids.has(g.parent) or g.parent == g.id):
|
|
|
|
|
g.parent = ""
|
|
|
|
|
for g in groups:
|
|
|
|
|
var seen := {g.id: true}
|
|
|
|
|
var p := get_group(g.parent)
|
|
|
|
|
while p != null:
|
|
|
|
|
if seen.has(p.id):
|
|
|
|
|
g.parent = ""
|
|
|
|
|
break
|
|
|
|
|
seen[p.id] = true
|
|
|
|
|
p = get_group(p.parent)
|
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
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:26 -06:00
|
|
|
## Upgrades a parsed file to FORMAT_VERSION, one version step at a time.
|
|
|
|
|
## To add a version, bump FORMAT_VERSION and add a _migrate_N_to_N1 step here.
|
|
|
|
|
static func migrate(d: Dictionary) -> Dictionary:
|
|
|
|
|
var v: int = int(d.get("format_version", 1))
|
|
|
|
|
while v < FORMAT_VERSION:
|
|
|
|
|
match v:
|
|
|
|
|
1:
|
|
|
|
|
d = _migrate_1_to_2(d)
|
|
|
|
|
_:
|
|
|
|
|
break
|
|
|
|
|
v += 1
|
|
|
|
|
d["format_version"] = v
|
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Version 1 had no id or name; they are filled in by whoever imports the file.
|
|
|
|
|
static func _migrate_1_to_2(d: Dictionary) -> Dictionary:
|
|
|
|
|
d["format_version"] = 2
|
|
|
|
|
if not d.has("id"):
|
|
|
|
|
d["id"] = ""
|
|
|
|
|
if not d.has("name"):
|
|
|
|
|
d["name"] = ""
|
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
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 list: Array = []
|
|
|
|
|
for t in tables:
|
|
|
|
|
list.append(t.to_dict())
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
var d := {"format_version": FORMAT_VERSION, "id": id, "name": name, "tables": list}
|
|
|
|
|
if not groups.is_empty():
|
|
|
|
|
var gl: Array = []
|
|
|
|
|
for g in groups:
|
|
|
|
|
gl.append(g.to_dict())
|
|
|
|
|
d["groups"] = gl
|
2026-11-10 19:02:46 -06:00
|
|
|
if not book.is_empty():
|
|
|
|
|
d["book"] = book_list()
|
Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.
Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
|
|
|
var pics := BoardImages.used(self)
|
|
|
|
|
if not pics.is_empty():
|
|
|
|
|
d["images"] = pics
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
return d
|
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_json() -> String:
|
|
|
|
|
return JSON.stringify(to_dict(), " ")
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:26 -06:00
|
|
|
## Replaces the board's tables (and id/name, when the text has them) from JSON
|
|
|
|
|
## text of any known version. Returns false if the text isn't a board.
|
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 load_json(text: String) -> bool:
|
|
|
|
|
var parsed: Variant = JSON.parse_string(text)
|
|
|
|
|
if not (parsed is Dictionary) or not (parsed.get("tables") is Array):
|
|
|
|
|
return false
|
2026-11-08 12:11:26 -06:00
|
|
|
return load_dict(parsed as Dictionary)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Same as load_json for an already parsed Dictionary.
|
|
|
|
|
func load_dict(src: Dictionary) -> bool:
|
|
|
|
|
if not (src.get("tables") is Array):
|
|
|
|
|
return false
|
|
|
|
|
var d: Dictionary = migrate(src.duplicate())
|
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 loaded: Array[RollTable] = []
|
2026-11-08 12:11:26 -06:00
|
|
|
for td in d["tables"]:
|
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 td is Dictionary:
|
|
|
|
|
loaded.append(RollTable.from_dict(td))
|
|
|
|
|
tables = loaded
|
Group cards and templates
Groups: an optional groups list on a collection (frame rect, collapsed,
members, details), saved by TowerBoard and kept by JsonIO. Expanded groups
draw a frame behind their cards with a title bar; collapsed ones become one
compact card that lists the members' lit results, with pipes re-routed to
its inlet and right edge. Build mode adds multi-select (Ctrl/Shift-click,
Ctrl-drag), Group (Ctrl+G), drop in/out of frames, rename, ungroup, delete
with undo and a details editor.
Templates: TemplateKit saves cards, groups or selections with relative
positions, internal pipes and outside pipes by name, detects {$name}
parameters and inserts with fresh ids. TemplateLibrary keeps user templates
in user://templates and lists the built-in ones in templates/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:01:34 -06:00
|
|
|
var loaded_groups: Array[TableGroup] = []
|
|
|
|
|
var src_groups: Variant = d.get("groups", [])
|
|
|
|
|
if src_groups is Array:
|
|
|
|
|
for gd: Variant in src_groups:
|
|
|
|
|
if gd is Dictionary:
|
|
|
|
|
loaded_groups.append(TableGroup.from_dict(gd))
|
|
|
|
|
groups = loaded_groups
|
|
|
|
|
clean_groups()
|
2026-11-10 19:02:46 -06:00
|
|
|
load_book(d.get("book", []))
|
Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.
Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
|
|
|
# Undo snapshots carry no pictures: keep the ones already loaded.
|
|
|
|
|
if d.get("images") is Dictionary:
|
|
|
|
|
images.merge(d["images"], true)
|
2026-11-08 12:11:26 -06:00
|
|
|
if str(d.get("id", "")) != "":
|
|
|
|
|
id = str(d["id"])
|
|
|
|
|
if str(d.get("name", "")) != "":
|
|
|
|
|
name = str(d["name"])
|
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 true
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:26 -06:00
|
|
|
## Writes text to path via a temp file and a rename, so a crash can't leave a
|
|
|
|
|
## half-written file. Creates the folder if needed.
|
|
|
|
|
static func write_text_atomic(path: String, text: String) -> Error:
|
|
|
|
|
var dir := path.get_base_dir()
|
|
|
|
|
if not DirAccess.dir_exists_absolute(dir):
|
|
|
|
|
var mk := DirAccess.make_dir_recursive_absolute(dir)
|
|
|
|
|
if mk != OK:
|
|
|
|
|
return mk
|
|
|
|
|
var tmp := path + ".tmp"
|
|
|
|
|
var f := FileAccess.open(tmp, FileAccess.WRITE)
|
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 f == null:
|
2026-11-08 12:11:26 -06:00
|
|
|
return FileAccess.get_open_error()
|
|
|
|
|
f.store_string(text)
|
|
|
|
|
var werr := f.get_error()
|
|
|
|
|
f.close()
|
|
|
|
|
if werr != OK:
|
|
|
|
|
DirAccess.remove_absolute(tmp)
|
|
|
|
|
return werr
|
|
|
|
|
var err := DirAccess.rename_absolute(tmp, path)
|
|
|
|
|
if err != OK and FileAccess.file_exists(path):
|
|
|
|
|
# Some platforms won't rename over an existing file.
|
|
|
|
|
DirAccess.remove_absolute(path)
|
|
|
|
|
err = DirAccess.rename_absolute(tmp, path)
|
|
|
|
|
if err != OK:
|
|
|
|
|
DirAccess.remove_absolute(tmp)
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func save(path: String = SAVE_PATH) -> bool:
|
|
|
|
|
var err := write_text_atomic(path, to_json())
|
|
|
|
|
if err != OK:
|
2026-11-10 18:24:23 -06:00
|
|
|
push_warning("Couldn't save the spread to %s: %s" % [path, error_string(err)])
|
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 false
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:26 -06:00
|
|
|
## Loads a board file, or returns null if there isn't a usable one.
|
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
|
|
|
static func load_saved(path: String = SAVE_PATH) -> TowerBoard:
|
|
|
|
|
if not FileAccess.file_exists(path):
|
|
|
|
|
return null
|
|
|
|
|
var b := TowerBoard.new()
|
|
|
|
|
if not b.load_json(FileAccess.get_file_as_string(path)) or b.tables.is_empty():
|
|
|
|
|
return null
|
|
|
|
|
return b
|