Jump to content

Noob scripting help please


delgathar

Recommended Posts

Posted

I've been trying to make a basic script which will be a fundamental part of all further scripts, and of course I can't even get this right.

 

This part of the script is just supposed to get a list of what is worn by the player, and display it.

 

That's it. 

 

 

My problems:

1. Whenever I change AddHeaderOption to AddTextOption I get errors.  But I don't see a need for everything to be a header.

2. It doesn't work.  I'm always showing None in all slots.

3. I"m afraid that when use GetWornForm and set as Armor that I might be losing information for non-armor items, such as jewlery or clothes.  Maybe that is why I keep getting None.

 

I want this information because I'm trying to create certain perks that only work when wearing cloth or jewlery, and carrying less than x weight.

 

This is more an attempt to learn than a request for someone else to do my work for me.  I've obviously already read the wikis and such, but if anyone could identify for me why I'm making my error and give pointers as to what details I'm overlooking, I would be grateful.

I'm  using dienes' Copy Armor mod as a source.  It has a page that displays worn armor so I thought that part would be useful.  But apparently copying and editing to fit isn't working.

Posted

Looking at your code you are trying to implement a MCM menu.

 

Follow the chapter for MCM pages in my Papyrus guide.

 

If you still have errors then post here your problems, and you will get help.

Try to be as mush as possible descriptive with your errors, and add code snippets, relevant lines of the papyrus.log, and compiling errors.

 

Posted
My problems:

1. Whenever I change AddHeaderOption to AddTextOption I get errors.  But I don't see a need for everything to be a header.

2. It doesn't work.  I'm always showing None in all slots.

3. I"m afraid that when use GetWornForm and set as Armor that I might be losing information for non-armor items, such as jewlery or clothes.  Maybe that is why I keep getting None.

 

1. AddTextOption and AddHeaderOption are two different things. The header is just dumb text whereas the text option is interactive. The reason you get errors is likely because the required arguments are different. Unfortunately there is no real "block text" option for the MCM so it either needs to be built from headers or relegated to the highlight text.

 

2. I recall having similar trouble with armor slots in the past. In the end I decided to avoid the slot functions altogether and just cut to the chase:

int amuletSlot = 0x00000020
Form playerAmuletForm = playerRef.GetWornForm(amuletSlot) as Armor

3. As far as the game is concerned every worn item is armor, the only differences are the values set on the forms.

Posted

Ok, this is getting annoying. This was supposed to be the EASY part, especially with an established mod to use as a reference. Been working on this for over 12 hours.  Thank you for the help so far, been reading CPU's guide and tried incorporating Sailing Rebel's suggestion too.

 

I changed a little bit of code.  Full code here.

Pertinent code in spoiler.

 

 

types = New String[4]
    types[0] = "Head"
    types[1] = "Body"
    types[2] = "Hands"
    types[3] = "Feet"
    headSlot     = 0x00001000
    bodySlot     = 0x00000004
    handsSlot    = 0x00000008
    feetSlot     = 0x00000080

;~~~~~~snip
	;on page reset
 		currentArmor[0] = playerRef.GetWornForm(headSlot) As Armor
		currentArmor[1] = playerRef.GetWornForm(bodySlot) As Armor
		currentArmor[2] = playerRef.GetWornForm(handsSlot) As Armor
		currentArmor[3] = playerRef.GetWornForm(feetSlot) As Armor
		
		Int i = 0
		While i < 4
			AddHeaderOption("Current worn " + types[i] )
			If (currentArmor[i] != None )
				AddHeaderOption( (currentArmor[i]).GetName() )
			Else
				AddHeaderOption("None")
			EndIf
			i = i + 1
		EndWhile
	; ...

 

 

But I still get None as result for all armors.  I would like to drop the array check, but it seems necessary for the error check, especially since I seem to only get errors.

Also, even though I have defined types[0] and types[1] in mixed case.  In MCM they are ALL CAPS.  But the other types are mixed case.

There are no error codes when I compile, and this version seems to have eliminated some mysterious recursive error that seemed to put multiple headers on the same line.

 

I've also tried creating an OnConfigOpen() event and sticking the currentArmor assignments

"currentArmor[0] = playerRef.GetWornForm(headSlot) As Armor"

there, but no different results

Posted

Are you sure the playerRef property is set correctly (ID 0x00000014) in CK?

 

What I usually so in these situations is cut the code back to the very basics. Lose the arrays and loops and MCM options and try to get some information from a single slot and report it in the log.

Posted

I double checked.

 

Alias Name = PlayerAlias

Specific Reference = Ref:"PlayerRef" (0000014) to NPC_'Player' (00000007)

Scripts SKI_PlayerLoadGameAlias

 

These are the only options I changed. Everything else is uncheck or NONE.

I went ahead and made a "Back to basics" change to test.

 

         currentArmor[0] = Game.GetPlayer().GetWornForm(headSlot) As Armor

Works. 

 

         currentArmor[0] = PlayerRef.GetWornForm(headSlot) As Armor

Does NOT work.  Only returns NONE

 

I've no idea why PlayerRef doesn't work.  I just know the guides said not to use Game.Getplayer() :/

 

 

 

Posted

Holy Crap!

 

This is why I always prefer unofficial guides to the official.  Because the official guides always leave out the important in-between things.  Chilton's guide: How do I get from picture 3 to picture 4?

I had added PlayerRef to my Quest Aliases as the official Quickstart guide said http://i.imgur.com/2LHw0.png

 

Well apparently Adding the PlayerRef as above created a blank property for my quest script named PlayerRef.  cell: "NONE" Ref: blank.  Which I never checked because the guide said "That is all you need."

 

Thank you Sailing Rebel for asking about the PlayerRef property, it got me looking in the right place. 

 

 

 

Archived

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

  • Recently Browsing   0 members

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