Jump to content

Help with dynamically-populated FormLists


HunterZ

Recommended Posts

So I'm working on my Bag of Holding mod, and I'm having trouble getting a new feature to work. What I'm trying to do is use the NVSE functions GetHotkeyItem and player.GetEquippedObject to build a FormList of the base IDs of all hotkeyed and player-equipped items, which I'm then trying to use an exclusion list for player.RemoveAllTypedItems calls.

 

Unfortunately, it's not working as expected. Specifically, I'm seeing the following problems:

  • If the player chooses to protect just equipped items, then all items get deposited - including equipped ones.
  • If the player chooses to protect hotkeyed items (or both hotkeyed and equipped items), then no items get deposited - including non-hotkeyed, non-equipped items.

 

Anyone know what the heck is going on? I've pasted my script into the spoiler tag below. Look under the "3 - NEW VALUE" comment for the most relevant section of code.

 

 

  Reveal hidden contents

 

 

I've tried commenting out the checks relating to whether or not hotkeyed and/or equipped items should be protected, so I know there's no problem there. It has to be something I'm doing with the FormList.

Link to comment
Share on other sites

If the number you use in your Label statement is greater than 255, it won't loop. (I'm assuming it's an 8 bit limit because I tried using 300, etc and no looping occurred).

change them to something safe, like 10, 20, 30 etc and then see.

Link to comment
Share on other sites

Ok, so I changed the labels (and corresponding goto's) to 10, 20 and 30. Unfortunately, the behavior now is that no items of any kind are deposited when either or both of the hotkey/equipped item protection options are active.
Link to comment
Share on other sites

Since Inventory items are not references, but base objects, instead of rItem.ListAddRef HZBagOfHoldingFormList, use this:

ListaddForm HZBagOfHoldingFormList rItem

Unfortunately, if more that one rItem is in the player's inventory, there's no way, script-wise, to determine which one is equipped or hot-keyed - the HZBagOfHoldingFormList will cause RemoveAllTypedItems to leave them all in the player's inventory.

Link to comment
Share on other sites

Thanks, I was actually just wondering whether there was a different approach needed for adding base objects to FormLists.

 

I already anticipated that this would potentially prevent deposit of items sharing base id's with equipped or hotkeyed items, but I figure it's still useful enough to be worth giving end-users the choice of whether or not to make use of it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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