Is there a wait function built-in to crawl?

I’m working on some code that auto-tabs so I don’t have to keep doing D1-3 over and over again, but the kill code doesn’t work because crawl seems send all the code at once, then process the keys I’m sending. Is there a way to delay the sending of the code so it updates the lastmsg variable after each “op” is sent and processed?

My .rc

Code:

:function more_explore()
  :local starting_hp = you.hp()
  :local i = 0
  :while you.hp() > starting_hp/1.5 and i < 5 do
    :local lastmsg = crawl.messages(1):sub(1,-3)
    :if lastmsg == "Done exploring." then
      :i = 10000
    :else
      :crawl.sendkeys("po")
      :lastmsg = crawl.messages(1):sub(1,-3)
      :crawl.mpr(lastmsg)
      :i = i + 1
    :end
  :end
:end

I’d suggest looking at qw (GitHub - crawl/qw: The DCSS-playing bot qw)

It’s a bot that runs in the rc file and can beat the game!

1 Thank