Level Speech

If you want to put some dramatical chit-chat before you let the people run off and get killed, you need a few things.

Everything will start from stage_OnStart() and stage_OnStep()

First load the relevant picture files for anybody who could be talking.

function stage_OnStart()
GRP.name=loadGraphic("img/face/file.gfx")
GRP.name2=loadGraphic("img/face/file2.gfx")

The talk event must be called from the stage_OnStep() function and care must be taken that it won't be called a second time. It would be convenient to put it in the stage's start function but doing so takes away your character selection without initiating the chat. This function starts the chat immediately, before any character selection. It also starts the chat before any enemies are displayed. The actual game has it wait for 10 steps before calling startTalkEvent().

function stage_OnStep()
if flag~=1 then
flag=1
startTalkEvent("TalkTest",true);
end
end

It may be desireable to have the player select their character first, so that character will engage in the conversation. This is done like this:

(st15.lua)

talk_ended=false
talk_chr=-1
function stage_OnStep()
if talk_ended==false then
if getPlayerCountInPlay()>0 then
startTalkEvent("talk_before",true)
talk_ended=true
end
end
end

function talk_before()
talk_chr=getPlayerCharacter(0)
if talk_chr<0 then
talk_chr=getPlayerCharacter(1)
end

this will get the character number of player 1, or if that returns as -1, there must be no player 1 in play and player 2's character is retrieved. The actual dialogue lines are handled as such:

setActor (0,GRP.name)
bringUp (0)
say("This is line 1","Here we talk again…",128,255,255)
coroutine.yield()
bringDown(0)
setActor (1,GRP.name1)
bringUp(1)
say("This is line 2","",255,192,192)

setActor() defines the picture to display in the left (0) or right (1)
bringUp (0) brings the left picture in focus
the say() function includes two speech lines, and an RGB color code. Use an empty string: "" to have a line blank.
coroutine.yield() will wait for an input before proceeding, not necessary on the final line, but you must have it in between dialogues
bringDown(0) puts the left picture in the background

then we define the next person to speak and the pattern follows. Were you to use the character specific speech you simply fit that person's speech into an if talk_chr==value.

(common.lua)

MEM_REIMU=0
MEM_MARISA=1
MEM_SAKUYA=2
MEM_YOUMU=3
MEM_RUMIA=4
MEM_CIRNO=5
MEM_ALICE=6
MEM_PACHOULI=7

showCaption("Title","Full Name") - If you want to show something over the enemy picture

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.