Jump to content

Script help


Recommended Posts

So I am setting up a simple blacksmithing script. When the anvil is activated it asks if you want to make weapons or armor, then asks you what material you'd like to use and finally what type of weapon or armor you want to make. I have a message box block set up for the first menu, and one for the weapon material, one for armor material, one for weapon selection and one for armor selection. The problem is that The first menu executes no problem, I click the option desired (weapon/armor/cancel all work fine) they bring up the proper second menu but when I select any option it just refreshes that menu. Cancel also does not work on the second menu and I can't get it to progress to the third menu. Here's the code

 

ScriptName CRAnvilscript

short button
short controlvar
short material

begin onactivate
Messagebox "What do you wish to make?" "Weapon" "Armor" "Cancel"
	set controlvar to 1
end

Begin GameMode
if (controlvar == 1) ; crafting choice
	set button to getbuttonpressed	
		if button == 0 ; weapon
			set controlvar to 10 ; weapon materials
		elseif button == 1 ; armor
			set controlvar to 20 ; armor materials
		elseif button == 2 ; cancel
			set controlvar to 0 ; restart
		endif
elseif controlvar == 10 ; weapon material choice
	messagebox "What material would you like to use?" "Iron" "Steel" "Cancel"
		set button to getbuttonpressed
			if button == 0 ; iron
				set controlvar to 11 ; weapon menu
				set material to 1
			elseif button == 1 ; steel
				set controlvar to 11 ; weapon menu
				set material to 2
			elseif button == 2 ; cancel
				set controlvar to 0
				return
			endif
elseif controlvar == 11 ; weapon choice
	messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Cancel"
		set button to getbuttonpressed
			if button == 0 ; dagger
				set controlvar to 0
				if material == 1
					player.additem WeapIronDagger 1
				elseif material == 2
					player.additem WeapSteelDagger 1
				endif
			elseif button == 1 ; short sword
				set controlvar to 0
				if material == 1
					player.additem WeapIronShortsword 1
				elseif material == 2
					player.additem WeapSteelShortsword 1
				endif
			elseif button == 2 ; cancel
				set controlvar to 0
				set button to -1
				set material to 0
				return
			endif
elseif controlvar == 20 ; armor material
	messagebox "What material would you like to use?" "Iron" "Steel" "Cancel"
		set button to getbuttonpressed
			if button == 0 ; iron
				set controlvar to 21 ; armor menu
				set material to 1
			elseif button == 1 ; steel
				set controlvar to 21 ; armor menu
				set material to 2
			elseif button == 2 ; cancel
				set controlvar to 0
				return
			endif
	elseif controlvar == 21 ; armor choice
	messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cancel"
		set button to getbuttonpressed
			if button == 0 ; Helm
				set controlvar to 0
					if material == 1
						player.additem Ironhelmet 1
					elseif material == 2
						player.additem Steelhelmet 1
					endif
			elseif button == 1 ; gauntlets
				set controlvar to 0
					if material == 1
						player.additem Irongauntlets 1
					elseif material == 2
						player.additem Steelgauntlets 1
					endif
			elseif button == 2 ; cancel
				set controlvar to 0
				set button to -1
				set material to 0
				return
			endif

endif
end

Link to comment
Share on other sites

Well, the code looks pretty similar to what I use for message boxes, except for one thing. I make sure that my message boxes display only once by changing the control_var when I display message boxes.

 

You could take a look at this thread. It was also about smithing. The code was longer though since it involved a lot more items/materials.

Link to comment
Share on other sites

Ok, so I went and looked over the other script the person was using. I have that mod of theirs but it does have a bunch of excess stuff I didn't want to include in my blacksmithing mod. After looking at the structure it looks like the only main difference I am spotting is that each menu segment is blocked off with IF/ENDIF commands whereas mine were a single IF check with ELSEIF blocks inside it for each menu. Mechanically they both should work fine, but all the same I changed it to the way his code was displayed and it dtill does the same thing. Goes to the second menu and then just gets you stuck there. It's like the controlvar is not being changed by the second menu or the getbuttonpressed commands on the second menu are doing nothing.

 

