Closeting Quest Items - ClosetQuest v0.8

muffins

Member
This is mostly for hardcore players and people who are super picky about keeping their inventory neat and clean...

What it does, essentially, is place (mostly NS) quest items in your closet as you come across them. In the case of items that require combination to be made, it will closet the individual items separately, then, when you can create the item(s), it will pull the individual items*, make the item(s), and place the item(s) in your closet.

It's still a work in progress, but I've semi-tested it with my main and my HCO characters and what few items they have by removing the quest items and/or the quest item's respective "parts" and it seems to work fine.

Why I made this: Well, the aforementioned pickiness, for one, but also because this makes it a lot easier to add certain items to the "junk" list without having to worry if I'm accidentally autoselling, for example, the only lowercase n I came across, or something.

Notes:
- This is (mostly) untested.
- It includes a bit for the pretentious artist quest, but only in the sense that, if you come across a piece or two by accident, it'll move 'em out of the way, to your closet, and if you have all the items, it'll turn 'em in, as well as pulling and selling any rat whiskers you might have.
- The functions are all sorted alphabetically, but the order in which things are done is: PA quest (see above, was only listed first for ease of commenting out if needed), the "smurf" (heh), the bean for the stalk, the REQUIRED keys, the instruments or parts of instruments**, the entryway items, the castle map items, RPPs for the shadow***, and the tower items.



* You must have the option to check the closet for ingredients enabled... I was too lazy to go in and write the extra bits for pulling stuff out.

** I only included the guitarrr, a broken skull, and the basic accordion here, because a) I figured the only reason you would have the parts for the stone banjo would be so you could make it at the time of being in the entryway, b) you already have a skeleton bone available to you from untinkering the skeleton key after using it, and c) if you HAVE a RnR legend, chances are you have that in your inventory for frequent use anyway.

*** Yeah, I still don't have funkslinging... comment the closet_red_pixel_potion(); line out of the closet_quest() function if you do.
I've added a check for this one. If you have Funkslinging, it won't bother to try to make the potions. I also changed this section of code back to my original version, which is ever so slightly more server friendly.

All comments, questions, suggestions, and optimizations are welcome!

Edited to add a title to the script... and a new version! ;) also, sorry for the insane amount of edits. I keep realizing I did something in... not the best way, heh.

Edit 0.6: Hopefully fixed the closet_candy function. No characters to test on at the moment, but we'll see... also fixed the NG/Wand functions so they shouldn't constantly closet all lowercase n's, only up to the amount needed.

Edit 0.7: Fixed a closing ).

Edit 0.8: Fixed a stupid item mixup type thing for the wand function... there's no G in there! I can't believe it took me so long to look into this again and fix it, especially since I'd been wondering why I had spares of certain letters and none of others! There may be other changes in there, but... I dunno, this is the only one I know of!
 

Attachments

  • closetquest.ash
    12.8 KB · Views: 93

macman104

Member
Re: Closeting Quest Items

You have many thank yous from me for doing the legwork for this script, I even have one semi-started, but far from complete. What would make this script, even doubly useful, would be to have a boolean variable in main, that true would be to print what you need. That'd be spiffilicious.
 

muffins

Member
Re: Closeting Quest Items

Hmm, I recall there being something like that already... hold on... ah, here http://kolmafia.us/index.php/topic,104.0.html

I'm not quite sure if that's what you were looking for, and in fact, I'd forgotten that it did closeting as well... hrm... well, mine makes stuff, too! :p

I'll consider adding in a reporting function, but it'll prolly come a bit later, if ever, 'cause even though I did this all in one evening, it was still a pain in the ass, and I imagine will be even moreso on the report creating side of things, heh.




Changes made to the script:

- It has a title!
- It has a version number!
- It now checks to see if you have Funkslinging so you don't "waste" pixels. I may let this be user configurable, though, if people would prefer that.

