# Text, placeholders, items, menus, boards
Text values and interpolation, `%placeholders%`, colors, item factories, chest menus and their clicks, sidebar, boss bar, holograms, dialogs, text input. Open for any UI, shop or message work.

## Text and placeholders
- Numbers `1`, `-2.5`. Text `"a"` or `'a'`; escapes `\n \t \" \' \\ \$`.
- Interpolation: `"$name"`, `"${expr}"`. A bare `$word` must be a declared variable; write `\$` for a literal `$`.
- Text placeholders (server fills them in at runtime; unknown ones are a compiler warning):
  targets `%player% %entity% %victim% %damager% %shooter% %killer% %selected% %display_name%`, each also `_uuid`
  (`%uuid%` = `%entity_uuid%`); `%space% %empty%`; `%player_amount%` (in world) `%online%` (server)
  `%entity_count% %damage% %random%` (0..1) `%random_uuid% %time%` (ISO-8601) `%worlds%`.
  Functions without closing %: `%var(x)` `%length(list)` `%index(list, i)` `%entry(map, key)`, each with
  `_local/_save/_line` for other scopes; `%val(value_id)`, `%math(...)`. `"$x"` already compiles to these.
  `jmvcc sig %victim%` explains one. Inside `${...}` goes a JustCode expression, not a placeholder:
  `"${x}"` or `"%var(x)"`, never `"${%var(x)}"`. `%var(x)` / `%length` / `%index` / `%entry` of a `var` / `line var` /
  `save var` x is compiled to its scope form (`%var_local(x)` ...), like `"${x}"`; a game x stays `%var(x)`. Comparing a game value with a misspelled text
  (`value::event_interaction == "phisical"`, a block id that does not exist) is a compiler warning.
- Booleans `true`/`false`: in a boolean argument they are the switch TRUE/FALSE; in a variable, a list or a map they
  are the numbers 1 / 0 (`var on = true` → 1, `if (on == true)` / `if (on == 1)` work, `"$on"` and `"${true}"` print 1).
  A boolean argument of an action (a switch) takes a condition too: `player::set_allow_flying(hp > 5)`, `(on)`,
  `ignore_case = b` compile to `if (...) { action(TRUE) } else { action(FALSE) }` (the server takes no variable there);
  other arguments are computed once before the if, at most two such switches per call.

## Time as text: std::mmss, std::hmmss, std::time
Built into the compiler; each call is ONE server action (no function is added to the module):
```js
var t = std::mmss(ms)                 // ms → "mm:ss", zero-padded: 75000 → "01:15" (hours dropped: 3725000 → "02:05")
var h = std::hmmss(ms)                // ms → "H:mm:ss": 3725000 → "1:02:05"
var p = std::time(ms, "m:ss.SSS")     // any pattern: H hours, mm minutes, ss seconds, SSS ms → "1:15.123"
player::action_bar("${std::mmss(value::timestamp - start)}")   // works inside text too
```
Takes MILLISECONDS (seconds → `std::mmss(secs * 1000)`). ≈4× cheaper on the server than a hand-written mm:ss function.

## Factories and items
- Factories (arguments must be LITERALS, not variables):
  `item("diamond_sword")`, `location(x, y, z, yaw, pitch)` (yaw defaults to 90!), `vector(x, y, z)`,
  `sound("entity.player.levelup")`, `particle("flame")`, `potion("speed")`.
  An `inline var` constant counts as a literal: `inline var NAME = "&bTop"` + `item("book", NAME)` is fine
  (a `var`/`game var` is a type-mismatch error). `item(id, name, count, lore = [...])`: `&` codes in name and
  lore are compiled into colored item text (`&aBread` → JSON name with color green; how it looks in a menu
  is not checked on the server).

## Verified text facts (also in topic server-facts)
- `\n` in text and `player::message([...], merging = "SEPARATE_LINES")` give line breaks.
- Colors: `&a`, `&c`... work (until the end of the text); MiniMessage `<red>` and `§b` do NOT (shown as text).
- Text components with `set_component_hover` / `set_component_click` work (show_text, copy_to_clipboard).
- A text value keeps at most 25000 characters: the rest is cut SILENTLY, no error (a literal, `repeat_text`, joining).
  Longer → split into a list of texts. The compiler warns `text-too-long` on such texts in the module.
- Placeholders in text: `%val(timestamp)`, `%val(x_coordinate)`, `%val(current_health)` (NOT `health` — unknown ids give 0);
  `%length(name)` / `%length_local(name)` (missing variable → -1); `%index(name, 0)` (from 0); `%entry(map, key)`
  (missing → 0); `%math(%length(gl)-1)` works; `%math(10/4)` = 2.5. `%%` is NOT an escape — never write it.
- `variable::format_timestamp(ms, "mm:ss", "UTC")` → `01:15` (zero-padded; hours are dropped past 60 min — use
  `"H:mm:ss"` → `1:02:05`); `"mm:ss.SSS"` → `01:15.123`; a single `S` does not shorten (`1:15.123`).
