Jump to content

proper way to use onobjectequip?


3aq

Recommended Posts

I am trying for onobjectequip to work for a specific item.

 

for example sake a copied Valdr's Lucky dagger that onobjectequipped will debug notify "You're feeling lucky"

likewise a copied Savior's Hide that onobjectequipped will debug notify "You're feeling ravenous"

 

I've tried time and again on both for what seems to be ages (3-4 hours) but regardless of what I do it doesn't work.

 

Just what exactly is the secret?

 

I've extended to Actor and after that didn't work I've tried SKI Configbase, that too did not work. I've referenced it to the item via their editor's ID, is that the reason? If that's the case, how do you call it then? I am stumped. Help is deeply appreciated.

 

Kind Regards,

Link to comment
Share on other sites

If this is for the player, an example that will display text when a specified weapon is equipped.

Scriptname SomeScript Extends ReferenceAlias

Weapon Property myWeapon Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
  If (akBaseObject as Weapon) == myWeapon
    Debug.Notification("My Weapon was equipped!")
  EndIf
EndEvent

Please note that when adding scripts to the player it needs to be done within a quest alias as otherwise only the last mod to modify the player record gets to work in game. Thus the example uses ReferenceAlias as the script being extended.

Link to comment
Share on other sites

thank you Mera, sadly I was unable to make it work regardless, I need a working mod example and examine the esp in detail. I am sure I have the scripting down properly, I am almost certain it's due to the esp. If anyone happen to have any working samples, please allow me the privilege of examining it, thank you.

 

but on the brightside, I was able to perform it though it's a tad more complicated.

 

The process requires OnEquip and using a data reference back to the main script / library script to call a function what should occur. This method has the plus side of drastically reducing the script bloat as well as it works on armor/weapon/spell array.

 

example:

scriptName testEquip extends objectReference
_testLib property DataRef auto
armor property RingRef auto
actor property PlayerRef auto
Int property iNote auto

function onEquipped(actor akActor)
    if (akActor == PlayerRef)
        akActor.UnequipItem(RingRef, false, true)
        DataRef.fNotify(iNote)
    endIf
endFunction
scriptName testLib extends SKI_Configbase
function fNotify(int iNote)
debug.notification("The ring is preventing you from equipping it. Perhaps you should go hurry and throw it into a volcano or something.")
endFunction
Edited by 3aq
Link to comment
Share on other sites

Working example of the OnObjectEquipped event?

 

There is one within my Inventory Management System Rebuilt mod. It is used with the Arrow and Bolt quiver containers. The event catches the equipped item, determines if it is a bow / crossbow and then calls a function that will fetch the appropriate ammo from the associated container.

 

An example can also be found in my Aesthetic Bolt Quiver mod. There it is used to catch the ammo being equipped, determine if it is a bolt and if it is then equip the visible armor piece as selected by the player's MCM choices.

 

Both mods are rather complex so deciphering what is going on may be tricky.

 

As far as your solution in the most recent post...

You do realize that you can just put the notification string on the same script as the OnEquipped event? No need to drag out the processing by calling to another script just for the text to display. Plus extending SKI_Configbase is intended for MCM scripts and the data that it needs. It is not intended for holding functions and such used by other scripts. If you must do that, extend quest and attach it to the same quest record. You can have more than one script attached to an object.

Link to comment
Share on other sites

Yup, but in my particular case, what I wanted to do at the end is/was for it to run a particular function that parses and puts an array after been it's equipped. The data and main library functions are mainly consolidated within the mcm so.. yeah. Regardless it works at the end of the day so no complaints. That said, I'll go and try to decipher those two mods. Thanks,

Link to comment
Share on other sites

  • Recently Browsing   0 members

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