Background script

eegee

Member
I can't seem to find if KoLmafia supports running a script in the background?

I have a script similar to the Code Samples on refresh_status(). It purchases some buffs and then waits for the buffs to arrive before purchasing some more. During the waiting period I would like to continue using the KoLmafia GUI for changing my outfit or casting some skills. Currently, I am still able to do this through the relay browser while the script waits, but I would like to know if I can avoid using the relay browser since using the GUI is much faster.
 
Last edited:

fronobulax

Developer
Staff member
Ah ok. Thanks for the reply. Should I make this into a feature request?

No. Let's talk about it more here, first. Right now if you are running a script, running another one will cause the second one to queue up rather than run immediately. I think that also applies to gCLI commands as well - they get queued. You want to enter commands into the gCLI and have them executed immediately while another script is running.

On a technical level I only know two ways to accomplish this. One would be to create a separate environment so that running things was independent as far as KoLmafia was concerned. The other way you be to implement all allowed commands so that they were 'safe' to run concurrently with each other. Ultimately I doubt that either would work because KoL itself is not really expecting concurrent requests from the same client.

Am I missing something? Is there a way to do this besides the above?

If a proposed approach is not especially easy and feature request is likely to be rejected because it takes a lot of work to implement and there is a partial work around available.
 

Theraze

Active member
If you ran it through a relay script and ran other items through the gCLI at the same time, that might work, yes? But I can't think of any other good ways to do it...
 

eegee

Member
My idea would be to leave out the concurrent stuff, since that can get messy. I was thinking of perhaps having a new kind of wait method implemented. It would be a yield (maybe “yield(int)”?) method that allows other scripts/commands to execute during its timeout.

e.g. When a script that is running and it calls yield(60) then the next queued script/command gets called and runs till it ends. Once that script/command has terminated, KoL checks if the 60 seconds specified have past and continues with the original script, else it runs the next queued script/command and so forth.
 

mredge73

Member
Mafia can run multiple scripts at the same time (chatbot + mainBot).
Mafia seems to have the ability to do this (run two scripts at once), but it doesn't have anything to keep it from hitting the server on both scripts at the same time.
 
Mafia can run multiple scripts at the same time (chatbot + mainBot).
Mafia seems to have the ability to do this (run two scripts at once), but it doesn't have anything to keep it from hitting the server on both scripts at the same time.

Indeed, mafia can run multiple scripts concurrently, but you can't really make them run from the CLI that way. One way would be to set the first script as some sort of keyword-driven chatbotScript, then it could do things without locking up the GUI.

Or, if you run this daily on login, you could set it as a login script. I frequently have failed to remember that the login script is running "in the background" and that calling another script executes it immediately and not in queue.
 

eegee

Member
...if you run this daily on login, you could set it as a login script. I frequently have failed to remember that the login script is running "in the background" and that calling another script executes it immediately and not in queue.

I tried that and it works, but KoLmafia still prevents me from changing my outfit from the gear changer tab while the login script is running.
 

fronobulax

Developer
Staff member
@fronobulax Any comments on my post #6?

Not yet. Bottom line at this moment is that I don't see a quick and easy way to implement that and I have not yet heard a compelling case for doing so. "Compelling" is a relative term measured against real life and other KoL "projects". If you feel like making a patch and posting a patch than the counts as 'compelling'. :)
 
Top