Jump to content

[LE] Cannot get object reference to work (new to modding, probably something stupid)


corrado33

Recommended Posts

So I'm trying to edit someone elses mod just to learn how to mod in skyrim.

 

The first thing I'm trying to do is to have a mannequin auto dress with random stuff that's in a chest when I push a button. Actually, to make it easier first I'm just trying to display the name of a random item in the chest when I press the button.

 

Right now I'm messing around with the "Drunken Dragon" mod (a player owned store). Super cool. I've already edited the script to do things I want, but I want to do something completely different now though.

 

 

So I put a duplicated dwemer button inside the cell, then edited the defaultDweButtonScript (I forgot to duplicate it... I know... I'm an idiot.)

 

So I got the button to display a dialog that says "Button Pressed" whenever I push it. That works great.

 

So here's the script.

scriptName defaultDweButtonScript extends objectReference

sound property QSTAstrolabeButtonPressX auto
objectReference property objSelf auto hidden
ObjectReference Property pppDrunkenDragonChestRefA  Auto 

event onCellAttach()
	objSelf = self as objectReference
	playAnimation("Open")
endEvent


auto state open
	event onActivate(objectReference akActivator)
		;goToState("waiting")
		playAnimationAndWait("Trigger01","done")
		if QSTAstrolabeButtonPressX
			QSTAstrolabeButtonPressX.play(objSelf)
		endif
		debug.MessageBox("Button Pressed")
		int iTotalItems = pppDrunkenDragonChestRefA.GetNumItems()
		debug.MessageBox("TotalItems: " + iTotalItems)
		int iRand = Utility.RandomInt(0,iTotalItems - 1)
		form oItem = pppDrunkenDragonChestRefA.GetNthForm(iRand)
		debug.MessageBox(oItem.getname())

	endEvent
endState

As you can see, I placed this line...

 

ObjectReference Property pppDrunkenDragonChestRefA Auto

 

at the top of the script. Then I edited the properties of the script and made sure that reference pointed to the chest in the cell. Then I loaded up the game and.... nothing.

 

It still displays "Button Pressed" and "TotalItems: 0" and just a blank message box (where I tried to display the name of the nonexistant item.)

 

So what am I doing wrong? It's obvious that the script isn't picking up the chest reference. Am I forgetting something?

 

Thanks!

Link to comment
Share on other sites

1. Are you trying from a clean start (e.g. using the console coc command to go directly to your test cell from the main menu)?

 

2. Did you save the *mod* after filling the property? Scripts save independently of the .esp, so if you're changing properties and such you need to re-save the whole mod.

Link to comment
Share on other sites

1. Are you trying from a clean start (e.g. using the console coc command to go directly to your test cell from the main menu)?

 

2. Did you save the *mod* after filling the property? Scripts save independently of the .esp, so if you're changing properties and such you need to re-save the whole mod.

 

1. No, is this important? Shouldn't this work... in game? I have an entire skyrim install (on a separate computer) for modding. I'd load into the game, leave the cell, run around for a few mins, then come back to the interior cell and push the button.)

2. Yes. If I'd edit the script or the esp, I'd save BOTH. Making sure to compile the script.

Edited by corrado33
Link to comment
Share on other sites

1. Are you trying from a clean start (e.g. using the console coc command to go directly to your test cell from the main menu)?

 

2. Did you save the *mod* after filling the property? Scripts save independently of the .esp, so if you're changing properties and such you need to re-save the whole mod.

 

Turns out if I DO a clean start using the coc command from the main menu, it works great. (In a test cell at least.)

Link to comment
Share on other sites

Yeah, it's important. Skyrim bakes stuff like script properties into your saves, so if you change them after they've been saved in the game, you get undesired behaviour. Always do a clean start when you're iterating scripts like this or you'll tear out your hair trying to chase down errors that aren't actually there.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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