Malacola Posted February 28, 2009 Share Posted February 28, 2009 My menu scripting is decidedly sub-par. I just can't seem to get this menu to do what it should do. I tried writing it according to this tutorial on the wiki, but I guess I must have messed up somewhere along the way, because all it's doing is changing the quest stage to 1. It'll do this for whichever button you press, and despite the absence of microfusion cells, so neither of those conditions are working, and I cannot for the life of me figure out why. It's frustrating because it's one of the simplest menus you could have, only two options, but I still can't get it work. Anybody see any glaring logic problems? scn ExplorerFastTravelScriptNotWorking Short Button Float ftimer Begin Gamemode if nofasttravelwithoutexplorerq.sMenu == 1 set Button to getbuttonpressed showmessage ExplorerDialog if (button > -1) if (Button == 0) ;Player has selected "Let's Ride", enable fast travel if they have fuel if (player.getItemCount AmmoMicroFusionCell > 0) player.removeitem AmmoMicroFusionCell 1 set fTimer to 5 setstage NoFastTravelwithoutExplorerq 1 set nofasttravelwithoutexplorerq.sMenu to 0 player.UnequipItem ExplorerToken 0 1 RemoveMe else ;Player doesn't have enough fuel, show warning showMessage ExplorerBikeNoFuel set nofasttravelwithoutexplorerq.sMenu to 0 player.UnequipItem ExplorerToken 0 1 RemoveMe endif ;/Fuel Check elseif (Button == 1) ;Player has selected "Don't want to ride", don't do anything set nofasttravelwithoutexplorerq.sMenu to 0 player.UnequipItem ExplorerToken 0 1 RemoveMe endif ;/button selection endif ;/button > -1 endif ;/sMenu elseif fTimer > 0 set fTimer to fTimer - GetSecondsPassed else setstage NoFastTravelwithoutExplorerq 1 endif End Here's the activator script: scriptname ExplorerActivatationScript short sDoOnce Begin onActivate if isActionRef player == 1 set sDoOnce to 1 addItem ExplorerToken 1 1 set nofasttravelwithoutexplorerq.sMenu to 1 endif End Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2009 Share Posted March 1, 2009 The problem is in the aptly named "ExplorerFastTravelScriptNotWorking". If I were to re-write your menu according to my Menu Template, which is used in the tutorial that you linked to, it would look something like this:ScriptName ExplorerFastTravelScriptWorking short sButton1 short sMenuLevel float fTimer Begin GameMode ; ================================================= ; INITIALISATION --> LEVEL 1 ; ================================================= if sMenuLevel == 0 ShowMessage ExplorerDialog set sMenuLevel to 1 endif ; ================================================= ; LEVEL 1 --> LEVEL 2 ; ================================================= if sMenuLevel == 1 set sButton1 to GetButtonPressed if sButton1 == -1 Return elseif sButton1 == 0 ; "Let's Ride" ; Enable fast travel if they have fuel if player.GetItemCount AmmoMicroFusionCell player.RemoveItem AmmoMicroFusionCell 1 set fTimer to 5 SetStage NoFastTravelwithoutExplorerq 1 set sMenuLevel to -1 ; Run timer else ; Player doesn't have enough fuel, show warning ShowMessage ExplorerBikeNoFuel RemoveMe endif elseif sButton1 == 1 ; "Don't want to ride" ; Don't do anything RemoveMe endif elseif sMenuLevel == -1 if fTimer > 0 set fTimer to fTimer - GetSecondsPassed else SetStage NoFastTravelwithoutExplorerq 1 RemoveMe endif endif End This is the menu template, if you or anyone else is interested:ScriptName MenuTokenScript short sMenuLevel ; Records the current depth of the ShowMessage framework ; 0 - Initialisation -> Level 1 ; 1 - Level 1 -> Level 2 ; 2 - Level 2 -> Final Level short sButton1 ; sButton variable for Level 1 short sButton2 ; sButton variable for Level 2 Begin GameMode ; ================================================= ; INITIALISATION --> LEVEL 1 ; ================================================= if sMenuLevel == 0 ShowMessage Level1Message ; Menu initialisation set sMenuLevel to 1 ; Menu Level initialisation endif ; ================================================= ; LEVEL 1 --> LEVEL 2 ; ================================================= if sMenuLevel == 1 set sButton1 to GetButtonPressed ; Button set if sButton1 == -1 ; Button check 1 - none of the buttons have been pressed yet Return elseif sButton1 == 0 ; Button check 2 - 0th button pressed ShowMessage Level2Message0 ; Button result - show the 0th Level 2 Menu elseif sButton1 == 1 ; Button check 2 - 1st button pressed ShowMessage Level2Message1 ; Button result - show the 1st Level 2 Menu else ; Button check 2 - "Done" button pressed RemoveMe ; Button result - close Menu endif set sMenuLevel to 2 ; Menu Level incrementation endif ; ================================================= ; LEVEL 2 --> FINAL LEVEL ; ================================================= if sMenuLevel == 2 set sButton2 to GetButtonPressed ; Button set if sButton2 == -1 ; Button check 1 - none of the buttons have been pressed yet Return elseif sButton1 == 0 ; Navigation check 1 - 0th Level 2 Menu if sButton2 == 0 ; Button check 2 - 0th button pressed ; Button result elseif sButton2 == 1 ; Button check 2 - 1st button pressed ; Button result else ; Button check 2 - "Back" button was pressed ShowMessage Level1Message ; Button result - return to Level1Message set sMenuLevel to 1 Return ; Exclude common button result endif ShowMessage Level2Message0 ; Common button result - reset current menu elseif sButton1 == 1 ; Navigation check 1 - 1st Level 2 Menu if sButton2 == 0 ; Button check 2 - 0th button pressed ; Button result elseif sButton2 == 1 ; Button check 2 - 1st button pressed ; Button result else ; Button check 2 - "Back" button was pressed ShowMessage Level1Message ; Button result - return to Level1Message set sMenuLevel to 1 Return ; Exclude common button result endif ShowMessage Level2Message1 ; Common button result - reset current menu endif endif End Cipscis Link to comment Share on other sites More sharing options...
Malacola Posted March 2, 2009 Author Share Posted March 2, 2009 The problem is in the aptly named "ExplorerFastTravelScriptNotWorking". If I were to re-write your menu according to my Menu Template, which is used in the tutorial that you linked to, it would look something like this:ScriptName ExplorerFastTravelScriptWorking short sButton1 short sMenuLevel float fTimer Begin GameMode ; ================================================= ; INITIALISATION --> LEVEL 1 ; ================================================= if sMenuLevel == 0 ShowMessage ExplorerDialog set sMenuLevel to 1 endif ; ================================================= ; LEVEL 1 --> LEVEL 2 ; ================================================= if sMenuLevel == 1 set sButton1 to GetButtonPressed if sButton1 == -1 Return elseif sButton1 == 0 ; "Let's Ride" ; Enable fast travel if they have fuel if player.GetItemCount AmmoMicroFusionCell player.RemoveItem AmmoMicroFusionCell 1 set fTimer to 5 SetStage NoFastTravelwithoutExplorerq 1 set sMenuLevel to -1 ; Run timer else ; Player doesn't have enough fuel, show warning ShowMessage ExplorerBikeNoFuel RemoveMe endif elseif sButton1 == 1 ; "Don't want to ride" ; Don't do anything RemoveMe endif elseif sMenuLevel == -1 if fTimer > 0 set fTimer to fTimer - GetSecondsPassed else SetStage NoFastTravelwithoutExplorerq 1 RemoveMe endif endif End This is the menu template, if you or anyone else is interested:ScriptName MenuTokenScript short sMenuLevel ; Records the current depth of the ShowMessage framework ; 0 - Initialisation -> Level 1 ; 1 - Level 1 -> Level 2 ; 2 - Level 2 -> Final Level short sButton1 ; sButton variable for Level 1 short sButton2 ; sButton variable for Level 2 Begin GameMode ; ================================================= ; INITIALISATION --> LEVEL 1 ; ================================================= if sMenuLevel == 0 ShowMessage Level1Message ; Menu initialisation set sMenuLevel to 1 ; Menu Level initialisation endif ; ================================================= ; LEVEL 1 --> LEVEL 2 ; ================================================= if sMenuLevel == 1 set sButton1 to GetButtonPressed ; Button set if sButton1 == -1 ; Button check 1 - none of the buttons have been pressed yet Return elseif sButton1 == 0 ; Button check 2 - 0th button pressed ShowMessage Level2Message0 ; Button result - show the 0th Level 2 Menu elseif sButton1 == 1 ; Button check 2 - 1st button pressed ShowMessage Level2Message1 ; Button result - show the 1st Level 2 Menu else ; Button check 2 - "Done" button pressed RemoveMe ; Button result - close Menu endif set sMenuLevel to 2 ; Menu Level incrementation endif ; ================================================= ; LEVEL 2 --> FINAL LEVEL ; ================================================= if sMenuLevel == 2 set sButton2 to GetButtonPressed ; Button set if sButton2 == -1 ; Button check 1 - none of the buttons have been pressed yet Return elseif sButton1 == 0 ; Navigation check 1 - 0th Level 2 Menu if sButton2 == 0 ; Button check 2 - 0th button pressed ; Button result elseif sButton2 == 1 ; Button check 2 - 1st button pressed ; Button result else ; Button check 2 - "Back" button was pressed ShowMessage Level1Message ; Button result - return to Level1Message set sMenuLevel to 1 Return ; Exclude common button result endif ShowMessage Level2Message0 ; Common button result - reset current menu elseif sButton1 == 1 ; Navigation check 1 - 1st Level 2 Menu if sButton2 == 0 ; Button check 2 - 0th button pressed ; Button result elseif sButton2 == 1 ; Button check 2 - 1st button pressed ; Button result else ; Button check 2 - "Back" button was pressed ShowMessage Level1Message ; Button result - return to Level1Message set sMenuLevel to 1 Return ; Exclude common button result endif ShowMessage Level2Message1 ; Common button result - reset current menu endif endif End Cipscis Thanks Cipscis, this worked beautifully! Link to comment Share on other sites More sharing options...
Cipscis Posted March 2, 2009 Share Posted March 2, 2009 Cool, I'm glad to hear that Malacola! That menu template was the first major script that I wrote for Fallout 3, and I've been making modifications and improvements to it since I first wrote it for AMPUTATE! in November last year. Scripts written from that template can often be optimised a bit afterwards, especially if they're only a single level, but I've found it incredibly helpful to have a template. My most recent Mod, CASM, uses a multi-level options menu and having this template saved me an immense amount of time when it came to writing the main menu script, which is over 450 lines long. I'm glad to hear that you've found it useful here. If anyone's interested, I've also written a tutorial on adding an Options Menu to a Mod, which includes an explanation of the basic structure of this template and how it should be used. It's available on the GECK Wiki - Adding an Options Menu Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.