Jump to content

Multi-menu options. Help please.


antstubell

Recommended Posts

I have seen this done many times and am attempting my own solution to it but the way I am approaching it means it will be massively difficult to follow.

So player activates a book and a message appear (first page of book). Player then can click 'Skip ahead' - only choice for page 1. Next message (section of book) has the options 'Go back' or 'Skip ahead' meaning return to previous message (page) or go to next message (page). This will continue - well I don't know - a few times at least there always being the option to go back to previous message and skip ahead to next.

This is simple enough to script for 2 messages but after that I am lost. I'll attach my script but I have no idea if this is the way I should go about it.

Thanks.

 

Float Property pause Auto
Message Property MyMsg1 Auto
Message Property MyMsg2 Auto
Message Property MyMsg3 Auto
Sound Property MySND Auto

Event OnActivate(ObjectReference akActionRef)

Int iButton = MyMsg1.show()
If iButton == 0
MySND.play(self)
Utility.wait(pause); allow sfx to finish
MyMsg2.show()

; the following menus will have 0 = Go back and 1 Skip ahead.

Endif

EndEvent

 

Link to comment
Share on other sites

I think something like:

 

 

Int iButton = myMsg1.Show()
If iButton == 0
  ;do stuff
  Int i2Button = myMsg2.Show()
  If i2Button == 0
    ;go back stuff
  Else  ; assumes only two options - use ElseIf when three or more options
    ;skip ahead stuff
    Int i3Button = myMsg3.Show()
    If i3Button == 0
      ;go back stuff
    Else
      ;skip ahead stuff
    EndIf
  EndIf
EndIf

 

But lets leave room for other methods as menus were never something that I did much work with.

 

PS. Indenting your script code can help make it easier to follow and track what is going on.

Edited by IsharaMeradin
Link to comment
Share on other sites

All "Message MENUS" must have 2 iButtons for this approach to work correctly.
Read carefully the "Descriptions" below the "Message Property" and watch which iButton is calling which Function, otherwise you might end up in a continuous "LOOP".
* And this can go on and on forever... calling "Functions" within "Functions".
Example:


 
Message Property Page01 Auto
{Message + MENU 01 Buttons with EXIT page & NEXT}
 
Message Property Page02 Auto
{Message + MENU 02 Buttons with PREVIOUS page & NEXT page}
 
Message Property Page03 Auto
{Message + MENU 03 Buttons with PREVIOUS page & NEXT page}
 
Message Property Page04 Auto
{Message + MENU 04 Buttons with PREVIOUS page & EXIT}
 
 
Event OnActivate(ObjectReference akActivator)
     if (akActivator == Game.GetPlayer())
           Int iButton = Page01.Show() 
        If iButton == 0   ; EXIT
           ; EXIT to be REACTIVATED
 
    ElseIf iButton == 1   ; NEXT PAGE
           Page02()
     EndIf
 EndIf
EndEvent
 
 
; This is required (Repeating Page01) so that you don't EXIT when pressing "PREVIOUS PAGE" on "Function Page02()"
Function Page01()
           Int iButton = Page01.Show() 
        If iButton == 0    ; EXIT
           ; EXIT to be REACTIVATED
 
    ElseIf iButton == 1    ; NEXT PAGE
           Page02()
    EndIf
Endfunction
 
Function Page02()
           Int iButton = Page02.Show() 
        If iButton == 0    ; PREVIOUS PAGE
           Page01()
 
    ElseIf iButton == 1   ; NEXT PAGE
           Page03()
    EndIf
Endfunction
 
Function Page03()
           Int iButton = Page03.Show() 
        If iButton == 0    ; PREVIOUS PAGE
           Page02()
 
    ElseIf iButton == 1
           Page04()        ; NEXT PAGE
    EndIf
Endfunction
 
Function Page04()
           Int iButton = Page04.Show() 
        If iButton == 0    ; PREVIOUS PAGE
           Page03()
 
    ElseIf iButton == 1    ; EXIT
           ; EXIT to be REACTIVATED
    EndIf
Endfunction

 

* Keep in mind for your book's pages that messages have a limit of 1023 characters, otherwise CTD will occur !!.

 

Edit: Typo...

Edited by maxarturo
Link to comment
Share on other sites

@IsharaMeradin

I used the script you posted and got this error. I can't see the error.

Message Property myMsg1 Auto
Message Property myMsg2 Auto
Message Property myMsg3 Auto

Event OnActivate(ObjectReference akActivator)
if (akActivator == Game.GetPlayer())

Int iButton = myMsg1.Show()
If iButton == 0
;do stuff
Int i2Button = myMsg2.Show()
If i2Button == 0
;go back stuff
Else ; assumes only two options - use ElseIf when three or more options
;skip ahead stuff
Int i3Button = myMsg3.Show()
If i3Buttom == 0
;go back stuff
Else
;skip ahead stuff
EndIf
EndIf
EndIf
Endif

Endevent

 

(19,7): variable i3Buttom is undefined

(19,16): cannot compare a none to a int (cast missing or types unrelated)

@maxarturo

Script doesn't go past page 1

EDIT - More specifically maxarturo clicking 'Skip ahead' on page 1 causes exit.

Edited by antstubell
Link to comment
Share on other sites

- First of all this is just an example showing the logic behind this approach.

- If you just copy/paste it, then the problem is on your side.

To make this script work correctly each Message Menu must have a specific iButton order.


* I checked the "Example" script and it has no issues.


* I didn't test and compile it, but i've use this logic so many times and in way more complicated things that there is no doubt that this might not work.

Link to comment
Share on other sites

@IsharaMeradin

I used the script you posted and got this error. I can't see the error.

<snip>

(19,7): variable i3Buttom is undefined

(19,16): cannot compare a none to a int (cast missing or types unrelated)

<snip>

Typo on my part in the provided example code. It has been fixed.

 

The error message tells you exactly what line has the problem, line 19 of the code you tried to compile.

Link to comment
Share on other sites

Glad you make it work !.

Just be careful if your "Book" has a lot of pages that each iButton is calling the correct Function each time (Back & Next), to avoid a continuous "LOOP", and putting the Player in a position with no other alternative to exit the book except "Ctrl - Alt - Del".


Have a Happy modding !.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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