Input Repetition and Macros

Name dcss:brainstorm:interface: input
Summary Macros, key repetition
Added by rob
Added on 2010-05-13 11:27

The current macroing and key repeat code is a mess. It's probably worth replacing at some point.

Use cases

Both to be able to design a possible replacement, and to have a chance at fixing the current implementation, it's necessary to know what people actually try to do, and what should work. Let's collect some examples here.

  • Macro 'z' to 'Z*'. With this, you can attack an enemy with 'za.', and should be able to repeat the attack with '`'.
  • Repeat quaffing from a fountain to empty it: '0100qy'.
  • '09ex' to eat up to 9 pieces from stack 'x' in inventory, e.g. sultanas.
  • Repeat that action (quaffing 100 times) with '`'.
  • Macro 'S' to '#S', so you get an automatic character dump when saving.
  • Macro 'p' to '===pray_prompt', where the Lua function pray_prompt is defined as below.
  • If a key is macroed to a Lua function, hitting that key and then '`' should result in the macro being called again. doesn't work
  • some specific examples where repeats should be aborted would be good to have

Example Lua userfunctions

Prompt when trying to pray to Elyvilon
: if you.god() == "Elyvilon" then
:   function pray_prompt() 
:     crawl.formatted_mpr("Really pray?", "prompt")
:     local res = crawl.getch()
:     if string.lower(string.char(res)) == "y" then
:       crawl.sendkeys("p")
:     end
:   end
: else 
:   function pray_prompt() 
:     crawl.sendkeys("p")
:   end
: end
Heal up before starting explore
function safe_explore ()
     local hp, mhp = you.hp()
     local mp, mmp =
     while hp < mhp or mp < mmp do
         hp, mhp = you.hp()
         mp, mmp =

function safe_explore_interrupt_macro(interrupt_name)
    return interrupt_name ~= "full_hp"

chk_interrupt_macro.safe_explore = safe_explore_interrupt_macro
Logged in as: Anonymous (VIEWER)
dcss/brainstorm/interface/input.txt · Last modified: 2011-12-22 19:36 by XuaXua
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki