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:
parent
86146782f7
commit
86644e6533
21 changed files with 81 additions and 54 deletions
|
|
@ -128,7 +128,7 @@ def NpcActs from "acts.lres"
|
|||
# a name somebody can have; `body` the game's (a pool per model), so a Nora is drawn as a woman
|
||||
export property NpcName {
|
||||
key: string = ""
|
||||
@Text name: string = ""
|
||||
name: string = "" # a person's name, the same in every language
|
||||
body: int = 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
# anything to say winning, each line in its turn given its `chance`; a line's words are its `text`,
|
||||
# or the story's (NpcTalk.say) when it `fill`s; a line may offer choices, each answered by a line
|
||||
export property NpcChoice {
|
||||
@Text text: string = ""
|
||||
@Text line: string = "" # the key of the line that answers it ("" ends the talk)
|
||||
@Text text: Key = null # its words (the derived key npc_lines.<row>.choices.<i>.text)
|
||||
line: string = "" # the key of the line that answers it ("" ends the talk)
|
||||
code: int = -1 # the game's, carried by the Talked fact
|
||||
}
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ export property NpcLine {
|
|||
@Ref(NpcActs) act: int = -1 # NPCA_* (-1: whatever they are doing)
|
||||
prio: int = 0
|
||||
chance: int = 100 # percent: how often this line is even considered
|
||||
@Text text: string = ""
|
||||
@Text text: Key = null # its words, a text key (null when it `fill`s)
|
||||
fill: bool = false
|
||||
choices: []NpcChoice = null
|
||||
}
|
||||
|
|
@ -30,7 +30,9 @@ function np_line_fits(p: NpcPerson, l: NpcLine) -> bool {
|
|||
export function npc_words(p: NpcPerson, line: int) -> string {
|
||||
if line < 0 or line >= NPCL_COUNT { return "" }
|
||||
if NpcLines[line].fill { return NpcTalk.say(p, line) }
|
||||
return NpcLines[line].text
|
||||
if NpcLines[line].text == null { return "" }
|
||||
@alloc_ok("a cast: a key's marked text, nothing is made")
|
||||
return string(NpcLines[line].text)
|
||||
}
|
||||
|
||||
# the line it would say now (-1: none), its words kept for npc_said()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# lines.lres - the test's lines: a fisher's hush, the story's news when it has any, a greeting with
|
||||
# two choices, and the answer to the first
|
||||
hush { act: NPCA_FISH, prio: 3, text: "Shh." }
|
||||
hush { act: NPCA_FISH, prio: 3, text: k"npc.shh" }
|
||||
news { prio: 2, fill: true }
|
||||
hello { prio: 1, text: "Morning.", choices: [{ text: "Any fish?", line: "fish_no", code: 7 }, { text: "Bye.", line: "" }] }
|
||||
fish_no { prio: -1, kind: NPCK_CAMPER, text: "Not today." }
|
||||
hello { prio: 1, text: k"npc.morning", choices: [{ text: k"npc.any_fish", line: "fish_no", code: 7 }, { text: k"npc.bye", line: "" }] }
|
||||
fish_no { prio: -1, kind: NPCK_CAMPER, text: k"npc.not_today" }
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ program NpcTest {
|
|||
let p = one(npc_st, npc_tests_fake_st, NPCK_CAMPER)
|
||||
npc_do(npc_st, p, NPCA_FISH, 100.0)
|
||||
expect_eq(npc_talk(npc_st, p, 0), NPCL_HUSH)
|
||||
expect(npc_said(npc_st) == "Shh.")
|
||||
expect(npc_said(npc_st) == string(k"npc.shh"))
|
||||
expect(npc_talked_today(p))
|
||||
npc_do(npc_st, p, NPCA_IDLE, 100.0)
|
||||
expect_eq(npc_line_for(npc_st, p), NPCL_HELLO)
|
||||
|
|
@ -212,7 +212,7 @@ program NpcTest {
|
|||
expect(npc_said(npc_st) == `{p.name} saw a bear.`)
|
||||
npc_test_st.news_on = false
|
||||
expect_eq(npc_choose(npc_st, p, NPCL_HELLO, 0, 0), NPCL_FISH_NO)
|
||||
expect(npc_said(npc_st) == "Not today.")
|
||||
expect(npc_said(npc_st) == string(k"npc.not_today"))
|
||||
expect_eq(npc_choose(npc_st, p, NPCL_HELLO, 1, 0), -1)
|
||||
let fs = q_drain(npc_facts(npc_st))
|
||||
expect_eq(len(fs), 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue