Scripting Choices

Post » Fri Feb 05, 2010 7:20 pm

Sorry to post something like this, but I can't for the life of me find information on it. How does the syntax work for making messagebox choices in the scripting engine? I'm trying to make a blast furnace that can smelt ore, but the choices aren't responding.
User avatar
james reed
 
Posts: 3371
Joined: Tue Sep 18, 2007 12:18 am

Post » Fri Feb 05, 2010 4:39 pm

It's pretty well explained in "Morrowind Scripting For Dummies". If you don't have that, you should get it, it's really handy.

Anyway, here is a sample of messagebox syntax:

Be sure to declare button as a short variable

short buttonshort StateIf ( State == 0 )		messagebox "What do you want to do?" "This" "That" "Other"		set State to 10endIf	if ( state == 10 )   set button to GetButtonPressed	if ( button == -1 )		return	elseif ( button == 0 )		Do This		set State to 40	elseif ( button == 1 )		Do that		set state to 40	else	        Do the Other	        set state to 40	endifendIf	

User avatar
Carlos Vazquez
 
Posts: 3407
Joined: Sat Aug 25, 2007 10:19 am

Post » Fri Feb 05, 2010 6:44 pm

Essentially, you just write all the options you want after the message box, like so:

MessageBox "Message goes here", "Choice 1", "Choice 2", "Choice 3"

These choices will become buttons, and which button is pressed can be detected by GetButtonPressed. Note that the first choice is the "0th" button, the second choice is the "1st" button, etc.

So:

Not yet clicked --> GetButtonPressed = -1
Click on Choice 1 --> GetButtonPressed = 0
Click on Choice 2 --> GetButtonPressed = 1
Click on Choice 3 --> GetButtonPressed = 2

I generally use a "messageOn" variable to determine when the message is on screen; when messageOn == 1, I check for GetButtonPressed. When a button is pressed, I set messageOn back to 0, so it stops checking for button presses.
User avatar
emily grieve
 
Posts: 3408
Joined: Thu Jun 22, 2006 11:55 pm

Post » Fri Feb 05, 2010 10:30 am

Thanks, that really helped! I think my problem was that I left out the if ( button == -1 ) block.
User avatar
jessica Villacis
 
Posts: 3385
Joined: Tue Jan 23, 2007 2:03 pm


Return to III - Morrowind