Feature Allow discarding of things with a discard link

> discard * fistful of ashes

Unable to invoke discard

This ought to work, but doesn't. For that matter...

> discard fistful of ashes

Unable to invoke discard

:(
 

Catch-22

Active member
Okay. I looked into this, and I learned something new. For starters, discard is actually different to smashing a huge pumpkin. Smashing a huge pumpkin indeed does appear to be an alternate form of inv_use.php (which is why I proposed an altuse command). Discard, on the other hand, is a completely separate inventory action altogether.

Secondly, I learned you can actually discard pretty much anything in your inventory that isn't marked as "Cannot be discarded" (funny about that). I haven't tried discarding an IotM (any takers?) but most (if not all) appear to be marked "Cannot be discarded" anyway.

I haven't attempted to discard any of the quest items that are not marked as "Cannot be discarded", of which there seems to be a few in the nemesis quests, but I currently have none to test this with.

I can also confirm that you can only discard a single item at a time (such as 1 useless powder at a time).

So the million meat question, do we open Pandora's Box and create a "discard" command that can be used for all discardable items?
 

Veracity

Developer
Staff member
Why not? I have the following script:

Code:
void discard_useless_powder( int n )
{
    for i from 1 to n
    {
        print( "Discarding useless powder (" + i + " of " + n + ")" );
        visit_url( "inventory.php?which=3&action=discard&pwd&whichitem=1437" );
    }
}

void main( int n )
{
    discard_useless_powder( n );
    print( "You have " + item_amount( $item[ useless powder] ) + " left." );
}
which I have used now and then. Doing it with a cli_execute( "discard" ) rather than a visit_url() seems cleaner.
 

Catch-22

Active member
Just wanting some explicit clarification here, should we be allowing players to discard things that do not have a discard link in the KoL interface? Veracity, your example script is something that can already be discarded via KoL.

Personally, I don't mind, but I know someone might be pissed off if they accidentally fell on their keyboard and typed "discard Tiny Plastic Sword" into the CLI.
 

Bale

Minion
Why not? I have the following script:

Code:
void discard_useless_powder( int n )
{
    for i from 1 to n
    {
        print( "Discarding useless powder (" + i + " of " + n + ")" );
        visit_url( "inventory.php?which=3&action=discard&pwd&whichitem=1437" );
    }
}

void main( int n )
{
    discard_useless_powder( n );
    print( "You have " + item_amount( $item[ useless powder] ) + " left." );
}
which I have used now and then. Doing it with a cli_execute( "discard" ) rather than a visit_url() seems cleaner.

You should add &ajax=1 to that visit_url() to reduce the server hit in which case which=3 becomes pretty irrelevant. To discard with OCD I do this:

PHP:
visit_url("inventory.php?action=discard&pwd&ajax=1&whichitem="+to_int(it));

It would be nice to have an actual discard command.
 
Last edited:

roippi

Developer
Personally, I don't mind, but I know someone might be pissed off if they accidentally fell on their keyboard and typed "discard Tiny Plastic Sword" into the CLI.

Or "discard tips" and fuzzy matching throws it away. Assuming that it can be thrown away; if not, insert other horrifying example.

Um.. I don't know? If we do add it, we should check for a autosell value > 0, and just print an error message (and do nothing) if so.
 

Bale

Minion
I'm pretty sure that it isn't possible to discard an item that lacks a discard link. Besides autosell is already nearly the same thing and it never seems to be a problem.
 

Veracity

Developer
Staff member
Regarding ajax:

The modification date of that script is Dec 7, 2007. I don't think CDM was on the KoL team, back then, and I don't think we had ajax back then to make page loads not include the whole inventory page. But, yes - now thtat we do, certainly we should include &ajax=1.

Regarding discard links:

KoLmafia has nothing in its data files to say which items have discard links and which do not. I say, let users (try to) discard anything they want. It either makes sense - and works - or doesn't make sense - and doesn't work.
 

Catch-22

Active member
I'm pretty sure that it isn't possible to discard an item that lacks a discard link.

I thought I had made it clear but, yes, it is possible. Try it yourself, I discarded wads of dough among other things.

Or "discard tips" and fuzzy matching throws it away. Assuming that it can be thrown away; if not, insert other horrifying example.

Yeah, this is what I was more or less getting at given that it's pretty unlikely you'd fall on your keyboard and accidentally discard something you wanted to keep, see also.

I'm still not entirely sure where people stand on this one. Roippi at least seems to understand my concerns.

Edit:

Um.. I don't know? If we do add it, we should check for a autosell value > 0, and just print an error message (and do nothing) if so.

Actually now that I think about it, I think you are exactly right. It would seem to me that the only reason discard links are on those items is because they are worthless to an NPC. I guess the other possible solution would be to patch the autosell command so that it will discard a worthless item instead. ie. "autosell useless powder" internally translates to discard useless powder.
 
Last edited:

Veracity

Developer
Staff member
If you can discard something with an autosell price of zero, report the bug to KoL and ask for it to be returned. If you discard something with an autosell price and no discard link, well, tough. Why is that something to worry about? If it hurts when you do that, well, stop doing that!

Or, perhaps you have some other "concern". Can you elaborate, please?
 

Catch-22

Active member
If you can discard something with an autosell price of zero
I think this is the whole point of discarding items, see above edit.

If you discard something with an autosell price and no discard link, well, tough. Why is that something to worry about? If it hurts when you do that, well, stop doing that!

Or, perhaps you have some other "concern". Can you elaborate, please?

Well if KoLmafia does "clever things" like purchases ingredients to make an item if it's cheaper than buying the item, one would think that autoselling an item with value instead of discarding it would also be a "clever thing" to do, but then we could just repurpose the autosell command to discard anything of no worth.
 
Actually now that I think about it, I think you are exactly right. It would seem to me that the only reason discard links are on those items is because they are worthless to an NPC. I guess the other possible solution would be to patch the autosell command so that it will discard a worthless item instead. ie. "autosell useless powder" internally translates to discard useless powder.

While this seems right from a conceptual perspective, it also seems obscure/confusing for users (not that that's stopped kolmafia in the past... :)). The best solution is probably both (a discard command that errors out if autosell > 0, and autosell discarding objects that have no autosell), but in lieu of that my vote, for what it's worth, is the former (a discard command that errors if autosell > 0).
 

Veracity

Developer
Staff member
I think this is the whole point of discarding items, see above edit.
I just love it when people edit their posts after I have responded to them and change the meaning such that my response no longer makes any sense. Not.

So the idea is that anything with an autosell value of zero and no "cannot be discarded" tag can/should be discarded. Otherwise, it should be autosold?

We need a "no discard" flag associated with items in our database. Presumably, in tradeitems.txt. Somewhere.

It should not be hard to modify DebugDatabase (which has code to parse item descriptions) to generate that flag as appropriate, for easy(ish) data file updating.
 

Fluxxdog

Active member
So the idea is that anything with an autosell value of zero and no "cannot be discarded" tag can/should be discarded. Otherwise, it should be autosold?
That would seem the best idea. KoL has built in protection for discarding non-discardable items. Anything worth meat should be autosold. Even in Fistcore, if you sell something, there's a benefit for the trophy. (Which reminds me, I still need to get that.)
 

heeheehee

Developer
Staff member
note: TPS and many other relatively expensive items having the "cannot be discarded" flag. Presumably this means you also cannot discard them via URL manipulation,

However, if anything has an autosell price, it can be discarded (I think).
 

Catch-22

Active member
I just love it when people edit their posts after I have responded to them and change the meaning such that my response no longer makes any sense. Not.

This wasn't intentional. It must've taken my 3 minutes to edit the post, because there were no new posts when I clicked edit.

We need a "no discard" flag associated with items in our database. Presumably, in tradeitems.txt. Somewhere.

Yeah, I made a separate FReq for this one, it needs to be done first.

It should not be hard to modify DebugDatabase (which has code to parse item descriptions) to generate that flag as appropriate, for easy(ish) data file updating.

I feel so dirty scraping every item on the KoL database, but I guess it needs to be done :)

However, if anything has an autosell price, it can be discarded (I think).

Well, technically speaking, anything which doesn't have "cannot be discarded" in the description, can be discarded. It happens to be that just about every item with an autosell price can also be discarded :)
 
Top