Bug - Fixed chat_macro() and /chamoisgoagain

Ruby Eyes

Member
Searching didn't yield anything, so I guess I may be the first to stumble upon this ...

So, I've been doing >50 double-nodule runs manually, with the helps of 1 combat macro to escape or kill as appropriate, and 3 chat macros.
1st macro to just heal, 2nd to dress up for max ML and put a proper familiar, and 3rd macro to dress up like a wuss, put the barrrnacle, heal up and then do /chamoisgoagain which wipes off my slimy cheeks properly and drops me feet-first back into the tube.

Trigger text:
Code:
/outfit min ml && /fam barrr && /cast cocoon && /chamoisgoagain
Macro name is just "8" because I'm lazy.

So I tried to write an ash script, my first ever, but I fail miserably - even after I got it to "run."
All I tried to do was make a list of things that I do 37 times (in a row, yes) each time, and have mafia do that. No, don't point me to other people's slime scripts, that's not the point of this post at all, thanks.

At the start of the whole thing, I have this line:

Code:
chat_macro("/8");
The script appears to be calling macro 8, but somehow not really:
it changes my outfit as desired, it puts the barrrnacle and heals me up. But for some reason, it won't use the chamois and enter the tube.
When I refresh the relay browser after script execution, I see the new outfit, familiar, HP, but still only 4 turns of Coated in Slime.
(Luckily, I have a check for (have_effect($effect[Coated in Slime]) > 6) after this so the rest does not execute at all.)

This leads me to 2 conclusions:
1. chat_macro() does not actually just send the macro name to the chat and have the game execute it all ... could it be that it reads the trigger text and tries to do all the work itself? If so, why?
2. chat_macro() doesn't want to deal with a chat command that makes you spend an adventure, apparently. Of course, for now, /chamoisgoagain is the only game chat command of that type.

So ... how do I make mafia execute a chat macro as specified in the in-game macro listing? As in, completely?


edit to add: another macro ending with /chamois instead, and a visit_url to the slimetube to get my effect in the script works, so at least it's not *that* urgent for me.
Still, I think there is a tiny bit that may need a fixing at some point.
 
Last edited:

holatuwol

Developer
KoLmafia should just execute your chat macro as-is.

That being said, even if it executes it, if what your macro consists of is a bunch of chat commands, nothing actually happens server-side when the macro is submitted. This is because chat commands come back as *instructions* on what URLs to go back and request to actually achieve desired end-state.

KoLmafia recognizes a standard 'go visit this URL instruction', but the instructions for /chamoisgoagain are unconventional in that it also includes a Javascript callback (arbitrary Javascript to execute once the original request is complete). KoLmafia doesn't recognize the idea of having a callback (it assumed everything was just a URL), so when it saw this particular dojax(), it didn't bother executing anything.

PHP:
<font color=green>Grabbing a chamois... and diving back into the tube.<!--js(dojax('clan_slimetube.php?action=chamois&ajax=1&pwd=HASH',function() { top.mainpane.location.href="/adventure.php?snarfblat=203";});)--></font><br>

Changes added to r11297 make KoLmafia automatically parse any URLs in the callback and visit them as well, but ... I'm not sure that's the right way to fix it since technically KoLmafia is also swallowing the command that's supposed to make your web browser load the page (and thus maybe allow you to do some additional interaction), but I guess we can figure out what the 'right' way of fixing it is later.
 

Ruby Eyes

Member
KoLmafia should just execute your chat macro as-is.

That being said, even if it executes it, if what your macro consists of is a bunch of chat commands, nothing actually happens server-side when the macro is submitted. This is because chat commands come back as *instructions* on what URLs to go back and request to actually achieve desired end-state.
Well, something has to happen server-side, since my chat macros are stored server-side. But reading further down, I think you mean something else ...

KoLmafia recognizes a standard 'go visit this URL instruction', but the instructions for /chamoisgoagain are unconventional in that it also includes a Javascript callback (arbitrary Javascript to execute once the original request is complete). KoLmafia doesn't recognize the idea of having a callback (it assumed everything was just a URL), so when it saw this particular dojax(), it didn't bother executing anything.

PHP:
<font color=green>Grabbing a chamois... and diving back into the tube.<!--js(dojax('clan_slimetube.php?action=chamois&ajax=1&pwd=HASH',function() { top.mainpane.location.href="/adventure.php?snarfblat=203";});)--></font><br>
Oh tricky! (Honestly, I have no idea how ajax stuff really works, this scriptery is nothing I can get my head around yet. If you could teach this to me using Cobol, that might work for me :D)
So, if the aventuring bit is actually enclosed in what looks like some HTML comment, I'd probably have ignored such requests, too.

Changes added to r11297 make KoLmafia automatically parse any URLs in the callback and visit them as well, but ... I'm not sure that's the right way to fix it since technically KoLmafia is also swallowing the command that's supposed to make your web browser load the page (and thus maybe allow you to do some additional interaction), but I guess we can figure out what the 'right' way of fixing it is later.

So I'll try my macro with r11297 out when I'm back home. I had tested it last night with r11296.

Thanks for looking at this :)



edit: So, r11297 works perfectly with /chamoisgoagain - thank you so much! This tube was a fast one :D
 
Last edited:
Top