- `%val(id)` uses the server id (`x_coordinate`, `y_coordinate`, `current_health`, `timestamp`, `event_final_damage`) and
  gives the same as `value::x`; an unknown id silently gives 0. `%length(x)`: list size, -1 for an unset variable,
  the text LENGTH for a text, the size of a map. `get_list_length` / `l[i]` on a non-list is a server error.
- `%index_local(l, 1)`, `%entry_line(m, k)`, `%length_line(l)` etc. work like the game-scope forms.

## Items, sound, menus (verified, also in topic server-facts)
- `give_item` without `amount` gives the item's count: `item("x")` → 1, `item("golden_apple", count = 3)` → 3.
  With `amount` it replaces count: `give_item(item("arrow", count = 16), amount = 2)` gives 2.
- `play_sound` without `location` plays to the player, not from a point.
- A missing key / index out of range in an explicit `get_map_value` / `get_map_value_single` / `get_list_value`
  call without `default_value` gives null: it prints "0" and math reads 0, but `== 0` and `in 0..0` are FALSE
  (verified). `m[k]` / `l[i]` pass `default_value = 0` for you; in explicit calls pass `default_value = 0`.
- `player_click_inventory` on a `show_menu`: `value::event_slot` from 0, `value::event_item` = the clicked
  menu item, `value::open_inventory_custom_id` = the `custom_id` of `show_menu`, `value::event_slot_type` =
  `"container"` for a menu slot. Only the menu half reaches `player_click_inventory`: clicks in the player's
  own inventory while a menu is open go to `player_click_own_inventory` (`event_slot` hotbar 0..8, main
  9..35, `event_slot_type` also `"container"`). There `value::open_inventory_custom_id` is also set (the open
  menu's id) and a shift-click has `value::event_inventory_click_type` = `"shift_left"`; `world::cancel_event()`
  on it keeps the item out of the menu.
- `show_menu` puts the 1st list item in slot 0, then slots follow list order. For a gap `item("air")` in the
  list probably gives an empty slot (compiles; not checked on the server).
- `player::set_boss_bar(..., progress)` is 0..100 (50 = half; 0.5 is almost empty); `&` colors in its title
  work (`&4&l` = dark red bold).
- `player::set_slot_item(item, 8)`: slot 8 is the LAST hotbar slot (slots start at 0). It overwrites that slot.
- `world::remove_scoreboard` of a board that does not exist does nothing; the code line goes on.
- Sidebar: `world::create_scoreboard(id, "&cTitle")` + `world::set_scoreboard_score(id, "Line text", n)` +
  `player::show_scoreboard(id)` shows it on the right; `text` is the line label, `&` colors work.
- `player_right_click` with a book in hand fires; `value::main_hand_item` is that book.
- `player::display_hologram(loc, "A\n&cB")`: two lines, & colors work; a second hologram at the SAME location replaces
  the first (update a board by re-displaying at the same spot), another location makes a separate one.

## Menus and text input (from the author's billiard; seen in a working game, not re-verified)
- A number slot accepts `%math(...)` text (`number_raw("%math(%var(speed)*7)")` in decompiled code).
- Menus: `player::show_menu(..., inventory_type = "HOPPER")` = 5 slots; `player::expand_menu(items, size = 3)` adds
  rows; `player::remove_menu_row(size, position = "BUTTON")` (the server enum is spelled BUTTON, not BOTTOM).
- Text input through chat: set a per-player flag from the menu, read `value::event_chat_message` in
  `event<player_chat>` + `world::cancel_event()`, clear the flag after a timeout (`wait` + compare a token).
- A shop menu with click dispatch, a menu item kept through death: topic recipes «More recipes».

## Dialogs (newer server actions, data 2026-11-27)
`world::create_dialog(id, title)`, `world::add_dialog_button`, `world::add_text_box_dialog_input`, ...,
`player::show_dialog_menu(id)`, `var t = variable::get_dialog_text(input_id)` (`jmvcc search dialog`).

## Colors and a framed chat block (also in topic look-and-feel)
- Colors: write the color FIRST, then `&l`: `"&#42A5F5&l1"` (a color code after `&l` resets bold — verified on item
  names). Hex `&#RRGGBB` is verified on item names and text displays; in chat the author says it works, in action bar
  and titles it is not checked. Pick colors against the block under them: a light floor (white_concrete) with
  saturated or dark digits, no gray on gray (minesweeper darkened 8 from #9E9E9E to #757575).
- A real batch of info for one player (rules on join, round summary): a framed, colored block, so it reads as UI:
  ```
  game var LINE = "&8&m                                                  "   // strikethrough spaces = a seamless line (verified; ━ ─ ▬ show seams)
  player::message([LINE, "  &#FFB300&lЗМЕЙКА", "  &7Ешь &6яблоки&7, не врежься в бортик", "  &e1-4 &7— повороты, &aизумруд &7— старт", LINE], merging = "SEPARATE_LINES")
  ```
  Hex `&#RRGGBB` works in chat and titles (verified, server-check-18). ~50 strikethrough spaces fit the default chat.
- Which channel for what (chat is the worst one), icons, flat text on blocks: topic look-and-feel.
