icecreamassassin Posted September 3, 2011 Share Posted September 3, 2011 So I have this script I'm working on (and it was working already but I have no clue what happened, CS bugged some scripts in my mod and I had to rebuild a gew things associated with one of my quests and this was apparently one of them) ScriptName CRforgescript short button short ironbars short steelbars short silverbars short goldbars short mithrilbars short bronzebars short copperbars short tinbars short ebonybars short daedricbars short silverN short goldN short ironore short coal short tinore short copperore short daedricore short mithrilore short controlvar Begin Onactivate MessageBox "What would you like to smelt?" "Iron Bars" "Steel Bars" "Silver Bars" "Mithril Bars" "Gold Bars" "Copper Bars" "Tin Bars" "Bronze Bars" "Ebony Bars" "Daedric Bars" set controlvar to 1 end begin gamemode if player.getincell frostfireforge == 1 if controlvar == 1 set ironbars to player.getitemcount CRbariron set steelbars to player.getitemcount CRbarsteel set silverbars to player.getitemcount CRbarsilver set goldbars to player.getitemcount CRbargold set mithrilbars to player.getitemcount CRbarmithril set bronzebars to player.getitemcount CRbarbronze set tinbars to player.getitemcount CRbartin set copperbars to player.getitemcount CRbarcopper set ebonybars to player.getitemcount CRbarebony set daedricbars to player.getitemcount CRbardaedric set ironore to player.getitemcount CRoreiron set coal to player.getitemcount CRcoal set tinore to player.getitemcount CRoretin set copperore to player.getitemcount CRorecopper set daedricore to player.getitemcount CRoredaedric set mithrilore to player.getitemcount CRoremithril set button to getbuttonpressed if button == 0 && ironore >= 3 ; iron player.removeitem CRoreiron 3 player.additem CRbariron 1 set controlvar to 0 elseif button == 1 && ironore >= 3 && coal >= 3 ; steel player.removeitem CRoreiron 3 player.removeitem CRcoal 3 player.additem CRbarsteel 1 set controlvar to 0 elseif button == 2 && silverN >= 2 ; silver player.removeitem gem0silvernugget 2 player.additem CRbarsilver 1 elseif button == 3 && mithrilore >= 3 ; mithril player.removeitem CRoremithril 3 player.additem CRbarmithril 1 set controlvar to 0 elseif button == 4 && goldN >= 2 ; gold player.removeitem gem0goldnugget 2 player.additem CRbargold 1 set controlvar to 0 elseif button == 5 && copperore >= 3 ; copper player.removeitem CRorecopper 3 player.additem CRbarcopper 1 set controlvar to 0 elseif button == 6 && tinore >= 3 ; tin player.removeitem CRoretin 3 player.additem CRbartin 1 set controlvar to 0 elseif button == 7 && copperbars >= 1 && tinbars >= 1 ; bronze player.removeitem CRbartin 1 player.removeitem CRbarcopper 1 player.additem CRbarbronze 1 set controlvar to 0 elseif button == 8 && steelbars >= 1 && mithrilbars >= 1 && silverN >= 1 && goldN >= 1 ; ebony player.removeitem CRbarsteel 1 player.removeitem CRbarmithril 1 player.removeitem gem0silvernugget 1 player.removeitem gem0goldnugget 1 player.additem CRbarebony 1 set controlvar to 0 elseif button == 9 && daedricbars >= 1 && mithrilbars >= 1 && silverN >= 1 && goldN >= 1 ; daedric player.removeitem CRbardaedric 1 player.removeitem CRbarmithril 1 player.removeitem gem0silvernugget 1 player.removeitem gem0goldnugget 1 player.additem CRbardaedric 1 set controlvar to 0 else message "You do not have the required materials" set controlvar to 0 endif endif endif end So basically what happens is I click the activator, the menu pops up, I select the option I wish and it closes and gives me the "You don't have the right supplies" message and does nothing else even though I DO have the right supplies in my inventory. I know I must be missing some mundane detail, but it's late so I defer to a fresh set of eyes. Any help is appreciated, thanks. Link to comment Share on other sites More sharing options...
fore Posted September 3, 2011 Share Posted September 3, 2011 It doesn't work that way. You have to wait with your query until the button is set. In your case the button is still set to -1, and that's why you get your message. Not because your equipment is too low. See GetButtonPressed :thumbsup: Link to comment Share on other sites More sharing options...
icecreamassassin Posted September 3, 2011 Author Share Posted September 3, 2011 It doesn't work that way. You have to wait with your query until the button is set. In your case the button is still set to -1, and that's why you get your message. Not because your equipment is too low. See GetButtonPressed :thumbsup: Sorry I'm not seeing AT ALL, what you are saying here. The script I listed above adheres to the same structure as the getbuttonpressed wiki entry (as far as I can see) as I can tell you need a Begin OnActivate which displays the message selection and sets the "controlvar" to 1 then a gamemode block that has a check for if controlvar == 1 and then you set the button var to getbutton pressed, then you button query box. I tinkered with the script and commented out the 'else message "you don't have enough materials" ' block and the script functions perfectly, save for the fact that there is no default message of the other items aren't true, but when the else condition is left it in doesn't function.... here's the new version: ScriptName CRforgescript short button short controlvar short ironbars short steelbars short silverbars short goldbars short mithrilbars short bronzebars short copperbars short tinbars short ebonybars short daedricbars short silverN short goldN short ironore short coal short tinore short copperore short daedricore short mithrilore Begin Onactivate MessageBox "What would you like to smelt?" "Iron Bars" "Steel Bars" "Silver Bars" "Mithril Bars" "Gold Bars" "Copper Bars" "Tin Bars" "Bronze Bars" "Ebony Bars" "Daedric Bars" set controlvar to 1 end begin gamemode if player.getincell frostfireforge == 1 if controlvar == 1 set ironbars to player.getitemcount CRbariron set steelbars to player.getitemcount CRbarsteel set silverbars to player.getitemcount CRbarsilver set goldbars to player.getitemcount CRbargold set mithrilbars to player.getitemcount CRbarmithril set bronzebars to player.getitemcount CRbarbronze set tinbars to player.getitemcount CRbartin set copperbars to player.getitemcount CRbarcopper set ebonybars to player.getitemcount CRbarebony set daedricbars to player.getitemcount CRbardaedric set ironore to player.getitemcount CRoreiron set coal to player.getitemcount CRcoal set tinore to player.getitemcount CRoretin set copperore to player.getitemcount CRorecopper set daedricore to player.getitemcount CRoredaedric set mithrilore to player.getitemcount CRoremithril set button to getbuttonpressed if button == 0 && ironore >= 3 ; iron player.removeitem CRoreiron 3 player.additem CRbariron 1 set controlvar to 0 elseif button == 1 && ironore >= 3 && coal >= 3 ; steel player.removeitem CRoreiron 3 player.removeitem CRcoal 3 player.additem CRbarsteel 1 set controlvar to 0 elseif button == 2 && silverN >= 2 ; silver player.removeitem gem0silvernugget 2 player.additem CRbarsilver 1 set controlvar to 0 elseif button == 3 && mithrilore >= 3 ; mithril player.removeitem CRoremithril 3 player.additem CRbarmithril 1 set controlvar to 0 elseif button == 4 && goldN >= 2 ; gold player.removeitem gem0goldnugget 2 player.additem CRbargold 1 set controlvar to 0 elseif button == 5 && copperore >= 3 ; copper player.removeitem CRorecopper 3 player.additem CRbarcopper 1 set controlvar to 0 elseif button == 6 && tinore >= 3 ; tin player.removeitem CRoretin 3 player.additem CRbartin 1 set controlvar to 0 elseif button == 7 && copperbars >= 1 && tinbars >= 1 ; bronze player.removeitem CRbartin 1 player.removeitem CRbarcopper 1 player.additem CRbarbronze 1 set controlvar to 0 elseif button == 8 && steelbars >= 1 && mithrilbars >= 1 && silverN >= 1 && goldN >= 1 ; ebony player.removeitem CRbarsteel 1 player.removeitem CRbarmithril 1 player.removeitem gem0silvernugget 1 player.removeitem gem0goldnugget 1 player.additem CRbarebony 1 set controlvar to 0 elseif button == 9 && daedricbars >= 1 && mithrilbars >= 1 && silverN >= 1 && goldN >= 1 ; daedric player.removeitem CRbardaedric 1 player.removeitem CRbarmithril 1 player.removeitem gem0silvernugget 1 player.removeitem gem0goldnugget 1 player.additem CRbardaedric 1 set controlvar to 0 ;else ; message "You do not have the required materials" endif endif endif end So then what is the proper way to get the else statement back in so it will work. I've compared this script to two other much more complex ones I've done with multiple menu boxes nested and they all terminate properly and display the message at the end if the other conditions aren't met but I can't see where the difference is between those scripts and this one. Link to comment Share on other sites More sharing options...
icecreamassassin Posted September 3, 2011 Author Share Posted September 3, 2011 Nevermind I figured it out, you described it in a very vague and confusing way to me. What was happening is that the message box was coming up all the time because the value of the button is -1 by default and therefore every time you push it, the else condition was always true and it terminated the script before the rest of the sections could be checked. So I basically had to add an IF query block to check that the value of the button was greater than -1 and enclose the whole button check code (like the getbuttonpressed link you posted showed. Funny thing is that my other scripts don't have this check and the messagebox functions properly, it's weird... Anyways thanks for the lead to figuring it out. Link to comment Share on other sites More sharing options...
Recommended Posts