Author Topic: Inventory Searches  (Read 251 times)

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Inventory Searches
« on: December 08, 2011, 03:09:58 pm »


               This question regards speed, efficiency and lag reduction. Since most PC inventory searches for items in a script seem to search a characters inventory starting on the first page, would encouraging folks to place various checked for widgets (like language tokens) and quest items on their first page decrease script runtimes by reducing the shear number of things checked? If so, would it be significant enough to ask folk to change their inventory management schemes?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Inventory Searches
« Reply #1 on: December 08, 2011, 03:35:41 pm »


               I am not currently in a place where I can check this out.  

But It has been my experence that the items are checked in a LastIn FirstOut format with the position in the inventory display not counting for much.  

A similar question would also be what is faster  when searching for an inventory for several items.  One loop of GetFirst/Next or several GetItemPossessedBy calls.   The GetFirst/Next get extra overhead from the VM.   The PossessedBy makes one loop through the inventory each call with less VM overhead.  I don't know the answer to that one either.   Would make an interesting study though.  It could be as reveling as the  GetObjectByTag discusion.
               
               

               
            

Legacy_SHOVA

  • Hero Member
  • *****
  • Posts: 893
  • Karma: +0/-0
Inventory Searches
« Reply #2 on: December 08, 2011, 03:46:52 pm »


               As a player, I hate getting a bunch of items that I must carry, that do not do anything but hold some scripters check box.

As a scripter I understand the need to check a item to see if something happens.

I tend to use the PC skin to hold all info, and the campaign database to hold all conversational type info.

As far as your question, it has been my experience as a DM, most players have no sense of organization when it comes to their PC inventories. If you give them bags, for specific things, they will cram them full of something else. If you say keep these things on your first page of your inventory, they will place them on the second to last page, because they have no idea what a first page is. Most players believe that any help out rule, but not enforced rule, does not apply to them. Simply a fact of gaming I guess.

What lags out in terms of inventory seems to come when there is more than 3 containers in the inventory, when the inventory is nearly full of little junk, and really only shows up, when the PC logs in and out of the server. Using the smaller containers, say the misc small, and misc thin items from CEP tend to push it down to 2. the more items, the more lag. In crafting mods, it can be a nightmare. Stacking does seem to help, but if the inventory is full of stacks, it can be even worse.

good luck!
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Inventory Searches
« Reply #3 on: December 08, 2011, 07:28:58 pm »


               

kalbaern wrote...

This question regards speed, efficiency and lag reduction. Since most PC inventory searches for items in a script seem to search a characters inventory starting on the first page, would encouraging folks to place various checked for widgets (like language tokens) and quest items on their first page decrease script runtimes by reducing the shear number of things checked? If so, would it be significant enough to ask folk to change their inventory management schemes?

Assuming your premise about inventory loops starting on the first page is correct, then yes, assuming you break; out of the loop when you find what you're looking for. Like Lightfoot, I'm curious about how many items you need to be getting before a loop becomes a better alternative. If I have a few spare minutes I may do a test run to test your premise and that question as well.

Funky
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Inventory Searches
« Reply #4 on: December 08, 2011, 08:11:19 pm »


               Think I'll craft some negative traps after loading my inventory in a set pattern to test the last in, first out. Could very well be "where" you place something is moot then.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Inventory Searches
« Reply #5 on: December 10, 2011, 01:28:53 am »


               This really shouldnt be problem. AI does much more crazy stuff every second so thats it.

Of course its a good prevention to reduce number of system items like "targetting wand", "id card", "emote wand" etc. and also use high stacks for 1x1 items so player can carry more items like herb in one stack which is count as a one item in loop. I am admin on a server where players are creating keeper characters instead of using persisten banking and they usually carry more than twenty full bags of different stuff along with full inventory. And there is a script in OnEnter that removes all temporary item properties from all items - and its fine.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Inventory Searches
« Reply #6 on: December 10, 2011, 07:24:42 am »


               I did a quick test.  The position in the enventory has no effect on the order the items are returned.  Moving the items in the inventory does not change the order they are returned in.  Moving items in and out of bags in the inventory does change the order however.  

If you really wanted to worrie about how fast the items are found and you are using the GetFirst/next method  you could add a SerachCount  to your search for the item.   If the SearchCount went over say 20 items.   Recreate the item in there inventory and create a new one.  that would keep the items towards the tio of the loop.  It would however move the item around in the PC inventory, Something that they just might not like.