Can anyone help me at all? I am going nuts trying to see where my flow problem is.

Link to comment
Share on other sites

Hold on, and I will have a look-see. Will return shortly.

 

EDIT

 

Ok, there we go;

 

 

scn 0CRAnvilscript

short button
short controlvar
short material

begin OnActivate
messagebox "What do you wish to make?" "Weapon" "Armor" "Cancel"
set controlvar to 1
end

begin GameMode
if controlvar == 1							; crafting choice
	set button to getbuttonpressed  
	if button == 0							; weapon
		messagebox "What material would you like to use?" "Iron" "Steel" "Cancel"
		set controlvar to 10				; weapon materials
	elseif button == 1						; armor
		messagebox "What material would you like to use?" "Iron" "Steel" "Cancel"
		set controlvar to 20				; armor materials
	elseif button == 2						; cancel
		set controlvar to 0					; restart
	endif
elseif controlvar == 10					; weapon material choice
	set button to getbuttonpressed
	if button == 0							; iron
		messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Cancel"
		set controlvar to 11				; weapon menu
		set material to 1
	elseif button == 1						; steel
		messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Cancel"
		set controlvar to 11				; weapon menu
		set material to 2
	elseif button == 2						; cancel
		set controlvar to 0
		return
	endif
elseif controlvar == 11					; weapon choice
	set button to getbuttonpressed
	if button == 0							; dagger
		set controlvar to 0
		if material == 1
			player.additem WeapIronDagger 1
		elseif material == 2
			player.additem WeapSteelDagger 1
		endif
	elseif button == 1						; short sword
		set controlvar to 0
		if material == 1
			player.additem WeapIronShortsword 1
		elseif material == 2
			player.additem WeapSteelShortsword 1
		endif
	elseif button == 2						; cancel
		set controlvar to 0
		set material to 0
		return
	endif
elseif controlvar == 20					; armor material
	set button to getbuttonpressed
	if button == 0							; iron
		messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cancel"
		set controlvar to 21				; armor menu
		set material to 1
	elseif button == 1						; steel
		messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cancel"
		set controlvar to 21				; armor menu
		set material to 2
	elseif button == 2						; cancel
		set controlvar to 0
		return
	endif
elseif controlvar == 21					; armor choice
	set button to getbuttonpressed
	if button == 0							; Helm
		set controlvar to 0
		if material == 1
			player.additem Ironhelmet 1
		elseif material == 2
			player.additem Steelhelmet 1
		endif
	elseif button == 1						; gauntlets
		set controlvar to 0
		if material == 1
			player.additem Irongauntlets 1
		elseif material == 2
			player.additem Steelgauntlets 1
		endif
	elseif button == 2						; cancel
		set controlvar to 0
		set material to 0
		return
	endif
endif
end

 

 

 

First of all, all it needed was a bit tidying up and some restructuring. I tested it ingame, and it works like a charm now.

 

Which brings me to the second matter; the script seems to be missing some inherent logic. Main example is that making these things doesn't cost anything. It can spawn infinite items the way it is designed at the moment.

 

But I'm sure you're aware of this. Just saying.

Edited by GreatLucifer
Link to comment
Share on other sites

Ah yer awesome, thanks I figured it was nested wrong or had some funky flow problem. I'll plug it into the mod and check it out. And yes I am aware that there are no material costs plugged in yet, I just wanted to make sure that the flow of the menus worked properly first, thanks again!
Link to comment
Share on other sites

So I plugged it in and started expanding on it and it all looks and works great. I kinda suspected I was putting the actual message choice boxes into the wrong block and that they actually needed to be placed in the block before it, but I wasn't quite able to wrap my head around how or why. Thanks again, and I plan on putting a special thanks for your help into my readme for the finished mod GreatLucifer
Link to comment
Share on other sites

Ok... now I'm bummed again. I'm like 2 items away from finishing this thing and suddenly the script hits it's limit, which I wasn't aware it had. I get to around 620 lines and it will not let me type another character.... Any thoughts?

 

ScriptName CRAnvilscript

