Jump to content

[LE] Going back in a script, message box


jim555511

Recommended Posts

Hi there, thanks for the help. So i have a message box, lets call it message box A. Message box A has a couple of different selections in it and when a certain selection is made a new message box appears which we'll call message box B. Now i have a back button in message box B but i'm not for sure how to script it, how can i get it so that when you select back on message box B you go back to message box A?

Link to comment
Share on other sites

Given two message boxes,

Box A
0 = Stop
1 = Show Box B
2 = Do Something Else

Box B
0 = Back to Box A
1 = Do Something Else
2 = Do Something Else


try this code:

Function MyFunction()
   Bool bWorking = True
   Int  iSelection
   While bWorking
      ;
      ; This loop just exists to show Box A repeatedly until bWorking is set to False. 
      ; As such, message boxes can either loop back to Box A, or set bWorking to False 
      ; to close the entire menu system.
      ;
      iSelection = MessageBoxA.Show()
      If iSelection == 0
         ;
         ; Stop showing message boxes
         ;
         bWorking = False
      ElseIf iSelection == 1
         ;
         ; Show Message Box B, and handle it
         ;
         iSelection = MessageBoxB.Show()
         If iSelection == 0
            ;
            ; Don't do anything here. The loop will carry us right back to Box A.
            ;
         ElseIf iSelection == 1
            ;
            ; Do whatever it is we need to do. If we want to stop after doing it, 
            ; set bWorking to False. Otherwise, just leave it True, and the loop 
            ; will carry us right back to Box A.
            ;
         ElseIf iSelection == 2
            ;
            ; Do whatever it is we need to do. If we want to stop after doing it, 
            ; set bWorking to False. Otherwise, just leave it True, and the loop 
            ; will carry us right back to Box A.
            ;
         EndIf
      ElseIf iSelection == 2
         ;
         ; ... do something else ...
         ;
      EndIf
   EndWhile
EndFunction
Link to comment
Share on other sites

  • 2 years later...

For Menus and Sub Menus I prefer to use functions. That way, you can specify which menu to go to and when. Example script:

 

 

 

Message Property Message1 Auto 
Message Property Message2 Auto 
Message Property Message3 Auto 


Event SomeEvent()
    Menu1() ;open main menu
EndEvent 


Function Menu1()
    Int Button = Message1.Show()
    
    If Button == 0
        ;do something 
    Elseif Button == 1
        Menu2() ;open sub menu 2
    Endif 
EndFunction 


Function Menu2()
    Int Button = Message2.Show()
    
    If Button == 0
        ;do something 
    Elseif Button == 1
        Menu3() ;open sub menu 3 
    Elseif Button == 2
        Menu1() ;go back to main menu
    Endif 
EndFunction 


Function Menu3()
    Int Button = Message3.Show()
    
    If Button == 0
        ;do something 
    Elseif Button == 1
        Menu2() ;go back to sub menu 2
    Elseif Button == 2
        Menu1() ;go back to main menu
    Endif 
EndFunction 

Edited by dylbill
Link to comment
Share on other sites

  • 9 months later...

 

For Menus and Sub Menus I prefer to use functions. That way, you can specify which menu to go to and when. Example script:

 

 

 

Message Property Message1 Auto 
Message Property Message2 Auto 
Message Property Message3 Auto 


Event SomeEvent()
    Menu1() ;open main menu
EndEvent 


Function Menu1()
    Int Button = Message1.Show()
    
    If Button == 0
        ;do something 
    Elseif Button == 1
        Menu2() ;open sub menu 2
    Endif 
EndFunction 


Function Menu2()
    Int Button = Message2.Show()
    
    If Button == 0
        ;do something 
    Elseif Button == 1
        Menu3() ;open sub menu 3 
    Elseif Button == 2
        Menu1() ;go back to main menu
    Endif 
EndFunction 


Function Menu3()
    Int Button = Message3.Show()
    
    If Button == 0
        ;do something 
    Elseif Button == 1
        Menu2() ;go back to sub menu 2
    Elseif Button == 2
        Menu1() ;go back to main menu
    Endif 
EndFunction 

This works perfectly for a mod I am working on!!! Thanks for sharing!!!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...