Jump to content

Script works but can it be better?


Recommended Posts

Hey, the fastest way to get equipped items on an actor would be to use Papyrus Extender: https://www.nexusmods.com/skyrimspecialedition/mods/22854 which has:

Form[] function AddAllEquippedItemsToArray(Actor akActor)

I remember suggesting this for getting equipped ammo, and I did test it. The function is really fast. You could still put a check for skse and Papyrus Extender, and use the function if it's installed.

I'm having difficulty testing this, I'm using:

scriptname dz_papyrus_test extends ObjectReference
;import po3_papyrusextender64
;import PO3_SKSEFunctions


Form[] function AddAllEquippedItemsToArray(Actor akActor) global native
Actor Property PlayerRef Auto
Form[] Items = AddAllEquippedItemsToArray(PlayerRef)


Event OnTriggerEnter(ObjectReference triggerRef)

If triggerRef == PlayerRef

debug.messagebox("Length of list is "+Items.length)

EndIf
EndEvent

as you can see I've been trying different things, can you help?

 

diziet

Link to comment
Share on other sites

Hey yeah, you need to use the function in your script, it's already defined in the Papyrus Extender script. So you would do:

 

scriptname dz_papyrus_test extends ObjectReference
;import po3_papyrusextender64
;import PO3_SKSEFunctions

Form[] EquippedItems
Actor Property PlayerRef Auto

Event OnTriggerEnter(ObjectReference triggerRef)

If triggerRef == PlayerRef
    EquippedItems = PO3_SKSEfunctions.AddAllEquippedItemsToArray(PlayerRef)
    debug.messagebox("Length of list is " + EquippedItems.length)
EndIf
EndEvent
Link to comment
Share on other sites

 

Hey yeah, you need to use the function in your script, it's already defined in the Papyrus Extender script. So you would do:

 

scriptname dz_papyrus_test extends ObjectReference
;import po3_papyrusextender64
;import PO3_SKSEFunctions

Form[] EquippedItems
Actor Property PlayerRef Auto

Event OnTriggerEnter(ObjectReference triggerRef)

If triggerRef == PlayerRef
    EquippedItems = PO3_SKSEfunctions.AddAllEquippedItemsToArray(PlayerRef)
    debug.messagebox("Length of list is " + EquippedItems.length)
EndIf
EndEvent

 

Ah, I see that I was putting the line:

Items = AddAllEquippedItemsToArray(PlayerRef) and its variants outside the event, inside the event it works, not sure why that is but now I can move on:)

 

Thanks

Link to comment
Share on other sites

  • Recently Browsing   0 members

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