Jump to content

Recommended Posts

Posted

Example: No need to call Game.GetPlayer() 10 times in a script, too many calls will slow down the script. The return value never changes, so you want to assign that to a variable instead.

Posted
  On 3/24/2020 at 6:34 AM, Rasikko said:

Example: No need to call Game.GetPlayer() 10 times in a script, too many calls will slow down the script. The return value never changes, so you want to assign that to a variable instead.

Does using 'PlayerRef' have the same effect? That's what I've been using.

Posted (edited)

The actor playerref property is even better as it is 1,000 times faster than the function, even if its assigned to a variable.

Edited by Rasikko
Posted
  On 3/20/2020 at 5:50 AM, dylbill said:

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

Posted

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
Posted
  On 3/24/2020 at 10:48 PM, dylbill said:

 

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

  • Recently Browsing   0 members

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