Item search - any easier solution?

Hello!

I'm currently trying to set up an item search function for my warehouse-simulator.
There are 13 item categories, with different "codes", which you can search for through input number to find out in which shelf they are currently stored (see pic below).

lLcBb


As you can see the amount of lines for each item is pretty long atm (as I have to search through each shelf inventory ranging from A to L with the according input number). With over 3500 items in the database of my simulator already (and possibly more coming in the future), I'm kinda scared that I'll run out of space in my event soon :S is there an easier way to search for items?
Can you repost your image? It is not showing.
$gameParty._items[itemNumber] is the easiest line there is.
@ mlogan Sorry, not sure what happened to the pic...Here it is 🙂
Basically I'm asking for an input number with 7 digits and then I've added condition branches. If item code is ABCDEFG check inventory A for it, switch inventory B, check for the item, etc - if the item is in no inventory, it will say "Item is not in the warehouse" - the other codes are added with the "else" branch...But yeah...that's A LOT of lines. works fine with 100 items (but I have 3500 atm and I'm planning on more...), so hence my question here xD

Nuti9cd.png


@Poryg Can you elaborate on that a bit? First time ever, that I see that line 😮

I tried it like this

hadg.png



but now I'm getting the following error "ReferenceError itemNumber is not defined"
Jesus 😀 You can't take me literally in javascript, you have to know how to use the thing.
ItemNumber is parameter for which you substitute a number.
For example $gameParty._items[30] returns you either a number or undefined depending on how many, if any, items number 30 you have in your inventory.
So if you search for an item, have a variable hold the item number you are searching for and then use if ($gameParty._items[$gameVariables.value(variableID)), where variable ID i the ID of that variable that carries the item number you're searching for.
@Poryg Owh, that's what you ment...But I already did that 😮 Check out the first picture. I assigned variables to the items, so if an input number was done and if the number was 1500333, then it was searching the inventories of the warehouse for item A, else if it was number 1500334, then it was searching the inventories of the warehouse for item B, else if the number was...etc...else if the input number didn't match any of the variables then it would tell the player "Item is not in the warehouse".

My question was: Is this the only way to do this, because it's taking a LOT of lines (since I have 12 different inventories right now - 1 inventory = 1 shelf - Hurray for HimeWorks!) to do that for all of my items (and I'm not sure if I will hit a limit sooner or later :/) or is there a simpler way, e.g. if there is a script that lets the input number check if the item with the according item ID is in the warehouses inventory somewhere directly, instead of me typing it out manually for every single item.
There is no script like that. However, I can maybe build one, if you tell me a little bit about how it works.

How do you count these items? Does every item in your game have a number?
If not, are all numbered items in one consecutive streak?
If not, are there at least some patterns in terms of how the items appear in your item database? (for example 100 numbered items, then 100 non-numbered items or something).
If not, then that is the least pleasant variant, but still a workable one.

What is the number of the first item?
Are all next numbers always one higher than the previous one? (for example beginning at 1500001, ending at 1503500) Or are the numberings random?
The thing is, you can build it easily with javascript, but since I'll be pinpointing names, I need to know these things so that I know how to construct the code.
@Poryg

Wow! You'd do that for me? 😀 That would be awesome!
Alright...so details!

