Feature enhance the put_display command to handle shelves

QVamp

Member
Using the ash command put_display(qty, item), it would be great if it also could take an optional shelf too.
 

Veracity

Developer
Staff member
How do you imagine that would work?

In the KoL browser interface, you can add or remove an item to the display with a single request. KoL will put it on (or take it from) which ever shelf you have put that kind of item on to.

If you want to move a particular kind of item from one shelf to another, you get to go to another screen in which you move ALL of your items to their desired shelf.

Note that put_display doesn't even require visiting the display case to know which shelf the item will end up on; it puts it "in the collection" and later, if you refresh the display (in order to remove something, for example), it will find where it ended up. There are issues associated with it, as described in another bug report which happens to be next in line on my to-do list, but until visiting the display, KoLmafia doesn't evn know which shelves you have.

Now, I wish you could have the same item on multiple shelves (to separate items I have received as a gift from those I bought, for example), and I wish KoL itself had an interface to put items on to particular shelves, but I seriously doubt if that will ever happen - and, until then, this Feature seems like a non-starter.
 

Darzil

Developer
It has been mentioned a couple of times on the radio show that the display may be one of the systems that CDM might be assigned to improve. So I think it may happen, but who knows when !
 

QVamp

Member
Veracity, I'm not sure I understand your question. Are you asking me the exact commands to make this work? I don't have that level of detail, but at a higher-level, I guess I was imagining that the command would change to put_display(1, myitem, myshelf1) or just put_display(1, myitem, 1), indicating to use the first shelf.

I have no idea if you'd need to go to a different page to do it, or if that's just the UI they put around a call that could be made from anywhere. I would hope if not, kol would give feedback as to whether or not that shelf exists.

Your idea of putting the same item on different shelves is similar to mine. I really would like to tag my items, instead of directly shelving them. That way I could tag something as 'crimbo 2012' AND 'food', or some such. I had thought about requesting that as a new feature in kol... but I have no idea how one does that.
 

Darzil

Developer
Most people suggest things for KoL by asking a radio question.

We pretty much only use the same commands as are sent when using the relay browser, apart from a few lookups added to make things more efficient by KoL. So in order to be able to do something automatically in KoL, it needs to be possible to do it in the browser, we also have to think about edge cases.

We generally try to avoid too many server hits, for performance reasons and for reducing impact of KoLmafia on KoL servers. We know that generating too many won't be popular with those running the actual game.

In this case, the most efficient way to (currently) move items to a specific shelf is to move items to the display case one at a time, then transfer them to the shelf in a batch. If any of the items are already in the display case, they'll automatically end up wherever they were, and if you're transferring them to a shelf they'll all move there instead. So whilst your command looks clean, because of how KoL handles the display case, it'd nearly double the required number of network and database transactions when moving large numbers of items to a particular shelf compared to moving them into the display case then moving them to the shelf in a batch.
 

Veracity

Developer
Staff member
Veracity, I'm not sure I understand your question. Are you asking me the exact commands to make this work? I don't have that level of detail, but at a higher-level, I guess I was imagining that the command would change to put_display(1, myitem, myshelf1) or just put_display(1, myitem, 1), indicating to use the first shelf.
My point was that KoL does not let you choose where to put an item.

- If you do not already have the item in the case, it goes onto the first shelf.
- If you do already have the item in the case, it goes into the shelf it is already on.

In order to put an item onto a specific shelf that it is not already on, you have to put it into the case (request #1) and then move it to the other shelf (request #2) - which will move ALL of the items of that sort to the new shelf, not just the number you just inserted.

Perhaps what is really needed, given how the display case works, is better shelf support.
- a function to get an array of shelves
- a function to return the shelf number that a particular item is on
- a function to move an item from one shelf to another.

The problem with the last one is that, although it would work, KoL allows you to move all of your items at once, if you wish, which is obviously more efficient than the "one item at a time" approach. So, presumably we'd need bulk functions which would get ALL the items and shelves and let you rearrange them en masse.

Probably easier (for us) to let the rare script that needs to do something like that code it up itself using visit_url().

I understood the function you were requesting. I was just pointing out that the display case itself does not work the way you want it to. If we provided put_display( count, item, shelf) implemented in terms of put_display( count, item) followed by move_displayed_item( item, shelf), I fully expect that people who don't understand the underlying limitation will complain that when they put the same item on shelf #1 and then on shelf #2, all the items ended on shelf #2.

NOT adding a "shelf" parameter to put_display, and instead adding, say, move_displayed_item, might eliminate that bug report waiting to happen. But, as I said, it's less efficient than KoL itself, if you will be moving lots of items.
 

QVamp

Member
resurrecting this thread... did anything every come from this? Or is there any workaround that people can think of?
 

heeheehee

Developer
Staff member
Code:
string [int] get_shelves() {
       string [int] ret;
       matcher m = create_matcher('name=newname(\\d+) value="([^"]*)"', visit_url("managecollection.php"));
       while (m.find()) {
       	     ret[m.group(1).to_int()] = m.group(2);
       }
       return ret;
}

void move_displayed_items(int [item] targets) {
     string str = "managecollectionshelves.php?pwd=" + my_hash() + "&action=arrange";
     foreach it, shelf in targets {
     	     str += "&whichshelf" + it.to_int() + "=" + shelf;
     }
     visit_url(str);
}

void move_displayed_item(item it, int shelf) {
    visit_url("managecollectionshelves.php?pwd=" + my_hash() + "&action=arrange&whichshelf" + it.to_int() + "=" + shelf);
}
 
Top