MightyLink Posted August 17, 2011 Share Posted August 17, 2011 (edited) I've been having trouble with this script lately with 2 menus, for some reason the second menu never works, It shows up but whenever I click on one of the buttons nothing happens and the menu goes away. I've been smashing my head on the desk for days over this trying to figure it out and I can't find the problem, so now I would really like some help. Here is the code:scriptName aamlinkwellscript Short controlvar Short button Short secondpage Begin OnEquip if ( player.getitemcount Quill01 == 0 ) MessageBox "A Quill is required to inscribe." elseif ( player.getitemcount BlankSheet == 0 ) MessageBox "You do not have any Parchments." else ;List of Scrolls Go Here MessageBox "Choose a Scroll Recipe to Inscribe:", "Life Touch", "Mana Source", "Energy Boost", "Flame Tempest", "Lightning Vortex", "Icy Storm", "[Next Page]" Set controlvar to 1 endif End Begin MenuMode Set button to GetButtonPressed ;Life Touch if ( button == 0 ) && ( controlvar == 1 ) player.additem aamlscrollLifeTouchscroll 1 player.removeitem BlankSheet 1 Set controlvar to 0 EndIf ;Mana Source if ( button == 1 ) && ( controlvar == 1 ) player.additem aamlscrolManaSourcescroll 1 player.removeitem BlankSheet 1 Set controlvar to 0 EndIf ;Energy Boost if ( button == 2 ) && ( controlvar == 1 ) player.additem aamlscrollEnergyBoostscroll 1 player.removeitem BlankSheet 1 Set controlvar to 0 EndIf ;Flame Tempest if ( button == 3 ) && ( controlvar == 1 ) if ( player.getitemcount FireSalts <= 4 ) MessageBox "You do not have enough Fire Salts." Set controlvar to 0 elseif ( player.getitemcount FireSalts >= 5 ) player.additem aamlFlameTempestscroll 1 player.removeitem BlankSheet 1 player.removeitem FireSalts 5 Set controlvar to 0 endif endif ;Lightning Vortex if ( button == 4 ) && ( controlvar == 1 ) if ( player.getitemcount VoidSalts <= 4 ) MessageBox "You do not have enough Void Salts." Set controlvar to 0 elseif ( player.getitemcount VoidSalts >= 5 ) player.additem aamlLightningVortexscroll 1 player.removeitem BlankSheet 1 player.removeitem VoidSalts 5 Set controlvar to 0 endif endif ;Icy Storm if ( button == 5 ) && ( controlvar == 1 ) if ( player.getitemcount FrostSalts <= 4 ) MessageBox "You do not have enough Frost Salts." Set controlvar to 0 elseif ( player.getitemcount FrostSalts >= 5 ) player.additem aamlIcyStormscroll 1 player.removeitem BlankSheet 1 player.removeitem FrostSalts 5 Set controlvar to 0 endif endif ;Next Page if ( button == 6 ) && ( controlvar == 1 ) Set controlvar to -1 EndIf End Begin MenuMode if ( controlvar == -1 ) MessageBox "Choose a Scroll Recipe to Inscribe:", "Summon Minion", "Summon Undead", "Raise Dead", "Rejuvenation", "Fortify Ancient Magicka", "Ancient Regeneration", "[Done]" Set controlvar to 0 Set secondpage to 1 endif End Begin MenuMode Set button to GetButtonPressed ;Summon Minion if ( button == 0 ) && ( secondpage == 1 ) if ( player.getitemcount Bonemeal <= 2 ) MessageBox "You do not have enough Bonemeal." Set secondpage to 0 elseif ( player.getitemcount Bonemeal >= 3 ) player.additem aamlSummonMinionscroll 1 player.removeitem BlankSheet 1 player.removeitem Bonemeal 3 Set secondpage to 0 endif EndIf ;Summon Undead if ( button == 1 ) && ( secondpage == 1 ) if ( player.getitemcount MortFlesh <= 2 ) MessageBox "You do not have enough Mort Flesh." Set secondpage to 0 elseif ( player.getitemcount MortFlesh >= 3 ) player.additem aamSummonUndeadscroll 1 player.removeitem BlankSheet 1 player.removeitem MortFlesh 3 Set secondpage to 0 endif EndIf ;Raise Dead if ( button == 2 ) && ( secondpage == 1 ) if ( player.getitemcount DaedraHeart <= 1 ) MessageBox "You do not have enough Daedra Heart's." Set secondpage to 0 elseif ( player.getitemcount DaedraHeart >= 2 ) player.additem aamRaiseDeadscroll 1 player.removeitem BlankSheet 1 player.removeitem DaedraHeart 2 Set secondpage to 0 endif EndIf ;Rejuvenation if ( button == 3 ) && ( secondpage == 1 ) if ( player.getitemcount TrollFat <= 2 ) MessageBox "You do not have enough Troll Fat." Set secondpage to 0 elseif ( player.getitemcount TrollFat >= 3 ) player.additem aamlRejuvenationscroll 1 player.removeitem BlankSheet 1 player.removeitem TrollFat 3 Set secondpage to 0 endif endif ;Fortify Ancient Magicka if ( button == 4 ) && ( secondpage == 1 ) if ( player.getitemcount WelkyndStone <= 4 ) MessageBox "You do not have enough Welkynd Stone's." Set secondpage to 0 elseif ( player.getitemcount WelkyndStone >= 5 ) player.additem aamlFortifyAncientMagickascroll 1 player.removeitem BlankSheet 1 player.removeitem WelkyndStone 5 Set secondpage to 0 endif endif ;Ancient Regeneration if ( button == 5 ) && ( secondpage == 1 ) if ( player.getitemcount VarlaStone == 0 ) MessageBox "You do not have a Varla Stone." Set secondpage to 0 elseif ( player.getitemcount VarlaStone >= 1 ) player.additem aamlAncientRegenerationscroll 1 player.removeitem BlankSheet 1 player.removeitem VarlaStone 1 Set secondpage to 0 endif endif ;Done if ( button == 6 ) && ( secondpage == 1 ) Set secondpage to 0 EndIf End It is a menu for a mod I am working on, the first page works fine, but for some reason when I click on choices on the second page nothing happens, I cannot understand why, all my variables look accurate to me, so please help, I'm still kind of newish to programming, I tried everything, I even tried following tutorials on the CS wiki, according to them it should work but its not. I am guessing the conditions for the second set of items isn't being true, but I set them up to be true before hand so idk whats wrong. When I look at that script, by the time it gets to for example: ( button == 0 ) && ( secondpage == 1 ) both those values should be true so it should run the remove and add items in that block, but its not, nothing happens when I click on any of the choices on the second page. Edited August 17, 2011 by MightyLink Link to comment Share on other sites More sharing options...
fg109 Posted August 17, 2011 Share Posted August 17, 2011 (edited) I hate making menus but I've had to make quite a few of them before. I don't know what might be wrong with how you're doing your menu (off-hand I would say it might be because of your multiple menumode blocks or else using the GetButtonPressed function multiple times per frame) but this is the format I use for my menus: scn menuscript short menu short choice Begin OnEquip ;or however you want the menu to be started set menu to 1 End Begin MenuMode ;or GameMode depending on how the menu is started if (menu == 1) set menu to -1 ;use negative values for checking the button pressed MessageBox "Message 1" "choice 0" "choice 1" "choice 2" ;etc. elseif (menu == -1) set choice to GetButtonPressed if (choice == 0) set menu to 10 ;do something elseif (choice == 1) set menu to 11 ;do something else elseif (choice == 2) set menu to 12 ;etc. elseif (choice == 8) ;the next page option set menu to 2 elseif (choice == 9) ;the cancel option set menu to 0 endif Return endif if (menu == 2) set menu to -2 MessageBox "Message 2" "choice 0" "choice 1" "choice 2" ;etc. elseif (menu == -2) ;set it up similar to menu = -1 endif if (menu == 10) ;the first submenu of first menu set menu to -10 MessageBox "Message 3" "choice 0" "choice 1" "choice 2" ;etc. elseif (menu == -10) set choice to GetButtonPressed if (choice == 0) set menu to 100 ;do something elseif (choice == 1) set menu to 101 ;do something else elseif (choice == 2) set menu to 102 ;etc. elseif (choice == 8) ;return to previous menu set menu to (menu / 10) elseif (choice == 9) ;the cancel option set menu to 0 endif Return endif if (menu == 20) ;the first submenu of the second menu set menu to -20 ;etc. endif ;etc. End Edited August 17, 2011 by fg109 Link to comment Share on other sites More sharing options...
MightyLink Posted August 17, 2011 Author Share Posted August 17, 2011 (edited) I hate making menus but I've had to make quite a few of them before. I don't know what might be wrong with how you're doing your menu (off-hand I would say it might be because of your multiple menumode blocks or else using the GetButtonPressed function multiple times per frame) but this is the format I use for my menus: scn menuscript short menu short choice Begin OnEquip ;or however you want the menu to be started set menu to 1 End Begin MenuMode ;or GameMode depending on how the menu is started if (menu == 1) set menu to -1 ;use negative values for checking the button pressed MessageBox "Message 1" "choice 0" "choice 1" "choice 2" ;etc. elseif (menu == -1) set choice to GetButtonPressed if (choice == 0) set menu to 10 ;do something elseif (choice == 1) set menu to 11 ;do something else elseif (choice == 2) set menu to 12 ;etc. elseif (choice == 8) ;the next page option set menu to 2 elseif (choice == 9) ;the cancel option set menu to 0 endif Return endif if (menu == 2) set menu to -2 MessageBox "Message 2" "choice 0" "choice 1" "choice 2" ;etc. elseif (menu == -2) ;set it up similar to menu = -1 endif if (menu == 10) ;the first submenu of first menu set menu to -10 MessageBox "Message 3" "choice 0" "choice 1" "choice 2" ;etc. elseif (menu == -10) set choice to GetButtonPressed if (choice == 0) set menu to 100 ;do something elseif (choice == 1) set menu to 101 ;do something else elseif (choice == 2) set menu to 102 ;etc. elseif (choice == 8) ;return to previous menu set menu to (menu / 10) elseif (choice == 9) ;the cancel option set menu to 0 endif Return endif if (menu == 20) ;the first submenu of the second menu set menu to -20 ;etc. endif ;etc. End Thank you so much man your a life saver, your code is much simpler and shorter and it worked. I've never learned to code before I started making mods for oblivion so I can never tell whats wrong with it, usually the CS script editor tells me when theres a problem but for some reason it didn't for my page script, now that I used yours it worked perfectly, thanks again, I'll give you credits for helping when I release my mod. [EDIT] My mod has been finished and uploaded here: http://www.tesnexus.com/downloads/file.php?id=39962 Edited August 17, 2011 by MightyLink Link to comment Share on other sites More sharing options...
Recommended Posts