glowplug Posted March 20, 2017 Share Posted March 20, 2017 I may well have missed something on the OBSE Documentation but I'm stumped.I want to loop through the items in a container and equip it's items on an actor - as possible.* If it's not an equippable item, ignore it.* If the equipment Slot is already in use, ignore it.I've found these problems...GetEquipmentSlot returns 0 both for headwear and non equippable such as Sweetroll.GetEquippedObject returns null or whatever if slot not equipped.How do we test the return variable?I would write the missing functions, as possible, to do something like this... array_var arrItems int iIndex int iSlot ref refTest ref refItem ref refParent begin onActivate ;remove default items here let refParent := getParentRef ;container removeAllItems refParent, 1 let iActivated := 1 refParent.activate playerRef end begin gameMode if iActivated > 0 let iActivated := 0 let arrItems := refParent.getItems let iIndex := ar_Size arrItems while iIndex > 0 let iIndex -= 1 let refItem := arrItems[iIndex] ;_I want to write something like IsEquippable that returns Equipement Slot ID where valid, -1 if not. let iSlot := IsEquippable refItem if iSlot > -1 let refTest := getEquippedObject iSlot ;_I want to write something that tests for Unset/Null/Empty reference variables. if RefVoid refTest addItem refItem, 1 endif endif loop endif ;loop adding default items where naked end ...it needs to resolve multiple body part slots but I will come back to that. Link to comment Share on other sites More sharing options...
forli Posted March 20, 2017 Share Posted March 20, 2017 (edited) ;_I want to write something like IsEquippable that returns Equipement Slot ID where valid, -1 if not. For "IsEquippable", you have two commands: - IsPlayable Only return true if the item has the flag playable/equippable, and the flag is checked. - IsPlayable2 As above, but also return true if the item doesn't have the flag at all (if the flag it doesn't appear when you open the object in the editor) What you're asking for, equipment slot, is more complicated.What you need is GetBipedSlotMask, but watch out for the result: the returned values in the bitmask are not the same as the slots. You need to reconvert the values to slots indexes. ;_I want to write something that tests for Unset/Null/Empty reference variables. if RefVoid refTest There are two ways: if refTest ;true if the variable contains a reference (doesn't check it's a valid reference) If IsFormValid refTest ;true if the variable contains a VALID referenceThe second one also include the first, it's a little slower but more secure and it's recommended when you receive the reference from an unknown source and you want to be sure something valid is in there before using it.In your case, since you get the reference from a checked source (the actor's inventory), you can't just use the first one. Edited March 20, 2017 by forli Link to comment Share on other sites More sharing options...
glowplug Posted March 20, 2017 Author Share Posted March 20, 2017 Many thanks once again Forli.Simple solutions to problems that would otherwise bloat out managing them. Thanks for mentioning IsPlayable2 as I missed it.I noticed GetBipedSlotMask and made a note to come back to that.I missed IsFormValid as well - as you point out, this is the correct solution for this problem. To be honest, I often find myself lost on the OBSE Documentation page as it is quite extensive.If I needed to spend more time using it then it would stay fresh in memory.For example, every now and then I come back to it looking for something from other languages. Once again I'm glad we have a knowledge base in you. Link to comment Share on other sites More sharing options...
Recommended Posts