HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

I need some help with a jass script

07-27-2006, 05:41 PM#1
Linera
I'm working on a function that i can call and will automate the process of showing the quest to the player. Every 16 lines they are required to press esc to continue text. I just thought of a problem i can see will occur with it. Its not a problem in the code, rather its the displaying of text.
I noticed that it will cause text to break, for example:
Quote:
Hello this i
s an exam
ple
when it should be
Quote:
Hello this
is an
example

I am hoping someone can help me. I'm not sure how to do this in the current script i wrote.
Here is my script:
Collapse JASS:
//Standard Functions
function MyBool takes nothing returns boolean
    return true
endfunction

function WaitForPlayerEvent_H2P takes handle h returns player
    return h
endfunction

function WaitForPlayerEvent_H2F takes handle h returns force
    return h
endfunction

function WaitForPlayerEvent_PE2I takes playerevent p returns integer
    if true then
        return p
    endif
    return 0
endfunction

function WaitForPlayerEvent_Enum takes nothing returns nothing
    call TriggerRegisterPlayerEvent(bj_delayedSuspendDecayTrig, GetEnumPlayer(), ConvertPlayerEvent(bj_forceCountPlayers))
endfunction

function WaitForPlayerEvent takes handle whichForceOrPlayer, playerevent whichPlayerEvent, boolexpr condition, real interval returns nothing
    local trigger bj_temp = bj_delayedSuspendDecayTrig
    local trigger t
    local triggercondition c
    local player whichPlayer = WaitForPlayerEvent_H2P(whichForceOrPlayer)
    local force whichForce = WaitForPlayerEvent_H2F(whichForceOrPlayer)
    if whichForceOrPlayer == null or whichPlayerEvent == null then
        set whichForce = null
        return
    elseif interval < 0 then
        set interval = 0
    endif
    set t = CreateTrigger()
    set bj_delayedSuspendDecayTrig = t
    set bj_forceCountPlayers = WaitForPlayerEvent_PE2I(whichPlayerEvent)
    call ForForce(whichForce, function WaitForPlayerEvent_Enum)
    call TriggerRegisterPlayerEvent(bj_delayedSuspendDecayTrig, whichPlayer, whichPlayerEvent)
    if condition != null then
        set c = TriggerAddCondition(bj_delayedSuspendDecayTrig, condition)
    endif
    set bj_delayedSuspendDecayTrig = bj_temp
    loop
        call TriggerSleepAction(interval)
        exitwhen GetTriggerExecCount(t) != 0
    endloop
    if condition != null then
        call TriggerRemoveCondition(t, c)
        set c = null
    endif
    call DestroyTrigger(t)
    set t = null
    set whichForce = null
endfunction

//End of Standard Functions

//Displays quest to player
function StartQuest takes unit u, player p, string t returns integer
    local integer substart = 0 //add 28 each line
    local integer subend = 27 //add 27 each line
    local integer lines = 16
    local integer currentline = 1
    local integer length = StringLength(t)
    
    loop
        exitwhen (subend>length)
    call DisplayTimedTextToPlayer( p, 0, 0, 1000000000.00, SubStringBJ(t, substart, subend))
    set currentline = currentline + 1
    if (currentline == lines) then
        if (subend>length) then
        call DisplayTimedTextToPlayer( p, 0, 0, 1000000000.00, "(Press ESC to Accept)")
        call WaitForPlayerEvent(p, EVENT_PLAYER_END_CINEMATIC, Condition(function MyBool), 1.00)
        return 1
        else
        call DisplayTimedTextToPlayer( p, 0, 0, 1000000000.00, "(Press ESC to continue)")
        call WaitForPlayerEvent(p, EVENT_PLAYER_END_CINEMATIC, Condition(function MyBool), 1.00)
        endif
    endif
    set substart = substart + 28
    set subend = subend + 27
    endloop
return 0
endfunction
07-27-2006, 06:16 PM#2
Sharingan
I don't remember how the
Collapse JASS:
SubStringBJ
works, but replace that with
Collapse JASS:
SubString
(without BJ) and
do
Collapse JASS:
set substart = substart + 27
instead of 28
07-27-2006, 06:22 PM#3
Linera
thats by letter not word
07-27-2006, 06:27 PM#4
The)TideHunter(
Collapse JASS:
native SubString takes string source, integer start, integer end returns string

function SubStringBJ takes string source, integer start, integer end returns string
    return SubString(source, start-1, end)
endfunction

EDIT: To answer you question.
Its a pretty complicated process, you need a function that can find spaces and return the integer (or substring) Then you need to add a |n in between the space.
Do you have a estimate of how many characters you want on each line?
07-27-2006, 06:38 PM#5
Linera
I figure I will only be able to hold about 27 letters across and 15 lines down (the last line is to tell the player what to do) at the last line when it displays Quest Objectives its suppose to give them two options press left arrow key to accept quest or press right arrow key to decline quest. After the player accepts or declines the quest it returns either 1 (accepted quest) or 0(declined quest)

Here is my test quest text(yes its WoW, but i'm too lazy to think of one just for a test map):
quest title is "A Threat Within"
Quote:
A Threat Within
I hope you strapped your
belt on tight, young <Class>,
because there is work to do
here in Northshire.

And I don't mean farming.

The Stormwind guards are hard
pressed to keep the peace here,
with so many of us in distant lands
and so many threats pressing close.
And so we're enlisting the aid of
anyone willing to defend their home.
And their alliance.

If you're here to answer the call,
then speak with my superior,
Marshal McBride. He's inside the
abbey behind me.

Quest Objectives
Speak with Marshal McBride.