Script Help - Multiple Messageboxes

Post » Sat May 28, 2011 2:19 am

I need some help making a script that, basically, displays a series of incremental "Messageboxes" (in sequence, depending on Player input):
(e.g., display "Message X"; -> Player choices: "Continue" (0 - move on to next message/scene), "Start Over" (1 - go back to first message/scene), "Ignore them" (2 - cancel and exit/leave menu)).
The script is meant to be placd on an activator, and "fire up" when the Player is within a certain distance from it.
After several fruitless attempts with the full script (which includes NPCs being enabled/disabled and/or doing things at different stages or 'scenes') I gave up and just tried to make a script that simply increments the "messageboxes."

This attempt (below) simply stops at the first message, and hangs up the game (requiring the [CTRL/ALT/DEL] three-finger rescue). Neither button (although displayed OK) does anything:

Begin _MontyTestshort doonceshort buttonshort statusif ( doonce == 0 )  set doonce to 1endifif ( GetDistance Player <= 400 )	Set status to 1EndifIf ( status == 0 )	Return ;; stop processing the script for this frame.EndifIf ( status == 1 )	MessageBox, "(As you enter the town center, you come upon an odd commotion. An Argonian in a strange-looking helmet, who appears to be an official of some sort, is beset by a group of peasants dragging a young woman dressed as a witch before him. Curious, you stop to listen.)", "0-Continue", "1-Ignore them"	Set status to 2EndifIf ( status == 2 )	Set button to GetButtonPressed	If ( button > 9 )		Return	endif	If ( button < 0 )		Return	endif	If ( button == 0 )		MessageBox, "Scene 2 Message", "0-Continue", "1-Start over", "2-Ignore them"		Set status to 10	endif	If ( button == 1 )  ;; Cancellation		Set status to 0		Return	endif EndifIf ( status == 10 ) 	Set button to GetButtonPressed	If ( button == 0 )		MessageBox, "Scene 3 Message", "0-Continue", "1-Start over", "2-Ignore them"		Set status to 20	endif	If ( button == 1 )		Set status to 1  ;; Back to Messagebox 1	endif	If ( button == 2 )  ;; Cancellation		Set status to 0		Return	endif EndifIf ( status == 20 )  ; wait for player decision	Set button to GetButtonPressed	If ( button == 0 )		MessageBox, "Scene 4 Message", "0-Continue", "1-Start over", "2-Ignore them"		Set status to 30	endif	If ( button == 1 )		Set status to 1  ;; Back to Messagebox 1	endif	If ( button == 2 )  ;; Cancellation		Set status to 0		Return	endif EndifIf ( status == 30 )  ; wait for player decision	Set button to GetButtonPressed	If ( button == 0 )		MessageBox, "Scene 5 Message", "0-OK"		Set status to 40	endif	If ( button == 1 )		Set status to 1  ;; Back to Messagebox 1	endif	If ( button == 2 )  ;; Cancellation		Set status to 0		Return	endif EndifIf ( status == 40 )  ; wait for player decision;;	Set button to GetButtonPressed;;	If ( button == 0 )		MessageBox, "Sancho walks away, looking impressed. You continue on your way."		Set status to 0		Return;;	endif EndifEnd _MontyTest


I'm now at my wit's end, and cannot see what I'm doing wrong. I would appreciate any help or advice the Community can offer.

Thanks in advance.
User avatar
Lynne Hinton
 
Posts: 3388
Joined: Wed Nov 15, 2006 4:24 am

Post » Fri May 27, 2011 11:39 pm

Your first message is set up to display every frame after the player closes distances - it needs to be made do-once. Perhaps that was your intend in declaring doOnce, but at present it does not do anything so I will eliminated it. There is a matter of the player canceling and being close enough to the activator to trigger the initial message again. I have scripted a delay that requires the player move away before resetting status to 0. I made it so that after the player has competed the narrative it cannot be read a second time - you can change that, of course. It is not a good idea to begin names with an underscore so I changed it, but it is up to you. There may be a messagebox buffer of either 256 or 512 characters (may depend on expansions being loaded) so watch out for truncation of your messages.

Begin MontyTestshort statusshort buttonif ( statue == -1 ) ; completed    returnendifif ( status == 0 )    if ( ( GetDistance player ) <= 400 )        set status to 1    endifendifif ( status == 1 )    set status to 2    messagebox "As you enter the town center, you come upon an odd commotion. An Argonian in a strange-looking helmet, who appears to be an official of some sort, is beset by a group of peasants dragging a young woman dressed as a witch before him. Curious, you stop to listen." "Continue" "Ignore them"endifif ( status == 2 )    set button to GetButtonPressed    if ( button == -1 ) ; no button pressed yet        return    elseif ( button == 0 ) ; player chooses to continue        messagebox "Presumably you have a fresh narrative here - scene 2." "Continue" "Start over" "Ignore them"        set status to 10    else ; player chooses to ignore        set status to 99 ; this is limbo state    endif    returnendifif ( status == 10 )     set button to GetButtonPressed    if ( button == -1 ) ; no button pressed yet        return    elseif ( button == 0 ) ; player chooses to continue        messagebox "Presumably you have a fresh narrative here - scene 3." "Continue" "Start over" "Ignore them"        set status to 20    elseif ( button == 1 ) ; player chooses to return to beginning        set status to 1    else ; player chooses to ignore        set status to 99 ; this is limbo state    endif    returnendifif ( status == 20 )     set button to GetButtonPressed    if ( button == -1 ) ; no button pressed yet        return    elseif ( button == 0 ) ; player chooses to continue        messagebox "Presumably you have a fresh narrative here - scene 4." "Continue" "Start over" "Ignore them"        set status to 30    elseif ( button == 1 ) ; player chooses to return to beginning        set status to 1    else ; player chooses to ignore        set status to 99 ; this is limbo state    endif    returnendifif ( status == 30 )     set button to GetButtonPressed    if ( button == -1 ) ; no button pressed yet        return    elseif ( button == 0 ) ; player chooses to continue        messagebox "Presumably you have a fresh narrative here - scene 5." "OK"        set status to 40    elseif ( button == 1 ) ; player chooses to return to beginning        set status to 1    else ; player chooses to ignore        set status to 99 ; this is limbo state    endif    returnendifif ( status == 40 )    set button to GetButtonPressed    if ( button == -1 ) ; no button pressed yet        return    endif    set status to -1 ; not 0 - do you really want it possible for the player to do this again?    messagebox "Sancho walks away, looking impressed. You continue on your way."endifif ( status == 99 )    if ( ( GetDistance player ) >= 800 ) ; set it to value you want greater than 400        set status to 0 ; reset for next time    endifendifEnd MontyTest

This code has not been tested.
User avatar
Bonnie Clyde
 
Posts: 3409
Joined: Thu Jun 22, 2006 10:02 pm

Post » Sat May 28, 2011 2:49 am

Thanks, Cyran0! Works fine now.
User avatar
Chris BEvan
 
Posts: 3359
Joined: Mon Jul 02, 2007 4:40 pm


Return to III - Morrowind