Jump to content

Scripting Help


Joolander

Recommended Posts

I am trying to get an object to run a script where the player chooses a category in a message box, and then, depending on the category chosen, a second message box with more specific choices appears

 

i can only get the first message box to show up in game

 

heres the code so far

 

scn V99ArmorDisplayScript

;armorstand to display and repair Power Armor
; 1. Which armors does the player have? Display as buttons.
; 2. If has armors needed to, do it; otherwise display "error" message


short HasPieces
short ArmorCategory
short Choice

Begin OnActivate
if IsActionRef player == 1
	; display message box of possible weapons
	set HasPieces to 0

	if ( player.GetItemCount ArmorPower > 0 )  
                   || ( player.GetItemCount ArmorPowerBrotherhoodOfSteel > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorPowerHelmet > 0 )  
                   || ( player.GetItemCount ArmorPowerLyons > 0 )  
                   || ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorPowerOutcast > 0 )  
                   || ( player.GetItemCount ArmorPowerHelmetOutcast > 0 )  
                   || ( player.GetItemCount MS10LindensOutcastPowerArmor> 0 )  
                   || ( player.GetItemCount MS14PowerArmorMorphine> 0 ) 
                   || ( player.GetItemCount FollowersOutfitCross> 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorPowerT51b > 0 )  
                   || ( player.GetItemCount ArmorPowerT51bHelmet > 0 )  
                   || ( player.GetItemCount DLC02ArmorPowerT51bWasteland > 0 )  
                   || ( player.GetItemCount DLC02ArmorPowerT51bHelmetWasteland > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorEnclave > 0 )  
                   || ( player.GetItemCount ArmorEnclaveHelmet > 0 )  
                   || ( player.GetItemCount ArmorUniqueEnclave > 0 )  
                   || ( player.GetItemCount ArmorUniqueEnclaveHelmet > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorTeslaPower > 0 ) 
                   || ( player.GetItemCount ArmorTeslaHelmet > 0 )  
                   || ( player.GetItemCount ArmorUniqueTeslaPower > 0 )
                   || ( player.GetItemCount ArmorUniqueTeslaHelmet > 0 )
		set HasPieces to 1
	endif

	if HasPieces == 1
		ShowMessage V99ArmorStandMsg
		set ArmorCategory to GetButtonPressed
			if ( ArmorCategory == 1 )
				ShowMessage V99ArmorStandMsg1
				set Choice to GetButtonPressed
			elseif ( ArmorCategory == 2 )
			ShowMessage V99ArmorStandMsg2
			set Choice to GetButtonPressed
			elseif ( ArmorCategory == 0 )
			endif
	else
		ShowMessage V99ArmorStandNoneMsg
	endif
endif

End

Begin GameMode

	if ( ArmorCategory  == 1 ) && ( Choice == 1 )
		; T-45d Power Armor
		; 1. check for components
		if ( player.GetItemCount ArmorPowerHelmet > 0 ) 
                          && ( player.GetItemCount ArmorPower > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmet 1
				player.RemoveItem ArmorPower 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureT45Msg
			ShowMessage V99ArmorStandMsg1
		endif	

	elseif ( ArmorCategory  == 1 ) && ( Choice == 2 )
		; T-45d Power Armor (BoS)
		; 1. check for components
		if ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 )
                          && ( player.GetItemCount ArmorPowerBrotherhoodOfSteel > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmetBrotherhoodOfSteel 1
				player.RemoveItem ArmorPowerBrotherhoodOfSteel 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureBOSMsg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 1 ) && ( Choice == 3 )
		; T-45d Power Armor (Lyon's Pride)
		; 1. check for components
		if ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 )
                       && ( player.GetItemCount ArmorPowerLyons > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmetBrotherhoodOfSteel 1
				player.RemoveItem ArmorPowerLyons 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureLyonsMsg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 1 ) && ( Choice == 4 )
		; T-45d Power Armor (Outcast)
		; 1. check for components
		if ( player.GetItemCount ArmorPowerHelmetOutcast > 0 )
                       && ( player.GetItemCount ArmorPowerOutcast > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmetOutcast 1
				player.RemoveItem ArmorPowerOutcast 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureOutcastMsg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 1 ) && ( Choice == 5 )
		; Linden's T-45d Power Armor (Outcast)
		; 1. check for components
		if ( player.GetItemCount ArmorPowerHelmetOutcast > 0 )
                          && ( player.GetItemCount MS10LindensOutcastPowerArmor > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmetOutcast 1
				player.RemoveItem MS10LindensOutcastPowerArmor 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureLindenMsg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 1 ) && ( Choice == 7 )
		; T-47a Prototype Medic Power Armor
		; 1. check for components
		if ( player.GetItemCount ArmorPowerHelmet > 0 ) 
                          && ( player.GetItemCount MS14PowerArmorMorphine > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmet 1
				player.RemoveItem MS14PowerArmorMorphine 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureMorphineMsg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 1 ) && ( Choice == 8 )
		; T-51b Power Armor
		; 1. check for components
		if ( player.GetItemCount ArmorPowerT51bHelmet > 0 ) 
                          && ( player.GetItemCount ArmorPowerT51b > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerT51bHelmet 1
				player.RemoveItem ArmorPowerT51b 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureT51Msg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 1 ) && ( Choice == 9 )
		; Winterized T-51b Power Armor
		; 1. check for components
		if ( player.GetItemCount DLC02ArmorPowerT51bHelmetWasteland > 0 ) 
                          && ( player.GetItemCount DLC02ArmorPowerT51bWasteland > 0 )
			; 2. place them
				player.RemoveItem DLC02ArmorPowerT51bHelmetWasteland 1
				player.RemoveItem DLC02ArmorPowerT51bWasteland 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureAnchMsg
			ShowMessage V99ArmorStandMsg1
		endif		

	elseif ( ArmorCategory  == 2 ) && ( Choice == 1 )
		; Adv. Power Armor MKII
		; 1. check for components
		if ( player.GetItemCount ArmorEnclave > 0 ) 
                         && ( player.GetItemCount ArmorEnclaveHelmet > 0 )
			; 2. place them
				player.RemoveItem ArmorEnclave 1
				player.RemoveItem ArmorEnclaveHelmet 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureEnclaveMsg
			ShowMessage V99ArmorStandMsg2
		endif

	elseif ( ArmorCategory  == 2 ) && ( Choice == 2 )
		; Tesla Adv. Power Armor MKII
		; 1. check for components
		if ( player.GetItemCount ArmorTeslaPower > 0 ) 
                          && ( player.GetItemCount ArmorTeslaHelmet > 0 )
			; 2. place them
				player.RemoveItem ArmorTeslaPower 1
				player.RemoveItem ArmorTeslaHelmet 1
				Disable

		else 
			ShowMessage V99ArmorStandFailureTeslaMsg
			ShowMessage V99ArmorStandMsg2
		endif

	elseif Choice == 0
	endif
endif
endif	

End

 

 

Any help would be greatly appreciated

Link to comment
Share on other sites

Please edit your script - one or more lines is too long and it is causing visual bugs on the page making it difficult for others to post. I didn't look through the whole script, but I did quickly run it through my Script Validator and found that you have two extra "endif" statements (on lines 198 and 199). This probably isn't the direct cause of the problem, but having incorrect structure in your conditional statements definitely won't help.

 

I've written a couple of tutorials on making multi-level menus, the most recent of which can be found on my website - Making a Menu. I recommend that you have a read of it, as it details how to do exactly what you're trying to do.

 

Cipscis

Link to comment
Share on other sites

ok, more questions, but its working better than before

 

i modified my script to look like this

 

scn V99ArmorDisplayScript

;armorstand to display and repair Power Armor
; 1. Which armors does the player have? Display as buttons.
; 2. If has armors needed to, do it; otherwise display "error" message


short HasPieces
int ArmorMenuLevel
int ArmorCategory
int Choice

Begin OnActivate
if IsActionRef player == 1
; display message box of possible weapons
	set HasPieces to 0

	if ( player.GetItemCount ArmorPower > 0 )  || 
			   ( player.GetItemCount ArmorPowerBrotherhoodOfSteel > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorPowerHelmet > 0 )  || 
			   ( player.GetItemCount ArmorPowerLyons > 0 )  || 
			   ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorPowerOutcast > 0 )  || 
			   ( player.GetItemCount ArmorPowerHelmetOutcast > 0 )  || 
			   ( player.GetItemCount MS10LindensOutcastPowerArmor> 0 )  || 
			   ( player.GetItemCount MS14PowerArmorMorphine> 0 )  || 
			   ( player.GetItemCount FollowersOutfitCross> 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorPowerT51b > 0 )  || 
			   ( player.GetItemCount ArmorPowerT51bHelmet > 0 )  || 
			   ( player.GetItemCount DLC02ArmorPowerT51bWasteland > 0 )  || 
			   ( player.GetItemCount DLC02ArmorPowerT51bHelmetWasteland > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorEnclave > 0 )  || 
			   ( player.GetItemCount ArmorEnclaveHelmet > 0 )  || 
			   ( player.GetItemCount ArmorUniqueEnclave > 0 )  || 
			   ( player.GetItemCount ArmorUniqueEnclaveHelmet > 0 )
		set HasPieces to 1
	endif
	if ( player.GetItemCount ArmorTeslaPower > 0 )  || 
			   ( player.GetItemCount ArmorTeslaHelmet > 0 )  || 
			   ( player.GetItemCount ArmorUniqueTeslaPower > 0 )  || 
			   ( player.GetItemCount ArmorUniqueTeslaHelmet > 0 )
		set HasPieces to 1
	endif

	if HasPieces == 1
		ShowMessage V99ArmorStandMsg
	else
		ShowMessage V99ArmorStandNoneMsg
	endif
endif

End

Begin GameMode

if ArmorMenuLevel == 0; Level 0

	set ArmorCategory to GetButtonPressed
	if ArmorCategory == -1; No button has been pressed yet
		Return
	
	elseif ArmorCategory == 0; t-4x and t-5x
		ShowMessage V99ArmorStandMsg1
		set ArmorMenuLevel to 1
	elseif ArmorCategory == 1; Enclave
		ShowMessage V99ArmorStandMsg2
		set ArmorMenuLevel to 1
	elseif ArmorCategory == 2; None
	endif
	

elseif ArmorMenuLevel == 1; Level 1

	set Choice to GetButtonPressed
	if Choice == -1; No button has been pressed yet
		Return
	endif

	elseif ArmorCategory == 0; t-4x and t-5x

		if Choice == 0; T-45d Power Armor
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmet > 0 ) && 
							   ( player.GetItemCount ArmorPower > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmet 1
				player.RemoveItem ArmorPower 1
				Disable

			else 
				ShowMessage V99ArmorStandFailureT45Msg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif
		
		elseif Choice == 1; T-45d Power Armor (BoS)
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 ) && 
							   ( player.GetItemCount ArmorPowerBrotherhoodOfSteel > 0 )
			; 2. place them
				player.RemoveItem ArmorPowerHelmetBrotherhoodOfSteel 1
				player.RemoveItem ArmorPowerBrotherhoodOfSteel 1
				Disable

			else 
				ShowMessage V99ArmorStandFailureBOSMsg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif
		
		elseif Choice == 2; T-45d Power Armor (Lyon's Pride)
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 ) && 
							   ( player.GetItemCount ArmorPowerLyons > 0 )
			; 2. place them
					player.RemoveItem ArmorPowerHelmetBrotherhoodOfSteel 1
					player.RemoveItem ArmorPowerLyons 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureLyonsMsg
				ShowMessage V99ArmorStandMsg1
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif

		elseif Choice == 3; Star Paladin Cross' T-45d Power Armor
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmetBrotherhoodOfSteel > 0 ) && 
							   ( player.GetItemCount FollowersOutfitCross > 0 )
			; 2. place them
					player.RemoveItem ArmorPowerHelmetBrotherhoodOfSteel 1
					player.RemoveItem FollowersOutfitCross 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureCrossMsg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif	

		elseif Choice == 4; T-45d Power Armor (Outcast)
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmetOutcast > 0 ) && 
							   ( player.GetItemCount ArmorPowerOutcast > 0 )
			; 2. place them
					player.RemoveItem ArmorPowerHelmetOutcast 1
					player.RemoveItem ArmorPowerOutcast 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureOutcastMsg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif	

		elseif Choice == 5; Linden's T-45d Power Armor (Outcast)
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmetOutcast > 0 ) && 
							   ( player.GetItemCount MS10LindensOutcastPowerArmor > 0 )
			; 2. place them
					player.RemoveItem ArmorPowerHelmetOutcast 1
					player.RemoveItem MS10LindensOutcastPowerArmor 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureLindenMsg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif

		elseif Choice == 6; T-47a Prototype Medic Power Armor
		; 1. check for components
			if ( player.GetItemCount ArmorPowerHelmet > 0 ) && 
							   ( player.GetItemCount MS14PowerArmorMorphine > 0 )
			; 2. place them
					player.RemoveItem ArmorPowerHelmet 1
					player.RemoveItem MS14PowerArmorMorphine 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureMorphineMsg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif

		elseif Choice == 7; T-51b Power Armor
		; 1. check for components
			if ( player.GetItemCount ArmorPowerT51bHelmet > 0 )&& 
							   ( player.GetItemCount ArmorPowerT51b > 0 )
			; 2. place them
					player.RemoveItem ArmorPowerT51bHelmet 1
					player.RemoveItem ArmorPowerT51b 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureT51Msg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif

		elseif Choice == 8; Winterized T-51b Power Armor
		; 1. check for components
			if ( player.GetItemCount DLC02ArmorPowerT51bHelmetWasteland > 0 ) && 
							   ( player.GetItemCount DLC02ArmorPowerT51bWasteland > 0 )
			; 2. place them
					player.RemoveItem DLC02ArmorPowerT51bHelmetWasteland 1
					player.RemoveItem DLC02ArmorPowerT51bWasteland 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureAnchMsg
				ShowMessage V99ArmorStandMsg1
				set ArmorMenuLevel to 1
				Return
			endif	

		elseif Choice == 9; Back
			ShowMessage V99ArmorStandMsg
			set ArmorMenuLevel to 0
			Return
		endif
		RemoveMe

	elseif ArmorCategory == 1; Enclave

		if Choice == 0; Adv. Power Armor MKII
		; 1. check for components
			if ( player.GetItemCount ArmorEnclave > 0 ) && 
							   ( player.GetItemCount ArmorEnclaveHelmet > 0 )
			; 2. place them
					player.RemoveItem ArmorEnclave 1
					player.RemoveItem ArmorEnclaveHelmet 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureEnclaveMsg
				ShowMessage V99ArmorStandMsg2
				set ArmorMenuLevel to 1
				Return
			endif

		elseif Choice == 1; Tesla Adv. Power Armor MKII
		; 1. check for components
			if ( player.GetItemCount ArmorTeslaPower > 0 ) && 
							   ( player.GetItemCount ArmorTeslaHelmet > 0 )
			; 2. place them
					player.RemoveItem ArmorTeslaPower 1
					player.RemoveItem ArmorTeslaHelmet 1
					Disable

			else 
				ShowMessage V99ArmorStandFailureTeslaMsg
				ShowMessage V99ArmorStandMsg2
				set ArmorMenuLevel to 1
				Return
			endif
		
		elseif Choice == 2; Back
			ShowMessage V99ArmorStandMsg
			set ArmorMenuLevel to 0
			Return
		endif
		RemoveMe

	endif

