Jump to content

Broken Script


Avelon

Recommended Posts

If this belongs in the general modding forum, I'm quite sorry - I didn't see anyone posting personal modding problems in either forum.

 

At any rate, if it is, a mod will move it and I'll know better next time, so...

 

I hate the way high-end quivers look - mainly because I don't wear high-end armour, usually. I tend to get unique armours and stick with them instead. So, I decided I'd just make my own. I made an equivalent to all 8 vanilla arrow types, using the 'Shadow Mail' quiver, and set about writing a script that would let me cannibalise vanilla arrows to make these 'shadow arrows'. But the script doesn't work.

 

I surmise that the problem is with 'set pcchoice to GetButtonPressed' - it falls through to the last case when I activate the script - it initially is set to -1 and then it seems it doesn't get set again. Could I get some help, please?

 

Here is the script in full, for you experts:

 

ScriptName AvesArrowConversion
short pcchoice
short type
short phase

Begin OnEquip
set pcchoice to -1

	MessageBox "What kind of arrow do you want to convert to shadow arrows?", "Iron", "Steel", "Silver", "Dwarven", "Elven", "Glass", "Ebony", "Daedric", "Never mind"
set pcchoice to GetButtonPressed
set phase to 1
end

Begin MenuMode
	if pcchoice >= -1
		if phase == 1
			if pcchoice == 0;making Iron
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 1
					set phase to 2
				endif
			elseif pcchoice == 1;making steel
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 2
					set phase to 2
				endif
			elseif pcchoice == 2;making silver
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 3
					set phase to 2
				endif
			elseif pcchoice == 3;making dwemer
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 4
					set phase to 2
				endif
			elseif pcchoice == 4;making elven
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 5
					set phase to 2
				endif
			elseif pcchoice == 5;making glass
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 6
					set phase to 2
				endif
			elseif pcchoice == 6;making ebony
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 7
					set phase to 2
				endif
			elseif pcchoice == 7;making daedric
				MessageBox "How many arrows do you want to make?" "5", "10", "20", "50", "100", "Never mind"
					set pcchoice to GetButtonPressed
					set type to 8
					set phase to 2
				endif
			elseif pcchoice == 8;quitting
					set phase to 0
				endif
			elseif pcchoice == -1
					Message "PCChoice isn't being set properly."
				endif
		elseif phase == 2;make them
			if type == 1
				if pcchoice == 0
					if player.GetItemCount Arrow1Iron >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow1Iron 10
						player.additem 1AveShadowArrow01 5
					else
						Messagebox "You must have 10 iron arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow1Iron >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow1Iron 20
						player.additem 1AveShadowArrow01 10
					else
						Messagebox "You must have 20 iron arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow1Iron >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow1Iron 40
						player.additem 1AveShadowArrow01 20
					else
						Messagebox "You must have 40 iron arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow1Iron >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow1Iron 100
						player.additem 1AveShadowArrow01 50
					else
						Messagebox "You must have 100 iron arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow1Iron >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow1Iron 200
						player.additem 1AveShadowArrow01 100
					else
						Messagebox "You must have 200 iron arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 2
				if pcchoice == 0
					if player.GetItemCount Arrow2Steel >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow2Steel 10
						player.additem 1AveShadowArrow02 5
					else
						Messagebox "You must have 10 steel arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow2Steel >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow2Steel 20
						player.additem 1AveShadowArrow02 10
					else
						Messagebox "You must have 20 steel arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow2Steel >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow2Steel 40
						player.additem 1AveShadowArrow02 20
					else
						Messagebox "You must have 40 steel arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow2Steel >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow2Steel 100
						player.additem 1AveShadowArrow02 50
					else
						Messagebox "You must have 100 steel arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow2Steel >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow2Steel 200
						player.additem 1AveShadowArrow02 100
					else
						Messagebox "You must have 200 steel arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 3
				if pcchoice == 0
					if player.GetItemCount Arrow3Silver >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow3Silver 10
						player.additem 1AveShadowArrow03 5
					else
						Messagebox "You must have 10 silver arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow3Silver >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow3Silver 20
						player.additem 1AveShadowArrow03 10
					else
						Messagebox "You must have 20 silver arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow3Silver >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow3Silver 40
						player.additem 1AveShadowArrow03 20
					else
						Messagebox "You must have 40 silver arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow3Silver >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow3Silver 100
						player.additem 1AveShadowArrow03 50
					else
						Messagebox "You must have 100 silver arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow3Silver >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow3Silver 200
						player.additem 1AveShadowArrow03 100
					else
						Messagebox "You must have 200 silver arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 4
				if pcchoice == 0
					if player.GetItemCount Arrow4Dwarven >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow4Dwarven 10
						player.additem 1AveShadowArrow04 5
					else
						Messagebox "You must have 10 dwarven arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow4Dwarven >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow4Dwarven 20
						player.additem 1AveShadowArrow04 10
					else
						Messagebox "You must have 20 dwarven arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow4Dwarven >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow4Dwarven 40
						player.additem 1AveShadowArrow04 20
					else
						Messagebox "You must have 40 dwarven arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow4Dwarven >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow4Dwarven 100
						player.additem 1AveShadowArrow04 50
					else
						Messagebox "You must have 100 dwarven arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow4Dwarven >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow4Dwarven 200
						player.additem 1AveShadowArrow04 100
					else
						Messagebox "You must have 200 dwarven arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 5
				if pcchoice == 0
					if player.GetItemCount Arrow5Elven >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow5Elven 10
						player.additem 1AveShadowArrow05 5
					else
						Messagebox "You must have 10 elven arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow5Elven >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow5Elven 20
						player.additem 1AveShadowArrow05 10
					else
						Messagebox "You must have 20 elven arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow5Elven >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow5Elven 40
						player.additem 1AveShadowArrow05 20
					else
						Messagebox "You must have 40 elven arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow5Elven >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow5Elven 100
						player.additem 1AveShadowArrow05 50
					else
						Messagebox "You must have 100 elven arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow5Elven >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow5Elven 200
						player.additem 1AveShadowArrow05 100
					else
						Messagebox "You must have 200 elven arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 6
				if pcchoice == 0
					if player.GetItemCount Arrow6Glass >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow6Glass 10
						player.additem 1AveShadowArrow06 5
					else
						Messagebox "You must have 10 glass arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow6Glass >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow6Glass 20
						player.additem 1AveShadowArrow06 10
					else
						Messagebox "You must have 20 glass arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow6Glass >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow6Glass 40
						player.additem 1AveShadowArrow06 20
					else
						Messagebox "You must have 40 glass arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow6Glass >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow6Glass 100
						player.additem 1AveShadowArrow06 50
					else
						Messagebox "You must have 100 glass arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow6Glass >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow6Glass 200
						player.additem 1AveShadowArrow06 100
					else
						Messagebox "You must have 200 glass arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 7
				if pcchoice == 0
					if player.GetItemCount Arrow7Ebony >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow7Ebony 10
						player.additem 1AveShadowArrow07 5
					else
						Messagebox "You must have 10 ebony arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow7Ebony >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow7Ebony 20
						player.additem 1AveShadowArrow07 10
					else
						Messagebox "You must have 20 ebony arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow7Ebony >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow7Ebony 40
						player.additem 1AveShadowArrow07 20
					else
						Messagebox "You must have 40 ebony arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow7Ebony >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow7Ebony 100
						player.additem 1AveShadowArrow07 50
					else
						Messagebox "You must have 100 ebony arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow7Ebony >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow7Ebony 200
						player.additem 1AveShadowArrow07 100
					else
						Messagebox "You must have 200 ebony arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			elseif type == 8
				if pcchoice == 0
					if player.GetItemCount Arrow8Daedric >= 10
						Message "You have fletched 5 shadow arrows."
						player.removeitem Arrow8Daedric 10
						player.additem 1AveShadowArrow08 5
					else
						Messagebox "You must have 10 daedric arrows to cannibalise."
					endif
				elseif pcchoice == 1
					if player.GetItemCount Arrow8Daedric >= 20
						Message "You have fletched 10 shadow arrows."
						player.removeitem Arrow8Daedric 20
						player.additem 1AveShadowArrow08 10
					else
						Messagebox "You must have 20 daedric arrows to cannibalise."
					endif
				elseif pcchoice == 2
					if player.GetItemCount Arrow8Daedric >= 40
						Message "You have fletched 20 shadow arrows."
						player.removeitem Arrow8Daedric 40
						player.additem 1AveShadowArrow08 20
					else
						Messagebox "You must have 40 daedric arrows to cannibalise."
					endif
				elseif pcchoice == 3
					if player.GetItemCount Arrow8Daedric >= 100
						Message "You have fletched 50 shadow arrows."
						player.removeitem Arrow8Daedric 100
						player.additem 1AveShadowArrow08 50
					else
						Messagebox "You must have 100 daedric arrows to cannibalise."
					endif
				elseif pcchoice == 4
					if player.GetItemCount Arrow8Daedric >= 200
						Message "You have fletched 100 shadow arrows."
						player.removeitem Arrow8Daedric 200
						player.additem 1AveShadowArrow08 100
					else
						Messagebox "You must have 200 daedric arrows to cannibalise."
					endif
				elseif pcchoice == 5
					set phase to 0
				endif
			endif
		endif
	endif
end

Link to comment
Share on other sites

Instead of using -1, try using 0 instead and increasing the values for the arrow types to match. And then you don't need to set it to anything initially, but could rather reset it after arrows have been made, or if no choice was made.

 

If it's not that, try setting the "getbuttonpressed" within the menumode block. IIRC, most the elements with choices in message boxes need to run within a blocktype that runs the frame after the message box. But this may cause other issues since having the message box up would also cause menumode blocks to run. You might want to limit the menumode block to only function when in your inventory.

 

I've never had much luck with message boxes with choices myself, so this may not help at all.

Link to comment
Share on other sites

Instead of using -1, try using 0 instead and increasing the values for the arrow types to match. And then you don't need to set it to anything initially, but could rather reset it after arrows have been made, or if no choice was made.

Well, the default value of a variable *is* 0. A few incarnations ago, the script would automatically convert 10 iron arrows to 5 shadow arrows before ever giving the first menu, so I put that line there. I don't think it would do that anymore, so I'll try removing it and seeing what happens. Thanks for pointing it out!

 

If it's not that, try setting the "getbuttonpressed" within the menumode block.

Okay, I did so. I also removed the initial setting of the variable, and now the quantity entry message box pops up (it didn't before). But only selecting 5 does anything - the rest brings me back to the menu. And when I select 5, it tells me I need 10 dwarven arrows.

 

Really odd.

 

IIRC, most the elements with choices in message boxes need to run within a blocktype that runs the frame after the message box. But this may cause other issues since having the message box up would also cause menumode blocks to run. You might want to limit the menumode block to only function when in your inventory.

Not sure I understand this part. Are you saying that I need to end each block with each messagebox and open a new one to GetButtonPressed?

 

Thanks for the help. =)

Link to comment
Share on other sites

Basically, getbuttonpressed needs to run the frame after the message box happened. In this case, you would need to move it to a point after the phase has been set, and use a return statement at the end of the previous phase.

Basically:

		if pcchoice >= -1
		if phase == 1
			 if pcchoice == 0
			 <stuff>
			 elseif pcchoice ==2
			 <stuff>
			 endif
		return
		elseif phase == 2
		set pcchoice to getbuttonpressed
			  if type == 1
				 <Lots of stuff
			  endif
		return
		endif
	endif

 

 

You really might want to try working with a much smaller script, that only involves one arrow type. Then you're looking at alot fewer entries to change, and less chance that something goofy will happen. You might also want to use "> -1" rather than ">= -1" in "if pcchoice >= -1" so that the remaining script will only run after an initial choice was made.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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