Jump to content

Checking Store for Item


Recommended Posts

I'd like to move a unique item from one store and add it to another.  I know how to remove and add items to stores, but I don't know how to check for an item's existence in the store.  Basically, I want a IF ITEM-IN-STORE THEN check.

I'm sure there's a way to traverse the store's inventory, but was hoping someone already wrote that so I'd not have to reinvent the wheel.

Edited by Lauriel
Link to comment

You can iterate through the items in the store fairly easily... but to be honest, in most circumstances you might as well just use FILE_CONTAINS to see if the resource name for the item occurs inside the store file. Unless your item has a weirdly short name, so that other item names contain it, or unless its name coincides with the name of a rumor dialog or a healing spell, that will be reliable. (And those are exceptionally weird edge cases.)

That said, if all you want to do is remove it from whatever store it occurs in (and you don't care which store it actually does occur in), you might as well just use REMOVE_STORE_ITEM on every store. Unless I'm mistaken (it's been known), REMOVE_STORE_ITEM doesn't care if the item wasn't there to begin with.

 

Link to comment
On 7/16/2020 at 6:10 PM, DavidW said:

in most circumstances you might as well just use FILE_CONTAINS to see if the resource name for the item occurs inside the store file

Tested this.  Does work.  Just an FYI in case anyone else is looking for a quick solution.  ... unless I'm completely unable to read the docs...which, ya know, is entirely possible.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...