Multiple Menuboxes in one script?

Post » Sat Feb 19, 2011 8:09 am

In my script, the first messagebox just keeps opening up again and again. I tried several different ways of writing it, this is the last attempt. Could anyone tell me why this method doesn't work for multiple messageboxes or write me a small sample script that has multiple messageboxes with choices and explains why that format and style works? This is a questscript btw.

SCN ArbUpgradeScriptShort ButtonShort StageRef StudentRefFloat TimerBegin GameModeIf Stage == 1Messagebox "Choose a task.", "Upgrade Armor", "............", ".........", "......."Set Stage to 1.1ElseIf Stage == 1.1 Set Button to ( GetButtonPressed + 1)If Button == 1Set Stage to 2Set Button to 0Elseif Button == 2Set Stage to 2Elseif Button == 3Set Stage to 3EndifEndifIf Stage == 2Messagebox "What kind of armor?", "Iron", "Steel", "Elven", "Dwarvern"Set Stage to 2.1EndifIf Stage == 2.1Set Button to (GetButtonPressed + 1 )EndifIf Button == 1StudentRef.Additem IronBoots 1StudentRef.Additem IronCuirass 1StudentRef.Additem IronGauntlets 1StudentRef.Additem IronGreaves 1Set Stage to 2.2Elseif Button == 2StudentRef.RemoveallItemsElseif Button == 3StudentRef.RemoveallItemsElseif Button == 4StudentRef.RemoveallItemsEndifIf Stage == 2.2If Timer < 5Set Timer to Timer + GetSecondsPassedElseStudentRef.EquipItem IronBootsStudentRef.EquipItem IronCuirassStudentRef.EquipItem IronGauntletsStudentRef.EquipItem IronGreavesSet Timer to 0Set Stage to 0EndifEndifEnd

User avatar
Kathryn Medows
 
Posts: 3547
Joined: Sun Nov 19, 2006 12:10 pm

Post » Fri Feb 18, 2011 5:54 pm

I don't know if "1.1" is a valid value for a variable of type "short", but then I've heard ObScript handles all numerical values as "float" anyways, so I'm not sure this is to blame. Nevertheless, short is "meant" to be an integer type, so I wouldn't assign a floating point value ever by definition, if only to play safe.

Using different stages, 1 each for displaying the messagebox, which is left immediately afterwards to go into the respective buttonpress collection stage, should be the right way to go.
If it helps any, here's how I did a similar stacking of hierarchical messageboxes:
if(doConfig == 1)	MessageBoxEX "Dragon Race > Do You want to keep all default settings?|Yes|No"	set doConfig to -2	returnelseif(doConfig == -2)	set choice to getButtonPressed	if(choice == 0) ;stick to defaults		MessageBoxEX "Dragon Race > Forced unequipping:%rBy default this will also affect items%rcovering more than 1 slot at once,%r(e.g. The Arena Raiments or DB Armor)%rleaving actors running around naked,%rif they weren't adapted yet.%rDo You wish to make an exception%rto allow non-fitting combined-slot items?|Yes|No"		set doConfig to 12	elseif(choice == 1) ;customize		MessageBoxEX "Dragon Race > Select Your shape:%rDo You want to be Full-Dragon shape?|Yes|No"		set doConfig to 2	endif	returnelseif(doConfig == 2) ;full-dragon or custom?	set choice to getButtonPressed	if(choice == 0) ;stay full-dragon		; ... do settings ...		MessageBoxEX "Dragon Race > Select Your shape:%rDo You want controlled helmet slot,%rnot actually force-equipping anything%rbut keeping non-fitting helmets unequipped?|Yes|No"		set doConfig to 5	elseif(choice == 1) ;further customize		MessageBoxEX "Dragon Race > Select Your shape:%rWhich wings & tail combination do You prefer?|Wings and tail|Only wings|Only tail|None at all"		set doConfig to 3	endif	returnelseif(doConfig == 3) ;tail & wings options
and it's going on and on and on...

Basically it's the same as you're doing, so I'd check this thing with assigning a float value into a short variable first.
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm

Post » Sat Feb 19, 2011 2:00 am

That's some unusual looking code. It could be written better, but you may be able to get it to work with a minimum of work. First thing I see is you have a short variable "stage" which uses non integers. Those are getting truncated at the decimal point. if you really want to use those numbers you should make the "stage" variable a float.
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm

Post » Fri Feb 18, 2011 10:37 pm

arrrhh, sorry guys. Figures it was such a stupid mistake. I always manage to do this when I start working on a new script after staring at the screen for hours >.<. Ah well, this could be educational yet. You said it was unusual looking code, why is that?

Could you demonstrate a better way to do it? My project is kind of big for a first mod, so I tend to get everything confused
User avatar
Sam Parker
 
Posts: 3358
Joined: Sat May 12, 2007 3:10 am

Post » Sat Feb 19, 2011 8:13 am

Well it's just confusing and with better formatting you can run the script more efficiently, and spot errors more easily. This is the way I do my messages...

Short ButtonShort StageRef StudentRefFloat TimerBegin GameModeIf Stage == 1   Messagebox "Choose a task.", "Upgrade Armor", "............", ".........", "......."   Set Stage to 1.1endifIf Stage == 1.1    Set Button to ( GetButtonPressed + 1) If Button == 1   Set Stage to 2   Set Button to 0  Elseif Button == 2   Set Stage to 2  Elseif Button == 3   Set Stage to 3EndifEndifIf Stage == 2   Messagebox "What kind of armor?", "Iron", "Steel", "Elven", "Dwarvern"   Set Stage to 2.1EndifIf Stage == 2.1   Set Button to (GetButtonPressed + 1 ) If Button == 1   StudentRef.Additem IronBoots 1   StudentRef.Additem IronCuirass 1   StudentRef.Additem IronGauntlets 1   StudentRef.Additem IronGreaves 1   Set Stage to 2.2 Elseif Button == 2   StudentRef.RemoveallItems Elseif Button == 3   StudentRef.RemoveallItems Elseif Button == 4   StudentRef.RemoveallItemsendifEndifIf Stage == 2.2 If Timer < 5   Set Timer to Timer + GetSecondsPassed  Else   StudentRef.EquipItem IronBoots   StudentRef.EquipItem IronCuirass   StudentRef.EquipItem IronGauntlets   StudentRef.EquipItem IronGreaves   Set Timer to 0   Set Stage to 0EndifEndifEnd


Also never saw anyone use getbuttonpressed + 1, most just start with button 0 instead of 1, but it's not a big deal if it makes it easier for you. I would probably just use the short variable and get rid of the floats for stage, but again nothing really wrong with it. The script looks like it would work once stage was turned to a float so you did good ;)
User avatar
Mandi Norton
 
Posts: 3451
Joined: Tue Jan 30, 2007 2:43 pm

Post » Fri Feb 18, 2011 8:57 pm

thanks! Well, I didn't know how to script very well when I first started this project. Many different modders have been giving me their advice so I just kind of took a little bit of style from each!

The sloppiness is my own addition to the "style"...have to give credit where credit is due >.>

I really appreciate the help though, thank you very much!
User avatar
Shirley BEltran
 
Posts: 3450
Joined: Wed Jul 26, 2006 4:14 pm


Return to IV - Oblivion