One more thing on the subject of pixels I feel I should mention is that currently, if you do not have the digital key, and you do not have 30 white pixels needed to make the digital key, it will attempt to make as many white pixels as possible (up to 30). At least, this is how it should work. This part is untested, but that is how it SHOULD work... now. If you have version 0.0-0.3, I'd recommend upgrading to 0.4, 'cause I forgot to add the math that actually checks how many white pixels you have and only makes 30 minus that number. Ugh. This should work as intended now.

I tested it out a tiny bit in the PFA on my main last night, and it did indeed correctly move the photoprotoneutron torpedo (I didn't find an A, bleh)... I'll test the pixels bit soon.

I'm considering adding something like 10 "custom" items that the user can elect to have all of moved to their closet... again, if there is enough of a "demand" for this, I'll add it!

[red]( zomg no doubel post plz! -Daychilde [this is my new attempt at making some mod notes funny, btw... ;-) ])[/red]

Edit: Meep! Sorry, Daychilde, I won't do it again! plz4givekthx (Edited just to remove the double post comment now that it isn't a double post, and to apologize) ;)

Edit the Second: I'll be adding sections for Richard's Star Key, star hat, and star pants sometime tomorrow. I knew I'd forget something. Otherwise, I've been using this script pretty regularly and it works like a charm so far!
 

muffins

Member
Re: Closeting Quest Items - ClosetQuest v0.4

I hope this doesn't count as one again... been over a month :p

I've run into a few problems with this script so farm, mainly being the all-purpose closet_candy function, which, if it doesn't find candy a OR candy b OR candy c in your closet, will attempt to closet candy a, b, or c, if you have one in your inventory. This ends up closeting ALL of EVERY type of candy it comes across, and I've tried using + instead of ||, but it doesn't fix it... can anyone suggest an improvement to that section, please?
 
Re: Closeting Quest Items - ClosetQuest v0.4

ZOMG!! That if statement is hard to read:
Your source:
Code:
void closet_candy() {
if(closet_amount($item[tasty fun good rice candy]) < 1 || closet_amount($item[angry farmer candy]) < 1 || closet_amount($item[marzipan skull]) < 1 && item_amount($item[tasty fun good rice candy]) < 1 || item_amount($item[angry farmer candy]) < 1 || item_amount($item[marzipan skull]) < 1) {
if(item_amount($item[tasty fun good rice candy]) >= 1) { put_closet(1, $item[tasty fun good rice candy]); }
if(item_amount($item[angry farmer candy]) >= 1) { put_closet(1, $item[angry farmer candy]); }
if(item_amount($item[marzipan skull]) >= 1) { put_closet(1, $item[marzipan skull]); }
}
}

Try this:
Code:
boolean Have_candy_closeted()
  {
  if(closet_amount($item[tasty fun good rice candy]) >= 1) {return true;}
  if(closet_amount($item[angry farmer candy]) >= 1) {return true;} 
  if(closet_amount($item[marzipan skull]) >= 1) {return true;} 
  return false;
  //ditch the inventory check.
  }

Code:
void closet_candy() 
  {
  if(!Have_candy_closeted())
    {
    if(item_amount($item[tasty fun good rice candy]) >= 1) 
      {put_closet(1, $item[tasty fun good rice candy]);}
      else
      {
      if(item_amount($item[angry farmer candy]) >= 1) 
        {put_closet(1, $item[angry farmer candy]);}
        else
        {
        if(item_amount($item[marzipan skull]) >= 1) 
          {put_closet(1, $item[marzipan skull]);}
        }
      }
    }
  }

That should do it.

