Multi-level message box choices

Post » Thu Jun 21, 2012 8:04 pm

Hi,

I messed around with some message boxes (with choices) and have some questions:

I want a message box with four choices (choices 0-2 just open some further message boxes, choice 3 get the player out of the choice menu). If I click on choice 0-2, a message should be shown. If I click "Ok" the message disappears and I want to go back to the previous choice menu (with the initial 4 choices). So far the plan. But it doesn't work.

I can click on one of the four choices and if I click the given message away, I even come back to the initial menu with the four choices again. But if I click then on one of them, I'm just out of my choice menu without any further text. But I want to be able to click around through all of my choices as long as I don't hit the button of choice == 3.

So here is my script:

ActorBase Property aPlayer AutoRace Property rArgonian AutoMessage Property ChoiceMessageArgonianRace AutoEvent OnRaceSwitchComplete()If aPlayer.GetRace() == rArgonianint choice = ChoiceMessageArgonianRace.Show()If (choice == 0)Debug.MessageBox("Text1")ChoiceMessageArgonianRace.Show()ElseIf (choice == 1)Debug.MessageBox("Text2")ChoiceMessageArgonianRace.Show()ElseIf (choice == 2)Debug.MessageBox("Text3")ChoiceMessageArgonianRace.Show()ElseIf (choice == 3)ReturnEndIfUnregisterForUpdate()EndIf[...]

I hope someone can help me.
Thanks!
JDB
User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Thu Jun 21, 2012 2:34 pm

The CK wiki has a tutorial on this I think, to do with IfCount (if-then-else). I'm new to all this so it may not be what you need :shrug:

http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Variables_and_Conditionals
User avatar
Latino HeaT
 
Posts: 3402
Joined: Thu Nov 08, 2007 6:21 pm

Post » Thu Jun 21, 2012 12:22 pm

You have a few options, but the easiest and best is a while loop. JustinOther made a page about creating a http://www.creationkit.com/Options_Menu over on the CK Wiki.

Based on your description and the code you posted here's my best guess about what you need.

ActorBase Property aPlayer AutoRace Property rArgonian AutoMessage Property ChoiceMessageArgonianRace AutoEvent OnRaceSwitchComplete()   If aPlayer.GetRace() == rArgonian      UnregisterForUpdate()   ; you should unregister as early as possible!      bool done = false      while !done         int choice = ChoiceMessageArgonianRace.Show()         If (choice == 0)             Debug.MessageBox("Text1")            ChoiceMessageArgonianRace.Show()         ElseIf (choice == 1)            Debug.MessageBox("Text2")            ChoiceMessageArgonianRace.Show()        ElseIf (choice == 2)            Debug.MessageBox("Text3")            ChoiceMessageArgonianRace.Show()       Else   ; If (choice == 3)             done = true       EndIf   EndIf[...]
User avatar
Beat freak
 
Posts: 3403
Joined: Thu Dec 14, 2006 6:04 am

Post » Fri Jun 22, 2012 12:36 am

For a While loop as described above:
Actor Property PlayerREF AutoRace Property ArgonianRace AutoMessage Property ChoiceMessageArgonianRace AutoEvent OnRaceSwitchComplete()	If PlayerREF.GetRace() == ArgonianRace		ArgonianMenu()	EndIfEndEventFunction ArgonianMenu(Bool abMenu = True, Int aiButton = 0)	While abMenu		If aiButton != -1 ; Wait for input			aiButton = ChoiceMessageArgonianRace.Show() ; Add the text to the buttons of a MESG form with "MessageBox" flag ticked			If aiButton == 0 ; Choice 01				Debug.MessageBox("Text1")			ElseIf aiButton == 1 ; Choice 02				Debug.MessageBox("Text2")			ElseIf aiButton == 2 ; Choice 03				Debug.MessageBox("Text3")			ElseIf aiButton == 3 ; Done				abMenu = False			EndIf		EndIf	EndWhileEndFunction
User avatar
Timara White
 
Posts: 3464
Joined: Mon Aug 27, 2007 7:39 am

Post » Thu Jun 21, 2012 5:04 pm

Thanks for the quick responses!

@ Justin: Small Typo, I think. The last "Endif" should be a "EndWhile", right? I try it with this and it works great!
User avatar
Bellismydesi
 
Posts: 3360
Joined: Sun Jun 18, 2006 7:25 am

Post » Fri Jun 22, 2012 3:20 am

Oops. Good call and yeah, typo. :facepalm:
User avatar
Jordyn Youngman
 
Posts: 3396
Joined: Thu Mar 01, 2007 7:54 am

Post » Thu Jun 21, 2012 4:33 pm

The line "If aiButton != -1 ; Wait for input" and it's matching "EndIf" do absolutely nothing of value. A messagebox will never return a -1, only Messages that don't have buttons return -1. (And those always return -1).
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Thu Jun 21, 2012 6:22 pm

