Scripting help required

Post » Wed Dec 05, 2012 9:43 am

Hey everyone.
I am attempting to complete a project (started by someone else) that brings Dawnfang and Duskfang to Skyrim.
Specifically, I need help with a specific scripting issue I encountered when using RegisterForUpdateGameTime(float afInterval) - or any RegisterForUpdate type of function, since none of them work - in an ObjectReference script attached to the swords.
I originally posted on a thread over on the Skyrim Nexus forums, but haven't received any help there and have since been directed here, because this is "where all the good scripters hang out".
I can't post a link, unfortunately (don't have permission apparently), so here's the details:

Spoiler
Scriptname DawnfangScript extends ObjectReference  {The script controlling Dawnfangs behavior}Actor UserGlobalVariable Property DawnfangKC autoGlobalVariable Property DuskfangKC autoWeapon property Duskfang autoWeapon property DuskfangS autofloat FUNCTION GetCurrentHourOfDay()	float temp = Utility.GetCurrentGameTime() * 24	return ((temp as int) % 24) + (temp - (temp as int))ENDFUNCTIONEvent OnEquipped(Actor akActor)	User = akActor	Debug.MessageBox("The time is " + getCurrentHourOfDay() as string)	if User == Game.GetPlayer()		float delay = 18-getCurrentHourOfDay()		Debug.MessageBox("The delay is " + delay as string);		if (delay &--#60; 0.1);			User.EquipItem(Duskfang, false, true);			Delete();		else;			RegisterForSingleUpdateGameTime(delay);		endif		RegisterForUpdateGameTime(0.1)		DuskfangKC.SetValueInt(0)	endifendEventEvent OnUpdateGameTime()	Debug.MessageBox("It's working! The time is " + getCurrentHourOfDay());	if getCurrentHourOfDay() &--#60; 6;		if getCurrentHourOfDay() &--#62; 18;			if DawnfangKC.GetValueInt() &--#62;= 12;				User.EquipItem(DuskfangS, false, true);			else;				User.EquipItem(Duskfang, false, true);			endif;			Delete();			UnregisterForUpdateGameTime();		endif;	endifendEventEvent OnUnequipped(Actor akActor)	UnregisterForUpdateGameTime()endEvent

While testing the OnUpdateGameTime() event, I had commented out all the unrelated code. I know that the Register line is executed.
Looking through the Papyrus logs, I noticed the following:

[12/04/2012 - 11:07:00PM] error: Unable to call RegisterForUpdateGameTime - no native object bound to the script object, or object is of incorrect typestack:		[Item 32 in container  (00000014)].DawnfangScript.RegisterForUpdateGameTime() - "" Line ?		[Item 32 in container  (00000014)].DawnfangScript.OnEquipped() - "DawnfangScript.psc" Line 28

The Creation Kit wiki page for Papyrus logs gives a number of possible reasons why this error message might appear.
Basically, it says that either the FormID keeps changing for some reason, or that my savegame is dodgy.
So a bit of background info: Every time I test the mod, I load the same save and then quit, so that save is always running the mod for the first time. It's hardly a clean save (with the 100 or so mods I have running), but also I've tested the mod using a brand new game (with "coc whiterun" from the main menu) with no success.

In the same .esp (and the same savegame/testing conditions), I created and tested an activator in the game world that gives messages every few seconds with the OnUpdateGameTime() event, so I know the event itself is working - it must be something specific to the Dawnfang sword in my inventory.

So I'm not sure what to make of it.
Maybe the FormID of items in the player's inventory changes depending on whether its the third or first-person model (or not equipped at all)?
Alternatively, maybe Weapon types cannot be registered for updates?
Or maybe the FormID can't be found because the mod was originally in a different load order?

If I type in "sv" with Dawnfang selected in the game console, it initially says the name of the attached script and variable values, as expected. But after equipping it, "sv" reports that it's registered for game updates but has no attached scripts, leading me to believe that the FormID is in fact changing somehow.

But I really don't know, I'm just shooting ideas into the dark, here.

I would greatly appreciate any insight as to the cause or solution to this problem.
Thanks.
User avatar
Oyuki Manson Lavey
 
Posts: 3438
Joined: Mon Aug 28, 2006 2:47 am

Return to V - Skyrim