Cabin Crew 34 · Show seat requests with shape and text

Cabin Crew Express · Lesson 34 of 50 · Intermediate to advanced · About 38 min

Two passengers can sit in the same row, so Ari needs an easy way to tell their seats and requests apart.

Storage cupboards, water and folded supplies in the compact onboard galley.
What you’ll make Give every request a seat code, item name, symbol and written status.

Download the projects from the course page. In Godot’s Project Manager, choose Import, select project.godot, and use Run Project (F5). Start from checkpoints/33 when the lesson builds on prior work, or copy the checkpoints/34 folder to try this lesson on its own. Read the file names in the steps before editing.

Seat. Keep A, B or F visible. → Item. Pair a symbol with a written request. → Outcome. Show a short text confirmation. → Focus. Let keyboard users activate the same controls.
Seat → Item → Outcome → Focus
Godot checkpoint window for Show seat requests with shape and text
From the running Godot checkpoint.

Build it step by step

Language and tools in this lesson Dictionary, Array, membership, string formatting, grab_focus.

  1. Open the editable checkpoint

    Start Godot 4.7.2, choose Import in Project Manager and select the project.godot file for this lesson. Open main.gd in FileSystem, then press F5. Stop the game with F8 before editing.

    Why it works This folder is its own project with a Control scene and an attached script. You can run it without files from any other lesson.

  2. Pair seat IDs with requests

    Find REQUESTS and SYMBOLS. Change the Water marker to + and run. Confirm 2A still asks for Water.

    const SYMBOLS := {"Water": "●", "Meal": "▲", "Blanket": "■"}

    Why it works The two dictionaries have different jobs. REQUESTS pairs a seat and item. SYMBOLS chooses how to draw that item.

  3. Format one complete label

    Study the %s placeholders in refresh. Point to which values fill them from left to right.

    control.text = "%s • %s %s%s" % [id, SYMBOLS[item], item, " ✓" if done else ""]

    Why it works Seat type, item symbol and item name survive without colour. The empty suffix becomes a tick after service.

  4. Add a second form of feedback

    Click seat 3F once, then again. Move the pointer over it and read the hover message.

    control.tooltip_text = "Seat %s: %s %s" % [id, item, "delivered" if done else "needed"]

    Why it works The written status describes whether an item was delivered or was already there. The same data can be used in a read-aloud feature.

  5. Test with colour removed

    Click Switch palette, then try another seat. Compare the symbols, item labels and delivery checks between palettes.

    quiet_view = not quiet_view

    Why it works The palette affects font colour. Delivery state is stored separately in served and always adds the same check symbol.

  6. Check a keyboard path

    Press F5 again, then use Tab and Enter to deliver to a labelled seat. Inspect grab_focus.

    seats["2A"].grab_focus()

    Why it works A useful first control is selected when the scene opens. Native Button controls can receive keyboard activation.

Watch the values change

  1. Open the scene No seat is in served.
    What you see. All three items have a shape and name.
  2. Activate 3F The ID enters served once.
    What you see. The button ends in a check and the caption says Meal delivered.
  3. Switch to white text Only the palette flag changes.
    What you see. The delivered and waiting states are still distinguishable.

Predict before you run If you remove all green from the game, how can you tell whether seat 3F has been served?

Reveal the answer

The label keeps its check and its written delivery message. It never depends on the green accent alone.

Complete checkpoint

Three seat buttons show unambiguous labels, checks and messages in either palette. Tab and Enter can reach each one.

main.gd

extends Control

const REQUESTS := {"2A": "Water", "3F": "Meal", "4B": "Blanket"}
const SYMBOLS := {"Water": "●", "Meal": "▲", "Blanket": "■"}
var served: Array[String] = []
var status: Label
var seats: Dictionary = {}
var quiet_view := false

func _ready() -> void:
	heading("Show every request without relying on colour", "ACCESSIBILITY")
	status = label("Every button shows the seat code, shape and request.", Vector2(48, 129))
	var index := 0
	for id: String in REQUESTS:
		var seat := button("", Vector2(48 + index * 283, 226), deliver.bind(id), 262)
		seats[id] = seat
		index += 1
	button("Switch palette", Vector2(48, 362), switch_palette, 205)
	button("Reset requests", Vector2(268, 362), reset_requests, 205)
	refresh()
	seats["2A"].grab_focus()

