zdswulyx Posted August 4, 2016 Share Posted August 4, 2016 (edited) I read the messagebox tutorial and here is the script for an activator I put in my mod. As you can see it pretty much the same from the tutorial, and I thought I got the logic, but I am obviously missing something. In fact when I activate the script the messagebox appear, but when I click in a option nothing happens a part of closing the messagebox. scn ezzeMenuScript Short Working Short Choosing Short Choice Begin onActivate Set Choosing to -1 Set Working to 1 End Begin GameMode If Working Set Working to 1 If (Choosing == 0) ;meaning it shouldn't be running Set Working to 0 ;Add anything that needs to be re-initialized Elseif (Choosing == -1) ;Display your menu Messagebox "TEST" "zero" "one" "two" "three" "four" "five" Set Choosing to 1 Set Choice to -1 Elseif (Choosing == 1) ;Catch the player's decision If (Choice == -1) ;No choice yet Set Choice to GetButtonPressed Elseif (Choice == 0) Message "Choice 0" Set Choosing to 0 Elseif (Choice == 1) Message "Choice 1" Set Choosing to 0 Elseif (Choice == 2) Message "Choice 2" Set Choosing to 0 Elseif (Choice == 3) Message "Choice 3" Set Choosing to 0 Elseif (Choice == 4) Message "Choice 4" Set Choosing to 0 Elseif (Choice == 5) Message "Choice 5" Set Choosing to 0 Endif Endif Endif End Edited August 4, 2016 by zdswulyx Link to comment Share on other sites More sharing options...
Surilindur Posted August 4, 2016 Share Posted August 4, 2016 I do not have access to the CS at the moment, but the script looks somewhat right, I think. People write different sorts of things for it, but the main idea is (the tutorial probably also said it) to:display a MessageBox with options -> game goes into MenuModeplayer clicks a button -> MessageBox closes, game enters GameModein one of the frames following the closing of the MessageBox, the GetButtonPressed command returns the pressed button oncegrab the button, if it is > -1, the do stuffMaybe it is just something minor in your script. Considering how displaying the messagebox and grabbing the button variable are separate actions of sorts, have you tried splitting the script in half, to the OnActivate and GameMode blocks, to make it easier to work on (more "straightforward", with OnActivate first, GameMode following it: ScriptName ezzeMenuScript Short Choice Short Activated Begin OnActivate PlayerRef ; do all preperational initialisations HERE set Activated to 1 Messagebox "TEST" "zero" "one" "two" "three" "four" "five" End Begin GameMode If ( Activated == 0 ) Return EndIf set Choice to GetButtonPressed If ( Choice < 0 ) Return EndIf set Activated to 0 If ( Choice == 0 ) Message "Choice 0" Elseif ( Choice == 1 ) Message "Choice 1" Elseif ( Choice == 2 ) Message "Choice 2" Elseif ( Choice == 3 ) Message "Choice 3" Elseif ( Choice == 4 ) Message "Choice 4" Elseif ( Choice == 5 ) Message "Choice 5" EndIf EndHopefully that helps a little. Link to comment Share on other sites More sharing options...
lubronbrons Posted August 4, 2016 Share Posted August 4, 2016 (edited) hi Zd L is here to help ( I am pretty super ultra bored --- right now I'm resizing all of my texture for better performance with nifty tools called Ordenador ) scn aogOSDoorCrypt Short showMenu Short choice Begin onActivate Let showMenu := 1 ;Add anything that needs := be re-initialized MessageBoxEX "Hello World !|zero|one|two|three|four|five" End Begin GameMode if showMenu Let choice := GetButtonPressed ;always try to get button press, user input if choice != -1 ;watch the user decision, and do some action if any menu button get pressed Let showMenu := 0 ;stop the menu checker after user choosed if choice == 0 MessageEX "choice %g" choice elseif choice == 1 MessageEX "choice %g" choice elseif choice == 2 MessageEX "choice %g" choice elseif choice == 3 MessageEX "choice %g" choice elseif choice == 4 MessageEX "choice %g" choice elseif choice == 5 MessageEX "choice %g" choice endif endif endif End Edited August 4, 2016 by lubronbrons Link to comment Share on other sites More sharing options...
zdswulyx Posted August 4, 2016 Author Share Posted August 4, 2016 (edited) Nothing seems to work, I wonder if I am missing something totally different... :S Obviously the executed script is the expected one, because I see the different messagebox (TEST and Hello World), but once I click the message close and nothing happens. According to the tutorial it's possible it is related to the fact that Activators must kept loaded. But even adding a dummy assignment as it's suggested there nothing changes. :S Edit, I tried to simplify as much as possible... nothing. scn ezzeLuggageMenuScript Short Working Short Choosing Short Choice Begin onActivate Set Choosing to 0 Set Working to 1 End Begin GameMode If Working == 1 Set Working to 1 ;ensure the script continues as it''s doing something If Choosing == 0 ; Display menu Messagebox "TEST3" "zero" "one" "two" "three" "four" "five" Set Choosing to 1 Set Choice to -1 ElseIf Choosing == 1 ; Catch the player''s decision If (Choice < 0) ;No choice yet Set Choice to GetButtonPressed Return EndIf Set Choosing to -1 Message "Choice %.0f " Choice ElseIf Choosing < 0 ; Stop the script Set Working to 0 Endif Endif ; if Working < 0 the script stops after one frame of doing nothing End Edited August 4, 2016 by zdswulyx Link to comment Share on other sites More sharing options...
lubronbrons Posted August 4, 2016 Share Posted August 4, 2016 (edited) heyI thought you are going to use this for one time eventwell now I know you want persistant menuso the code should be like this scn ezzeMenuScript Short showMenu Short choice Begin onActivate Let showMenu := 1 ;Add anything that needs to be re-initialized MessageBoxEX "Hello World !|zero|one|two|three|four|five|Exit Menu" ;---> notice the different I add new 7th 'Exit Menu' End Begin GameMode if showMenu Let choice := GetButtonPressed ;always try to get button press, user input if choice != -1 ;watch the user decision, and do some action if any menu button get pressed if choice == 6 MessageEX "bye bye" Let showMenu := 0 ;exit infinite loop, stop the menu checker after user choose 'Exit Menu' else if choice == 0 MessageEX "choice %g" choice elseif choice == 1 MessageEX "choice %g" choice elseif choice == 2 MessageEX "choice %g" choice elseif choice == 3 MessageEX "choice %g" choice elseif choice == 4 MessageEX "choice %g" choice elseif choice == 5 MessageEX "choice %g" choice endif MessageBoxEX "Hello World !|zero|one|two|three|four|five|Exit Menu" ;---> notice the different I add new 7th 'Exit Menu' endif endif endif End Edited August 4, 2016 by lubronbrons Link to comment Share on other sites More sharing options...
zdswulyx Posted August 4, 2016 Author Share Posted August 4, 2016 (edited) I am not sure we are in the same page, I tried to put some messages:scn ezzeMenuScript Short Working Short Choosing Short Choice Short ShowModeOnce Begin onActivate Set Choosing to 0 Set Working to 1 Set ShowModeOnce to 1 message "OnActivate!" ;;;THIS APPEARS End Begin GameMode If Working == 1 Set Working to 1 ;ensure the script continues as it''s doing something if ShowModeOnce == 1 message "GameMode!" ;;;THIS APPEARS Set ShowModeOnce to 2 endIf If Choosing == 0 ; Display menu Messagebox "TEST3" "zero" "one" "two" "three" "four" "five" Set Choosing to 1 Set Choice to -1 ElseIf Choosing == 1 ; Catch the player''s decision if ShowModeOnce == 2 message "Choosing == 1!" ;; THIS DOES NOT APPEAR! Set ShowModeOnce to 3 endIf If (Choice < 0) ;No choice yet Set Choice to GetButtonPressed Return EndIf if ShowModeOnce == 3 message "Choice done!" ;; THIS DOES NOT APPEAR EITHER! Set ShowModeOnce to 4 endIf Set Choosing to -1 Message "Choice %.0f " Choice ElseIf Choosing < 0 ; Stop the script Set Working to 0 Endif Endif ; if Working < 0 the script stops after one frame of doing nothing End I am not sure what's going. The variable Choosing is clearly set to one after displaying the menu. Edited August 4, 2016 by zdswulyx Link to comment Share on other sites More sharing options...
lubronbrons Posted August 4, 2016 Share Posted August 4, 2016 well...I suggest you try my script first. and there is two version of it, my first script is for one-time-event and the second is for infinite loop menu chooser (must choose Exit to quit the infinite loop cycle)if you still insist with your first script it will not workhere's my thought 1. there's no need to set this again and again if you know that this value already 1 Set Working to 1 ;ensure the script continues as it''s doing something 2. you need to get value with syntax 'GetButtonPressed'so don't bury that syntax too deep like just you didit's better that syntax must be run first after validation like this if showMenu MessageBoxEX "Hello World !|zero|one|two|three|four|five|Exit Menu" ;---> notice the different I add new 7th 'Exit Menu' Let choice := GetButtonPressed ;always try to get button press, user input Link to comment Share on other sites More sharing options...
zdswulyx Posted August 4, 2016 Author Share Posted August 4, 2016 (edited) Actually the variable is set up again and again for a reason. Assuming the tutorial is right of course, it's needed to ensure the script continue working.About your script, I tried the first version and I have the same problem as I posted in a previous message. Besides are you sure that MessageBoxEx has to be called every frame?It is true I did not try the second, but it looks as the first a part that the menu is repeated. Edited August 4, 2016 by zdswulyx Link to comment Share on other sites More sharing options...
lubronbrons Posted August 4, 2016 Share Posted August 4, 2016 (edited) quote : " but it looks as the first a part that the menu is repeated. "A : that is intentional since you not use paging aren't you ?if you use paging function the whole code is different and a little bit much more difficultrepeated action on show MessageBox is no problemyou'll see it yourself if you try that EDIT : maximum menu in one page is 10 menuso you can do it like this MessageBoxEX "Hello World !|zero|one|two|three|four|five|six|seven|eight|nine" if you do this, it may become something unsightly MessageBoxEX "Hello World !|zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve" ;---> this is not recommended, menu more than 10 in one message box Edited August 4, 2016 by lubronbrons Link to comment Share on other sites More sharing options...
zdswulyx Posted August 4, 2016 Author Share Posted August 4, 2016 What is this paging you are talking about? I am confused, sorry. Link to comment Share on other sites More sharing options...
Recommended Posts