Script: OnUpdate() on Weapon

Post » Tue Jun 19, 2012 3:26 pm

I have added this script to the Iron Dagger,

Spoiler
Scriptname aaHCMORHealthScript extends ObjectReference

Event OnLoad()
RegisterForUpdate(2)
Debug.Notification("Item has Registered on Load")
EndEvent

Event OnEquipped(Actor akActor)
RegisterForUpdate(2)
Debug.Notification("Item has Registered on Equipped")
EndEvent

Event OnUpdate()
Debug.Notification("Item is Updating")
EndEvent

When I equip the dagger I see the "Item has Registered on Equipped" but I never see the "Item is Updating"

Can anyone tell me why?
User avatar
Heather beauchamp
 
Posts: 3456
Joined: Mon Aug 13, 2007 6:05 pm

Post » Tue Jun 19, 2012 8:38 pm

I have added this script to the Iron Dagger,

Spoiler
Scriptname aaHCMORHealthScript extends ObjectReference

Event OnLoad()
RegisterForUpdate(2)
Debug.Notification("Item has Registered on Load")
EndEvent

Event OnEquipped(Actor akActor)
RegisterForUpdate(2)
Debug.Notification("Item has Registered on Equipped")
EndEvent

Event OnUpdate()
Debug.Notification("Item is Updating")
EndEvent

When I equip the dagger I see the "Item has Registered on Equipped" but I never see the "Item is Updating"

Can anyone tell me why?

I guess there is a limit to the number of debug.notification.

From what I know should be about three.

With an update each 2 seconds, you probably don't get them.
Jashkar
User avatar
james reed
 
Posts: 3371
Joined: Tue Sep 18, 2007 12:18 am

Post » Tue Jun 19, 2012 8:55 pm

The item is registered for continual updates, so that won't be the problem.

What happens if you drop the item then pick it back up again?

Cipscis
User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm

Post » Wed Jun 20, 2012 1:57 am

Indeed not. I had tried changing the time from 2 to 5 to 10 but no difference. However, it seems to matter what Save I work from because now, having cleared the Mod from my game and resaved, your suggestion, Cipscis, of dropping it caused the OnLoad() to trigger the OnUpdate() Event and I now get both notifications with a repetition of the second. But if I return to my previous save I go back to the script not working correctly.

It seems as though my tinkering with the script, or the mod, gets baked into my savegame and causes issues.

Thanks for your help. I can now press on.
User avatar
Amiee Kent
 
Posts: 3447
Joined: Thu Jun 15, 2006 2:25 pm

Post » Tue Jun 19, 2012 5:36 pm

Just to confirm, was dropping the weapon what enabled it to be registered for updates?

You might want to take a look at this page on the wiki, which discusses how scripts and saves work together - http://www.creationkit.com/Save_File_Notes_(Papyrus)
Basically, disabling a plugin file will not remove scripts attached to objects by that plugin file.

Cipscis
User avatar
Yama Pi
 
Posts: 3384
Joined: Wed Apr 18, 2007 3:51 am

Post » Tue Jun 19, 2012 7:53 pm

To confirm.

I already have the Iron Dagger in my inventory. I have added the script to it and enabled the mod.

If I equip the dagger I get the message "Item has Registered on Equipped" but I do not get the "Item is Updating" message.

If I drop the dagger I get the message "Item has Registered on Load" and get the "Item is Updating" message at regular intervals.

This is not very helpful unfortunately as I want the script to run on the weapons in my inventory.

I think I may have fallen foul of the "Removing Scripts From an Object" clause. The wiki is not clear on whether this problem is in anyway fixable. In my attempts to get this working I had removed a previous version of the script from the iron dagger and deleted it altogether. I seem to remember that items in the inventory and items dropped from it into the world in Oblivion were different items. Is this the same in Skyrim?

Edit:

Something that I thought might help was to add an event block that unregistered for updates on unequipping the dagger. But the updating continues. I really have screwed up this dagger.

Second Edit:

I have now also tried starting a new game from the beginning but when I get an Iron Dagger I get exactly the same results as before. The OnUpdate() Block is only running if triggered by the OnLoad() block. I am off to bed.
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am

Post » Wed Jun 20, 2012 6:42 am

OK, frustration levels are getting high.

I have tried a number of different things with script and it always comes back to the problem that the OnEquipped Event does not start the OnUpdate Event.

Does anyone have a clue why this should be? It currently feels as though scripts on weapons are broken.
User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am

Post » Tue Jun 19, 2012 3:42 pm

I am now trying States to turn the OnUpdate event on and off. I will let you know how I get on.
User avatar
Rob Davidson
 
Posts: 3422
Joined: Thu Aug 02, 2007 2:52 am


Return to V - Skyrim