This is a quick script made for delivering a series of up to nine statements via hudPrint(). To use it, place it in a script object, and connect a trigger, or call the longSpeech() function.
To customize it, simply change the quoted text in the 'statement' table, and [optionally] adjust the values in the 'pause' table, to best suit your text ~that is if the automatic delay is not ideal.
If it's not, simply replace the entry with your own number as the delay.
Code: Select all
--[[ This script supports up to nine statement entries, with pauses between them.
Add or remove the statement entries as needed.
This script does not ~technically~ support multi-line statements, but it is possible
to format a string with extra spaces and escape code \n, to fit in a second line of text.
The extra empty spaces would be needed to center the text manually, and you might want
to use a number to override the delay, as the spaces would count to lengthen the pause.
The statement table must have nine entries (statements). They can be empty; empty quotes are
ignored, and should ~only~ exist as the last entries; to fill up the remainder of the nine slots.
IMPORTANT: Only call this script once (obviously), you should only call it via script, or with a one-time use pressure plate.
If you do call it more than once with script, make sure that it has had time to stop; or else the statements can overlap.
--]]
statement = {
"This is the first statement.",
"And this is the second. (After a brief pause)",
"[clears throat]",
"and this is the final statement.",
"[an awkward silence ensues]",
"Where has the rum gone?",
" Double line of text, \n it kind of works, but it\'s not perfect.",
"",
"",
} -- There must always be nine statements. Pad the end of your dialog with "",
pauses = {0,
#statement[1]/5,
#statement[2]/5,
#statement[3]/5,
#statement[4]/5,
#statement[5]/5, -- replacing this line with 35, would add a 35 second delay after the fifth statement.
#statement[6]/5,
#statement[7]/5,
#statement[8]/5
}
--[[ Pause #1 should always be zero. The other '#statement[?]/5' values can be replaced with your own number
of seconds to wait. One reason that you might wish to do this, is to include an extended pause.
For this you must still type something as a statement entry ~be it only a blank space " ", or even some
descriptive note like "[an awkward silence ensues]". it cannot be empty quotes.
--]]
function _statementPrint(caller) _screenClear() hudPrint(tostring(statement[tonumber(string.sub(caller.id,-1))])) caller:destroy() end
function _delayEval(x)
local temp = pauses[1]
if x ~= nil then
for y = 1, x do
if statement[y] == "" then break
else
temp = temp + pauses[y]
end
end
end
return temp
end
function longSpeech()
for x= 1, #pauses do
local delay = _delayEval(x)
local name = 'timer_['..getStatistic('play_time').."]_"..x
if statement[x] == "" then return
else
spawn('timer', party.level, 1,1,1, name )
:setTimerInterval(delay)
:addConnector("activate", self.id, "_statementPrint")
:addConnector("activate", "name", "destroy")
:activate()
end
end
end
function _screenClear() hudPrint("") hudPrint("") hudPrint("") hudPrint("") hudPrint("") end