short button
short controlvar
short material

short ironbars
short steelbars
short silverbars
short goldbars
short mithrilbars
short bronzebars
short ebonybars
short daedricbars
short goldN
short silverN
short copperore

begin OnActivate
       messagebox "What do you wish to make?" "Weapon" "Armor" "Cancel"
       set controlvar to 1
end

begin GameMode
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 ebonybars to player.getitemcount CRbarebony
set daedricbars to player.getitemcount CRbardaedric
set copperore to player.getitemcount CRorecopper
set goldN to gem0goldnugget
set silverN to gem0silvernugget

       if controlvar == 1                                                      ; crafting choice
               set button to getbuttonpressed  
               if button == 0                                                  ; weapon
                       messagebox "What material would you like to use?" "Iron" "Steel" "Silver" "Elven Steel" "Dwarven Bronze" "Ebony" "Daedric Iron" "Cancel"
                       set controlvar to 10                            ; weapon materials
               elseif button == 1                                              ; armor
                       messagebox "What material would you like to use?" "Iron" "Steel" "Elven Steel" "Mithril" "Dwarven Bronze" "Orcish Iron" "Ebony" "Daedric Iron" "Cancel"
                       set controlvar to 20                            ; armor materials
               elseif button == 2                                              ; cancel
                       set controlvar to 0                                     ; restart
               endif
       elseif controlvar == 10                                 ; weapon material choice
               set button to getbuttonpressed
               if button == 0                                                  ; iron
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 1
               elseif button == 1                                              ; steel
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 2
		elseif button == 2                                              ; silver
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 3
		elseif button == 3                                              ; elven
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 4
		elseif button == 4                                              ; dwarf
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 6
		elseif button == 5                                              ; ebony
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 8
		elseif button == 6                                              ; daedric
                       messagebox "What weapon would you like to make?" "Dagger" "Short sword" "Long sword" "Claymore" "war axe" "Battle axe" "Mace" "Warhammer" "Arrows" "Cancel"
                       set controlvar to 11                            ; weapon menu
                       set material to 9
               elseif button == 7                                              ; cancel
                       set controlvar to 0
                       return
               endif
       elseif controlvar == 11                                 ; weapon choice
               set button to getbuttonpressed
               if button == 0                                                  ; dagger
                       set controlvar to 0
                       if material == 1 && ironbars >= 1
                               player.removeitem CRbariron 1
					  player.additem WeapIronDagger 1
                       elseif material == 2 && steelbars >= 1
                               player.removeitem CRbarsteel 1
                               player.additem WeapSteelDagger 1
				elseif material == 3 && silverbars >= 1
                               player.removeitem CRbarsilver 1
                               player.additem WeapSilverDagger 1
				elseif material == 4 && steelbars >= 1 && goldN >= 1
                               player.removeitem CRbarsteel 1
					  player.removeitem gem0goldnugget 1
                               player.additem WeapElvenDagger 1
				elseif material == 6 && bronzebars >= 1
					  player.removeitem CRbarbronze 1
                               player.additem WeapDwarvenDagger 1
				elseif material == 8 && steelbars >= 1 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbarsteel 1
					  player.removeitem CRbarmithril 1
                               player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
					  player.additem WeapEbonyDagger 1
				elseif material == 9 && daedricbars >= 1 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbardaedric 1
					  player.removeitem CRbarmithril 1
                               player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
					  player.additem WeapDaedricDagger 1
				else
					message "You don't have the right materials"
                     endif
               elseif button == 1                                              ; short sword
                       set controlvar to 0
                       if material == 1 && ironbars >= 1
					  player.removeitem CRbariron 1
                               player.additem WeapIronShortsword 1
                       elseif material == 2 && steelbars >= 1
					  player.removeitem CRbarsteel 1
                               player.additem WeapSteelShortsword 1
				elseif material == 3 && silverbars >= 1
					  player.removeitem CRbarsilver 1
                               player.additem WeapSilverShortsword 1
				elseif material == 4 && steelbars >= 2 && goldN >= 2
					  player.removeitem CRbarsteel 2
					  player.removeitem gem0goldnugget 2
                               player.additem WeapElvenShortsword 1
				elseif material == 6 && bronzebars >= 2
					  player.removeitem CRbarbronze 2
                               player.additem WeapDwarvenShortsword 1
				elseif material == 8 && ebonybars >= 2
					  player.removeitem CRbarebony 2
                               player.additem WeapEbonyShortsword 1
				elseif material == 9 && daedricbars >= 1 && mithrilbars >= 1 && goldn >= 1 && silverN >= 1
					  player.removeitem CRbardaedric 1
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
                               player.additem WeapDaedricShortsword 1
				else
					message "You don't have the right materials"

				endif
		 elseif button == 2                                              ; long sword
                       set controlvar to 0
                       if material == 1 && ironbars >= 3
					  player.removeitem CRbariron 3
                               player.additem WeapIronLongsword 1
                       elseif material == 2 && steelbars >= 3
					  player.removeitem CRbarsteel 3
                               player.additem WeapSteelLongsword 1
				elseif material == 3 && silverbars >= 3
					  player.removeitem CRbarsilver 3
                               player.additem WeapSilverLongsword 1
				elseif material == 4 && steelbars >= 3 && goldbars >= 1
					  player.removeitem CRbargold 1
					  player.removeitem CRbarsteel 3
                               player.additem WeapElvenLongsword 1
				elseif material == 6 && bronzebars >= 3
					  player.removeitem CRbarbronze 3
                               player.additem WeapDwarvenLongsword 1
				elseif material == 8 && steelbars >= 3 && goldN >= 2 && silverN >= 2
					  player.removeitem CRbarsteel 3
					  player.removeitem gem0goldnugget 2
					  player.removeitem gem0silvernugget 2
                               player.additem WeapEbonyLongsword 1
				elseif material == 9 && daedricbars >= 3 && goldbars >= 1 && silverbars >= 1
					  player.removeitem CRbardaedric 3
					  player.removeitem CRbarsilver 1
					  player.removeitem CRbargold 1
                               player.additem WeapDaedricLongsword 1
				else
					message "You don't have the right materials"

				endif
		elseif button == 3                                              ; claymore
                       set controlvar to 0
                       if material == 1 && ironbars >= 4
					  player.removeitem CRbariron 4
                               player.additem WeapIronclaymore 1
                       elseif material == 2 && steelbars >= 4
					  player.removeitem CRbarsteel 4
                               player.additem WeapSteelclaymore 1
				elseif material == 3 && silverbars >= 4
					  player.removeitem CRbarsilver 4
                               player.additem WeapSilverclaymore 1
				elseif material == 4 && steelbars >= 4 && goldbars >= 1
					  player.removeitem CRbarsteel 4
					  player.removeitem CRbargold 1
                               player.additem WeapElvenclaymore 1
				elseif material == 6 && bronzebars >= 4
					  player.removeitem CRbarbronze 4
                               player.additem WeapDwarvenclaymore 1
				elseif material == 8 && steelbars >= 4 && goldbars >= 2 && silverbars >= 1
					  player.removeitem CRbarsteel 4
					  player.removeitem CRbargold 2
				 	  player.removeitem CRbarsilver 1
                               player.additem WeapEbonyclaymore 1
				elseif material == 9
                               player.additem WeapDaedricclaymore 1
				else
					message "You don't have the right materials"

				endif
		elseif button == 4                                              ; waraxe
                       set controlvar to 0
                       if material == 1 && ironbars >= 3
					  player.removeitem CRbariron 3
                               player.additem WeapIronwaraxe 1
                       elseif material == 2 && steelbars >= 3
					  player.removeitem CRbarsteel 3
                               player.additem WeapSteelwaraxe 1
				elseif material == 3 && silverbars >= 3
					  player.removeitem CRbarsilver 3
                               player.additem WeapSilverwaraxe 1
				elseif material == 4 && steelbars >= 3 && goldbars >= 1
					  player.removeitem CRbargold 1
					  player.removeitem CRbarsteel 3
                               player.additem WeapElvenwaraxe 1
				elseif material == 6 && bronzebars >= 3
					  player.removeitem CRbarbronze 3
                               player.additem WeapDwarvenwaraxe 1
				elseif material == 8 && steelbars >= 3 && goldN >= 2 && silverN >= 2
					  player.removeitem CRbarsteel 3
					  player.removeitem gem0goldnugget 2
					  player.removeitem gem0silvernugget 2
                               player.additem WeapEbonywaraxe 1
				elseif material == 9 && daedricbars >= 3 && mithrilbars >= 1 && goldbars >= 1 && silverbars >= 1
					  player.removeitem CRbardaedric 3
					  player.removeitem CRbarsilver 1
					  player.removeitem CRbargold 1
					  player.removeitem CRbarmithril 1
                               player.additem WeapDaedricwaraxe 1
				else
					message "You don't have the right materials"

				endif
		elseif button == 5                                              ; battleaxe
                       set controlvar to 0
                       if material == 1 && ironbars >= 4
					  player.removeitem CRbariron 4
                               player.additem WeapIronbattleaxe 1
                       elseif material == 2 && steelbars >= 4
					  player.removeitem CRbarsteel 4
                               player.additem WeapSteelbattleaxe 1
				elseif material == 3 && silverbars >= 4
					  player.removeitem CRbarsilver 4
                               player.additem WeapSilverbattleaxe 1
				elseif material == 4 && steelbars >= 4 && goldbars >= 2
					  player.removeitem CRbarsteel 4
					  player.removeitem CRbargold 2
                               player.additem WeapElvenbattleaxe 1
				elseif material == 6 && bronzebars >= 4
					  player.removeitem CRbarbronze 4
                               player.additem WeapDwarvenbattleaxe 1
				elseif material == 8 && steelbars >= 4 && goldbars >= 2 && silverbars >= 1
					  player.removeitem CRbarsteel 4
					  player.removeitem CRbargold 2
				 	  player.removeitem CRbarsilver 1
                               player.additem WeapEbonybattleaxe 1
				elseif material == 9 && daedricbars >= 3 && mithrilbars >= 2 && goldbars >= 2 && silverbars >= 1
					  player.removeitem CRbardaedric 3
					  player.removeitem CRbarmithril 2
					  player.removeitem CRbargold 2
					  player.removeitem CRbarsilver 1
                               player.additem WeapDaedricbattleaxe 1
				else
					message "You don't have the right materials"
				endif
		elseif button == 6                                              ; mace
                       set controlvar to 0
                        if material == 1 && ironbars >= 3
					  player.removeitem CRbariron 3
                               player.additem WeapIronmace 1
                       elseif material == 2 && steelbars >= 3
					  player.removeitem CRbarsteel 3
                               player.additem WeapSteelmace 1
				elseif material == 3 && silverbars >= 3
					  player.removeitem CRbarsilver 3
                               player.additem WeapSilvermace 1
				elseif material == 4 && steelbars >= 3 && goldbars >= 1
					  player.removeitem CRbargold 1
					  player.removeitem CRbarsteel 3
                               player.additem WeapElvenmace 1
				elseif material == 6 && bronzebars >= 3
					  player.removeitem CRbarbronze 3
                               player.additem WeapDwarvenmace 1
				elseif material == 8 && steelbars >= 3 && goldN >= 2 && silverN >= 2
					  player.removeitem CRbarsteel 3
					  player.removeitem gem0goldnugget 2
					  player.removeitem gem0silvernugget 2
                               player.additem WeapEbonymace 1
				elseif material == 9 && daedricbars >= 3 && goldbars >= 1 && silverbars >= 1
					  player.removeitem CRbardaedric 3
					  player.removeitem CRbarsilver 1
					  player.removeitem CRbargold 1
                               player.additem WeapDaedricmace 1
				else
					message "You don't have the right materials"

				endif
		elseif button == 7                                             ; warhammer
                       set controlvar to 0
                       if material == 1 && ironbars >= 5
					  player.removeitem CRbariron 5
                               player.additem WeapIronbattleaxe 1
                       elseif material == 2 && steelbars >= 5
					  player.removeitem CRbarsteel 5
                               player.additem WeapSteelbattleaxe 1
				elseif material == 3 && silverbars >= 5
					  player.removeitem CRbarsilver 5
                               player.additem WeapSilverbattleaxe 1
				elseif material == 4 && steelbars >= 5 && goldbars >= 2
					  player.removeitem CRbarsteel 5
					  player.removeitem CRbargold 2
                               player.additem WeapElvenbattleaxe 1
				elseif material == 6 && bronzebars >= 5
					  player.removeitem CRbarbronze 5
                               player.additem WeapDwarvenbattleaxe 1
				elseif material == 8 && steelbars >= 4 && goldbars >= 2 && silverbars >= 2
					  player.removeitem CRbarsteel 4
					  player.removeitem CRbargold 2
				 	  player.removeitem CRbarsilver 2
                               player.additem WeapEbonybattleaxe 1
				elseif material == 9 && daedricbars >= 4 && mithrilbars >= 2 && goldbars >= 2 && silverbars >= 2
					  player.removeitem CRbardaedric 4
					  player.removeitem CRbarmithril 2
					  player.removeitem CRbargold 2
					  player.removeitem CRbarsilver 2
                               player.additem WeapDaedricbattleaxe 1
				else
					message "You don't have the right materials"

				endif
		elseif button == 8                                             ; arrowheads
                       set controlvar to 0
                       if material == 1 && ironbars >= 2
					  player.removeitem CRbariron 2
                               player.additem Arrow1iron 25
                       elseif material == 2 && steelbars >= 2
                               player.removeitem CRbarsteel 2
					  player.additem Arrow2steel 25
				elseif material == 3 && silverbars >= 2
					  player.removeitem CRbarsilver 2
                               player.additem Arrow3silver 25
				elseif material == 4 && steelbars >= 1 && goldbars >= 1
					  player.removeitem CRbarsteel 1
					  player.removeitem CRbargold 1
                               player.additem Arrow5Elven 25
				elseif material == 6 && bronzebars >= 2
					  player.removeitem CRbarbronze 2
                               player.additem Arrow4dwarven 25
				elseif material == 7 && steelbars >= 1 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbarsteel 1
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
                               player.additem Arrow7ebony 25
				elseif material == 9 && daedricbars >= 1 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbardaedric 1
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0silvernugget 1
					  player.removeitem gem0goldnugget 1
                               player.additem Arrow8daedric 25
				else
					message "You don't have the right materials"

				endif
               elseif button == 9                                              ; cancel
                       set controlvar to 0
                       set material to 0
                       return
               endif
       elseif controlvar == 20                                 ; armor material
               set button to getbuttonpressed
               if button == 0                                                  ; iron
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 1
               elseif button == 1                                              ; steel
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 2
		elseif button == 2                                             ; Elven
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 4
		elseif button == 3                                              ; mithril
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 5
		elseif button == 4                                              ; dwarven
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 6
		elseif button == 5                                              ; orcish
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 7
		elseif button == 6                                              ; ebony
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 8
		elseif button == 7                                              ; daedric
                       messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
                       set controlvar to 21                            ; armor menu
                       set material to 9
               elseif button == 8                                              ; cancel
                       set controlvar to 0
                       return
               endif
       elseif controlvar == 21                                 ; armor choice
               set button to getbuttonpressed
               if button == 0                                                  ; Helm
                       set controlvar to 0
                       if material == 1 && ironbars >= 3
					  player.removeitem CRbariron 3
                               player.additem Ironhelmet 1
                       elseif material == 2 && steelbars >= 3
					  player.removeitem CRbarsteel 3
                               player.additem Steelhelmet 1
				elseif material == 4 && steelbars >= 2 && goldbars >= 1
					  player.removeitem CRbarsteel 2
					  player.removeitem CRbargold 1
                               player.additem Elvenhelmet 1
				elseif material == 5 && mithrilbars >= 3
					  player.removeitem CRbarmithril 3
                               player.additem Mithrilhelmet 1
				elseif material == 6 && bronzebars >= 3
					  player.removeitem CRbarbronze 3
                               player.additem Dwarvenhelmet 1
				elseif material == 7 && ironbars >= 2 && copperore >= 3
					  player.removeitem CRbariron 2
					  player.removeitem CRorecopper 3
                               player.additem Orcishhelmet 1
				elseif material == 8 && steelbars >= 2 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbarsteel 2
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
				   	  player.removeitem gem0silvernugget 1
                               player.additem Ebonyhelmet 1
				elseif material == 9 && daedricbars >= 2 && mithrilbars >=1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbardaedric 2
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
                               player.additem Daedrichelmet 1
				else
					message "You don't have the right materials"

                       endif
               elseif button == 1                                              ; gauntlets
                       set controlvar to 0
                        if material == 1 && ironbars >= 3
					  player.removeitem CRbariron 3
                               player.additem Ironhelmet 1
                       elseif material == 2 && steelbars >= 3
					  player.removeitem CRbarsteel 3
                               player.additem Steelhelmet 1
				elseif material == 4 && steelbars >= 2 && goldbars >= 1
					  player.removeitem CRbarsteel 2
					  player.removeitem CRbargold 1
                               player.additem Elvenhelmet 1
				elseif material == 5 && mithrilbars >= 3
					  player.removeitem CRbarmithril 3
                               player.additem Mithrilhelmet 1
				elseif material == 6 && bronzebars >= 3
					  player.removeitem CRbarbronze 3
                               player.additem Dwarvenhelmet 1
				elseif material == 7 && ironbars >= 2 && copperore >= 3
					  player.removeitem CRbariron 2
					  player.removeitem CRorecopper 3
                               player.additem Orcishhelmet 1
				elseif material == 8 && steelbars >= 2 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbarsteel 2
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
				   	  player.removeitem gem0silvernugget 1
                               player.additem Ebonyhelmet 1
				elseif material == 9 && daedricbars >= 2 && mithrilbars >=1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbardaedric 2
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
                               player.additem Daedrichelmet 1
				else
					message "You don't have the right materials"

                       endif
		 elseif button == 2                                              ; Cuirass
                       set controlvar to 0
                       if material == 1
                               player.additem Ironcuirass 1
                       elseif material == 2
                               player.additem Steelcuirass 1
				elseif material == 4
                               player.additem Elvencuirass 1
				 elseif material == 5
                               player.additem Mithrilcuirass 1
				 elseif material == 6
                               player.additem Dwarvencuirass 1
				 elseif material == 7
                               player.additem Orcishcuirass 1
				 elseif material == 8
                               player.additem ebonycuirass 1
				 elseif material == 9
                               player.additem daedriccuirass 1
                       endif
		 elseif button == 3                                              ; greaves
                       set controlvar to 0
                       if material == 1 && ironbars >= 4
					  player.removeitem CRbariron 4
                               player.additem Ironhelmet 1
                       elseif material == 2 && steelbars >= 4
					  player.removeitem CRbarsteel 4
                               player.additem Steelhelmet 1
				elseif material == 4 && steelbars >= 3 && goldbars >= 1
					  player.removeitem CRbarsteel 3
					  player.removeitem CRbargold 1
                               player.additem Elvenhelmet 1
				elseif material == 5 && mithrilbars >= 4
					  player.removeitem CRbarmithril 4
                               player.additem Mithrilhelmet 1
				elseif material == 6 && bronzebars >= 4
					  player.removeitem CRbarbronze 4
                               player.additem Dwarvenhelmet 1
				elseif material == 7 && ironbars >= 3 && copperore >= 5
					  player.removeitem CRbariron 3
					  player.removeitem CRorecopper 5
                               player.additem Orcishhelmet 1
				elseif material == 8 && steelbars >= 3 && mithrilbars >= 1 && goldN >= 1 && silverN >= 2
					  player.removeitem CRbarsteel 3
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
				   	  player.removeitem gem0silvernugget 2
                               player.additem Ebonyhelmet 1
				elseif material == 9 && daedricbars >= 3 && mithrilbars >=1 && goldN >= 2 && silverN >= 1
					  player.removeitem CRbardaedric 3
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 2
					  player.removeitem gem0silvernugget 1
                               player.additem Daedrichelmet 1
				else
					message "You don't have the right materials"

                       endif
		 elseif button == 4                                              ; boots
                       set controlvar to 0
                        if material == 1 && ironbars >= 3
					  player.removeitem CRbariron 3
                               player.additem Ironhelmet 1
                       elseif material == 2 && steelbars >= 3
					  player.removeitem CRbarsteel 3
                               player.additem Steelhelmet 1
				elseif material == 4 && steelbars >= 2 && goldbars >= 1
					  player.removeitem CRbarsteel 2
					  player.removeitem CRbargold 1
                               player.additem Elvenhelmet 1
				elseif material == 5 && mithrilbars >= 3
					  player.removeitem CRbarmithril 3
                               player.additem Mithrilhelmet 1
				elseif material == 6 && bronzebars >= 3
					  player.removeitem CRbarbronze 3
                               player.additem Dwarvenhelmet 1
				elseif material == 7 && ironbars >= 2 && copperore >= 3
					  player.removeitem CRbariron 2
					  player.removeitem CRorecopper 3
                               player.additem Orcishhelmet 1
				elseif material == 8 && steelbars >= 2 && mithrilbars >= 1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbarsteel 2
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
				   	  player.removeitem gem0silvernugget 1
                               player.additem Ebonyhelmet 1
				elseif material == 9 && daedricbars >= 2 && mithrilbars >=1 && goldN >= 1 && silverN >= 1
					  player.removeitem CRbardaedric 2
					  player.removeitem CRbarmithril 1
					  player.removeitem gem0goldnugget 1
					  player.removeitem gem0silvernugget 1
                               player.additem Daedrichelmet 1
				else
					message "You don't have the right materials"

                       endif
		elseif button == 5                                              ; shield
                       set controlvar to 0
                       if material == 1
                               player.additem Ironshield 1
                       elseif material == 2
                               player.additem Steelshield 1
				elseif material == 4
                               player.additem Elvenshield 1
				 elseif material == 5
                               player.additem Mithrilshield 1
				 elseif material == 6
                               player.additem Dwarvenshield 1
				 elseif material == 7
                               player.additem Orcishshield 1
				 elseif material == 8
                               player.additem ebonyshield 1
				 elseif material == 9
                               player.additem daedricshield 1
                       endif
               elseif button == 6                                              ; cancel
                       set controlvar to 0
                       set material to 0
                       return
               endif
       endif
