Please help to create a multi-menu MessageBox

Discussions and questions about the CS and mods for Oblivion
Post Reply
Sergeek
Layman
Layman
Posts: 1
Joined: Mon Aug 21, 2023 7:36 pm
ES Games: Oblivion, Morrowind
Platform: PC
UESPoints: 0

Please help to create a multi-menu MessageBox

Post by Sergeek »

I am at loss. I read the Guide at wiki and another one at Nexus, but they are so complicated, and they only got me so far...

I want to make a book that prompts a MessageBox (above its actual contents, like in Oghma Infinium) with four initial choices when you read it both from the floor and from the inventory (hence both Activate and Equip beginnings). These choices being the three skill specializations and "exit" button. Upon clicking the specializations, another menu should appear with seven respective skills plus the "back" button. Each skill button should increase the respective skill with ModPCSkill command by one, while keeping you inside the same specialization menu. The "back" button should return you to the initial menu where you select specializations. It is way beyond my understanding. I only managed to make a single-layer menu that keeps you inside of it, when you choose the first three options.

Code: Select all

ScriptName MyBook

short Choosing
short Choice

Begin OnActivate

	Activate
	Set Choosing to 1

End

Begin OnEquip

	Set Choosing to 1

End

Begin MenuMode

	If ( Choosing == 1 )
		MessageBox "Select Specializations", "Combat", "Magic", "Stealth", "Exit"
		Set Choosing to 2
		Set Choice to -1
	ElseIf ( Choosing == 2 )
		If ( Choice == -1 )
			Set Choice to GetButtonPressed
		ElseIf ( Choice == 0 )
			Set Choosing to 1
		ElseIf ( Choice == 1 )
			Set Choosing to 1
		ElseIf ( Choice == 2 )
			Set Choosing to 1
		ElseIf ( Choice == 3 )
			Set Choosing to 0
		EndIf
	EndIf

	If ( Choosing == 0 )
		return
	EndIf

End
Please, I have no background in coding and any feedback will be greatly appreciated.
Balota
Associate
Associate
Posts: 10
Joined: Fri Aug 25, 2023 3:52 pm
ES Games: ESO, Morrowind
Platform: PC
UESPoints: 0

Re: Please help to create a multi-menu MessageBox

Post by Balota »

I've been a VB6 programmer for about 35 years. This isn't that language, but the structure and function of If, ElseIf, EndIf is pretty universal. I think your problem may be pretty simple.

Your first If block in MenuMode checks to see if Choosing = 1. If it does, it sets Choosing = 2 and Choice = -1. So far, so good.

But then you use ElseIf. The problem is that after the program executes the If block, it skips over the ElseIf to the EndIf.

Replace

ElseIf ( Choosing == 2 )

with the following:

EndIf

If (Choosing == 2)

Hope that helps.
Balota
aka, Killer Thief Sally
"What's mine is mine and what's yours is mine. You just don't know it yet..."
User avatar
Lord Timster
Journeyman
Journeyman
Posts: 297
Joined: Sun Nov 23, 2014 5:23 pm
ES Games: III, IV, V
Platform: XB1
Status: Non-Euclidean
UESPoints: 10
Location: R'lyeh

Re: Please help to create a multi-menu MessageBox

Post by Lord Timster »

Firstly I would recommend starting with just one skill in your book. When the basic framework does what it's supposed to then expand it bit by bit checking it still works at every step.

I haven't written any mods for Oblivion but I had a look at the cs wiki tutorials and I think that the code for the MenuMode section (for one skill) could look something like this...

I am not 100% sure about some of the details... but I can't test it on the XBox.

Code: Select all

Begin MenuMode

   If ( Choosing == 0 )
      return
   EndIf

   If ( Choosing == 1 )
      MessageBox "Select Specialization", "Combat", "Exit"
      Set Choosing to -1
      Set Choice to -1
   ElseIf ( Choosing == -1 )
      If ( Choice == -1 )
         Set Choice to GetButtonPressed
      ElseIf ( Choice == 0 )
         Set Choosing to 10
      ElseIf ( Choice == 1 )
         Set Choosing to 0
      EndIf

   ElseIf ( Choosing == 10 )
      MessageBox "Select Skill", "Blade", "Back"
      Set Choosing to -10
      Set Choice to -1
   ElseIf ( Choosing == -10 )
      If ( Choice == -1 )
         Set Choice to GetButtonPressed
      ElseIf ( Choice == 0 )
         ModPCSkill Blade 1
         Set Choosing to 10 
      ElseIf ( Choice == 1 )
         Set Choosing to 1
      EndIf

   EndIf
End
Apathy is on the rise, but no-one cares.
Post Reply