Skip to content

Custom Dialogue

Bradley edited this page Feb 13, 2023 · 4 revisions

To add dialogue, its not that hard...

Here is some example code from week6

weeks:generateNotes("data/week6/senpai/senpai" .. difficulty .. ".json")
dialogue.set("data/week6/senpai/senpaiDialogue.txt")

if storyMode and not died then
	dialogue.addSpeaker("dad", love.filesystem.load("sprites/week6/senpaiPortrait.lua")(), 650, 375, 6, 6, true)
	dialogue.setSpeakerBox("dad", love.filesystem.load("sprites/week6/dialogueBox.lua")(), 650, 375, 6, 6, true)

	dialogue.addSpeaker("bf", love.filesystem.load("sprites/week6/bfPortrait.lua")(), 650, 375, 6, 6, true)
	dialogue.setSpeakerBox("bf", love.filesystem.load("sprites/week6/dialogueBox.lua")(), 650, 375, 6, 6, true)

	dialogue.setMusic(love.audio.newSource("music/pixel/Lunchbox.ogg", "stream"))

	dialogue.setCallback(
		function()
			weeks:setupCountdown()
		end
	)
else
	weeks:setupCountdown()
end

For dialogue.addSpeaker, the arguments go in this order: speaker, file, x, y, sizeX, sizeY, isSprite, replayAnim dialogue.addSpeakerBox is the same thing

Somewhere in the update function, put the following code in it

if inCutscene then
	dialogue.doDialogue(dt)
end

if input:pressed("confirm") and inCutscene then
	dialogue.next()
end

in the draw function, replace weeks:drawUI() with

if inCutscene then 
        dialogue.draw()
else
	weeks:drawUI()
end
Clone this wiki locally