end

Link to comment
Share on other sites

Just in the interests of shortening the code generally - suggestion - this chunk:

 

if button == 0 ; iron

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 1

elseif button == 1 ; steel

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 2

elseif button == 2 ; Elven

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 4

elseif button == 3 ; mithril

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 5

elseif button == 4 ; dwarven

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 6

elseif button == 5 ; orcish

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 7

elseif button == 6 ; ebony

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 8

elseif button == 7 ; daedric

messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"

set controlvar to 21 ; armor menu

set material to 9

elseif button == 8 ; cancel

set controlvar to 0

return

endif

 

 

Rework it to use the same messagebox statement, and the same set controlvar statement rather than repeating it 8 times. The only bit that differs is the material.

 

And if you rework the material numbers to shift all the materials up by 1, and move silver to the end number, you could just use "set material to (button+1)" - shame there's no silver armour. Or re-jig the equivalent weapon crafting section in the suggested way and you don't have to play with materials at all.

Edited by MarkInMKUK
Link to comment
Share on other sites

Yeah, that whole block that MarkInMKUK just listed, could be shortened to:

 

if button < 8
 messagebox "What armor would you like to make?" "Helm" "Gauntlets" "Cuirass" "Greaves" "Boots" "Shield" "Cancel"
 set controlvar to 21 ; armor menu
 set material to Button + 1 + ( Button > 1 )
else
 set controlvar to 0
 return
endif

Concise coding helps keep a script under control, and makes it easier to rectify or change if neccessary. What this script really needs is a few bucket-fulls of arrays!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...