41 lines
1.1 KiB
Lua
41 lines
1.1 KiB
Lua
-- ============================================================================
|
|
-- npc.lua - NPC with multi-line dialogue
|
|
-- ============================================================================
|
|
-- Tests: onInteract, onButtonPress, Controls, UI text,
|
|
-- scene-level dialogue system, Input constants
|
|
|
|
local talked = false
|
|
|
|
function onCreate(self)
|
|
talked = false
|
|
end
|
|
|
|
function onInteract(self)
|
|
if isInDialogue() then return end
|
|
|
|
if not talked then
|
|
talked = true
|
|
startDialogue({
|
|
"Hello, traveler!",
|
|
"Welcome to the test scene.",
|
|
"There are collectibles, a door,",
|
|
"triggers, and a portal here.",
|
|
"Press CROSS to advance dialogue.",
|
|
"Good luck exploring!"
|
|
})
|
|
else
|
|
startDialogue({
|
|
"You again?",
|
|
"Go find the collectibles!",
|
|
"There should be three of them."
|
|
})
|
|
end
|
|
end
|
|
|
|
function onButtonPress(self, button)
|
|
if not isInDialogue() then return end
|
|
if button == Input.CROSS then
|
|
advanceDialogue()
|
|
end
|
|
end
|