Jump to content

Script that combines RemoveItem with RemoveAllItems


Recommended Posts

Hello everyone!

 

Script noob here, so please bear with me. I'd like to make an object sorter in player-house I'm working on: bunch of containers and an activator. But it's crucial for me to keep object data, like if it was stolen, it's durability and charge, and so on, when moving objects between PC inventory and the containers. So, RemoveItem and AddItem functions aren't good for that. There is RemoveAllItems functions which lets us to specify container/inventory the objects will be added after removal and it keeps all the data, but it doesn't let us to specify the object to move... So the question is, is there any way to achieve "remove only specified items and move them to specified inventory" functionality? And not the question but more of a wondering: why there's no such function in the CS to begin with...?

Link to comment
Share on other sites

The only other command you can use is RemoveMEIR (link), You would need to do it in a foreach loop. See this OBSE page.

 

Something like this:

ref rItem
ref refOtherContainer

foreach rItem <- player
    if I want this item
        RemoveMEIR refOtherContainer
    endif
loop

However, RemoveMEIR does not care if the item is playable or a quest item, whereas RemoveAllItems won't remove quest items, and I think the same goes for unplayable items. RemoveMEIR, will not cause the item's script OnAdd block to fire. You would probably only need to care when using this to move items from a container to the player's inventory.

Edited by GamerRick
Link to comment
Share on other sites

Thanks for the answer. As I said, I'm a noob when it comes to scripting, so I'll need some time to understand what you've said/written, but I think I'll manage. :wink:

 

EDITED

 

OK, I understand (or so I think) the basics behind ForEach and RemoveMeIR functions. But I have no idea how to construct if statement to take only item(s) I would like to - my script removes all items (standard ForEach behaviour) or no items at all. And I thought it will be sunshine and bunnies all the way...

Edited by MajorKirrahe89
Link to comment
Share on other sites

  • Recently Browsing   0 members

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