func refresh() -> void:
	for id: String in REQUESTS:
		var item: String = REQUESTS[id]
		var control: Button = seats[id]
		var done := id in served
		control.text = "%s • %s %s%s" % [id, SYMBOLS[item], item, " ✓" if done else ""]
		control.tooltip_text = "Seat %s: %s %s" % [id, item, "delivered" if done else "needed"]
		control.add_theme_color_override("font_color", Color.WHITE if quiet_view or not done else Color("#b1e6ba"))

func deliver(id: String) -> void:
	if id in served:
		status.text = "Seat %s already received its item." % id
		return
	served.append(id)
	status.text = "✓ Seat %s: %s delivered." % [id, REQUESTS[id]]
	refresh()

func switch_palette() -> void:
	quiet_view = not quiet_view
	status.text = "White text mode." if quiet_view else "Colour accent mode."
	refresh()

func reset_requests() -> void:
	served.clear()
	status.text = "All three seats are waiting."
	refresh()

func heading(caption: String, topic: String) -> void:
	label("CABIN CREW EXPRESS     /     " + topic, Vector2(48, 41), 15, Color("#ffca7b"))
	label(caption, Vector2(48, 73), 27)

func label(text: String, at: Vector2, pixels: int = 20, ink: Color = Color("#f7f4e9")) -> Label:
	var item := Label.new()
	item.text = text
	item.position = at
	item.add_theme_font_size_override("font_size", pixels)
	item.add_theme_color_override("font_color", ink)
	add_child(item)
	return item

func button(text: String, at: Vector2, action: Callable, width: float = 155.0) -> Button:
	var item := Button.new()
	item.text = text
	item.position = at
	item.custom_minimum_size = Vector2(width, 47)
	item.pressed.connect(action)
	add_child(item)
	return item

