Page 1 of 1

About ready() and autoexplore

PostPosted: Friday, 18th May 2018, 21:20
by Fingolfin
Hi, I am trying to do a bit of rcfile magic, and would like to update my auto_butcher settings while autoexplore is running.
What I gather is happening : When I press 'o', autoexplore takes the wheel and the ready() function is only called at the end of exploration, not during it.
What I could do about it : Write a my_autoexplore() function and macro it to 'o'. I do not want to do that.

Is my assumption about what's happening correct ? Is my solution the only one ? Is there another function that is called after each autoexplore step, or a function that returns what the next autoexplore step would be ?

Re: About ready() and autoexplore

PostPosted: Saturday, 7th July 2018, 01:31
by ebering
I've been digging into the crawl Lua api to document it (final results coming soon). But I know enough to answer your question now.

What you gather is happening is correct. ready() is only called when there is no pending input and you are not currently processing a delay (any multi turn action is a delay internally; autoexplore processes as a TravelDelay).

Autoexplore is implemented in C++ and not in clua, so it is not extensible in the way you'd like (redefine a Lua function). The best that's available are the pair of callback hooks ch_start_running and ch_stop_running. Crawl will call these when you start/stop running or resting, with a single string parameter that is either "travel", "interlevel", "explore", "explore_greedy", or "".

You can define these functions to have something update automatically at the start/end of autoexplore.

Re: About ready() and autoexplore

PostPosted: Saturday, 7th July 2018, 03:10
by Fingolfin
Wow thanks a lot for taking the time to reply to this old thread :D
Unfortunately what I want to do is change options while in the middle of autoexploring, which you're telling me is impossible (short of rewriting autoexplore in Lua).
Thank you very much for the info though, at least now I know :)