Scripting noob seeks assistance

aesir

New member
Hi,

I'd like to write a script to do the chrome ore portion of the L337 Tr4pz0r Itsnotyourzitz Mine quest. Writting the checks for mining gear and a script to equip the mining gear should be simple enough, but I figure out how to handle the mining mini game portion. Is there some way for the game to parse out which strikes from the available portions of cave wall are promising veins, or how to command it to strike a vein at all?

I was thinking it might be similar to the KoL CLI command "tavern" since it also involves "using" parts of the screen, but I can't find a way to access the source code of KoL Mafia so I can't get a look at how the CLI tavern script runs.

For now I'm gonna go muck around with a bunch of pre-written scripts so I can get a better idea of how to write scripts in general. It's been a long time since I've done any sort of programming  :)

Thanks for any help!

Edit: Should I have posted this in the scripting discussion thread?
 

Tirian

Member
A mining script would be quite an interesting challenge to undertake. ASH is nearly deliberate in its lack of support for you; the lead programmer has said on many occasions that when he writes mining support into KoLmafia that it will be the last thing he does on the project because then the game will be completely mechanical to him.

With what exists now, you can drill in a given square, using cli_execute and whatever URL it takes to drill in square X. You won't be able to tell if the square is sparkly beforehand, and the only way you'll be able to tell if you got anything of interest is by refreshing your inventory and checking it to see if you have more of the ores than you did one adventure before. And you won't be able to tell what the trapper wanted, so you'll have to visit him every time you get three of a certain ore and then refresh your inventory and see if they vanished. It's all pretty nasty, so I personally do it by hand. :)
 

Nightmist

Member
Yeah. EXPECT to be using atleast 24 adventures to "script the mine".

Is it hard to script? No.
Is is hard to script in a "Effective" manner? Hell yes.

Well yeah you really can expect a script that does this in a effective manner since you lack the "Is sparkly" checks and also the "What ore am I looking for" checks. I personally say don't expect the ability to check these in a script to ever be possible so you stuck with the "Mine blindly" tactic. Which is actually pretty easy...

Well there is one step up which is the "Mine blindly but know that a single ore type will always be grouped together and so use a queue system to minimise the turns spent mining blindly"... but thats probably out of your league if your still looking at pre-made scripts to get an idea of how scripting works.
 

aesir

New member
Hmmm, thanks for the input guys, it seems that this is one of those things that's just much more efficient to do by hand. It did raise an interesting question that I can't seem to find an answer for elsewhere; however, How can I have a script use a URL?

I know Tirian said I can do it with cli_execute but what's the exact syntax?

cli_execute("URL here");

Because when I tried that I got a session timed out error, I think because when I logged in to try to copy the URL from the trapper's cabin I'm on a different www server than when KOL mafia logs in, causing the timeout error.

Having the ability to click on any portion of the screen with the URL cli_execute seems like a handy tool to have in my pocket before I start to tackle any other projects I might come up with :)
 

Tirian

Member
Long story short, my recommendation is that you use the mini-browser, do the task that you want to automate, and copy down the URL that is in the mini-browser's window, because that's exactly the format that you want to use for the cli_execute command. The character that I'm logged in as right now isn't up to the mines yet, so I can't pull that out, but as a separate example, here's how you might go about finishing the Friar's ritual:

Code:
cli_execute("friars.php?pwd&action=ritual");

For all I know, the Ritual location has been added to the location menu since I wrote this function, but that's at least how we used to have to do it. :) But CLI will do magic with this URL like referencing the proper server and replacing pwd with passing your actual password and things like that.

There are plenty of reasons why cli_execute is sub-optimal behavior. For one, it makes Veracity sad that we're hacking her nice language. Beyond that, though, the results won't be parsed, which is why you won't know if you picked up an ore or three meat stacks or whatever from the adventure. So, at all times, use a raw URL only as a last alternative
 
Top