func _draw() -> void:
	draw_rect(Rect2(Vector2.ZERO, size), Color("#102336"))
	draw_rect(Rect2(Vector2(28, 25), Vector2(904, 483)), Color("#18364b"))

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 main.gd line by line
  1. extends ControlStarts with Godot's Control type. This script gets the abilities of that type and adds the game's own rules.
  2. const REQUESTS := {"2A": "Water", "3F": "Meal", "4B": "Blanket"}Store the exact food or comfort item each of the three example seats wants.
  3. const SYMBOLS := {"Water": "●", "Meal": "▲", "Blanket": "■"}Give every item a second identity cue independent of its colour.
  4. var served: Array[String] = []Keep the completed seat IDs in a typed list you can check or clear.
  5. var status: LabelDeclares status for later use. A colon followed by a type says which kind of value belongs here.
  6. var seats: Dictionary = {}Remember the visible Button associated with each seat ID.
  7. var quiet_view := falseCreates a variable named quiet_view. The expression uses the yes-or-no value false. Godot infers the type from the first value.
  8. 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.
  9. heading("Show every request without relying on colour", "ACCESSIBILITY")Calls heading with the values in its parentheses.
  10. status = label("Every button shows the seat code, shape and request.", Vector2(48, 129))Stores the new value in status. The expression calls label with the values in its parentheses.
  11. var index := 0Creates a variable named index. The expression uses the whole number 0. Godot infers the type from the first value.
  12. for id: String in REQUESTS:Repeats the indented instructions for each value in REQUESTS.
  13. var seat := button("", Vector2(48 + index * 283, 226), deliver.bind(id), 262)Bind the seat code while creating its button so the right passenger gets the delivery on click.
  14. seats[id] = seatFile a reference to this button under its seat code for later drawing updates.
  15. index += 1Reads index, adds to its old value, then stores the result back in the same place.
  16. button("Switch palette", Vector2(48, 362), switch_palette, 205)Calls button with the values in its parentheses.
  17. button("Reset requests", Vector2(268, 362), reset_requests, 205)Calls button with the values in its parentheses.
  18. refresh()Calls refresh with the values in its parentheses.
  19. seats["2A"].grab_focus()Move keyboard focus to the first passenger so Tab and Enter have a useful starting place.
  20. func refresh() -> 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.
  21. for id: String in REQUESTS:Repeats the indented instructions for each value in REQUESTS.
  22. var item: String = REQUESTS[id]Creates a variable named item. 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.
  23. var control: Button = seats[id]Creates a variable named control. 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.
  24. var done := id in servedLook up this seat rather than assuming a whole passenger row is complete.
  25. control.text = "%s • %s %s%s" % [id, SYMBOLS[item], item, " ✓" if done else ""]Show the ID, shape and written request. Append a tick to a completed request.
  26. control.tooltip_text = "Seat %s: %s %s" % [id, item, "delivered" if done else "needed"]Offer a second readable way to see whether this seat has already been served.
  27. control.add_theme_color_override("font_color", Color.WHITE if quiet_view or not done else Color("#b1e6ba"))Change the visual accent while leaving the semantic label and tick untouched.
  28. func deliver(id: String) -> void:Defines deliver, 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.
  29. if id in served:Reject a duplicate delivery before the seat can be added to progress twice.
  30. status.text = "Seat %s already received its item." % idUpdates status.text, which controls the words a player sees. The expression uses the text inside the quotes.
  31. returnFinishes the function right here. Any later instructions in this function are skipped.
  32. served.append(id)Record only the first accepted service for this seat code.
  33. status.text = "✓ Seat %s: %s delivered." % [id, REQUESTS[id]]Updates status.text, which controls the words a player sees. The expression uses the text inside the quotes.
  34. refresh()Calls refresh with the values in its parentheses.
  35. func switch_palette() -> void:Defines switch palette, 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.
  36. quiet_view = not quiet_viewStores the new value in quiet_view. The expression reads not quiet_view.
  37. status.text = "White text mode." if quiet_view else "Colour accent mode."Updates status.text, which controls the words a player sees. The expression chooses one of two values by checking the condition in the middle.
  38. refresh()Calls refresh with the values in its parentheses.
  39. func reset_requests() -> void:Defines reset requests, 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.
  40. served.clear()Remove the stored completions so the three labels can return to the waiting state.
  41. status.text = "All three seats are waiting."Updates status.text, which controls the words a player sees. The expression uses the text inside the quotes.
  42. refresh()Calls refresh with the values in its parentheses.
  43. func heading(caption: String, topic: String) -> void:Defines heading, 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.
  44. label("CABIN CREW EXPRESS / " + topic, Vector2(48, 41), 15, Color("#ffca7b"))Calls label with the values in its parentheses.
  45. label(caption, Vector2(48, 73), 27)Calls label with the values in its parentheses.
  46. func label(text: String, at: Vector2, pixels: int = 20, ink: Color = Color("#f7f4e9")) -> Label:Defines 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.
  47. var item := Label.new()Creates a variable named item. The expression creates a new Label object. Godot infers the type from the first value.
  48. item.text = textUpdates item.text, which controls the words a player sees. The expression reads text.
  49. item.position = atUpdates item.position, which controls the node's local x and y location. The expression reads at.
  50. item.add_theme_font_size_override("font_size", pixels)Calls item.add_theme_font_size_override with the values in its parentheses.
  51. item.add_theme_color_override("font_color", ink)Calls item.add_theme_color_override with the values in its parentheses.
  52. add_child(item)Adds the new node to the scene tree so that Godot can run and draw it.
  53. return itemFinishes the function and hands its result back to the caller. The expression reads item.
  54. func button(text: String, at: Vector2, action: Callable, width: float = 155.0) -> 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.
  55. var item := Button.new()Creates a variable named item. The expression creates a new Button object. Godot infers the type from the first value.
  56. item.text = textUpdates item.text, which controls the words a player sees. The expression reads text.
  57. item.position = atUpdates item.position, which controls the node's local x and y location. The expression reads at.
  58. item.custom_minimum_size = Vector2(width, 47)Updates item.custom_minimum_size, which controls the smallest space the layout should reserve for this control. The expression packs x and y into one value.
  59. item.pressed.connect(action)Links a signal to the function that should run when the event happens.
  60. add_child(item)Adds the new node to the scene tree so that Godot can run and draw it.
  61. return itemFinishes the function and hands its result back to the caller. The expression reads item.
  62. func _draw() -> void:Godot calls this when the node needs drawing. The instructions inside paint the current state.
  63. draw_rect(Rect2(Vector2.ZERO, size), Color("#102336"))Paints a rectangle at the given position and size.
  64. draw_rect(Rect2(Vector2(28, 25), Vector2(904, 483)), Color("#18364b"))Paints a rectangle at the given position and size.

Find and fix a bug

If no button shows its item, confirm refresh is called after seats have been created. The dictionary must have a button for each request.

Try a change

Ages 10–12 can invent a fourth symbol with an item name. Ages 13–16 can try different palettes and compare foreground contrast with a known contrast checker.