endif

End

 

 

and now, the first time it activates, it will go forward through the menus just fine. if i decide to go back it will exit the menus

if i try to activate it again, i get the first menu, but when i choose a category it just exits the menu

 

also, on the first time, when i do make a choice of armor, it exits the menu and does not remove any of the players items

 

 

im sorry for all the questions, this is my first script that is supposed to do more than turn on a light or open a door

Link to comment
Share on other sites

I just ran that script through my Script Validator again, and there's an extra "endif" statement on line 284. I think, in fact, that instead of an extra "endif" statement you're missing the beginning of a block of conditional statements in your script, because at the moment most of your code will only run when your "ArmorMenuLevel" variable is equal to neither 0 nor 1. Considering that this situation will never occur, most of the code in your script will never run.

 

I'm going to assume that, in your script, your conditions are all on a single line and that you've separated them here to avoid the visual bug caused by long lines of code within "codebox" tags.

 

You can also simplify your conditions quite a lot by removing all of the operators that you've used that don't actually do anything. For example, both lines in both of the following two examples do the exact same thing, but the first line in each example is more efficient:

IsActionRef player
IsActionRef player == 1

player.GetItemCount ArmorPower
player.GetItemCount ArmorPower > 0

Instead of checking "IsActionRef" in your OnActivate block, you might want to just pass "player" as a parameter to OnActivate:

Begin OnActivate player

Considering that the conditions in your OnActivate block are effectively alternates of one another (i.e. only one should run in a single iteration) you should use "elseif" statements instead of placing each in their own block of conditional statements. The easiest way to do this check, however, would be to create a form list containing all relevant items and passing it as a parameter of GetItemCount:

if player.GetItemCount <PowerArmorList>

Simplifying the check in this way will also allow you to get rid of your "HasPieces" variable:

Begin OnActivate player
; display message box of possible weapons
if player.GetItemCount <PowerArmorList>
	ShowMessage V99ArmorStandMsg
else
	ShowMessage V99ArmorStandNoneMsg
endif
End

 

You'll also want to have another look at your "common results" and back buttons if you want the player to be able to go back through the menu properly. Have a look at the "Large Multi-Level Menu" example in Making a Menu to see how you could set these up so that the player can only exit the menu from the first level. Considering that (as far as I can tell) you don't want to remove the scripted item from the player's inventory, you shouldn't be calling RemoveMe anywhere in your script.

 

Cipscis

Link to comment
Share on other sites

Considering that the conditions in your OnActivate block are effectively alternates of one another (i.e. only one should run in a single iteration) you should use "elseif" statements instead of placing each in their own block of conditional statements. The easiest way to do this check, however, would be to create a form list containing all relevant items and passing it as a parameter of GetItemCount

 

 

The only real reason i still had that part in there was i had basically copied the Bethesda script for the workbench.

 

and yes i realize that was my first mistake :thumbsup:

 

 

as for the code only running when ArmorMenuLevel is 0 or 1, i think thats right because i only have 2 menu levels (the level that chooses a category, and the level that chooses the armor). or do i need another level? the V99ArmorStandMsg1 and V99ArmorStandMsg2 are alternates for the category chosen

 

 

the item that is going to be getting this script a container in the shape of the armor stand from operation anchorage.

 

what i want the script to do is have the play chose what armor hes going to put on the stand, remove that armor set from the players inventory, disable the container from rendering, and enable the model of the armor hanging up and a static model of the stand.

 

the model of the armor on the stand would then be an activator with a script that (when activated by the player) would disable the armor activator reference, the static stand reference, re enable the the stand container reference, and give repaired armor back to the player. also, in the cell i am building there will be eight of these

 

 

 

thats the plan so far

Link to comment
Share on other sites

  • Recently Browsing   0 members

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