49 lines
2.2 KiB
Text
49 lines
2.2 KiB
Text
# attributes.ludic — editor metadata on the @-syntax: which registry a field indexes, which constants
|
|
# it takes, its range, its unit, the kind of file it names, that it is a colour, and a registry's own
|
|
# rules (append only, saved by key). None of them changes what the program does: `ludicc
|
|
# --emit-schema` carries them to an editor with every record, registry entry and const. Two are
|
|
# checked - @Ref must name a registry that exists, and @Node a field of its record naming a glTF.
|
|
#
|
|
# Running it prints: 2 1 Lantern 2
|
|
program Attributes {
|
|
# a shop in the valley
|
|
property Vendor {
|
|
key: string = ""
|
|
name: string = "" # what the sign over the counter says
|
|
}
|
|
@AppendOnly @ByKey
|
|
registry Vendors of Vendor as VD
|
|
def Vendors store { name: "General store" }
|
|
def Vendors marina { name: "Marina" }
|
|
|
|
# a tool a camp keeps
|
|
property Tool {
|
|
key: string = ""
|
|
name: string = ""
|
|
@Ref(Vendors) seller: int = 0 # who sells it
|
|
@Range(0, 20.5) @Unit("kg") weight: float = 1.0
|
|
@Asset("gltf")
|
|
model: string = "" # its model, under assets/kit
|
|
@Color tint: int = 16777215
|
|
@OneOf(VD_) stocked_at: int = VD_STORE
|
|
@Node(model) grip: string = "grip" # where a hand holds it, a node in that model
|
|
@Derived reach: float = 0.0 # worked out at boot from the model
|
|
@Text @Multiline blurb: string = "" # what the shop says about it
|
|
@Key bind: int = 0 # the key that takes it in hand
|
|
}
|
|
@AppendOnly
|
|
registry Tools of Tool as TL from "data/attr_tools.lres"
|
|
# a tool hung on the camp's rack: which, and from which node of ITS model
|
|
property RackSlot {
|
|
@Ref(Tools) tool: int = 0
|
|
@Node(tool) hook: string = "grip"
|
|
}
|
|
const CAMP_TOOLS: int = 2 * VD_COUNT # how many a camp can carry
|
|
# the tool a new camp starts with
|
|
function first_tool() -> string { return Tools[0].name }
|
|
# what a pack of n of a tool weighs - a fn(Tool,int)->float an editor can offer a field of that type
|
|
function pack_weight(t: Tool, n: int) -> float { return t.weight * float(n) }
|
|
entry {
|
|
print(`{TL_COUNT} {Tools[TL_LANTERN].seller} {Tools[TL_LANTERN].name} {CAMP_TOOLS / 2}`)
|
|
}
|
|
}
|