cold medicine cabinet scripting

esko

New member
Hi all. I'm having an issue figuring out how to script the cold medicine cabinet. I realize I can check the properties to see how many pulls I have left and that isn't a problem but figuring out how to redeem an item from the medicine cabinet is giving me a bit of an issue. Any suggestions?
 

VladYvhuce

Member
I just know that there's different conditions for how you get stuff on the variable things, like food/booze/spleen/potion. Fleshizol may be particularly difficult if you don't have access to underwater adventuring, for example.
 
Hi all. I'm having an issue figuring out how to script the cold medicine cabinet. I realize I can check the properties to see how many pulls I have left and that isn't a problem but figuring out how to redeem an item from the medicine cabinet is giving me a bit of an issue. Any suggestions?
Here is how garbo handles it, where it picks the most valuable item from the cabinet (and it always considers Extrovermectin because it spends lots of turns indoors, and so it knows it will be available to pick up later)

This is not ash, but typescript, and it is typescript using the libram library which adds in some additional features, but I think the point gets across.


JavaScript:
function coldMedicineCabinet(): void {
  if (getWorkshed() !== $item`cold medicine cabinet`) return;

  if (
    property.getNumber("_coldMedicineConsults") >= 5 ||
    property.getNumber("_nextColdMedicineConsult") > totalTurnsPlayed()
  ) {
    return;
  }
  const options = visitUrl("campground.php?action=workshed");
  let i = 0;
  let match;
  const regexp = /descitem\((\d+)\)/g;
  const itemChoices = new Map<Item, number>();
  if (!globalOptions.noBarf) {
    // if spending turns at barf, we probably will be able to get an extro so always consider it
    itemChoices.set($item`Extrovermectin™`, -1);
  }

  while ((match = regexp.exec(options)) !== null) {
    i++;
    const item = descToItem(match[1]);
    itemChoices.set(item, i);
  }

  const bestItem = argmax(Array.from(itemChoices.keys()).map((i) => [i, mallPrice(i)]));
  const bestChoice = itemChoices.get(bestItem);
  if (bestChoice && bestChoice > 0) {
    visitUrl("campground.php?action=workshed");
    runChoice(bestChoice);
  }
}
 

esko

New member
Here is how garbo handles it, where it picks the most valuable item from the cabinet (and it always considers Extrovermectin because it spends lots of turns indoors, and so it knows it will be available to pick up later)

This is not ash, but typescript, and it is typescript using the libram library which adds in some additional features, but I think the point gets across.


JavaScript:
function coldMedicineCabinet(): void {
  if (getWorkshed() !== $item`cold medicine cabinet`) return;

  if (
    property.getNumber("_coldMedicineConsults") >= 5 ||
    property.getNumber("_nextColdMedicineConsult") > totalTurnsPlayed()
  ) {
    return;
  }
  const options = visitUrl("campground.php?action=workshed");
  let i = 0;
  let match;
  const regexp = /descitem\((\d+)\)/g;
  const itemChoices = new Map<Item, number>();
  if (!globalOptions.noBarf) {
    // if spending turns at barf, we probably will be able to get an extro so always consider it
    itemChoices.set($item`Extrovermectin™`, -1);
  }

  while ((match = regexp.exec(options)) !== null) {
    i++;
    const item = descToItem(match[1]);
    itemChoices.set(item, i);
  }

  const bestItem = argmax(Array.from(itemChoices.keys()).map((i) => [i, mallPrice(i)]));
  const bestChoice = itemChoices.get(bestItem);
  if (bestChoice && bestChoice > 0) {
    visitUrl("campground.php?action=workshed");
    runChoice(bestChoice);
  }
}
This will work! Thank you!
 
Top