| 07-27-2006, 05:41 PM | #1 | ||
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:
Quote:
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: 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 |
I don't remember how the JASS:SubStringBJ JASS:SubStringdo JASS:set substart = substart + 27 |
| 07-27-2006, 06:22 PM | #3 |
thats by letter not word |
| 07-27-2006, 06:27 PM | #4 |
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 | |
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:
|
