packages: the registry text a game fills is keys (Maroon Lake's phase 26.4) - ThingKind.name, GearKind blurb/howto/names, HintCard's words, JobDef title/text/how, NpcLine and NpcChoice text, WeatherKind.name are @Text Key fields (a compiled row that leaves one out takes its derived key, the English is the game's en.po); what a package hands back as text is the key's marked text, "" for none; NpcName.name, NpcChoice.line and SettingDef.text are not text and lose @Text; ludic.i18n's tr/trf/trn/key_text say @alloc_ok (tr is a cast); the packages' tests with key literals (built, not run); changes/text-keys-data.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-30 00:29:03 +03:00
parent 86146782f7
commit 86644e6533
21 changed files with 81 additions and 54 deletions

View file

@ -44,9 +44,12 @@ export function hints_mute_card(hints_st: mut HintsState) -> void {
# a step's words and its picture (n 1..3): the glyph's name, or the item (-1 when it is a glyph)
export function hints_step_text(id: int, n: int) -> string {
if n == 1 { return Hints[id].s1 }
if n == 2 { return Hints[id].s2 }
return Hints[id].s3
var k = Hints[id].s3
if n == 1 { k = Hints[id].s1 }
if n == 2 { k = Hints[id].s2 }
if k == null { return "" }
@alloc_ok("a cast: a key's marked text, nothing is made")
return string(k)
}
export function hints_step_icon(id: int, n: int) -> string {

View file

@ -11,18 +11,18 @@ export property HintCard {
@OneOf(HINTS_TIP, HINTS_NOTE, HINTS_WARN, HINTS_URGENT) urgency: int = HINTS_TIP
icon: string = ""
@Ref(Items) item: int = -1
@Text line: string = "" # the chip on the rail: five or six words
@Text title: string = "" # the card's heading
@Text s1: string = "" # three steps, each with a picture
@Text s2: string = ""
@Text s3: string = ""
@Text line: Key = null # the chip on the rail: five or six words
@Text title: Key = null # the card's heading
@Text s1: Key = null # three steps, each with a picture
@Text s2: Key = null
@Text s3: Key = null
pic1: string = ""
pic2: string = ""
pic3: string = ""
@Ref(Items) item1: int = -1
@Ref(Items) item2: int = -1
@Ref(Items) item3: int = -1
@Text @Multiline later: string = "" # how not to be here next time
@Text @Multiline later: Key = null # how not to be here next time
}
# the game's cards; a card's mute is kept by its key, so their order is free

View file

@ -1,3 +1,3 @@
# cards.lres - two cards from a file, after the test's own defs
bear { urgency: HINTS_URGENT, line: "Bear near", title: "A bear", icon: "bear" }
fire { urgency: HINTS_NOTE, line: "Light the fire", later: "Carry three logs." }
bear { urgency: HINTS_URGENT, line: k"hints.bear_near", title: k"hints.a_bear", icon: "bear" }
fire { urgency: HINTS_NOTE, line: k"hints.light_fire", later: k"hints.carry_logs" }

View file

@ -4,11 +4,11 @@ import "ludic.hints"
import "ludic.base"
program HintsTest {
numbers float
def Hints thirsty { urgency: HINTS_NOTE, line: "Thirsty - drink", title: "Water", s1: "Drink at a shore", pic1: "water", item2: 7 }
def Hints parched { urgency: HINTS_URGENT, line: "You must drink now", title: "Water, now" }
def Hints rain { urgency: HINTS_TIP, line: "Rain coming" }
def Hints cold { urgency: HINTS_WARN, line: "Cold" }
def Hints night { urgency: HINTS_TIP, line: "Night soon" }
def Hints thirsty { urgency: HINTS_NOTE, line: k"hints.thirsty", title: k"hints.water", s1: k"hints.drink_shore", pic1: "water", item2: 7 }
def Hints parched { urgency: HINTS_URGENT, line: k"hints.drink_now", title: k"hints.water_now" }
def Hints rain { urgency: HINTS_TIP, line: k"hints.rain" }
def Hints cold { urgency: HINTS_WARN, line: k"hints.cold" }
def Hints night { urgency: HINTS_TIP, line: k"hints.night" }
def Hints from "cards.lres"
state HintsTestState {
@ -40,10 +40,10 @@ program HintsTest {
expect_eq(HINT_COUNT, 7)
expect_eq(hints_find("parched"), HINT_PARCHED)
expect_eq(Hints[HINT_BEAR].urgency, HINTS_URGENT)
expect(Hints[HINT_FIRE].later == "Carry three logs.")
expect(Hints[HINT_FIRE].later == k"hints.carry_logs")
expect(hints_step_icon(HINT_THIRSTY, 1) == "water")
expect_eq(hints_step_item(HINT_THIRSTY, 2), 7)
expect(hints_step_text(HINT_THIRSTY, 1) == "Drink at a shore")
expect(hints_step_text(HINT_THIRSTY, 1) == string(k"hints.drink_shore"))
}
test "the most urgent true cards, capped, ties in registry order" (hints_st: mut HintsState, hints_test_st: mut HintsTestState) {