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
|
|
@ -10,7 +10,9 @@ export function thing_name(t: Thing) -> string {
|
|||
let s = k.name_of(t)
|
||||
if s != "" { return s }
|
||||
}
|
||||
return k.name
|
||||
if k.name == null { return "" }
|
||||
@alloc_ok("a cast: a key's marked text, nothing is made")
|
||||
return string(k.name)
|
||||
}
|
||||
|
||||
export function thing_prompt(t: Thing) -> string {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export property Thing {
|
|||
|
||||
export property ThingKind {
|
||||
key: string = "" # the entry's own name: what the save calls the kind
|
||||
@Text name: string = "" # what it is called when nothing about the one in front of you changes it
|
||||
@Text name: Key = null # what it is called when nothing about the one in front of you changes it
|
||||
reach: float = 2.2 # how close it is used from, when the Thing does not say
|
||||
personal: bool = false # one belongs to whoever put it down
|
||||
saved: bool = false # the save's section keeps a placed one (the port has the last word)
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ program ThingsTest {
|
|||
}
|
||||
function far_reach(t: Thing) -> float { return 9.0 }
|
||||
|
||||
def ThingKinds tent { name: "A tent", name_of: fn tent_name }
|
||||
def ThingKinds fire { name: "The fire", prompt: fn lit_prompt, use: fn lit_use, keeps: true }
|
||||
def ThingKinds branch { name: "Firewood", reach: 1.5, use: fn branch_use }
|
||||
def ThingKinds lure { name: "A lure", tick: fn lure_tick, put_down: true, saved: true }
|
||||
def ThingKinds sign { name: "A sign", reach_of: fn far_reach }
|
||||
def ThingKinds tent { name: k"things.tent", name_of: fn tent_name }
|
||||
def ThingKinds fire { name: k"things.fire", prompt: fn lit_prompt, use: fn lit_use, keeps: true }
|
||||
def ThingKinds branch { name: k"things.firewood", reach: 1.5, use: fn branch_use }
|
||||
def ThingKinds lure { name: k"things.lure", tick: fn lure_tick, put_down: true, saved: true }
|
||||
def ThingKinds sign { name: k"things.sign", reach_of: fn far_reach }
|
||||
|
||||
function hill(x: float, z: float) -> float { return x * 0.5 }
|
||||
function on_placed(things_test_st: mut ThingsTestState, t: Thing) -> void { things_test_st.drawn += 1 }
|
||||
|
|
@ -102,7 +102,7 @@ program ThingsTest {
|
|||
test "the kind answers: name, prompt, use, reach" (things_st: mut ThingsState) {
|
||||
things_clear(things_st)
|
||||
let t = put(things_st, TH_TENT, 0.0, 0.0)
|
||||
expect(thing_name(t) == "A tent")
|
||||
expect(thing_name(t) == string(k"things.tent"))
|
||||
t.owner = 0
|
||||
expect(thing_name(t) == "Your tent")
|
||||
let f = put(things_st, TH_FIRE, 0.0, 0.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue