Page 1 of 1

ListRootItemsInContainer(container)

Posted: Thu Sep 14, 2006 11:22 am
by Developer Silver
We think this could be usefull... or at least fast :P
A function to obtain items (array of UObject) placed directly in the container passed as parameter... like EnumerateItemsInContainer() without sub-container items :D

Even if this can done with a simple eScript function, POL core should certainly be much faster... especially if container has many items... ;)

Posted: Thu Sep 14, 2006 3:08 pm
by Austin
Script it. Not everything is going to be put in the core.

Even though you most likely already know how to do it... for others and future requests:

Code: Select all


function ListRootItemsInContainer(container)
     var item_list := array;
     foreach item in ( EnumerateItemsInContainer(container)
          if ( item.container == container )
               item_list.Append(item);
          endif
          SleepMs(2);
     endforeach
     
     return item_list;
endfunction

Im going to coin the new term:

'Scriptaphobe' -A fear of scripting because everything (even 1+1) takes up too many cycles.

If everything was desired to be hardcoded into the executable for speed, wouldn't UOX still be on top?

Posted: Thu Sep 14, 2006 3:38 pm
by Developer Silver
No problem... we have that function from years, but I've seen that cycling through many many items in a container can slow things down, and I was thinking that reducing number of analyzed items could help system performance...
Never mind... :)

Posted: Thu Sep 14, 2006 6:13 pm
by MuadDib
Firstly, unless it's just skeery as hell, containers usually have set max items to 125. By skeery, i mean, you make it something like 1234823402342 max items (GOD HELP ME).

And a search, with a sleepms(2) should go very fast anyway.

Posted: Fri Sep 15, 2006 1:22 am
by Developer Silver
Even if max items is 125, a container with many subcontainers, with many subcontainers, ... results in a large array, no? :?

Anyway... just one last thing...

No new function, but what about adding a flag to EnumerateItemsInContainer()?
As ENUMERATE_IGNORE_LOCKED, something like ENUMERATE_IGNORE_SUBCONTAINERS...
Useless like above suggestion? :P

I thought it was fast to implement... if not, never mind, I'll go on as usual and I'll post other suggestions :D

Posted: Fri Sep 15, 2006 2:04 am
by Austin
Its still recursive... so if you have a container in a container, and insert something lower, it still counts towards the top... so you never go over the max item amount.

Example using MuadDib's standard backpack layout
The parenthesis shows its item count.

Code: Select all

  *BACK PACK* (6)
      *BAG* (5)
         *LOCKED STRONGBOX* (4)
            - Thong panties
            - Underwire bra
            - Wild Turkey bottle
            - Book titled "Lipstick on Sheep"

Posted: Fri Sep 15, 2006 3:17 am
by Austin
A flag for just that container could be fair..
ENUMERATE_ROOT_ONLY

The POLitburo will put your request into the queue and process it when the resources to do-so are available.

Posted: Fri Sep 15, 2006 3:21 am
by DeiviD
ignore locked wouldnt be bad too ;)

Posted: Fri Sep 15, 2006 3:23 am
by Austin
That flag already exists.