The line "If aiButton != -1 ; Wait for input" and it's matching "EndIf" do absolutely nothing of value. A messagebox will never return a -1, only Messages that don't have buttons return -1. (And those always return -1).
It does do something. Try it or the http://www.gamesas.com/topic/1380144-blockactivation-not-working-on-alias/page__view__findpost__p__20912781 when you last asserted this. Also, it becomes a necessity as a menu grows, so I find it best to put it in from the onset.

*puts it back in 2'nd and 3'rd Wiki examples.
User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Fri Jun 22, 2012 2:59 am

This is getting very frustrating. JustinOther you keep telling people that a check for -1 matters and I have tested it and found that it absolutely does not. I'm not going to get into an edit war on the page you created on the WiKi but you are wrong on this.

A call to Show() will always return -1 when it's used on a Message that isn't a Message Box. It shows a notification in the top corner instead.

A call to Show() on an un-filled property (with the None value) will fail and return a 0.

A call to Show() on a Message Box message that doesn't have any buttons defined will get a default "OK" button which returns 0 when pressed.

A call to Show() on a Message Box message that does have buttons defined will return the matching button number.

The thing that is making a multi-level menu work correctly is the use of the bool variable and thw while loop. Adding the check for -1 is just a worthless step that makes it harder for people to understand. -1 was useful with GetButtonPressed in previous games, but it not part of Papyrus's message box strategy.
User avatar
sharon
 
Posts: 3449
Joined: Wed Nov 22, 2006 4:59 am

Post » Thu Jun 21, 2012 10:25 pm

This is getting very frustrating. JustinOther you keep telling people that a check for -1 matters and I have tested it and found that it absolutely does not. I'm not going to get into an edit war on the page you created on the WiKi but you are wrong on this.
It DOES do something, that is it prevents the MesageBox from firing on the way out. For the second example on the Wiki, removing the -1 check means the player can order lunch, the main menu opens, then they can order breakfast too. Hell, they could order every meal in the menu and, unless a 'Done' button is added, they're stuck in the menu forever. It's not always desireable to add a 'Done' button... Keeping the -1 check ensures only one meal can be ordered. Particularly with large, multi-level, looping menus, the -1 check becomes increasingly important, thus it's best to add it from the onset as it prevents problems down the road. You're wrong and yes, this is getting frustrating. The Wiki examples aren't broken, so don't "Fix" them. The check is harmless and does have a purpose.
User avatar
Harry Hearing
 
Posts: 3366
Joined: Sun Jul 22, 2007 6:19 am

Post » Fri Jun 22, 2012 12:30 am

It DOES do something, that is it prevents the MesageBox from firing on the way out. For the second example on the Wiki, removing the -1 check means the player can order lunch, the main menu opens, then they can order breakfast too. Hell, they could order every meal in the menu and, unless a 'Done' button is added, they're stuck in the menu forever. It's not always desireable to add a 'Done' button... Keeping the -1 check ensures only one meal can be ordered. Particularly with large, multi-level, looping menus, the -1 check becomes increasingly important, thus it's best to add it from the onset as it prevents problems down the road. You're wrong and yes, this is getting frustrating. The Wiki examples aren't broken, so don't "Fix" them. The check is harmless and does have a purpose.

As I said, I will not edit your page, but a message box style menu can not ever return a -1. I have tested that quite carefully, so any check comparing to -1 is not doing what you think. What makes the second example work is the "abMenu = False ; End the function" line.

Please go back and try your examples without the test for -1. I suspect that in some of your early experimentation with Skyrim's new message boxes you were making use of the -1 value and not using the abMenu boolean. Then when you cleaned them up to use the abMenu boolean variable you simply didn't notice that your old -1 check is not really needed.
User avatar
Naomi Ward
 
Posts: 3450
Joined: Fri Jul 14, 2006 8:37 pm

Post » Thu Jun 21, 2012 10:54 pm

As I said, I will not edit your page, but a message box style menu can not ever return a -1.
Then it wouldn't do anything and, again, it does. A few menus I've made did not work properly without the -1 check. I'd not added it arbitrarily or as a tribute to ObScript or anything, but out of necessity, thus it's still included in the multi-level examples. :shrug:
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm

Post » Thu Jun 21, 2012 12:52 pm

Please provide one of those examples. I really do want to know what you're seeing because I haven't found any situation where a show on a message box can return -1. And with your insistence that the -1 check is sometimes important I have tried.
User avatar
jasminε
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am

Post » Thu Jun 21, 2012 12:44 pm

Please provide one of those examples. I really do want to know what you're seeing because I haven't found any situation where a show on a message box can return -1. And with your insistence that the -1 check is sometimes important I have tried.
Next time I encounter it, sure. All of my menus have that check though as, ever after I found a menu during the beta I'd made didn't work correctly without it, I've made sure to add it. While in some cases it isn't a necessity, it can help particularly if reusing aiButton for other purposes within submenus. If making a multilevel menu, it's as preventative maintenance.
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am


Return to V - Skyrim