Edit:
To simplify the function even more:
Code:
boolean closet_candy()
  {
  if(Have_candy_closeted()) {return true;}
  if(put_closet(1, $item[tasty fun good rice candy]) {return true;}
  if(put_closet(1, $item[angry farmer candy]) {return true;}
  if(put_closet(1, $item[marzipan skull]) {return true;}
  return false;
  }
this takes advantage of the fact that as soon as kolmafia executes a return command, it exits the current function with the result indicated so the rest of the function never executes. saying "return true" is saying "I'm done processing the result is true." You don't have to use the return value anywhere in your script.


Finally The actual problem broke down:
if(closet_amount($item[tasty fun good rice candy]) < 1
|| closet_amount($item[angry farmer candy]) < 1
|| closet_amount($item[marzipan skull]) < 1
&& item_amount($item[tasty fun good rice candy]) < 1
|| item_amount($item[angry farmer candy]) < 1
|| item_amount($item[marzipan skull]) < 1)

you need to evaluate that statement. if "item_amount($item[marzipan skull]) < 1)" returns true, the whole statement evaluates to true. so if you do not have any marzipan skulls in your inventory the code following is executed. The same applies for "item_amount($item[angry farmer candy])", "closet_amount($item[angry farmer candy]) < 1", "closet_amount($item[tasty fun good rice candy]) < 1".

"closet_amount($item[marzipan skull]) < 1
&& item_amount($item[tasty fun good rice candy]) < 1"
is handled differently. Say you have no marzipan skulls, but have tasty fun good rice candy this evaluates to: "if true && false" which evaluates to false. This goes into operator precedence. I think you wanted:

if(closet_amount($item[tasty fun good rice candy]) < 1
|| closet_amount($item[angry farmer candy]) < 1
|| closet_amount($item[marzipan skull]) < 1)
{
if (item_amount($item[tasty fun good rice candy]) < 1
|| item_amount($item[angry farmer candy]) < 1
|| item_amount($item[marzipan skull]) < 1))
{
//code to execute here
}
}
but that would not work either. I think you used the less than operator when you meant to use the greater than or equal to operator. It would also execute the planned action if you don't have 1 of each candy in your closet. I believe you only want 1 piece of candy not caring which one. If I keep going with the cleanup I end up right back here:

Code:
boolean Have_candy_closeted()
  {
  if(closet_amount($item[tasty fun good rice candy]) >= 1) {return true;}
  if(closet_amount($item[angry farmer candy]) >= 1) {return true;} 
  if(closet_amount($item[marzipan skull]) >= 1) {return true;} 
  return false;
  //ditch the inventory check.
  }

boolean closet_candy()
  {
  if(Have_candy_closeted()) {return true;}
  if(put_closet(1, $item[tasty fun good rice candy]) {return true;}
  if(put_closet(1, $item[angry farmer candy]) {return true;}
  if(put_closet(1, $item[marzipan skull]) {return true;}
  return false;
  }
 

Nightmist

Member
Re: Closeting Quest Items - ClosetQuest v0.4

Heh since you already rewritten the function a simple edit to make it work is semi-redundant but having a look at that section of code I get the feeling the "closet_amount()" functions should be &&ed together not ||ed. Stick brackets around the "item_amount()" functions, and change the "<" to ">=" in the "item_amount()" functions, resulting in this:

Code:
 if( closet_amount($item[tasty fun good rice candy]) < 1 && closet_amount($item[angry farmer candy]) < 1 && closet_amount($item[marzipan skull]) < 1 && (item_amount($item[tasty fun good rice candy]) >= 1 || item_amount($item[angry farmer candy]) >= 1 || item_amount($item[marzipan skull]) >= 1))
Effectively it runs as: "Do I need to put any candy in my closet (the first 3 ifs), do I have any candy on hand (The next 3 ifs in the brackets)

Edit: Thats assuming you only want 1 of the candies. Not to mention you could just cut out the end part into this:
Code:
 if( closet_amount($item[tasty fun good rice candy]) < 1 && closet_amount($item[angry farmer candy]) < 1 && closet_amount($item[marzipan skull]) < 1)
Because the checks for the items is "repeated" for each item separately. You might want to if-else those separate candy checks though since it might end up putting 1 of each into the closet... (Like the "closet_candy()" function efilnikufecin posted.)
 

muffins

Member
Re: Closeting Quest Items - ClosetQuest v0.6

Okay, I tried Nightmist's suggestion, mostly just 'cause it kept with the format I used in all the other functions and didn't need to introduce a new one... also fixed the accidental less than instead of greater than for marzipan skull. Also fixed a similar issue with lowercase n's being "overclosetted", heh.

Nothing to test with at the moment, but I'll keep running this and see how it holds up. Looks like it should work fine, now.

Thanks for the help, guys!
 
Top