Clovers (was Chatbot)

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
If you ask chatbot "Does the Hermit have clover today?" he will reply and tell you if today is a clover day. One could then combine that with something like
Code:
buy hermit permit
hermit clover
use ten-leaf clover
and then put that into the breakfast script.

But how do you make a conditional script based on a response in IM?

Gausie
 

Metraxis

Member
Re: Chatbot

On the other hand, a change to the 'hermit' behavior which actually revealed the number of clovers available that day would not be amiss, methinks.
 
Re: Chatbot

No need asking chatbot.
You must have a worthless item and access to the hermit via hermit permit or quest completion.

Code:
int kiss_clovers_in_stock()
{
string source = visit_url("hermit.php");
if(contains_text(source, "(1 left in stock for today)")){return 1;}
if(contains_text(source, "(2 left in stock for today)")){return 2;}
if(contains_text(source, "(3 left in stock for today)")){return 3;}
if(contains_text(source, "(4 left in stock for today)")){return 4;}
if(contains_text(source, "(5 left in stock for today)")){return 5;}
if(contains_text(source, "(6 left in stock for today)")){return 6;}
return 0;
}

it's called kiss_clovers_in_stock as a reminder to me. Instead of trying to read the number from the source and return it, this is much simpler. Kiss means "keep it simple stupid"

Fixed an omission in the script function
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
Hmm... thats really useful...

I'm not a very good coder, but could you make a script that checked whether you had a hermit permit, if not go and buy one (with money from your person, or from your closet), then check for clovers, then get all the clovers with the standard "loot the hermit" script?

Gausie
 
Does things the way I do them. Copy pasted from a pre-written script, and "void main()" added for simplicity.

Code:
boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");

int kiss_clovers_in_stock()
  {
  string source = visit_url("hermit.php");
  if(contains_text(source, "(1 left in stock for today)")){return 1;}
  if(contains_text(source, "(2 left in stock for today)")){return 2;}
  if(contains_text(source, "(3 left in stock for today)")){return 3;}
  if(contains_text(source, "(4 left in stock for today)")){return 4;}
  if(contains_text(source, "(5 left in stock for today)")){return 5;}
  if(contains_text(source, "(6 left in stock for today)")){return 6;}
  return 0;
  }

void get_hermits_clovers()
  {
  //deal with hermit permits if quest status forces using them
  if(haxored)
    {
    if(closet_amount($item[hermit script]) > 0){take_closet(1, $item[hermit script]);}
    if(item_amount($item[hermit script]) > 0){use(1, $item[hermit script]);}
    }
    else
    {
    if(item_amount($item[hermit permit]) < 6)
      {
      buy(6 - item_amount($item[hermit permit]), $item[hermit permit]);
      }
    }
  
  //deal with worthless items.
  while(item_amount($item[Worthless trinket]) + item_amount($item[Worthless gewgaw]) + item_amount($item[Worthless knick-knack]) < 6)
    {
    if(haxored)
      {
      retrieve_item(1, $item[31337 scroll]);
      use(1, $item[31337 scroll]);
      }
      else
      {
      cli_execute("acquire 6 worthless item");
      }
    }
  
  int cloves = kiss_clovers_in_stock();
  if(cloves > 0)
    {
    cli_execute("hermit " + cloves + " ten-leaf clover");
    }

  }
  
void main()
  {
  get_hermits_clovers();
  }

this script is designed to be ran daily, and you will have extra hermit permits (if not haxored) most of the time. They will be used later by the script, and should never be more than 7. If you are haxored then you will see extra worthless items in inventory most of the time. Again they will be used by the script later, and should not be a mass amount.

(fixed a typo in the script)
 

dangerpin

Member
Code:
boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");

Even though my questlog contains that exact string, it still seems to think I haven't completed the quest and starts trying to make the 31337 scrolls.

I'm still used to the CLI interface and am not quite sure how to troubleshoot the ash scripts, as they don't give me the kind of feedback I am used to. Any ideas?
 
The script makes and uses 31337 scrolls to obtain worthless trinkets if the quest is completed. If the quest is not completed, it tries to complete the quest and continue. It is designed to fail if you are the correct level for the quest, but haven't taken the adventuring steps to complete the quest. The failure when imported into another script should fail the importing script too. This way when called before adventuring you may manually complete the adventuring steps (get an abridged dictionary and untinker it). If you are not high enough level, the script reverts to kolmafia's internal handling to obtain the worthless items, and buys hermit permits for hermit access.

In simple terms, it doesn't think you have not completed the quest, it is obtaining worthless items my way which normally ends up with an extra (or more than 1) clover and doesn't use adventures.[br]Posted on: January 24, 2007, 06:20:20 PM
Here is a log of todays daily run of the script:

Code:
Verifying ingredients for 31337 scroll... 
Searching for items... 
Purchasing 30669 scroll (1 @ 299)... 
You acquire an item: 30669 scroll 
Purchases complete. 
Verifying ingredients for 668 scroll... 
Searching for items... 
Purchasing 334 scroll (2 @ 2,500)... 
You acquire 2 334 scrolls 
Purchases complete. 
Creating 668 scroll (1)... 
You acquire an item: 668 scroll 
Successfully created 1 668 scroll 
Creating 31337 scroll (1)... 
You acquire an item: 31337 scroll 
Successfully created 1 31337 scroll 
Using 31337 scroll... 
You acquire an item: worthless gewgaw 
You acquire 2 worthless knick-knacks 
You acquire 2 ten-leaf clovers 
Finished using 1 31337 scroll. 
Verifying ingredients for 31337 scroll... 
Creating 1 meat paste... 
You acquire an item: meat paste 
Searching for items... 
Purchasing 30669 scroll (1 @ 299)... 
You acquire an item: 30669 scroll 
Purchases complete. 
Verifying ingredients for 668 scroll... 
Searching for items... 
Purchasing 334 scroll (2 @ 2,500)... 
You acquire 2 334 scrolls 
Purchases complete. 
Creating 668 scroll (1)... 
You acquire an item: 668 scroll 
Successfully created 1 668 scroll 
Creating 31337 scroll (1)... 
You acquire an item: 31337 scroll 
Successfully created 1 31337 scroll 
Using 31337 scroll... 
You acquire an item: worthless trinket 
You acquire an item: worthless knick-knack 
You acquire an item: ten-leaf clover 
Finished using 1 31337 scroll. 
Robbing the hermit... 
You acquire 4 ten-leaf clovers 
Hermit successfully looted! 
Using ten-leaf clover (7)... 
You acquire 7 disassembled clovers 
Finished using 7 ten-leaf clover. 
Script succeeded!
note I added code to disassemble the clovers as a form of clover protection. As you can see I gained 3 clovers from the scrolls, and the worthless items for the hermit. From the hermit I got 4 clovers.

Total clovers gained: 7
meat spent: 10,598
adventures used: 0
mall value of clovers today: 3,950 meat (ignoring limit X per day stores)
total value of clovers: 27,650
profits: 17,052 + (your average value of an adventure * number of adventures required to gain 6 worthless items)

as you can see, this script has making the most profits in mind.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
When I run the script I get this error...

Code:
No availiable namespace with function: boolean haxored = contains_text

Any help?

Gausie
 
obviously it's finding line 1 offensive.

Line1:
Code:
boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");

2 possibilities. 1 you have encountered a bug for the version you are using, or 2 the way kolmafia handles variable assignments has changed. Try removing line 1, and replacing with these 2 lines of code:
Code:
boolean haxored;
haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");
 
Top