Evangela Posted March 24, 2020 Share Posted March 24, 2020 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. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted March 24, 2020 Author Share Posted March 24, 2020 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. Link to comment Share on other sites More sharing options...
Evangela Posted March 24, 2020 Share Posted March 24, 2020 (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 March 24, 2020 by Rasikko Link to comment Share on other sites More sharing options...
dizietemblesssma Posted March 24, 2020 Author Share Posted March 24, 2020 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 More sharing options...
dylbill Posted March 24, 2020 Share Posted March 24, 2020 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 More sharing options...
dizietemblesssma Posted March 25, 2020 Author Share Posted March 25, 2020 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 More sharing options...
dylbill Posted March 25, 2020 Share Posted March 25, 2020 No problem. And yes that's correct. You can only use functions inside events. Properties can be defined outside of events. Link to comment Share on other sites More sharing options...
Recommended Posts