Of course! Fair warning, I wouldn't call this elegant code :
- Code:
{
function custom_move_dl()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_DOWN_LEFT"
else
a[1] = "CMD_MOVE_DOWN_LEFT"
end
crawl.do_commands(a)
end
function custom_move_l()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_LEFT"
else
a[1] = "CMD_MOVE_LEFT"
end
crawl.do_commands(a)
end
function custom_move_d()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_DOWN"
else
a[1] = "CMD_MOVE_DOWN"
end
crawl.do_commands(a)
end
function custom_move_r()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_RIGHT"
else
a[1] = "CMD_MOVE_RIGHT"
end
crawl.do_commands(a)
end
function custom_move_dr()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_DOWN_RIGHT"
else
a[1] = "CMD_MOVE_DOWN_RIGHT"
end
crawl.do_commands(a)
end
function custom_move_u()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_UP"
else
a[1] = "CMD_MOVE_UP"
end
crawl.do_commands(a)
end
function custom_move_ur()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_UP_RIGHT"
else
a[1] = "CMD_MOVE_UP_RIGHT"
end
crawl.do_commands(a)
end
function custom_move_ul()
a = {}
if safe_move_toggle then
a[1] = "CMD_SAFE_MOVE_UP_LEFT"
else
a[1] = "CMD_MOVE_UP_LEFT"
end
crawl.do_commands(a)
end
safe_move_toggle = true
crawl.setopt("mon_glyph += player : green")
function toggle_safe_move()
if safe_move_toggle then
safe_move_toggle = false
crawl.message("<cyan>safe move off</cyan>", 0)
crawl.setopt("mon_glyph += player : red")
else
safe_move_toggle = true
crawl.message("<cyan>safe move on</cyan>", 0)
crawl.setopt("mon_glyph += player : green")
end
end
}
macros += M b ===custom_move_dl
macros += M h ===custom_move_l
macros += M j ===custom_move_d
macros += M k ===custom_move_u
macros += M l ===custom_move_r
macros += M n ===custom_move_dr
macros += M u ===custom_move_ur
macros += M y ===custom_move_ul
macros += M \{27} ===toggle_safe_move
Dump that whole thing in your rcfile. The macros at the bottom are where the actual keys are bound, so change those if you don't use vikeys to move or want the toggle to be on something other than escape.
I mocked up a version of the third idea too, which uses a force more instead of two modes for movement commands, and which is much more concise. This seems to work in a casual try-out but I haven't actually tested it in a real game or anything.
- Code:
{
safe = you.feel_safe()
function update_safe()
local old_safe = safe
safe = you.feel_safe()
if not safe and old_safe then
crawl.mpr("Danger!")
crawl.more()
end
end
function ready()
update_safe()
end
}