doubleclick123 Posted August 21, 2011 Share Posted August 21, 2011 scn AnvilScriptTest short ButtonPressshort Button begin onActivate if ( ButtonPress == 0 )messagebox "Smithing" "Bronze" "Iron" "Steel" "Etc" set ButtonPress to 1 ElseIf ( ButtonPress > 1 ) Activate EndIfEnd begin GameMode; Note to self, make sure that you make the statue. set ButtonPress to 1 set Button to GetButtonPressed if (Button == -1) return ElseIf (Button == 2) messagebox "Selected Material" "Cuirass" "Greaves & Boots" "Shield" "Helmet" "-Click here for weapons-" set ButtonPress to 2 Else Messagebox "Still Testing" set ButtonPress to -1 EndifElseif ( ButtonPress == 2 ) Activate Endifend First of all... Im not sure the spoiler is gonna work.... Second; It did not say there was an error in the script, it only does not activate even when you "activate it".. I even tried it on a wayshrine... (because i though there was a problem with the NIF model perhaps) It would really help if you answered, thanks. Link to comment Share on other sites More sharing options...
fg109 Posted August 21, 2011 Share Posted August 21, 2011 (edited) It's because you have "set ButtonPress to 1" in your GameMode block. That's what is preventing you from activating it. However, there are a few other things wrong with the script too. You need to put everything in your GameMode block under an if condition that'll only be true when you've activated the object. Otherwise, all your code there will be running even if you haven't done anything to the object yet. So if for some reason you were in the same cell as the object, and a menu from some other mod is displayed, choosing the 3rd button would run the code from that mod and display your message box with the equipment choices. You also don't have anything that sets ButtonPress back to 0, so you would only be able to forge something once. There's also a problem with setting ButtonPress to 2. You have it set to activate the object when it's 2, but you have nothing setting ButtonPress to something else, so you will actually keep activating the object forever. The last problem is with your Activate line in the GameMode block. You don't have an action ref (the one who is activating the object) parameter defined there. It's not necessary if used in OnActivate blocks but you should have one in the other blocks. Edited August 21, 2011 by fg109 Link to comment Share on other sites More sharing options...
doubleclick123 Posted August 22, 2011 Author Share Posted August 22, 2011 Thanks for the help fg, i managed to get it to be "pressable"... It's a test so i'm not really worried about other message boxes (yet)... My main concern though is to make sure that i can get the buttons right... I modified it a little... short Selectionshort Chose ; Normal Selection Standards.Short BronzeFlaws ; Each 'flaw' meaning you donot have enough bars.Short IronFlaws ; Setting multiple variables would make things a little easier.short MetalChooseshort Weapon ; Setting it so that we can use the messagebox to craft metals... Easier than trying ot put each metal in eh? begin onActivate player if player.getitemcount SmithingHammer < 1 messagebox "You donot have the proper hammer to use"else if ( Selection >= 1 ) set Selection to 0elseif ( Selection == 0 ) set Selection to 1set MetalChoose to 0set Weapon to 0if player.getitemcount Gem1Bronze < 3set BronzeFlaws to 5 endif endifend begin GameMode if ( Selection == -1) set Selection to 1 ElseIf (selection == 1) messagebox "Metals to Choose from" "Bronze" "Iron" "Steel" "Still Testing" set Chose to GetButtonPressed if ( Chose == 0 ) ; set MetalChoose to 5 set Selection to 0 endif endifend begin GameMode ; BRONZE if (MetalChoose == 2) messagebox "Armor" "Cuirass" "Greaves and Boots" "Shield" "Helmet" "See Weapon List" if ( Chose == 0 ) set MetalChoose to 507 elseif ( Chose == 1) set MetalChoose to 508 elseif ( Chose == 2) set MetalChoose to 509 elseif ( Chose == 3) Set MetalChoose to 510 elseif ( Chose == 4 ) set MetalChoose to 0 Set Weapon to 5 ; This is our longest 'test' script so far. (it's our only test script so far) elseif (BronzeFlaws == 5) messagebox "You donot have enough bars to craft anything." endif endifendifend Well actually, i restarted.. With a lot more variables.... (Ignore the bronze part... Unless my current problem has something to do with it...) When the "bronze" button is pressed, the Selection (which is our ButtonPress) is set to zero. But when i pressed the bronze button IN game, it actually just kept it on the original messagebox, the one choosing the metal. THanks for the reply again btw... Link to comment Share on other sites More sharing options...
Hickory Posted August 22, 2011 Share Posted August 22, 2011 Script formatted and placed inside xml box. short Selection short Chose ; Normal Selection Standards. Short BronzeFlaws ; Each 'flaw' meaning you donot have enough bars. Short IronFlaws ; Setting multiple variables would make things a little easier. short MetalChoose short Weapon ; Setting it so that we can use the messagebox to craft metals... Easier than trying ot put each metal in eh? begin onActivate player if player.getitemcount SmithingHammer < 1 messagebox "You donot have the proper hammer to use" else if ( Selection >= 1 ) set Selection to 0 elseif ( Selection == 0 ) set Selection to 1 set MetalChoose to 0 set Weapon to 0 if player.getitemcount Gem1Bronze < 3 set BronzeFlaws to 5 endif endif end begin GameMode if ( Selection == -1) set Selection to 1 ElseIf (selection == 1) messagebox "Metals to Choose from" "Bronze" "Iron" "Steel" "Still Testing" set Chose to GetButtonPressed if ( Chose == 0 ) ; set MetalChoose to 5 set Selection to 0 endif endif end begin GameMode ; BRONZE if (MetalChoose == 2) messagebox "Armor" "Cuirass" "Greaves and Boots" "Shield" "Helmet" "See Weapon List" if ( Chose == 0 ) set MetalChoose to 507 elseif ( Chose == 1) set MetalChoose to 508 elseif ( Chose == 2) set MetalChoose to 509 elseif ( Chose == 3) Set MetalChoose to 510 elseif ( Chose == 4 ) set MetalChoose to 0 Set Weapon to 5 ; This is our longest 'test' script so far. (it's our only test script so far) elseif (BronzeFlaws == 5) messagebox "You donot have enough bars to craft anything." endif endif endif end Well actually, i restarted.. With a lot more variables.... (Ignore the bronze part... Unless my current problem has something to do with it...) When the "bronze" button is pressed, the Selection (which is our ButtonPress) is set to zero. But when i pressed the bronze button IN game, it actually just kept it on the original messagebox, the one choosing the metal. THanks for the reply again btw... You have two GameModes (unless that is what you meant by 'ignore the bronze part'). And your 'bronze part' has a spurious EndIf. Link to comment Share on other sites More sharing options...
fg109 Posted August 22, 2011 Share Posted August 22, 2011 begin GameMode if ( Selection == -1) set Selection to 1 ElseIf (selection == 1) messagebox "Metals to Choose from" "Bronze" "Iron" "Steel" "Still Testing" set Chose to GetButtonPressed if ( Chose == 0 ) ; set MetalChoose to 5 set Selection to 0 endif endif end You should change your "selection" variable when you display the message box. Right now, this is what's happening: 1. "Selection" variable is 1, so let's display the metal selection menu!2. The game is now in menu mode, ignore the gamemode blocks now.3. A button got clicked! Go back to game mode.4. "Selection" variable is 1, so let's display the metal selection menu!etc. I suggest that you read this Message Box tutorial. It's very long and probably filled with lots of things that you don't need, but that's why it's very thorough. I think it's a good tutorial. Link to comment Share on other sites More sharing options...
MarkInMKUK Posted August 22, 2011 Share Posted August 22, 2011 begin GameMode if ( Selection == -1) set Selection to 1 ElseIf (selection == 1) messagebox "Metals to Choose from" "Bronze" "Iron" "Steel" "Still Testing" set Chose to GetButtonPressed if ( Chose == 0 ) ; set MetalChoose to 5 set Selection to 0 endif endif end You should change your "selection" variable when you display the message box. Right now, this is what's happening: 1. "Selection" variable is 1, so let's display the metal selection menu!2. The game is now in menu mode, ignore the gamemode blocks now.3. A button got clicked! Go back to game mode.4. "Selection" variable is 1, so let's display the metal selection menu!etc. I suggest that you read this Message Box tutorial. It's very long and probably filled with lots of things that you don't need, but that's why it's very thorough. I think it's a good tutorial.From that code snippet, I'd also evaluate Selection == 1 first - there is JUST a chance (if the script is handled badly) that if you follow the Selection == -1 path, it'll set Selection = 1, then that will be caught by the "elseif" and get evaluated by the Selection == 1 branch. Conversely, if you INTEND the -1 to be replaced by a 1, and then evaluated by the next branch, don't rely on the elseif catching it. Link to comment Share on other sites More sharing options...
Recommended Posts