diff --git a/init.lua b/init.lua index 56be308..bae956b 100644 --- a/init.lua +++ b/init.lua @@ -147,43 +147,12 @@ composition.define_template{ tags = {"renderable", "item"}, } --- Stone-Pick-Template: output of rock_pick recipe (1 rock + 1 stick). --- Lives only in the backpack post-craft in v0.11 (no world-drop path yet --- via the Crafting-Panel). slot_05_tee_open reads as a tool-shaped tile. -composition.define_template{ - id = "rock_pick", - properties = { - stack_mode = "individual", - name = "Stone Pick", - description = "A crude pick for mining stone.", - weight = 2.8, -- rock + stick (real units) - volume = 0.0015, - ["composition.stone"] = 0.9, - ["composition.wood"] = 0.1, - sprite_atlas = "", - sprite_uv = {x = 0, y = 0, w = 1, h = 1}, - position = {x = 0, y = 0}, - }, - tags = {"renderable", "item"}, -} - --- Rock-Pile-Template: output of 3×rock recipe. slot_13_solid reads as --- a dense cluster tile — visually distinct from a single rock. -composition.define_template{ - id = "rock_pile", - properties = { - stack_mode = "individual", - name = "Rock Pile", - description = "A stack of rocks bundled together for storage.", - weight = 7.5, -- 3x rock - volume = 0.003, - ["composition.stone"] = 1.0, - sprite_atlas = "", - sprite_uv = {x = 0, y = 0, w = 1, h = 1}, - position = {x = 0, y = 0}, - }, - tags = {"renderable", "item"}, -} +-- NOTE: Crafted-output templates (rock_pick, rock_pile) are defined inside +-- M.init rather than at top-level, because their sprite_atlas defaults need +-- the resolved blob_rect_stone PNG path. Crafting calls composition.create +-- with no extra properties, so the template defaults are the only place to +-- carry sprite_atlas / sprite_uv onto crafted items. See M.init for the +-- actual define_template calls. -- Player-Actor-Template (Phase A.6). Vagrant's player is an actor whose -- position drives the puppet (sync each frame). NOT tagged renderable — @@ -497,6 +466,51 @@ function M.init(ctx) stone_uvs[t.name] = { x = t.uv[1], y = t.uv[2], w = t.uv[3], h = t.uv[4] } end + -- Crafted-output templates: defined here (not top-level) so their + -- sprite_atlas defaults can carry the resolved blob_rect_stone PNG path. + -- crafting.craft calls composition.create with no overrides, so the + -- template defaults are the only carrier for sprite_atlas / sprite_uv + -- on the crafted instance. Without this, crafted items render as a + -- "?" placeholder in the inventory and a magenta-fallback square on + -- drop (lib-core.render path-3). + -- slot_05_tee_open reads as a tool-shaped tile (rock_pick). + -- slot_13_solid reads as a dense cluster tile (rock_pile). + local rock_pick_uv = stone_uvs["slot_05_tee_open"] + composition.define_template{ + id = "rock_pick", + properties = { + stack_mode = "individual", + name = "Stone Pick", + description = "A crude pick for mining stone.", + weight = 2.8, -- rock + stick (real units) + volume = 0.0015, + ["composition.stone"] = 0.9, + ["composition.wood"] = 0.1, + sprite_atlas = stone_atlas_png, + sprite_uv = {x = rock_pick_uv.x, y = rock_pick_uv.y, + w = rock_pick_uv.w, h = rock_pick_uv.h}, + position = {x = 0, y = 0}, + }, + tags = {"renderable", "item"}, + } + local rock_pile_uv = stone_uvs["slot_13_solid"] + composition.define_template{ + id = "rock_pile", + properties = { + stack_mode = "individual", + name = "Rock Pile", + description = "A stack of rocks bundled together for storage.", + weight = 7.5, -- 3x rock + volume = 0.003, + ["composition.stone"] = 1.0, + sprite_atlas = stone_atlas_png, + sprite_uv = {x = rock_pile_uv.x, y = rock_pile_uv.y, + w = rock_pile_uv.w, h = rock_pile_uv.h}, + position = {x = 0, y = 0}, + }, + tags = {"renderable", "item"}, + } + -- Spawn Rock-Entity 80px to the left of the backpack so it sits in a -- distinct position: visible to the player on first load, not overlapping -- the backpack, reachable by walking left from spawn. @@ -668,7 +682,7 @@ function M.init(ctx) lines[#lines + 1] = "Output: " .. recipe.output.template .. " \xc3\x97 " .. recipe.output.count notify.post{ - tags = {"craft", "inspect", "detail"}, + tags = {"inspect", "detail"}, text = table.concat(lines, "\n"), severity = "info", } @@ -683,7 +697,7 @@ function M.init(ctx) -- Channels (created BEFORE display attach + widget register) notify.create_channel{ id = "inspect", filter = {"inspect"}, display_mode = "detail" } - notify.create_channel{ id = "events", filter = {"pickup", "drop", "crafting", "craft"}, + notify.create_channel{ id = "events", filter = {"pickup", "drop", "craft"}, display_mode = "toast" } notify.create_channel{ id = "log", filter = {}, -- catch-all display_mode = "log" }