Follow a shelf edit
- Receive an action. Read a chosen package, an instruction to clear a slot or a tile selection.
- Check the rules. Check that the shelf index exists and that placing the miniature stays within the available stock.
- Apply the action. Update the chosen slot, then recalculate stock from the shelf.
- Refresh the studio. Show the shelf, current stock and the latest clue feedback. A completed brief unlocks progress on this device.
Find a display that follows every clue
The solver starts with a copy of the shelf and calculates how many of each piece remain. It starts with the slots that name a required product. At each open slot the solver tries an available piece, checks whether all clues could still be met, then tries the next slot. When a branch fails, it removes the attempted piece and puts it back into the trial stock. When it reaches the end, the hint can compare the answer with the real shelf and suggest one change.
Try the process on two empty slots. Put a drink in the first slot, then check a clue that asks for a craft product there. That guess fails immediately. Put the drink back into stock and try Pocket Paints before continuing to the next slot.
GDScript line by line
Follow the line numbers, including the indent at the start of each line. Find the code the game will run first, then look for the function that reacts when you tap or change something.
Read scripts/brief_catalog.gd line by line
-
extends RefCountedStarts with Godot's RefCounted type. This script gets the abilities of that type and adds the game's own rules. -
const MANIFEST := "res://levels/briefs.json"Creates a constant named MANIFEST. The expression uses the text inside the quotes. Godot infers the type from the first value. -
const Rules = preload("res://scripts/shelf_rules.gd")Creates a constant named Rules. The expression prepares a resource at a fixed project path when the script is loaded. -
static func read(path: String = MANIFEST) -> Array[Dictionary]:Defines read, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var catalog: Array[Dictionary] = []Creates a variable named catalog. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
if not FileAccess.file_exists(path):Checks not FileAccess.file_exists(path). The indented instructions below run only if this test passes. -
push_error("Display brief file is missing.")Reports an error message to help you find a problem. -
return catalogFinishes the function and hands its result back to the caller. The expression reads catalog. -
var decoded: Variant = JSON.parse_string(FileAccess.get_file_as_string(path))Creates a variable named decoded. The expression tries to turn JSON text back into a value. The type after the colon says what kind of value it can hold. -
if not (decoded is Array):Checks not (decoded is Array). The indented instructions below run only if this test passes. -
push_error("Display briefs need a JSON array.")Reports an error message to help you find a problem. -
return catalogFinishes the function and hands its result back to the caller. The expression reads catalog. -
var ids := {}Creates a variable named ids. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value. -
for entry in decoded:Repeats the indented instructions for each value in decoded. -
if not (entry is Dictionary) or not Rules.valid_brief(entry):Checks not (entry is Dictionary) or not Rules.valid_brief(entry). The indented instructions below run only if this test passes. -
push_error("A display brief has an invalid map, stock or clue.")Reports an error message to help you find a problem. -
return []Finishes the function and hands its result back to the caller. The expression makes a list whose items keep their order. -
if ids.has(entry.id):Checks ids.has(entry.id). The indented instructions below run only if this test passes. -
push_error("Display brief IDs must be unique: " + str(entry.id))Reports an error message to help you find a problem. -
return []Finishes the function and hands its result back to the caller. The expression makes a list whose items keep their order. -
for index in range(entry.active.size()):Repeats the indented instructions for each value in range(entry.active.size()). -
entry.active[index] = int(entry.active[index])Stores the new value in entry.active[index]. The expression converts a suitable value to a whole number. -
ids[entry.id] = trueStores the new value in ids[entry.id]. The expression uses the yes-or-no value true. -
catalog.append(entry)Adds an item to the end of a list. -
return catalogFinishes the function and hands its result back to the caller. The expression reads catalog.
Read scripts/catalog.gd line by line
-
extends RefCountedStarts with Godot's RefCounted type. This script gets the abilities of that type and adds the game's own rules. -
const PRODUCTS := {Creates a constant named PRODUCTS. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value. -
"lemon_fizz": {"name": "Lemon Fizz", "category": "drinks", "tag": "FIZZ", "colour": "#f6c449", "ink": "#312749", "shape": "can", "symbol": "sun", "detail": "A sunny citrus can with a pull tab and a tiny slice of lemon on the front."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"moon_milk": {"name": "Moon Milk", "category": "drinks", "tag": "MOON", "colour": "#87a6e9", "ink": "#172447", "shape": "carton", "symbol": "moon", "detail": "A blue gable-top carton with a crescent that curves like a milk splash."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"berry_brew": {"name": "Berry Brew", "category": "drinks", "tag": "BERRY", "colour": "#d897c5", "ink": "#462444", "shape": "bottle", "symbol": "berries", "detail": "A short berry bottle with a plum cap and three printed berries."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"jam_toast": {"name": "Jam Toast", "category": "snacks", "tag": "JAM", "colour": "#ec967e", "ink": "#431f38", "shape": "box", "symbol": "heart", "detail": "A breakfast box with a painted jam heart and a warm toast-coloured flap."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"comet_crisps": {"name": "Comet Crisps", "category": "snacks", "tag": "COMET", "colour": "#96c4ec", "ink": "#232c58", "shape": "bag", "symbol": "star", "detail": "A crimped crisp packet with a star that looks as though it has just landed."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"honey_hoops": {"name": "Honey Hoops", "category": "snacks", "tag": "HOOPS", "colour": "#f2bb72", "ink": "#432e22", "shape": "box", "symbol": "rings", "detail": "A tall honey-coloured cereal box with two rings stamped on the label."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"rainbow_soap": {"name": "Rainbow Soap", "category": "care", "tag": "SOAP", "colour": "#f0a9ba", "ink": "#4e2648", "shape": "pouch", "symbol": "rainbow", "detail": "A flatter wrapper with three little stripes over a cream label."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"mint_paste": {"name": "Mint Paste", "category": "care", "tag": "MINT", "colour": "#8bd4bc", "ink": "#123d3a", "shape": "tube", "symbol": "leaf", "detail": "A green squeeze tube with a narrow cap and a dark mint-leaf mark."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"cloud_cream": {"name": "Cloud Cream", "category": "care", "tag": "CLOUD", "colour": "#c4b6e4", "ink": "#352650", "shape": "jar", "symbol": "cloud", "detail": "A low lilac jar with a wide lid and a little three-puff cloud on the label."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"pocket_paints": {"name": "Pocket Paints", "category": "crafts", "tag": "PAINTS", "colour": "#f1b8a0", "ink": "#42263c", "shape": "tin", "symbol": "dots", "detail": "A compact paint tin with three sample colours printed across the lid."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"star_stickers": {"name": "Star Stickers", "category": "crafts", "tag": "STARS", "colour": "#f1d683", "ink": "#3f304e", "shape": "pouch", "symbol": "star", "detail": "A small hanging envelope with a shining star in the centre."},Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"pebble_pencils": {"name": "Pebble Pencils", "category": "crafts", "tag": "PENCIL", "colour": "#a7c7a5", "ink": "#273a39", "shape": "carton", "symbol": "pencil", "detail": "A slim green carton with a short pencil mark and a fold along the top."}Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
}Closes the parentheses, list or dictionary opened above. Any trailing comma separates this item from the next. -
const CHAPTERS := ["First Displays", "Colour & Craft", "Collector’s Showcase"]Creates a constant named CHAPTERS. The expression makes a list whose items keep their order. Godot infers the type from the first value. -
const CATEGORIES := ["drinks", "snacks", "care", "crafts"]Creates a constant named CATEGORIES. The expression makes a list whose items keep their order. Godot infers the type from the first value. -
static func name_for(id: String) -> String:Defines name for, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if id.is_empty():Checks id.is_empty(). The indented instructions below run only if this test passes. -
return "Empty slot"Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
return str(PRODUCTS.get(id, {}).get("name", "Unknown package"))Finishes the function and hands its result back to the caller. The expression turns a value into text for a player message. -
static func category_of(id: String) -> String:Defines category of, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
return str(PRODUCTS.get(id, {}).get("category", ""))Finishes the function and hands its result back to the caller. The expression turns a value into text for a player message.
Read scripts/pack_piece.gd line by line
-
extends ControlStarts with Godot's Control type. This script gets the abilities of that type and adds the game's own rules. -
const Catalog = preload("res://scripts/catalog.gd")Creates a constant named Catalog. The expression prepares a resource at a fixed project path when the script is loaded. -
const CREAM := Color("#fff3d5")Creates a constant named CREAM. The expression builds a colour from these values. Godot infers the type from the first value. -
var product := ""Creates a variable named product. The expression uses the text inside the quotes. Godot infers the type from the first value. -
func use_product(value: String) -> void:Defines use product, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
product = valueStores the new value in product. The expression reads value. -
queue_redraw()Asks Godot to call _draw again on a later frame so the screen matches the new state. -
func _ready() -> void:Godot calls this once after the scene and its children are ready. Use it to set up the room and connect controls. -
mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
func _draw() -> void:Godot calls this when the node needs drawing. The instructions inside paint the current state. -
if not Catalog.PRODUCTS.has(product):Checks not Catalog.PRODUCTS.has(product). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
var obj: Dictionary = Catalog.PRODUCTS[product]Creates a variable named obj. The expression looks up the item or key written between the square brackets. The type after the colon says what kind of value it can hold. -
var colour := Color(obj.colour)Creates a variable named colour. The expression builds a colour from these values. Godot infers the type from the first value. -
var ink := Color(obj.ink)Creates a variable named ink. The expression builds a colour from these values. Godot infers the type from the first value. -
var scale_factor := minf(size.x / 66.0, size.y / 79.0)Creates a variable named scale_factor. The expression calls minf with the values in its parentheses. Godot infers the type from the first value. -
var origin := (size - Vector2(66, 79) * scale_factor) / 2.0Creates a variable named origin. The expression calculates a new value from the expressions on either side of the operator. Godot infers the type from the first value. -
draw_set_transform(origin, 0.0, Vector2.ONE * scale_factor)Calls draw_set_transform with the values in its parentheses. -
pill(Rect2(8, 72, 51, 6), Color(0.15, 0.08, 0.21, 0.32), 3)Calls pill with the values in its parentheses. -
match obj.shape:Compares obj.shape to the patterns below and runs the first matching branch. -
"can":Starts the instructions for this branch. The indented lines belong together. -
pill(Rect2(12, 5, 43, 67), colour, 10)Calls pill with the values in its parentheses. -
pill(Rect2(13, 5, 40, 7), CREAM, 4)Calls pill with the values in its parentheses. -
pill(Rect2(13, 65, 41, 7), colour.darkened(0.21), 4)Calls pill with the values in its parentheses. -
pill(Rect2(43, 14, 8, 49), colour.darkened(0.13), 4)Calls pill with the values in its parentheses. -
pill(Rect2(23, 6, 14, 2), Color("#a69aa4"), 1)Calls pill with the values in its parentheses. -
"carton":Starts the instructions for this branch. The indented lines belong together. -
draw_colored_polygon(PackedVector2Array([Vector2(12, 20), Vector2(21, 4), Vector2(42, 4), Vector2(55, 20), Vector2(55, 70), Vector2(12, 70)]), colour)Calls draw_colored_polygon with the values in its parentheses. -
draw_colored_polygon(PackedVector2Array([Vector2(12, 20), Vector2(21, 4), Vector2(42, 4), Vector2(45, 20)]), colour.lightened(0.36))Calls draw_colored_polygon with the values in its parentheses. -
draw_rect(Rect2(43, 20, 12, 50), colour.darkened(0.16))Paints a rectangle at the given position and size. -
pill(Rect2(19, 6, 18, 3), CREAM, 1)Calls pill with the values in its parentheses. -
"bottle":Starts the instructions for this branch. The indented lines belong together. -
pill(Rect2(22, 4, 22, 10), ink, 3)Calls pill with the values in its parentheses. -
pill(Rect2(25, 12, 17, 13), colour.lightened(0.28), 4)Calls pill with the values in its parentheses. -
pill(Rect2(11, 21, 45, 50), colour, 11)Calls pill with the values in its parentheses. -
pill(Rect2(45, 31, 7, 33), colour.darkened(0.15), 3)Calls pill with the values in its parentheses. -
"box":Starts the instructions for this branch. The indented lines belong together. -
pill(Rect2(9, 6, 47, 65), colour, 5)Calls pill with the values in its parentheses. -
draw_rect(Rect2(46, 9, 10, 59), colour.darkened(0.16))Paints a rectangle at the given position and size. -
draw_line(Vector2(13, 13), Vector2(43, 13), colour.lightened(0.38), 2, true)Paints a line between two points with the chosen colour and width. -
"bag":Starts the instructions for this branch. The indented lines belong together. -
draw_colored_polygon(PackedVector2Array([Vector2(6, 7), Vector2(58, 7), Vector2(52, 22), Vector2(57, 67), Vector2(8, 71), Vector2(12, 51), Vector2(10, 21)]), colour)Calls draw_colored_polygon with the values in its parentheses. -
pill(Rect2(7, 7, 49, 6), colour.darkened(0.17), 2)Calls pill with the values in its parentheses. -
pill(Rect2(10, 64, 45, 6), colour.lightened(0.38), 2)Calls pill with the values in its parentheses. -
"tube":Starts the instructions for this branch. The indented lines belong together. -
draw_colored_polygon(PackedVector2Array([Vector2(10, 6), Vector2(55, 6), Vector2(44, 60), Vector2(22, 60)]), colour)Calls draw_colored_polygon with the values in its parentheses. -
pill(Rect2(10, 5, 45, 6), colour.lightened(0.38), 2)Calls pill with the values in its parentheses. -
pill(Rect2(21, 59, 25, 12), ink, 3)Calls pill with the values in its parentheses. -
"jar", "tin":Starts the instructions for this branch. The indented lines belong together. -
pill(Rect2(5, 25, 55, 46), colour, 11)Calls pill with the values in its parentheses. -
pill(Rect2(5, 22, 55, 11), colour.darkened(0.22), 5)Calls pill with the values in its parentheses. -
pill(Rect2(8, 23, 47, 3), colour.lightened(0.32), 1)Calls pill with the values in its parentheses. -
_:Handles every match value that the branches above did not handle. -
pill(Rect2(5, 17, 56, 53), colour, 9)Calls pill with the values in its parentheses. -
pill(Rect2(7, 18, 52, 7), colour.lightened(0.28), 3)Calls pill with the values in its parentheses. -
pill(Rect2(8, 64, 50, 4), colour.darkened(0.18), 2)Calls pill with the values in its parentheses. -
pill(Rect2(13, 40, 40, 20), CREAM, 5)Calls pill with the values in its parentheses. -
var font := get_theme_default_font()Creates a variable named font. The expression calls get_theme_default_font with the values in its parentheses. Godot infers the type from the first value. -
var text_width := font.get_string_size(obj.tag, HORIZONTAL_ALIGNMENT_LEFT, -1, 9).xCreates a variable named text_width. The expression calls font.get_string_size with the values in its parentheses. Godot infers the type from the first value. -
draw_string(font, Vector2((66 - text_width) / 2.0, 54.0), obj.tag, HORIZONTAL_ALIGNMENT_LEFT, -1, 9, ink)Paints a piece of text with a font at a position measured from the node's origin. -
var mark_at := Vector2(32, 28)Creates a variable named mark_at. The expression packs x and y into one value. Godot infers the type from the first value. -
if obj.shape in ["jar", "tin"]:Checks obj.shape in ["jar", "tin"]. The indented instructions below run only if this test passes. -
mark_at = Vector2(32, 36)Stores the new value in mark_at. The expression packs x and y into one value. -
mark(mark_at, obj.symbol, ink, colour)Calls mark with the values in its parentheses. -
func pill(frame: Rect2, colour: Color, curve: int) -> void:Defines pill, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var style := StyleBoxFlat.new()Creates a variable named style. The expression creates a new StyleBoxFlat object. Godot infers the type from the first value. -
style.bg_color = colourStores the new value in style.bg_color. The expression reads colour. -
style.set_corner_radius_all(curve)Calls style.set_corner_radius_all with the values in its parentheses. -
draw_style_box(style, frame)Calls draw_style_box with the values in its parentheses. -
func mark(at: Vector2, symbol: String, ink: Color, base: Color) -> void:Defines mark, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
match symbol:Compares symbol to the patterns below and runs the first matching branch. -
"sun", "rings":Starts the instructions for this branch. The indented lines belong together. -
draw_arc(at, 7, 0, TAU, 20, ink, 1.8, true)Calls draw_arc with the values in its parentheses. -
draw_arc(at + Vector2(3, -3), 4, 0, TAU, 16, CREAM, 1.3, true)Calls draw_arc with the values in its parentheses. -
"moon":Starts the instructions for this branch. The indented lines belong together. -
draw_circle(at, 7, ink, true, -1, true)Paints a filled circle or outline in this node's local coordinates. -
draw_circle(at + Vector2(4, -2), 5.5, base, true, -1, true)Paints a filled circle or outline in this node's local coordinates. -
"heart":Starts the instructions for this branch. The indented lines belong together. -
var heart := PackedVector2Array([at + Vector2(-8, -2), at + Vector2(-7, -6), at + Vector2(-3, -7), at, at + Vector2(3, -7), at + Vector2(7, -6), at + Vector2(8, -2), at + Vector2(0, 7)])Creates a variable named heart. The expression calls PackedVector2Array with the values in its parentheses. Godot infers the type from the first value. -
draw_colored_polygon(heart, ink)Calls draw_colored_polygon with the values in its parentheses. -
"star":Starts the instructions for this branch. The indented lines belong together. -
var star := PackedVector2Array()Creates a variable named star. The expression calls PackedVector2Array with the values in its parentheses. Godot infers the type from the first value. -
for i in range(10):Repeats the indented instructions for each value in range(10). -
var radius := 8.0 if i % 2 == 0 else 3.1Creates a variable named radius. The expression chooses one of two values by checking the condition in the middle. Godot infers the type from the first value. -
star.append(at + Vector2.from_angle(TAU * i / 10.0 - PI / 2.0) * radius)Adds an item to the end of a list. -
draw_colored_polygon(star, ink)Calls draw_colored_polygon with the values in its parentheses. -
"rainbow":Starts the instructions for this branch. The indented lines belong together. -
for i in range(3):Repeats the indented instructions for each value in range(3). -
var colour := [ink, CREAM, Color("#b34e69")][i] as ColorCreates a variable named colour. The expression makes a list whose items keep their order. Godot infers the type from the first value. -
draw_arc(at + Vector2(0, 5), 8 - i * 2, PI, TAU, 16, colour, 1.5, true)Calls draw_arc with the values in its parentheses. -
"leaf":Starts the instructions for this branch. The indented lines belong together. -
var leaf := PackedVector2Array([at + Vector2(-7, 7), at + Vector2(-6, 0), at + Vector2(-1, -5), at + Vector2(8, -6), at + Vector2(6, 1), at + Vector2(1, 6)])Creates a variable named leaf. The expression calls PackedVector2Array with the values in its parentheses. Godot infers the type from the first value. -
draw_colored_polygon(leaf, ink)Calls draw_colored_polygon with the values in its parentheses. -
draw_line(at + Vector2(-6, 7), at + Vector2(5, -2), CREAM, 1, true)Paints a line between two points with the chosen colour and width. -
"cloud":Starts the instructions for this branch. The indented lines belong together. -
draw_circle(at + Vector2(-5, 0), 4, ink)Paints a filled circle or outline in this node's local coordinates. -
draw_circle(at + Vector2(0, -3), 5, ink)Paints a filled circle or outline in this node's local coordinates. -
draw_circle(at + Vector2(5, 0), 4, ink)Paints a filled circle or outline in this node's local coordinates. -
draw_rect(Rect2(at - Vector2(6, 1), Vector2(12, 5)), ink)Paints a rectangle at the given position and size. -
"pencil":Starts the instructions for this branch. The indented lines belong together. -
draw_line(at + Vector2(-6, 6), at + Vector2(5, -5), ink, 4, true)Paints a line between two points with the chosen colour and width. -
draw_circle(at + Vector2(-7, 7), 1.2, ink)Paints a filled circle or outline in this node's local coordinates. -
_:Handles every match value that the branches above did not handle. -
draw_circle(at + Vector2(-5, -1), 3.4, ink)Paints a filled circle or outline in this node's local coordinates. -
draw_circle(at + Vector2(4, -2), 3.4, CREAM)Paints a filled circle or outline in this node's local coordinates. -
draw_circle(at + Vector2(0, 5), 3.4, ink.lightened(0.29))Paints a filled circle or outline in this node's local coordinates.
Read scripts/progress.gd line by line
-
extends RefCountedStarts with Godot's RefCounted type. This script gets the abilities of that type and adds the game's own rules. -
const SAVE := "user://tiny_shelf_studio.cfg"Creates a constant named SAVE. The expression uses the text inside the quotes. Godot infers the type from the first value. -
const VERSION := 1Creates a constant named VERSION. The expression uses the whole number 1. Godot infers the type from the first value. -
const Catalog = preload("res://scripts/catalog.gd")Creates a constant named Catalog. The expression prepares a resource at a fixed project path when the script is loaded. -
static func load_record(path: String = SAVE) -> Dictionary:Defines load record, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var blank := {"completed": {}, "collected": {}}Creates a variable named blank. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value. -
var file := ConfigFile.new()Creates a variable named file. The expression creates a new ConfigFile object. Godot infers the type from the first value. -
if file.load(path) != OK:Checks file.load(path) != OK. The indented instructions below run only if this test passes. -
return blankFinishes the function and hands its result back to the caller. The expression reads blank. -
var version: Variant = file.get_value("studio", "version", 0)Creates a variable named version. The expression calls file.get_value with the values in its parentheses. The type after the colon says what kind of value it can hold. -
if not (version is int) or version != VERSION:Checks not (version is int) or version != VERSION. The indented instructions below run only if this test passes. -
return blankFinishes the function and hands its result back to the caller. The expression reads blank. -
var completed: Variant = file.get_value("studio", "completed", {})Creates a variable named completed. The expression calls file.get_value with the values in its parentheses. The type after the colon says what kind of value it can hold. -
var collected: Variant = file.get_value("studio", "collected", {})Creates a variable named collected. The expression calls file.get_value with the values in its parentheses. The type after the colon says what kind of value it can hold. -
if completed is Dictionary:Checks completed is Dictionary. The indented instructions below run only if this test passes. -
for id in completed:Repeats the indented instructions for each value in completed. -
if id is String and completed[id] == true:Checks id is String and completed[id] == true. The indented instructions below run only if this test passes. -
blank.completed[id] = trueStores the new value in blank.completed[id]. The expression uses the yes-or-no value true. -
if collected is Dictionary:Checks collected is Dictionary. The indented instructions below run only if this test passes. -
for id in collected:Repeats the indented instructions for each value in collected. -
if id is String and Catalog.PRODUCTS.has(id) and collected[id] == true:Checks id is String and Catalog.PRODUCTS.has(id) and collected[id] == true. The indented instructions below run only if this test passes. -
blank.collected[id] = trueStores the new value in blank.collected[id]. The expression uses the yes-or-no value true. -
return blankFinishes the function and hands its result back to the caller. The expression reads blank. -
static func save_record(record: Dictionary, path: String = SAVE) -> Error:Defines save record, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var file := ConfigFile.new()Creates a variable named file. The expression creates a new ConfigFile object. Godot infers the type from the first value. -
file.set_value("studio", "version", VERSION)Calls file.set_value with the values in its parentheses. -
file.set_value("studio", "completed", record.completed)Calls file.set_value with the values in its parentheses. -
file.set_value("studio", "collected", record.collected)Calls file.set_value with the values in its parentheses. -
return file.save(path)Finishes the function and hands its result back to the caller. The expression calls file.save with the values in its parentheses.
Read scripts/shelf_rules.gd line by line
-
extends RefCountedStarts with Godot's RefCounted type. This script gets the abilities of that type and adds the game's own rules. -
const Catalog = preload("res://scripts/catalog.gd")Creates a constant named Catalog. The expression prepares a resource at a fixed project path when the script is loaded. -
const WIDTH := 4Creates a constant named WIDTH. The expression uses the whole number 4. Godot infers the type from the first value. -
const HEIGHT := 3Creates a constant named HEIGHT. The expression uses the whole number 3. Godot infers the type from the first value. -
const SIZE := WIDTH * HEIGHTCreates a constant named SIZE. The expression calculates a new value from the expressions on either side of the operator. Godot infers the type from the first value. -
static func empty_board() -> Array[String]:Defines empty board, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var board: Array[String] = []Creates a variable named board. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
board.resize(SIZE)Calls board.resize with the values in its parentheses. -
board.fill("")Calls board.fill with the values in its parentheses. -
return boardFinishes the function and hands its result back to the caller. The expression reads board. -
static func slot_label(index: int) -> String:Defines slot label, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
return "%s%d" % ["ABCD"[index % WIDTH], index / WIDTH + 1]Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
static func near(first: int, second: int) -> bool:Defines near, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var x := absi(first % WIDTH - second % WIDTH)Creates a variable named x. The expression calls absi with the values in its parentheses. Godot infers the type from the first value. -
var y := absi(first / WIDTH - second / WIDTH)Creates a variable named y. The expression calls absi with the values in its parentheses. Godot infers the type from the first value. -
return x + y == 1Finishes the function and hands its result back to the caller. The expression evaluates the test to see whether it is true or false. -
static func whole(value: Variant) -> bool:Defines whole, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
return (value is int or value is float) and value == int(value)Finishes the function and hands its result back to the caller. The expression evaluates the test to see whether it is true or false. -
static func valid_brief(brief: Dictionary) -> bool:Defines valid brief, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
for key in ["id", "title", "story"]:Repeats the indented instructions for each value in ["id", "title", "story"]. -
if not (brief.get(key) is String) or brief[key].is_empty():Checks not (brief.get(key) is String) or brief[key].is_empty(). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
var chapter: Variant = brief.get("chapter")Creates a variable named chapter. The expression looks up a named or indexed value, using a fallback when the call gives one. The type after the colon says what kind of value it can hold. -
if not whole(chapter) or chapter < 0 or chapter >= Catalog.CHAPTERS.size():Checks not whole(chapter) or chapter < 0 or chapter >= Catalog.CHAPTERS.size(). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
if not (brief.get("active") is Array) or brief.active.is_empty():Checks not (brief.get("active") is Array) or brief.active.is_empty(). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
var open := {}Creates a variable named open. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value. -
for slot in brief.active:Repeats the indented instructions for each value in brief.active. -
if not whole(slot) or slot < 0 or slot >= SIZE or open.has(int(slot)):Checks not whole(slot) or slot < 0 or slot >= SIZE or open.has(int(slot)). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
open[int(slot)] = trueContinues this part of the script. Read the expression on this line in the context of the nearby declaration or function. -
if not (brief.get("stock") is Dictionary):Checks not (brief.get("stock") is Dictionary). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
var stock_total := 0Creates a variable named stock_total. The expression uses the whole number 0. Godot infers the type from the first value. -
for id in brief.stock:Repeats the indented instructions for each value in brief.stock. -
var count: Variant = brief.stock[id]Creates a variable named count. The expression looks up the item or key written between the square brackets. The type after the colon says what kind of value it can hold. -
if not Catalog.PRODUCTS.has(id) or not whole(count) or count < 1 or count > SIZE:Checks not Catalog.PRODUCTS.has(id) or not whole(count) or count < 1 or count > SIZE. The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
stock_total += int(count)Reads stock_total, adds to its old value, then stores the result back in the same place. -
if stock_total < open.size():Checks stock_total < open.size(). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
for key in ["fixed", "rows", "pairs"]:Repeats the indented instructions for each value in ["fixed", "rows", "pairs"]. -
if not (brief.get(key) is Array):Checks not (brief.get(key) is Array). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
var fixed_slots := {}Creates a variable named fixed_slots. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value. -
for clue in brief.fixed:Repeats the indented instructions for each value in brief.fixed. -
if not (clue is Dictionary) or not whole(clue.get("slot")):Checks not (clue is Dictionary) or not whole(clue.get("slot")). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
if not open.has(int(clue.slot)) or fixed_slots.has(int(clue.slot)):Checks not open.has(int(clue.slot)) or fixed_slots.has(int(clue.slot)). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
if not brief.stock.has(clue.get("product")):Checks not brief.stock.has(clue.get("product")). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
fixed_slots[int(clue.slot)] = clue.productContinues this part of the script. Read the expression on this line in the context of the nearby declaration or function. -
for clue in brief.rows:Repeats the indented instructions for each value in brief.rows. -
if not (clue is Dictionary) or not whole(clue.get("row")) or not whole(clue.get("count")):Checks not (clue is Dictionary) or not whole(clue.get("row")) or not whole(clue.get("count")). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
if clue.row < 0 or clue.row >= HEIGHT or clue.count < 0 or clue.count > WIDTH:Checks clue.row < 0 or clue.row >= HEIGHT or clue.count < 0 or clue.count > WIDTH. The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
if not clue.get("category") in Catalog.CATEGORIES:Checks not clue.get("category") in Catalog.CATEGORIES. The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
for clue in brief.pairs:Repeats the indented instructions for each value in brief.pairs. -
if not (clue is Dictionary):Checks not (clue is Dictionary). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
if not brief.stock.has(clue.get("left")) or not brief.stock.has(clue.get("right")):Checks not brief.stock.has(clue.get("left")) or not brief.stock.has(clue.get("right")). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
return trueFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value true. -
static func available(brief: Dictionary, board: Array[String], id: String) -> int:Defines available, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
return int(brief.stock.get(id, 0)) - board.count(id)Finishes the function and hands its result back to the caller. The expression converts a suitable value to a whole number. -
static func with_piece(brief: Dictionary, board: Array[String], slot: int, id: String) -> Array[String]:Defines with piece, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if board.size() != SIZE or not slot in brief.active or board[slot] == id:Checks board.size() != SIZE or not slot in brief.active or board[slot] == id. The indented instructions below run only if this test passes. -
return []Finishes the function and hands its result back to the caller. The expression makes a list whose items keep their order. -
if not id.is_empty() and available(brief, board, id) <= 0:Checks not id.is_empty() and available(brief, board, id) <= 0. The indented instructions below run only if this test passes. -
return []Finishes the function and hands its result back to the caller. The expression makes a list whose items keep their order. -
var next := board.duplicate()Creates a variable named next. The expression copies the collection so a later change can leave the original alone. Godot infers the type from the first value. -
next[slot] = idStores the new value in next[slot]. The expression reads id. -
return nextFinishes the function and hands its result back to the caller. The expression reads next. -
static func clue_text(brief: Dictionary) -> Array[String]:Defines clue text, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var lines: Array[String] = []Creates a variable named lines. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
for clue in brief.fixed:Repeats the indented instructions for each value in brief.fixed. -
lines.append("%s holds %s." % [slot_label(int(clue.slot)), Catalog.name_for(clue.product)])Adds an item to the end of a list. -
for clue in brief.rows:Repeats the indented instructions for each value in brief.rows. -
lines.append("Row %d takes %d from %s." % [int(clue.row) + 1, int(clue.count), str(clue.category).capitalize()])Adds an item to the end of a list. -
for clue in brief.pairs:Repeats the indented instructions for each value in brief.pairs. -
lines.append("%s beside %s." % [Catalog.name_for(clue.left), Catalog.name_for(clue.right)])Adds an item to the end of a list. -
return linesFinishes the function and hands its result back to the caller. The expression reads lines. -
static func product_fits_slot(brief: Dictionary, slot: int, id: String) -> bool:Defines product fits slot, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
for clue in brief.fixed:Repeats the indented instructions for each value in brief.fixed. -
if int(clue.slot) == slot:Checks int(clue.slot) == slot. The indented instructions below run only if this test passes. -
return clue.product == idFinishes the function and hands its result back to the caller. The expression evaluates the test to see whether it is true or false. -
return trueFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value true. -
static func pair_possible(brief: Dictionary, board: Array[String], remaining: Dictionary, first: String, second: String) -> bool:Defines pair possible, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
for left in brief.active:Repeats the indented instructions for each value in brief.active. -
var left_slot := int(left)Creates a variable named left_slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
var left_id := board[left_slot]Creates a variable named left_id. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
if left_id != first and (not left_id.is_empty() or int(remaining.get(first, 0)) <= 0):Checks left_id != first and (not left_id.is_empty() or int(remaining.get(first, 0)) <= 0). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
if not product_fits_slot(brief, left_slot, first):Checks not product_fits_slot(brief, left_slot, first). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
for right in brief.active:Repeats the indented instructions for each value in brief.active. -
var right_slot := int(right)Creates a variable named right_slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if not near(left_slot, right_slot):Checks not near(left_slot, right_slot). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
var right_id := board[right_slot]Creates a variable named right_id. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
if right_id != second and (not right_id.is_empty() or int(remaining.get(second, 0)) <= 0):Checks right_id != second and (not right_id.is_empty() or int(remaining.get(second, 0)) <= 0). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
if first == second and left_id.is_empty() and right_id.is_empty() and int(remaining.get(first, 0)) < 2:Checks first == second and left_id.is_empty() and right_id.is_empty() and int(remaining.get(first, 0)) < 2. The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
if product_fits_slot(brief, right_slot, second):Checks product_fits_slot(brief, right_slot, second). The indented instructions below run only if this test passes. -
return trueFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value true. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
static func partial_possible(brief: Dictionary, board: Array[String], remaining: Dictionary) -> bool:Defines partial possible, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
for clue in brief.fixed:Repeats the indented instructions for each value in brief.fixed. -
var id := board[int(clue.slot)]Creates a variable named id. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
if id != clue.product and (not id.is_empty() or int(remaining.get(clue.product, 0)) <= 0):Checks id != clue.product and (not id.is_empty() or int(remaining.get(clue.product, 0)) <= 0). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
for clue in brief.rows:Repeats the indented instructions for each value in brief.rows. -
var matching := 0Creates a variable named matching. The expression uses the whole number 0. Godot infers the type from the first value. -
var empty := 0Creates a variable named empty. The expression uses the whole number 0. Godot infers the type from the first value. -
for value in brief.active:Repeats the indented instructions for each value in brief.active. -
var slot := int(value)Creates a variable named slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if slot / WIDTH != int(clue.row):Checks slot / WIDTH != int(clue.row). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
var id := board[slot]Creates a variable named id. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
matching += int(Catalog.category_of(id) == clue.category)Reads matching, adds to its old value, then stores the result back in the same place. -
empty += int(id.is_empty())Reads empty, adds to its old value, then stores the result back in the same place. -
if matching > int(clue.count) or matching + empty < int(clue.count):Checks matching > int(clue.count) or matching + empty < int(clue.count). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
for clue in brief.pairs:Repeats the indented instructions for each value in brief.pairs. -
if not pair_possible(brief, board, remaining, clue.left, clue.right):Checks not pair_possible(brief, board, remaining, clue.left, clue.right). The indented instructions below run only if this test passes. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
return trueFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value true. -
static func count_remaining(brief: Dictionary, board: Array[String]) -> Dictionary:Defines count remaining, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if board.size() != SIZE:Checks board.size() != SIZE. The indented instructions below run only if this test passes. -
return {}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
var counts := {}Creates a variable named counts. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value. -
for id in brief.stock:Repeats the indented instructions for each value in brief.stock. -
counts[id] = int(brief.stock[id])Stores the new value in counts[id]. The expression converts a suitable value to a whole number. -
for slot in range(SIZE):Repeats the indented instructions for each value in range(SIZE). -
var id := board[slot]Creates a variable named id. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
if id.is_empty():Checks id.is_empty(). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
if not slot in brief.active or not counts.has(id):Checks not slot in brief.active or not counts.has(id). The indented instructions below run only if this test passes. -
return {}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
counts[id] -= 1Reads counts[id], subtracts from its old value, then stores the result back in the same place. -
if counts[id] < 0:Checks counts[id] < 0. The indented instructions below run only if this test passes. -
return {}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
return countsFinishes the function and hands its result back to the caller. The expression reads counts. -
static func result(brief: Dictionary, board: Array[String]) -> String:Defines result, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var rest := count_remaining(brief, board)Creates a variable named rest. The expression calls count_remaining with the values in its parentheses. Godot infers the type from the first value. -
if rest.is_empty():Checks rest.is_empty(). The indented instructions below run only if this test passes. -
return "The shelf contains stock that this brief does not supply."Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
for value in brief.active:Repeats the indented instructions for each value in brief.active. -
if board[int(value)].is_empty():Checks board[int(value)].is_empty(). The indented instructions below run only if this test passes. -
return "Fill each of the open display slots."Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
for clue in brief.fixed:Repeats the indented instructions for each value in brief.fixed. -
if board[int(clue.slot)] != clue.product:Checks board[int(clue.slot)] != clue.product. The indented instructions below run only if this test passes. -
return "%s needs %s." % [slot_label(int(clue.slot)), Catalog.name_for(clue.product)]Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
for clue in brief.rows:Repeats the indented instructions for each value in brief.rows. -
var matching := 0Creates a variable named matching. The expression uses the whole number 0. Godot infers the type from the first value. -
for value in brief.active:Repeats the indented instructions for each value in brief.active. -
var slot := int(value)Creates a variable named slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if slot / WIDTH == int(clue.row) and Catalog.category_of(board[slot]) == clue.category:Checks slot / WIDTH == int(clue.row) and Catalog.category_of(board[slot]) == clue.category. The indented instructions below run only if this test passes. -
matching += 1Reads matching, adds to its old value, then stores the result back in the same place. -
if matching != int(clue.count):Checks matching != int(clue.count). The indented instructions below run only if this test passes. -
return "Row %d needs exactly %d from %s." % [int(clue.row) + 1, int(clue.count), str(clue.category).capitalize()]Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
for clue in brief.pairs:Repeats the indented instructions for each value in brief.pairs. -
if not pair_possible(brief, board, rest, clue.left, clue.right):Checks not pair_possible(brief, board, rest, clue.left, clue.right). The indented instructions below run only if this test passes. -
return "Place %s and %s beside each other." % [Catalog.name_for(clue.left), Catalog.name_for(clue.right)]Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
return ""Finishes the function and hands its result back to the caller. The expression uses the text inside the quotes. -
static func solution(brief: Dictionary, board: Array[String]) -> Array[String]:Defines solution, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var left := count_remaining(brief, board)Creates a variable named left. The expression calls count_remaining with the values in its parentheses. Godot infers the type from the first value. -
if left.is_empty() or not partial_possible(brief, board, left):Checks left.is_empty() or not partial_possible(brief, board, left). The indented instructions below run only if this test passes. -
return []Finishes the function and hands its result back to the caller. The expression makes a list whose items keep their order. -
var draft := board.duplicate()Creates a variable named draft. The expression copies the collection so a later change can leave the original alone. Godot infers the type from the first value. -
var slots: Array[int] = []Creates a variable named slots. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
for clue in brief.fixed:Repeats the indented instructions for each value in brief.fixed. -
var slot := int(clue.slot)Creates a variable named slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if draft[slot].is_empty():Checks draft[slot].is_empty(). The indented instructions below run only if this test passes. -
slots.append(slot)Adds an item to the end of a list. -
for value in brief.active:Repeats the indented instructions for each value in brief.active. -
var slot := int(value)Creates a variable named slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if draft[slot].is_empty() and not slot in slots:Checks draft[slot].is_empty() and not slot in slots. The indented instructions below run only if this test passes. -
slots.append(slot)Adds an item to the end of a list. -
return draft if search(brief, draft, left, slots, 0) else []Finishes the function and hands its result back to the caller. The expression chooses one of two values by checking the condition in the middle. -
static func search(brief: Dictionary, board: Array[String], left: Dictionary, slots: Array[int], depth: int) -> bool:Defines search, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if depth == slots.size():Checks depth == slots.size(). The indented instructions below run only if this test passes. -
return trueFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value true. -
var slot := slots[depth]Creates a variable named slot. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
for id in Catalog.PRODUCTS:Repeats the indented instructions for each value in Catalog.PRODUCTS. -
if int(left.get(id, 0)) <= 0 or not product_fits_slot(brief, slot, id):Checks int(left.get(id, 0)) <= 0 or not product_fits_slot(brief, slot, id). The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
board[slot] = idStores the new value in board[slot]. The expression reads id. -
left[id] -= 1Reads left[id], subtracts from its old value, then stores the result back in the same place. -
if partial_possible(brief, board, left) and search(brief, board, left, slots, depth + 1):Checks partial_possible(brief, board, left) and search(brief, board, left, slots, depth + 1). The indented instructions below run only if this test passes. -
return trueFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value true. -
board[slot] = ""Stores the new value in board[slot]. The expression uses the text inside the quotes. -
left[id] += 1Reads left[id], adds to its old value, then stores the result back in the same place. -
return falseFinishes the function and hands its result back to the caller. The expression uses the yes-or-no value false. -
static func hint(brief: Dictionary, board: Array[String]) -> Dictionary:Defines hint, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if board.size() != SIZE:Checks board.size() != SIZE. The indented instructions below run only if this test passes. -
return {}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
var route := solution(brief, board)Creates a variable named route. The expression calls solution with the values in its parentheses. Godot infers the type from the first value. -
if route.is_empty():Checks route.is_empty(). The indented instructions below run only if this test passes. -
route = solution(brief, empty_board())Stores the new value in route. The expression calls solution with the values in its parentheses. -
if route.is_empty():Checks route.is_empty(). The indented instructions below run only if this test passes. -
return {}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
for value in brief.active:Repeats the indented instructions for each value in brief.active. -
var slot := int(value)Creates a variable named slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if board[slot] != route[slot] and available(brief, board, route[slot]) > 0:Checks board[slot] != route[slot] and available(brief, board, route[slot]) > 0. The indented instructions below run only if this test passes. -
return {"slot": slot, "product": route[slot], "remove": false}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
for value in brief.active:Repeats the indented instructions for each value in brief.active. -
var slot := int(value)Creates a variable named slot. The expression converts a suitable value to a whole number. Godot infers the type from the first value. -
if board[slot] != route[slot]:Checks board[slot] != route[slot]. The indented instructions below run only if this test passes. -
return {"slot": slot, "product": board[slot], "remove": true}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key. -
return {}Finishes the function and hands its result back to the caller. The expression makes a dictionary that looks up values by key.
Read scripts/studio.gd line by line
-
extends ControlStarts with Godot's Control type. This script gets the abilities of that type and adds the game's own rules. -
const Catalog = preload("res://scripts/catalog.gd")Creates a constant named Catalog. The expression prepares a resource at a fixed project path when the script is loaded. -
const BriefCatalog = preload("res://scripts/brief_catalog.gd")Creates a constant named BriefCatalog. The expression prepares a resource at a fixed project path when the script is loaded. -
const Rules = preload("res://scripts/shelf_rules.gd")Creates a constant named Rules. The expression prepares a resource at a fixed project path when the script is loaded. -
const Progress = preload("res://scripts/progress.gd")Creates a constant named Progress. The expression prepares a resource at a fixed project path when the script is loaded. -
const Pack = preload("res://scripts/pack_piece.gd")Creates a constant named Pack. The expression prepares a resource at a fixed project path when the script is loaded. -
const TITLE_FONT = preload("res://art/studio-serif.ttf")Creates a constant named TITLE_FONT. The expression prepares a resource at a fixed project path when the script is loaded. -
const STUDIO = preload("res://art/studio.jpg")Creates a constant named STUDIO. The expression prepares a resource at a fixed project path when the script is loaded. -
const SHOWCASE = preload("res://art/showcase.jpg")Creates a constant named SHOWCASE. The expression prepares a resource at a fixed project path when the script is loaded. -
const ICON = preload("res://art/icon-android.png")Creates a constant named ICON. The expression prepares a resource at a fixed project path when the script is loaded. -
const INK := Color("#2d233a")Creates a constant named INK. The expression builds a colour from these values. Godot infers the type from the first value. -
const PLUM := Color("#503354")Creates a constant named PLUM. The expression builds a colour from these values. Godot infers the type from the first value. -
const DEEP := Color("#392943")Creates a constant named DEEP. The expression builds a colour from these values. Godot infers the type from the first value. -
const MID := Color("#645069")Creates a constant named MID. The expression builds a colour from these values. Godot infers the type from the first value. -
const CREAM := Color("#fff1da")Creates a constant named CREAM. The expression builds a colour from these values. Godot infers the type from the first value. -
const PALE := Color("#f5e5cc")Creates a constant named PALE. The expression builds a colour from these values. Godot infers the type from the first value. -
const PAPER := Color("#fff7e9")Creates a constant named PAPER. The expression builds a colour from these values. Godot infers the type from the first value. -
const GOLD := Color("#f7ca69")Creates a constant named GOLD. The expression builds a colour from these values. Godot infers the type from the first value. -
const PINK := Color("#f0bbab")Creates a constant named PINK. The expression builds a colour from these values. Godot infers the type from the first value. -
const FAINT := Color("#e2cbb7")Creates a constant named FAINT. The expression builds a colour from these values. Godot infers the type from the first value. -
const TEA := Color("#c4e7d5")Creates a constant named TEA. The expression builds a colour from these values. Godot infers the type from the first value. -
var briefs: Array[Dictionary] = []Creates a variable named briefs. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var board: Array[String] = []Creates a variable named board. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var history: Array[Array] = []Creates a variable named history. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var record: Dictionary = {}Creates a variable named record. The expression makes a dictionary that looks up values by key. The type after the colon says what kind of value it can hold. -
var save_path := Progress.SAVECreates a variable named save_path. The expression reads Progress.SAVE. Godot infers the type from the first value. -
var current := 0Creates a variable named current. The expression uses the whole number 0. Godot infers the type from the first value. -
var selected := ""Creates a variable named selected. The expression uses the text inside the quotes. Godot infers the type from the first value. -
var removing := falseCreates a variable named removing. The expression uses the yes-or-no value false. Godot infers the type from the first value. -
var hint_slot := -1Creates a variable named hint_slot. The expression reads -1. Godot infers the type from the first value. -
var display_complete := falseCreates a variable named display_complete. The expression uses the yes-or-no value false. Godot infers the type from the first value. -
var hint_text := ""Creates a variable named hint_text. The expression uses the text inside the quotes. Godot infers the type from the first value. -
var back: TextureRectDeclares back for later use. A colon followed by a type says which kind of value belongs here. -
var brief_label: LabelDeclares brief_label for later use. A colon followed by a type says which kind of value belongs here. -
var story_label: LabelDeclares story_label for later use. A colon followed by a type says which kind of value belongs here. -
var chapter_label: LabelDeclares chapter_label for later use. A colon followed by a type says which kind of value belongs here. -
var display_status: LabelDeclares display_status for later use. A colon followed by a type says which kind of value belongs here. -
var shelf_buttons: Array[Button] = []Creates a variable named shelf_buttons. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var shelf_caps: Array[Label] = []Creates a variable named shelf_caps. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var shelf_names: Array[Label] = []Creates a variable named shelf_names. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var shelf_packs: Array[Control] = []Creates a variable named shelf_packs. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var stock_controls: Array[Button] = []Creates a variable named stock_controls. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var stock_packs: Array[Control] = []Creates a variable named stock_packs. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var stock_names: Array[Label] = []Creates a variable named stock_names. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var stock_counters: Array[Label] = []Creates a variable named stock_counters. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var stock_order: Array[String] = []Creates a variable named stock_order. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold. -
var stock_empty: LabelDeclares stock_empty for later use. A colon followed by a type says which kind of value belongs here. -
var clues: VBoxContainerDeclares clues for later use. A colon followed by a type says which kind of value belongs here. -
var clue_scroll: ScrollContainerDeclares clue_scroll for later use. A colon followed by a type says which kind of value belongs here. -
var overlay: ControlDeclares overlay for later use. A colon followed by a type says which kind of value belongs here. -
var overlay_body: ControlDeclares overlay_body for later use. A colon followed by a type says which kind of value belongs here. -
var overlay_title: LabelDeclares overlay_title for later use. A colon followed by a type says which kind of value belongs here. -
var overlay_deck: LabelDeclares overlay_deck for later use. A colon followed by a type says which kind of value belongs here. -
var overlay_close: ButtonDeclares overlay_close for later use. A colon followed by a type says which kind of value belongs here. -
var overlay_source: ButtonDeclares overlay_source for later use. A colon followed by a type says which kind of value belongs here. -
var overlay_page := ""Creates a variable named overlay_page. The expression uses the text inside the quotes. Godot infers the type from the first value. -
var album_button: ButtonDeclares album_button for later use. A colon followed by a type says which kind of value belongs here. -
var inspect_button: ButtonDeclares inspect_button for later use. A colon followed by a type says which kind of value belongs here. -
var remove_button: ButtonDeclares remove_button for later use. A colon followed by a type says which kind of value belongs here. -
var undo_button: ButtonDeclares undo_button for later use. A colon followed by a type says which kind of value belongs here. -
var check_button: ButtonDeclares check_button for later use. A colon followed by a type says which kind of value belongs here. -
var next_button: ButtonDeclares next_button for later use. A colon followed by a type says which kind of value belongs here. -
func _ready() -> void:Godot calls this once after the scene and its children are ready. Use it to set up the room and connect controls. -
briefs = BriefCatalog.read()Stores the new value in briefs. The expression calls BriefCatalog.read with the values in its parentheses. -
record = Progress.load_record(save_path)Stores the new value in record. The expression calls Progress.load_record with the values in its parentheses. -
build_interface()Calls build_interface with the values in its parentheses. -
if briefs.is_empty():Checks briefs.is_empty(). The indented instructions below run only if this test passes. -
display_status.text = "The brief catalogue could not be opened."Updates display_status.text, which controls the words a player sees. The expression uses the text inside the quotes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
open_brief(0)Calls open_brief with the values in its parentheses. -
func style(Defines style, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
fill: Color, edge: Color, curve: int = 12, outline: int = 1,Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
shadow: bool = falseContinues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
) -> StyleBoxFlat:Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
var result := StyleBoxFlat.new()Creates a variable named result. The expression creates a new StyleBoxFlat object. Godot infers the type from the first value. -
result.bg_color = fillStores the new value in result.bg_color. The expression reads fill. -
result.border_color = edgeStores the new value in result.border_color. The expression reads edge. -
result.set_corner_radius_all(curve)Calls result.set_corner_radius_all with the values in its parentheses. -
result.set_border_width_all(outline)Calls result.set_border_width_all with the values in its parentheses. -
if shadow:Checks shadow. The indented instructions below run only if this test passes. -
result.shadow_size = 5Stores the new value in result.shadow_size. The expression uses the whole number 5. -
result.shadow_offset = Vector2(0, 4)Stores the new value in result.shadow_offset. The expression packs x and y into one value. -
result.shadow_color = Color(0.17, 0.08, 0.16, 0.50)Stores the new value in result.shadow_color. The expression builds a colour from these values. -
result.content_margin_left = 9Stores the new value in result.content_margin_left. The expression uses the whole number 9. -
result.content_margin_right = 9Stores the new value in result.content_margin_right. The expression uses the whole number 9. -
result.content_margin_top = 4Stores the new value in result.content_margin_top. The expression uses the whole number 4. -
result.content_margin_bottom = 4Stores the new value in result.content_margin_bottom. The expression uses the whole number 4. -
return resultFinishes the function and hands its result back to the caller. The expression reads result. -
func arrange(control: Control, parent: Control, frame: Rect2) -> void:Defines arrange, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
parent.add_child(control)Adds the new node to the scene tree so that Godot can run and draw it. -
control.position = frame.positionUpdates control.position, which controls the node's local x and y location. The expression reads frame.position. -
control.size = frame.sizeUpdates control.size, which controls the control's width and height. The expression reads frame.size. -
func panel(parent: Control, frame: Rect2, colour: Color, border: Color, corner: int = 18, lift: bool = false) -> Panel:Defines panel, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var result := Panel.new()Creates a variable named result. The expression creates a new Panel object. Godot infers the type from the first value. -
result.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates result.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
result.add_theme_stylebox_override("panel", style(colour, border, corner, 1, lift))Calls result.add_theme_stylebox_override with the values in its parentheses. -
arrange(result, parent, frame)Calls arrange with the values in its parentheses. -
return resultFinishes the function and hands its result back to the caller. The expression reads result. -
func text(Defines text, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
parent: Control, frame: Rect2, words: String, font_size: int,Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
ink: Color = INK, serif: bool = false, centre: bool = false, wrap: bool = falseContinues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
) -> Label:Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
var result := Label.new()Creates a variable named result. The expression creates a new Label object. Godot infers the type from the first value. -
result.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates result.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
result.add_theme_font_size_override("font_size", font_size)Calls result.add_theme_font_size_override with the values in its parentheses. -
result.add_theme_color_override("font_color", ink)Calls result.add_theme_color_override with the values in its parentheses. -
if serif:Checks serif. The indented instructions below run only if this test passes. -
result.add_theme_font_override("font", TITLE_FONT)Calls result.add_theme_font_override with the values in its parentheses. -
if centre:Checks centre. The indented instructions below run only if this test passes. -
result.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTERStores the new value in result.horizontal_alignment. The expression reads HORIZONTAL_ALIGNMENT_CENTER. -
if wrap:Checks wrap. The indented instructions below run only if this test passes. -
result.autowrap_mode = TextServer.AUTOWRAP_WORD_SMARTStores the new value in result.autowrap_mode. The expression reads TextServer.AUTOWRAP_WORD_SMART. -
else:Runs the indented fallback instructions if none of the earlier tests passed. -
result.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSISStores the new value in result.text_overrun_behavior. The expression reads TextServer.OVERRUN_TRIM_ELLIPSIS. -
result.vertical_alignment = VERTICAL_ALIGNMENT_CENTERStores the new value in result.vertical_alignment. The expression reads VERTICAL_ALIGNMENT_CENTER. -
arrange(result, parent, frame)Calls arrange with the values in its parentheses. -
result.text = wordsUpdates result.text, which controls the words a player sees. The expression reads words. -
return resultFinishes the function and hands its result back to the caller. The expression reads result. -
func button(Defines button, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
parent: Control, frame: Rect2, words: String, choose: Callable,Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
fill: Color = PALE, ink: Color = INK, font_size: int = 17Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
) -> Button:Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
var result := Button.new()Creates a variable named result. The expression creates a new Button object. Godot infers the type from the first value. -
result.text = wordsUpdates result.text, which controls the words a player sees. The expression reads words. -
result.accessibility_name = wordsStores the new value in result.accessibility_name. The expression reads words. -
result.focus_mode = Control.FOCUS_ALLStores the new value in result.focus_mode. The expression reads Control.FOCUS_ALL. -
result.add_theme_font_size_override("font_size", font_size)Calls result.add_theme_font_size_override with the values in its parentheses. -
result.add_theme_color_override("font_color", ink)Calls result.add_theme_color_override with the values in its parentheses. -
result.add_theme_color_override("font_hover_color", ink)Calls result.add_theme_color_override with the values in its parentheses. -
result.add_theme_color_override("font_pressed_color", ink)Calls result.add_theme_color_override with the values in its parentheses. -
result.add_theme_color_override("font_focus_color", ink)Calls result.add_theme_color_override with the values in its parentheses. -
result.add_theme_color_override("font_disabled_color", Color("#8a7889"))Calls result.add_theme_color_override with the values in its parentheses. -
result.pressed.connect(choose)Links a signal to the function that should run when the event happens. -
button_face(result, fill, FAINT)Calls button_face with the values in its parentheses. -
arrange(result, parent, frame)Calls arrange with the values in its parentheses. -
return resultFinishes the function and hands its result back to the caller. The expression reads result. -
func button_face(control: Button, fill: Color, edge: Color) -> void:Defines button face, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
control.add_theme_stylebox_override("normal", style(fill, edge))Calls control.add_theme_stylebox_override with the values in its parentheses. -
control.add_theme_stylebox_override("hover", style(fill.lightened(0.14), edge, 12, 2))Calls control.add_theme_stylebox_override with the values in its parentheses. -
control.add_theme_stylebox_override("pressed", style(fill.darkened(0.10), edge, 12, 2))Calls control.add_theme_stylebox_override with the values in its parentheses. -
control.add_theme_stylebox_override("disabled", style(fill.darkened(0.24), edge.darkened(0.20)))Calls control.add_theme_stylebox_override with the values in its parentheses. -
control.add_theme_stylebox_override("focus", style(Color.TRANSPARENT, Color("#ffb23f"), 12, 3))Calls control.add_theme_stylebox_override with the values in its parentheses. -
func package(parent: Control, frame: Rect2, id: String = "") -> Control:Defines package, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
var piece := Pack.new()Creates a variable named piece. The expression creates a new Pack object. Godot infers the type from the first value. -
arrange(piece, parent, frame)Calls arrange with the values in its parentheses. -
piece.use_product(id)Calls piece.use_product with the values in its parentheses. -
return pieceFinishes the function and hands its result back to the caller. The expression reads piece. -
func build_interface() -> void:Defines build interface, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
back = TextureRect.new()Stores the new value in back. The expression creates a new TextureRect object. -
back.texture = STUDIOStores the new value in back.texture. The expression reads STUDIO. -
back.expand_mode = TextureRect.EXPAND_IGNORE_SIZEStores the new value in back.expand_mode. The expression reads TextureRect.EXPAND_IGNORE_SIZE. -
back.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVEREDStores the new value in back.stretch_mode. The expression reads TextureRect.STRETCH_KEEP_ASPECT_COVERED. -
back.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates back.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
arrange(back, self, Rect2(0, 0, 1280, 720))Calls arrange with the values in its parentheses. -
panel(self, Rect2(30, 24, 1220, 94), CREAM, CREAM, 23, true)Calls panel with the values in its parentheses. -
var emblem := TextureRect.new()Creates a variable named emblem. The expression creates a new TextureRect object. Godot infers the type from the first value. -
emblem.texture = ICONStores the new value in emblem.texture. The expression reads ICON. -
emblem.expand_mode = TextureRect.EXPAND_IGNORE_SIZEStores the new value in emblem.expand_mode. The expression reads TextureRect.EXPAND_IGNORE_SIZE. -
emblem.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates emblem.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
arrange(emblem, self, Rect2(50, 38, 66, 66))Calls arrange with the values in its parentheses. -
text(self, Rect2(135, 38, 485, 43), "Tiny Shelf Studio", 34, INK, true)Calls text with the values in its parentheses. -
text(self, Rect2(137, 83, 470, 20), "Style a window display, one tiny package at a time.", 15, MID)Calls text with the values in its parentheses. -
button(self, Rect2(745, 48, 148, 46), "Display briefs", show_briefs)Calls button with the values in its parentheses. -
album_button = button(self, Rect2(908, 48, 154, 46), "Scrapbook", show_album)Stores the new value in album_button. The expression calls button with the values in its parentheses. -
button(self, Rect2(1077, 48, 148, 46), "How to play", show_help)Calls button with the values in its parentheses. -
panel(self, Rect2(30, 135, 740, 545), PLUM, Color("#b48194"), 23, true)Calls panel with the values in its parentheses. -
chapter_label = text(self, Rect2(57, 148, 470, 21), "", 15, GOLD)Stores the new value in chapter_label. The expression calls text with the values in its parentheses. -
brief_label = text(self, Rect2(54, 176, 671, 42), "", 30, CREAM, true)Stores the new value in brief_label. The expression calls text with the values in its parentheses. -
story_label = text(self, Rect2(57, 217, 684, 21), "", 15, CREAM)Stores the new value in story_label. The expression calls text with the values in its parentheses. -
build_shelf()Calls build_shelf with the values in its parentheses. -
remove_button = button(self, Rect2(56, 566, 156, 45), "Remove mode", toggle_remove, PINK, INK, 15)Stores the new value in remove_button. The expression calls button with the values in its parentheses. -
undo_button = button(self, Rect2(223, 566, 87, 45), "Undo", undo, PALE, INK, 15)Stores the new value in undo_button. The expression calls button with the values in its parentheses. -
button(self, Rect2(321, 566, 91, 45), "Reset", confirm_reset, PALE, INK, 15)Calls button with the values in its parentheses. -
button(self, Rect2(423, 566, 88, 45), "Hint", show_hint, PALE, INK, 15)Calls button with the values in its parentheses. -
check_button = button(self, Rect2(523, 566, 218, 45), "Check display", check_display, GOLD, INK, 16)Stores the new value in check_button. The expression calls button with the values in its parentheses. -
next_button = button(self, Rect2(523, 566, 218, 45), "Next brief", next_brief, TEA, INK, 16)Stores the new value in next_button. The expression calls button with the values in its parentheses. -
next_button.hide()Makes this control invisible. -
panel(self, Rect2(56, 623, 685, 40), DEEP, Color("#a16c8e"), 12)Calls panel with the values in its parentheses. -
display_status = text(self, Rect2(68, 626, 658, 32), "", 15, CREAM, false, false, true)Stores the new value in display_status. The expression calls text with the values in its parentheses. -
panel(self, Rect2(789, 135, 461, 545), CREAM, CREAM, 23, true)Calls panel with the values in its parentheses. -
text(self, Rect2(813, 154, 262, 33), "Stock drawers", 23, INK, true)Calls text with the values in its parentheses. -
text(self, Rect2(814, 189, 390, 21), "Choose a package, then a shelf slot.", 14, MID)Calls text with the values in its parentheses. -
inspect_button = button(self, Rect2(1093, 151, 131, 43), "Inspect pack", show_inspect, TEA, INK, 15)Stores the new value in inspect_button. The expression calls button with the values in its parentheses. -
build_stock()Calls build_stock with the values in its parentheses. -
panel(self, Rect2(813, 412, 410, 1), FAINT, FAINT, 0)Calls panel with the values in its parentheses. -
text(self, Rect2(813, 419, 410, 34), "Display clues", 23, INK, true)Calls text with the values in its parentheses. -
clue_scroll = ScrollContainer.new()Stores the new value in clue_scroll. The expression creates a new ScrollContainer object. -
clue_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLEDStores the new value in clue_scroll.horizontal_scroll_mode. The expression reads ScrollContainer.SCROLL_MODE_DISABLED. -
arrange(clue_scroll, self, Rect2(814, 457, 407, 193))Calls arrange with the values in its parentheses. -
clues = VBoxContainer.new()Stores the new value in clues. The expression creates a new VBoxContainer object. -
clues.size_flags_horizontal = Control.SIZE_EXPAND_FILLStores the new value in clues.size_flags_horizontal. The expression reads Control.SIZE_EXPAND_FILL. -
clues.add_theme_constant_override("separation", 5)Calls clues.add_theme_constant_override with the values in its parentheses. -
clue_scroll.add_child(clues)Adds the new node to the scene tree so that Godot can run and draw it. -
build_overlay()Calls build_overlay with the values in its parentheses. -
func build_shelf() -> void:Defines build shelf, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
panel(self, Rect2(55, 249, 685, 303), DEEP, Color("#bd91a0"), 15)Calls panel with the values in its parentheses. -
for row in range(Rules.HEIGHT):Repeats the indented instructions for each value in range(Rules.HEIGHT). -
for col in range(Rules.WIDTH):Repeats the indented instructions for each value in range(Rules.WIDTH). -
var slot := row * Rules.WIDTH + colCreates a variable named slot. The expression calculates a new value from the expressions on either side of the operator. Godot infers the type from the first value. -
var frame := Rect2(63 + col * 169, 257 + row * 96, 161, 89)Creates a variable named frame. The expression describes a position and a size. Godot infers the type from the first value. -
var tile := button(self, frame, "", choose_slot.bind(slot), DEEP, CREAM)Creates a variable named tile. The expression calls button with the values in its parentheses. Godot infers the type from the first value. -
shelf_buttons.append(tile)Adds an item to the end of a list. -
shelf_caps.append(text(tile, Rect2(8, 4, 52, 23), "", 13, GOLD))Adds an item to the end of a list. -
shelf_packs.append(package(tile, Rect2(58, 3, 45, 61)))Adds an item to the end of a list. -
shelf_names.append(text(tile, Rect2(6, 63, 149, 21), "", 14, CREAM, false, true))Adds an item to the end of a list. -
func build_stock() -> void:Defines build stock, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
for i in range(12):Repeats the indented instructions for each value in range(12). -
var frame := Rect2(814 + (i % 3) * 139, 217 + (i / 3) * 46, 132, 42)Creates a variable named frame. The expression describes a position and a size. Godot infers the type from the first value. -
var pick := button(self, frame, "", choose_stock.bind(i), PAPER)Creates a variable named pick. The expression calls button with the values in its parentheses. Godot infers the type from the first value. -
stock_controls.append(pick)Adds an item to the end of a list. -
stock_packs.append(package(pick, Rect2(5, 2, 30, 37)))Adds an item to the end of a list. -
stock_names.append(text(pick, Rect2(38, 3, 92, 18), "", 12))Adds an item to the end of a list. -
stock_counters.append(text(pick, Rect2(38, 19, 92, 17), "", 12, MID))Adds an item to the end of a list. -
stock_empty = text(self, Rect2(815, 225, 395, 44), "No stock has been loaded.", 16, MID)Stores the new value in stock_empty. The expression calls text with the values in its parentheses. -
func open_brief(index: int) -> void:Defines open brief, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if index < 0 or index >= briefs.size():Checks index < 0 or index >= briefs.size(). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
current = indexStores the new value in current. The expression reads index. -
board = Rules.empty_board()Stores the new value in board. The expression calls Rules.empty_board with the values in its parentheses. -
history.clear()Empties this collection. -
selected = ""Stores the new value in selected. The expression uses the text inside the quotes. -
removing = falseStores the new value in removing. The expression uses the yes-or-no value false. -
hint_slot = -1Stores the new value in hint_slot. The expression reads -1. -
display_complete = falseStores the new value in display_complete. The expression uses the yes-or-no value false. -
hint_text = ""Stores the new value in hint_text. The expression uses the text inside the quotes. -
back.texture = SHOWCASE if int(briefs[current].chapter) == 2 else STUDIOStores the new value in back.texture. The expression chooses one of two values by checking the condition in the middle. -
stock_order.clear()Empties this collection. -
for product in Catalog.PRODUCTS:Repeats the indented instructions for each value in Catalog.PRODUCTS. -
if briefs[current].stock.has(product):Checks briefs[current].stock.has(product). The indented instructions below run only if this test passes. -
stock_order.append(product)Adds an item to the end of a list. -
for child in clues.get_children():Repeats the indented instructions for each value in clues.get_children(). -
clues.remove_child(child)Calls clues.remove_child with the values in its parentheses. -
child.queue_free()Asks Godot to remove this node safely at the end of the frame. -
for clue in Rules.clue_text(briefs[current]):Repeats the indented instructions for each value in Rules.clue_text(briefs[current]). -
var note := Label.new()Creates a variable named note. The expression creates a new Label object. Godot infers the type from the first value. -
note.text = "• " + clueUpdates note.text, which controls the words a player sees. The expression uses the text inside the quotes. -
note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMARTStores the new value in note.autowrap_mode. The expression reads TextServer.AUTOWRAP_WORD_SMART. -
note.add_theme_color_override("font_color", INK)Calls note.add_theme_color_override with the values in its parentheses. -
note.add_theme_font_size_override("font_size", 15)Calls note.add_theme_font_size_override with the values in its parentheses. -
clues.add_child(note)Adds the new node to the scene tree so that Godot can run and draw it. -
clue_scroll.scroll_vertical = 0Stores the new value in clue_scroll.scroll_vertical. The expression uses the whole number 0. -
refresh("Choose a package from the stock drawers.")Calls refresh with the values in its parentheses. -
func refresh(message: String) -> void:Defines refresh, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if briefs.is_empty():Checks briefs.is_empty(). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
var brief := briefs[current]Creates a variable named brief. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
var completed_before: bool = record.completed.has(brief.id)Creates a variable named completed_before. The expression asks whether the collection contains the value or key. The type after the colon says what kind of value it can hold. -
chapter_label.text = "%s · Brief %d of %d%s" % [Catalog.CHAPTERS[int(brief.chapter)], current + 1, briefs.size(), " · Badge earned" if completed_before else ""]Updates chapter_label.text, which controls the words a player sees. The expression uses the text inside the quotes. -
brief_label.text = brief.titleUpdates brief_label.text, which controls the words a player sees. The expression reads brief.title. -
story_label.text = brief.storyUpdates story_label.text, which controls the words a player sees. The expression reads brief.story. -
display_status.text = messageUpdates display_status.text, which controls the words a player sees. The expression reads message. -
for i in range(Rules.SIZE):Repeats the indented instructions for each value in range(Rules.SIZE). -
var open: bool = i in brief.activeCreates a variable named open. The expression evaluates the test to see whether it is true or false. The type after the colon says what kind of value it can hold. -
var tile := shelf_buttons[i]Creates a variable named tile. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
tile.disabled = not open or display_completeUpdates tile.disabled, which controls whether the control should ignore activation. The expression evaluates the test to see whether it is true or false. -
var edge := GOLD if i == hint_slot else Color("#a57496")Creates a variable named edge. The expression chooses one of two values by checking the condition in the middle. Godot infers the type from the first value. -
var face := Color("#704b73") if open else Color("#4a3b53")Creates a variable named face. The expression builds a colour from these values. Godot infers the type from the first value. -
button_face(tile, face, edge)Calls button_face with the values in its parentheses. -
shelf_caps[i].text = Rules.slot_label(i)Updates shelf_caps[i].text, which controls the words a player sees. The expression calls Rules.slot_label with the values in its parentheses. -
shelf_packs[i].use_product(board[i])Continues this part of the script. Read the expression on this line in the context of the nearby declaration or function. -
var tag := "Choose slot" if open else "Closed"Creates a variable named tag. The expression chooses one of two values by checking the condition in the middle. Godot infers the type from the first value. -
if not board[i].is_empty():Checks not board[i].is_empty(). The indented instructions below run only if this test passes. -
tag = Catalog.name_for(board[i])Stores the new value in tag. The expression calls Catalog.name_for with the values in its parentheses. -
shelf_names[i].text = tagUpdates shelf_names[i].text, which controls the words a player sees. The expression reads tag. -
tile.accessibility_name = "%s, %s" % [Rules.slot_label(i), tag]Stores the new value in tile.accessibility_name. The expression uses the text inside the quotes. -
for i in range(stock_controls.size()):Repeats the indented instructions for each value in range(stock_controls.size()). -
var pick := stock_controls[i]Creates a variable named pick. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
pick.visible = i < stock_order.size()Updates pick.visible, which controls whether the node should appear. The expression reads i < stock_order.size(). -
if not pick.visible:Checks not pick.visible. The indented instructions below run only if this test passes. -
continueSkips the rest of this turn through the loop and moves on to the next item. -
var id := stock_order[i]Creates a variable named id. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
var selected_here := id == selectedCreates a variable named selected_here. The expression evaluates the test to see whether it is true or false. Godot infers the type from the first value. -
var left := Rules.available(brief, board, id)Creates a variable named left. The expression calls Rules.available with the values in its parentheses. Godot infers the type from the first value. -
button_face(pick, TEA if selected_here else PAPER, Color("#5e836d") if selected_here else FAINT)Calls button_face with the values in its parentheses. -
stock_names[i].text = Catalog.name_for(id)Updates stock_names[i].text, which controls the words a player sees. The expression calls Catalog.name_for with the values in its parentheses. -
stock_counters[i].text = "%d left%s" % [left, " · selected" if selected_here else ""]Updates stock_counters[i].text, which controls the words a player sees. The expression chooses one of two values by checking the condition in the middle. -
stock_packs[i].use_product(id)Continues this part of the script. Read the expression on this line in the context of the nearby declaration or function. -
pick.accessibility_name = "%s, %d left%s" % [Catalog.name_for(id), left, ", selected" if selected_here else ""]Stores the new value in pick.accessibility_name. The expression chooses one of two values by checking the condition in the middle. -
stock_empty.visible = stock_order.is_empty()Updates stock_empty.visible, which controls whether the node should appear. The expression calls stock_order.is_empty with the values in its parentheses. -
inspect_button.disabled = selected.is_empty()Updates inspect_button.disabled, which controls whether the control should ignore activation. The expression calls selected.is_empty with the values in its parentheses. -
remove_button.text = "Removing · on" if removing else "Remove mode"Updates remove_button.text, which controls the words a player sees. The expression chooses one of two values by checking the condition in the middle. -
remove_button.accessibility_name = remove_button.textStores the new value in remove_button.accessibility_name. The expression reads remove_button.text. -
remove_button.disabled = display_completeUpdates remove_button.disabled, which controls whether the control should ignore activation. The expression reads display_complete. -
undo_button.disabled = history.is_empty() or display_completeUpdates undo_button.disabled, which controls whether the control should ignore activation. The expression calls history.is_empty with the values in its parentheses. -
check_button.visible = not display_complete or current + 1 == briefs.size()Updates check_button.visible, which controls whether the node should appear. The expression evaluates the test to see whether it is true or false. -
check_button.disabled = display_completeUpdates check_button.disabled, which controls whether the control should ignore activation. The expression reads display_complete. -
next_button.visible = display_complete and current + 1 < briefs.size()Updates next_button.visible, which controls whether the node should appear. The expression evaluates the test to see whether it is true or false. -
album_button.text = "Scrapbook %d/%d" % [record.collected.size(), Catalog.PRODUCTS.size()]Updates album_button.text, which controls the words a player sees. The expression uses the text inside the quotes. -
album_button.accessibility_name = album_button.textStores the new value in album_button.accessibility_name. The expression reads album_button.text. -
func choose_stock(index: int) -> void:Defines choose stock, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if index < 0 or index >= stock_order.size():Checks index < 0 or index >= stock_order.size(). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
selected = stock_order[index]Stores the new value in selected. The expression looks up the item or key written between the square brackets. -
removing = falseStores the new value in removing. The expression uses the yes-or-no value false. -
var left := Rules.available(briefs[current], board, selected)Creates a variable named left. The expression calls Rules.available with the values in its parentheses. Godot infers the type from the first value. -
var message := "%s selected. Choose an open slot." % Catalog.name_for(selected)Creates a variable named message. The expression uses the text inside the quotes. Godot infers the type from the first value. -
if left == 0:Checks left == 0. The indented instructions below run only if this test passes. -
message = "%s is already on the shelf. You can still inspect it." % Catalog.name_for(selected)Stores the new value in message. The expression uses the text inside the quotes. -
refresh(message)Calls refresh with the values in its parentheses. -
func choose_slot(index: int) -> void:Defines choose slot, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if display_complete:Checks display_complete. The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
if selected.is_empty() and not removing:Checks selected.is_empty() and not removing. The indented instructions below run only if this test passes. -
refresh("Choose a package to place, or turn on Remove mode.")Calls refresh with the values in its parentheses. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
var id := "" if removing else selectedCreates a variable named id. The expression chooses one of two values by checking the condition in the middle. Godot infers the type from the first value. -
var step := Rules.with_piece(briefs[current], board, index, id)Creates a variable named step. The expression calls Rules.with_piece with the values in its parentheses. Godot infers the type from the first value. -
if step.is_empty():Checks step.is_empty(). The indented instructions below run only if this test passes. -
refresh("That slot cannot change. Check your stock or choose another slot.")Calls refresh with the values in its parentheses. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
history.append(board)Adds an item to the end of a list. -
board = stepStores the new value in board. The expression reads step. -
if index == hint_slot:Checks index == hint_slot. The indented instructions below run only if this test passes. -
hint_slot = -1Stores the new value in hint_slot. The expression reads -1. -
hint_text = ""Stores the new value in hint_text. The expression uses the text inside the quotes. -
var message := "Placed %s in %s." % [Catalog.name_for(id), Rules.slot_label(index)]Creates a variable named message. The expression uses the text inside the quotes. Godot infers the type from the first value. -
if removing:Checks removing. The indented instructions below run only if this test passes. -
message = "%s is clear. The package went back to stock." % Rules.slot_label(index)Stores the new value in message. The expression uses the text inside the quotes. -
refresh(message)Calls refresh with the values in its parentheses. -
func toggle_remove() -> void:Defines toggle remove, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
removing = not removingStores the new value in removing. The expression reads not removing. -
selected = ""Stores the new value in selected. The expression uses the text inside the quotes. -
refresh("Choose a filled slot to put a package back." if removing else "Choose a package from the stock drawers.")Calls refresh with the values in its parentheses. -
func undo() -> void:Defines undo, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if history.is_empty() or display_complete:Checks history.is_empty() or display_complete. The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
board.assign(history.pop_back())Calls board.assign with the values in its parentheses. -
hint_slot = -1Stores the new value in hint_slot. The expression reads -1. -
hint_text = ""Stores the new value in hint_text. The expression uses the text inside the quotes. -
refresh("Undid the last shelf change.")Calls refresh with the values in its parentheses. -
func confirm_reset() -> void:Defines confirm reset, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
open_overlay("reset", "Start this display again?", "The packages on this shelf go back to their drawers.")Calls open_overlay with the values in its parentheses. -
text(overlay_body, Rect2(24, 20, 703, 62), "The current arrangement will be cleared. Badges and scrapbook finds stay saved.", 21, INK, false, false, true)Calls text with the values in its parentheses. -
button(overlay_body, Rect2(24, 126, 190, 54), "Reset display", reset_current, PINK)Calls button with the values in its parentheses. -
button(overlay_body, Rect2(233, 126, 190, 54), "Keep arranging", close_overlay, TEA)Calls button with the values in its parentheses. -
func reset_current() -> void:Defines reset current, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
close_overlay()Calls close_overlay with the values in its parentheses. -
open_brief(current)Calls open_brief with the values in its parentheses. -
func show_hint() -> void:Defines show hint, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if briefs.is_empty() or display_complete:Checks briefs.is_empty() or display_complete. The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
var tip := Rules.hint(briefs[current], board)Creates a variable named tip. The expression calls Rules.hint with the values in its parentheses. Godot infers the type from the first value. -
if tip.is_empty():Checks tip.is_empty(). The indented instructions below run only if this test passes. -
refresh("Your display matches the clues. Try Check display.")Calls refresh with the values in its parentheses. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
hint_slot = int(tip.slot)Stores the new value in hint_slot. The expression converts a suitable value to a whole number. -
var label := Rules.slot_label(hint_slot)Creates a variable named label. The expression calls Rules.slot_label with the values in its parentheses. Godot infers the type from the first value. -
hint_text = "Clear %s first, then ask again." % label if tip.remove else "Try %s at %s." % [Catalog.name_for(tip.product), label]Stores the new value in hint_text. The expression chooses one of two values by checking the condition in the middle. -
refresh(hint_text)Calls refresh with the values in its parentheses. -
func check_display() -> void:Defines check display, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if display_complete:Checks display_complete. The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
var brief := briefs[current]Creates a variable named brief. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
var problem := Rules.result(brief, board)Creates a variable named problem. The expression calls Rules.result with the values in its parentheses. Godot infers the type from the first value. -
if not problem.is_empty():Checks not problem.is_empty(). The indented instructions below run only if this test passes. -
refresh(problem)Calls refresh with the values in its parentheses. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
for id in board:Repeats the indented instructions for each value in board. -
if not id.is_empty():Checks not id.is_empty(). The indented instructions below run only if this test passes. -
record.collected[id] = trueStores the new value in record.collected[id]. The expression uses the yes-or-no value true. -
record.completed[brief.id] = trueStores the new value in record.completed[brief.id]. The expression uses the yes-or-no value true. -
display_complete = trueStores the new value in display_complete. The expression uses the yes-or-no value true. -
hint_slot = -1Stores the new value in hint_slot. The expression reads -1. -
var saved := Progress.save_record(record, save_path)Creates a variable named saved. The expression calls Progress.save_record with the values in its parentheses. Godot infers the type from the first value. -
if saved == OK:Checks saved == OK. The indented instructions below run only if this test passes. -
refresh("Display accepted! Badge and shelf finds saved to your scrapbook.")Calls refresh with the values in its parentheses. -
else:Runs the indented fallback instructions if none of the earlier tests passed. -
refresh("Display accepted. The device could not save progress.")Calls refresh with the values in its parentheses. -
func unlocked(index: int) -> bool:Defines unlocked, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
return index == 0 or record.completed.has(briefs[index - 1].id)Finishes the function and hands its result back to the caller. The expression evaluates the test to see whether it is true or false. -
func next_brief() -> void:Defines next brief, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if display_complete and current + 1 < briefs.size():Checks display_complete and current + 1 < briefs.size(). The indented instructions below run only if this test passes. -
open_brief(current + 1)Calls open_brief with the values in its parentheses. -
func build_overlay() -> void:Defines build overlay, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
overlay = Control.new()Stores the new value in overlay. The expression creates a new Control object. -
overlay.mouse_filter = Control.MOUSE_FILTER_STOPUpdates overlay.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_STOP. -
arrange(overlay, self, Rect2(0, 0, 1280, 720))Calls arrange with the values in its parentheses. -
var mask := ColorRect.new()Creates a variable named mask. The expression creates a new ColorRect object. Godot infers the type from the first value. -
mask.color = Color(0.16, 0.10, 0.22, 0.83)Stores the new value in mask.color. The expression builds a colour from these values. -
mask.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates mask.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
arrange(mask, overlay, Rect2(0, 0, 1280, 720))Calls arrange with the values in its parentheses. -
panel(overlay, Rect2(190, 91, 900, 535), CREAM, PALE, 23, true)Calls panel with the values in its parentheses. -
overlay_title = text(overlay, Rect2(224, 112, 672, 49), "", 34, INK, true)Stores the new value in overlay_title. The expression calls text with the values in its parentheses. -
overlay_deck = text(overlay, Rect2(226, 168, 825, 27), "", 17, MID)Stores the new value in overlay_deck. The expression calls text with the values in its parentheses. -
overlay_close = button(overlay, Rect2(952, 118, 109, 45), "Close", close_overlay, PALE)Stores the new value in overlay_close. The expression calls button with the values in its parentheses. -
overlay_body = Control.new()Stores the new value in overlay_body. The expression creates a new Control object. -
overlay_body.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates overlay_body.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE. -
arrange(overlay_body, overlay, Rect2(222, 211, 831, 390))Calls arrange with the values in its parentheses. -
overlay.hide()Makes this control invisible. -
func open_overlay(page: String, label: String, explainer: String) -> void:Defines open overlay, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if not overlay.visible:Checks not overlay.visible. The indented instructions below run only if this test passes. -
overlay_source = get_viewport().gui_get_focus_owner() as ButtonStores the new value in overlay_source. The expression calls get_viewport with the values in its parentheses. -
for child in overlay_body.get_children():Repeats the indented instructions for each value in overlay_body.get_children(). -
overlay_body.remove_child(child)Calls overlay_body.remove_child with the values in its parentheses. -
child.queue_free()Asks Godot to remove this node safely at the end of the frame. -
for child in get_children():Repeats the indented instructions for each value in get_children(). -
if child is Button:Checks child is Button. The indented instructions below run only if this test passes. -
child.focus_mode = Control.FOCUS_NONEStores the new value in child.focus_mode. The expression reads Control.FOCUS_NONE. -
overlay_title.text = labelUpdates overlay_title.text, which controls the words a player sees. The expression reads label. -
overlay_deck.text = explainerUpdates overlay_deck.text, which controls the words a player sees. The expression reads explainer. -
overlay_page = pageStores the new value in overlay_page. The expression reads page. -
overlay.show()Makes this control visible. -
overlay_close.grab_focus()Gives this control keyboard focus so Space, Enter or arrow keys can reach it. -
func close_overlay() -> void:Defines close overlay, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
overlay.hide()Makes this control invisible. -
overlay_page = ""Stores the new value in overlay_page. The expression uses the text inside the quotes. -
for child in get_children():Repeats the indented instructions for each value in get_children(). -
if child is Button:Checks child is Button. The indented instructions below run only if this test passes. -
child.focus_mode = Control.FOCUS_ALLStores the new value in child.focus_mode. The expression reads Control.FOCUS_ALL. -
if is_instance_valid(overlay_source) and overlay_source.is_visible_in_tree() and not overlay_source.disabled:Checks is_instance_valid(overlay_source) and overlay_source.is_visible_in_tree() and not overlay_source.disabled. The indented instructions below run only if this test passes. -
overlay_source.grab_focus()Gives this control keyboard focus so Space, Enter or arrow keys can reach it. -
overlay_source = nullStores the new value in overlay_source. The expression uses null to say there is no object or value here. -
func show_help() -> void:Defines show help, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
open_overlay("help", "Arrange your first display", "Every brief gives you a fixed drawer of packages and a small list of clues.")Calls open_overlay with the values in its parentheses. -
var points := [Creates a variable named points. The expression makes a list whose items keep their order. Godot infers the type from the first value. -
"Choose a package in Stock drawers. Inspect pack opens a close-up of the miniature.",Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"Choose an open shelf slot to place it. Remove mode returns the package to its drawer.",Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"Read the clues. Packages beside each other share an edge. Diagonal corners do not count.",Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
"Use Check display to earn a badge and add placed miniatures to the scrapbook."Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above. -
]Closes the parentheses, list or dictionary opened above. Any trailing comma separates this item from the next. -
for i in range(points.size()):Repeats the indented instructions for each value in range(points.size()). -
var frame := Rect2(13, 1 + i * 65, 801, 53)Creates a variable named frame. The expression describes a position and a size. Godot infers the type from the first value. -
panel(overlay_body, frame, PAPER, FAINT, 12)Calls panel with the values in its parentheses. -
text(overlay_body, Rect2(frame.position + Vector2(14, 5), Vector2(765, 43)), "%d. %s" % [i + 1, points[i]], 18, INK, false, false, true)Calls text with the values in its parentheses. -
text(overlay_body, Rect2(16, 273, 798, 60), "Tap the on-screen controls, or use Tab and Enter on a keyboard. Use Escape to close these panels. A hint suggests one change at a time.", 17, MID, false, false, true)Calls text with the values in its parentheses. -
func show_inspect() -> void:Defines show inspect, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if not Catalog.PRODUCTS.has(selected):Checks not Catalog.PRODUCTS.has(selected). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
var data: Dictionary = Catalog.PRODUCTS[selected]Creates a variable named data. The expression looks up the item or key written between the square brackets. The type after the colon says what kind of value it can hold. -
open_overlay("inspect", data.name, "%s · Original miniature package" % str(data.category).capitalize())Calls open_overlay with the values in its parentheses. -
panel(overlay_body, Rect2(14, 5, 291, 326), Color(data.colour).lightened(0.68), FAINT)Calls panel with the values in its parentheses. -
package(overlay_body, Rect2(62, 24, 195, 274), selected)Calls package with the values in its parentheses. -
text(overlay_body, Rect2(335, 35, 440, 52), "On the workbench", 26, INK, true)Calls text with the values in its parentheses. -
text(overlay_body, Rect2(337, 93, 455, 100), data.detail, 20, INK, false, false, true)Calls text with the values in its parentheses. -
var count := Rules.available(briefs[current], board, selected)Creates a variable named count. The expression calls Rules.available with the values in its parentheses. Godot infers the type from the first value. -
text(overlay_body, Rect2(338, 203, 452, 44), "%d available in this brief" % count, 18, MID)Calls text with the values in its parentheses. -
button(overlay_body, Rect2(337, 260, 209, 52), "Back to the shelf", close_overlay, TEA)Calls button with the values in its parentheses. -
func show_briefs() -> void:Defines show briefs, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if briefs.is_empty():Checks briefs.is_empty(). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
open_overlay("briefs", "Display briefs", "Complete a brief to open the next one. Replay any brief you have opened.")Calls open_overlay with the values in its parentheses. -
for c in range(Catalog.CHAPTERS.size()):Repeats the indented instructions for each value in range(Catalog.CHAPTERS.size()). -
text(overlay_body, Rect2(14 + c * 273, 0, 251, 36), Catalog.CHAPTERS[c], 19, INK, true)Calls text with the values in its parentheses. -
for i in range(briefs.size()):Repeats the indented instructions for each value in range(briefs.size()). -
var item := briefs[i]Creates a variable named item. The expression looks up the item or key written between the square brackets. Godot infers the type from the first value. -
var earned: bool = record.completed.has(item.id)Creates a variable named earned. The expression asks whether the collection contains the value or key. The type after the colon says what kind of value it can hold. -
var open := unlocked(i)Creates a variable named open. The expression calls unlocked with the values in its parentheses. Godot infers the type from the first value. -
var frame := Rect2(13 + (i / 3) * 273, 48 + (i % 3) * 87, 256, 70)Creates a variable named frame. The expression describes a position and a size. Godot infers the type from the first value. -
var detail := "Badge earned" if earned else ("Open brief" if open else "Unlock the prior brief")Creates a variable named detail. The expression chooses one of two values by checking the condition in the middle. Godot infers the type from the first value. -
var take := button(overlay_body, frame, "", choose_brief.bind(i), TEA if earned else PAPER)Creates a variable named take. The expression calls button with the values in its parentheses. Godot infers the type from the first value. -
take.disabled = not openUpdates take.disabled, which controls whether the control should ignore activation. The expression reads not open. -
take.accessibility_name = "%s, %s" % [item.title, detail]Stores the new value in take.accessibility_name. The expression uses the text inside the quotes. -
text(take, Rect2(12, 5, 231, 33), item.title, 18, INK if open else MID)Calls text with the values in its parentheses. -
text(take, Rect2(12, 38, 230, 24), detail, 14, MID)Calls text with the values in its parentheses. -
func choose_brief(index: int) -> void:Defines choose brief, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
if not unlocked(index):Checks not unlocked(index). The indented instructions below run only if this test passes. -
returnFinishes the function right here. Any later instructions in this function are skipped. -
close_overlay()Calls close_overlay with the values in its parentheses. -
open_brief(index)Calls open_brief with the values in its parentheses. -
func show_album() -> void:Defines show album, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect. -
open_overlay("scrapbook", "Miniature scrapbook", "Complete displays to collect their miniature packages. %d of %d found." % [record.collected.size(), Catalog.PRODUCTS.size()])Calls open_overlay with the values in its parentheses. -
var i := 0Creates a variable named i. The expression uses the whole number 0. Godot infers the type from the first value. -
for id in Catalog.PRODUCTS:Repeats the indented instructions for each value in Catalog.PRODUCTS. -
var found: bool = record.collected.has(id)Creates a variable named found. The expression asks whether the collection contains the value or key. The type after the colon says what kind of value it can hold. -
var frame := Rect2(14 + (i % 4) * 203, 4 + (i / 4) * 111, 190, 101)Creates a variable named frame. The expression describes a position and a size. Godot infers the type from the first value. -
var card := panel(overlay_body, frame, TEA if found else PAPER, FAINT)Creates a variable named card. The expression calls panel with the values in its parentheses. Godot infers the type from the first value. -
var title := Catalog.name_for(id) if found else "Yet to collect"Creates a variable named title. The expression calls Catalog.name_for with the values in its parentheses. Godot infers the type from the first value. -
if found:Checks found. The indented instructions below run only if this test passes. -
package(card, Rect2(65, 3, 60, 62), id)Calls package with the values in its parentheses. -
else:Runs the indented fallback instructions if none of the earlier tests passed. -
text(card, Rect2(63, 3, 64, 58), "?", 29, MID, true, true)Calls text with the values in its parentheses. -
text(card, Rect2(6, 67, 178, 26), title, 15, INK, false, true)Calls text with the values in its parentheses. -
i += 1Reads i, adds to its old value, then stores the result back in the same place. -
func _unhandled_input(event: InputEvent) -> void:Godot calls this for inputs that other controls have left unhandled. -
if event.is_action_pressed("ui_cancel") and overlay.visible:Checks event.is_action_pressed("ui_cancel") and overlay.visible. The indented instructions below run only if this test passes. -
close_overlay()Calls close_overlay with the values in its parentheses. -
get_viewport().set_input_as_handled()Calls get_viewport with the values in its parentheses.