chroma_solstice/dialogable.lua

28 lines
991 B
Lua
Raw Normal View History

2026-08-08 00:09:44 -04:00
-- Dialogable: a mixin that makes any Entity subclass talkable. `include` it and
-- give the entity a `self.book` (an Ink book); bumping the entity then opens the
-- modal Dialogue. npcs, signs, artifacts — anything you can talk to — are just
-- Dialogables. For now an entity carries one book; later it can swap books as it
-- progresses. All it does is route a bump to the dialogue manager.
Dialogable = {}
function Dialogable:onBump()
2026-08-12 12:27:52 -04:00
if self.book then
local wasOpen = Dialogue.isOpen()
Dialogue.open(self.book, self:dialogueBindings())
2026-08-12 12:27:52 -04:00
if Sound and not wasOpen then Sound.jabber() end
end
2026-08-08 00:09:44 -04:00
return true
end
-- Ink external functions exposed to this talker's book. A walking NPC (one that
-- includes Walker) can be sent to a named Mark with `~ walk_to("mark_name")`,
-- e.g. to leave after a conversation.
function Dialogable:dialogueBindings()
local talker = self
return {
walk_to = function(markName)
if talker.sendTo then talker:sendTo(markName) end
end,
}
end