I currently have 13 different categories of items (I've used Yanflys ItemCategories plugin for that). Each category has it's own prefix, e.g. office items have a 150 prefix, decoration items have a 300 prefix, etc. I've noticed this kind of codes above the bar codes when I went shopping at the local shopping center and asked one of the salesmen there. Always wondered what they were about and now I know xD There are always 7 digits for each item, e.g. the pencil from my example pic has the number 1500333.

Each item in my simulator has it's own number in theory as I changed that in the database using notepad++. Here and there I left some item spots blank, in case I can think of another item I want to add.
Overall I added 3623 items to the database already, but I'd like to get to at least 4500 to keep it somewhat close to reality of a small shopping center. The way it appears in my database is that I've organized the items by category, so office items are next to office items and decoration items are next to decoration items etc, with their according prefixes.

The number of the first item in the database is 0001 atm, as I haven't deleted the baseline items yet...The first item I added is 1000001 though, which is a toothbrush. (100 = bathroom items). So far I have 500 bathroom items slots, 391 of them being used for actual items, while 109 are blank atm, then it continues with the next category, which has another prefix. Usually the item numbers are always one higher than the previous one though, e.g. pencil with sharpener is 1500333 and a pencil without a sharpener is 1500334.

I've looked into java myself today, using Sublime Text to create my own plugin. I was successful in the creation of the file (thanks to SRDudes tutorial vid), but now I'm searching through the rpg_objects.js file and trying to figure out how to manipulate input number to search the inventories for the item with the according item ID in the database...But yeah...that's not going too well xD I lack the exp to find what I'm searching for :s

Kinda hoped I could do something like

input number = itemID (true/false)

if false "Sorry, such an item does not exist"
if true check inventories of shelfs

item in the shelf? (true/false)
if false "Sorry, that item is currently not in the warehouse...We should order it!"
if true "Item is in shelf A" or "Item is in shelf B" or "Item is in shelf A and B!"

I know this is a pretty specific and probably not a lot of people are into warehouse simulators, but I'd really like to expand it to a shopping center RPG one day and get it as close to reality as possible, with warehouse organization, sales floors, different kind of workers and behavior/traits (e.g. "is restocking office by default" or "has good eyes and spots thieves more likely"). I know this is a very big project, so I wanted to focus on the items and warehouse for now and maybe pass on some exp to other people with similar projects 😛
Good 😀 This will be a piece of cake. I'll upload the file here with instructions on how to use it once it is done, should take about 30-60 minutes to make it.

Took a bit longer, because debugging without the appropriate plugin is not the easiest 😀 (and because for some time I programmed something I wasn't supposed to)

Instructions:
Before you begin using this plugin, you need to perform a couple of edits.

1. You need to edit variable begins. It's an object holding this information:
First 3 numbers: First occurence of the item in the database.

So for example if you have 10000001 in 4th slot and 15000001 in 340th slot, it'll look like this:
var begins = {100: 4, 150: 340}.
Then you need to edit variable sizes, which holds the information of how large your item categories are.
If category 100 is 500 slots long and 150 is 200 slots long, will look like this:
var sizes = {100: 500, 150: 200}
Note that it is programmed so that it goes for consecution! That means it will take the first occurence in database (the one you type in) and runs through X items, where X is the size you type in. If you have one item section separated to two, you'll have to increase the size by the missing number!
For example you have 10000001 in item slots 100-350, then you have 100 items with code 150, then you have another 200 items of code 100.
In practice it is 250 + 200 items of code 100, but due to the additional 100 items of code 150 between these two groups the size is not 450, but 600!
And of course I'll leave the edit of the message strings to you.

I'll get $20 😛
Nah, just kidding. It easy to make, I just made it more difficult to myself than I should have. If I just let it run through all items, it'd been much shorter to program 😀

Don't worry about anything else. This program runs through the database, sees if you have any items in your regals (btw. maybe you'll have to update the regal names, since I'm not sure how you named your inventories) and the plugin will do everything for you, including showing message.

How you use it:
Screenshot_392.png


Also, it's not java, but javascript. Java is a compiled language, javascript is an interpreted one 😛
And if you want to learn it, SRDude's tutorials will NOT help you. You need to study the basics first, I can recommend sololearn.com.
Thanks a bunch! 😀
I'll try to edit it properly in the following days and post the results 🙂 One thing I noticed though: It doesn't show up in the plugin manager 😮 is that supposed to be that way until I edit it?

I'll get $20 😛

Sorry, I only have G :< But I can offer you a boost to your experience points! 😉
Nah seriously, thanks a lot ^^
It should show in the plugin manager, it just doesn't show any parameters or things.

Original thread: https://forums.rpgmakerweb.com/threads/item-search-any-easier-solution.87090/