Ports the zMUD/CMUD numpad.set convention: plain numpad for normal movement, Ctrl+numpad for moving up a level in that direction, and Ctrl+Alt+numpad for moving down a level, all sent as literal MUD commands via Accelerator. Alt+Enter toggles the whole set on/off (with a sound + spoken confirmation) by clearing/restoring the accelerators, so a disabled numpad types normally instead of doing nothing. Cleared the numbers/*/-/+ entries in the world's native <keypad> block since they'd otherwise double-send alongside the new Accelerator-based bindings - left "." and "/" (hide/inventory) alone since those aren't part of this feature. Documented the full three-layer key list and the toggle in the readme.
108 lines
3.4 KiB
XML
108 lines
3.4 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
|
|
<muclient>
|
|
<plugin
|
|
name="NumpadMovement"
|
|
author="Antigravity"
|
|
id="3f8a1c6e7b2d49f0a5c8e6d1"
|
|
save_state="y"
|
|
language="Lua"
|
|
purpose="Toggleable numpad movement: plain numpad for normal movement, Ctrl for up-movement, Ctrl+Alt for down-movement."
|
|
requires="4.82"
|
|
version="1.0"
|
|
>
|
|
</plugin>
|
|
|
|
<!-- Script -->
|
|
<script>
|
|
<![CDATA[
|
|
-- Three layers of numpad bindings, matching the classic zMUD numpad.set
|
|
-- convention: plain numpad for level movement, Ctrl+numpad for moving up
|
|
-- a level while heading that direction, Ctrl+Alt+numpad for moving down
|
|
-- a level while heading that direction. Alt+Enter toggles the whole set
|
|
-- on/off, so the numpad can be freed up for typing numbers when needed.
|
|
--
|
|
-- Accelerator(key, "") clears a binding, and Accelerator(key, "command")
|
|
-- with a plain string sends that command as if typed - this plugin just
|
|
-- flips all of them on or off together rather than gating each key
|
|
-- individually, so a disabled numpad behaves exactly like an unbound one
|
|
-- (keys type normally) instead of silently swallowing keystrokes.
|
|
|
|
local NUMPAD_BINDINGS = {
|
|
-- plain numpad - normal movement
|
|
{ "Numpad1", "southwest" },
|
|
{ "Numpad2", "south" },
|
|
{ "Numpad3", "southeast" },
|
|
{ "Numpad4", "west" },
|
|
{ "Numpad5", "look" },
|
|
{ "Numpad6", "east" },
|
|
{ "Numpad7", "northwest" },
|
|
{ "Numpad8", "north" },
|
|
{ "Numpad9", "northeast" },
|
|
{ "Numpad0", "exits" },
|
|
{ "Multiply", "in" },
|
|
{ "Ctrl+Multiply", "out" },
|
|
{ "Subtract", "up" },
|
|
{ "Add", "down" },
|
|
|
|
-- Ctrl+numpad - move up a level while heading that direction
|
|
{ "Ctrl+Numpad1", "southwestup" },
|
|
{ "Ctrl+Numpad2", "southup" },
|
|
{ "Ctrl+Numpad3", "southeastup" },
|
|
{ "Ctrl+Numpad4", "westup" },
|
|
{ "Ctrl+Numpad6", "eastup" },
|
|
{ "Ctrl+Numpad7", "northwestup" },
|
|
{ "Ctrl+Numpad8", "northup" },
|
|
{ "Ctrl+Numpad9", "northeastup" },
|
|
{ "Ctrl+Subtract", "upstairs" },
|
|
{ "Ctrl+Add", "downstairs" },
|
|
|
|
-- Ctrl+Alt+numpad - move down a level while heading that direction
|
|
{ "Ctrl+Alt+Numpad1", "southwestdown" },
|
|
{ "Ctrl+Alt+Numpad2", "southdown" },
|
|
{ "Ctrl+Alt+Numpad3", "southeastdown" },
|
|
{ "Ctrl+Alt+Numpad4", "westdown" },
|
|
{ "Ctrl+Alt+Numpad5", "go" },
|
|
{ "Ctrl+Alt+Numpad6", "eastdown" },
|
|
{ "Ctrl+Alt+Numpad7", "northwestdown" },
|
|
{ "Ctrl+Alt+Numpad8", "northdown" },
|
|
{ "Ctrl+Alt+Numpad9", "northeastdown" },
|
|
{ "Ctrl+Alt+Subtract", "climbup" },
|
|
{ "Ctrl+Alt+Add", "climbdown" },
|
|
}
|
|
|
|
local function set_numpad_bindings(enabled)
|
|
for _, binding in ipairs(NUMPAD_BINDINGS) do
|
|
local key, command = binding[1], binding[2]
|
|
Accelerator(key, enabled and command or "")
|
|
end
|
|
end
|
|
|
|
function toggle_numpad()
|
|
local enabled = GetVariable("numpad_movement") ~= "0"
|
|
enabled = not enabled
|
|
SetVariable("numpad_movement", enabled and "1" or "0")
|
|
set_numpad_bindings(enabled)
|
|
|
|
if enabled then
|
|
ppi.play(dir.."sounds/ogg/general/misc/on.ogg", 0, 0, 100)
|
|
Execute("tts_interrupt Numpad movement enabled.")
|
|
else
|
|
ppi.play(dir.."sounds/ogg/general/misc/off.ogg", 0, 0, 100)
|
|
Execute("tts_interrupt Numpad movement disabled.")
|
|
end
|
|
end
|
|
|
|
function OnPluginInstall()
|
|
Accelerator("alt+enter", "toggle_numpad")
|
|
-- Enabled by default, matching the always-on native keypad behaviour
|
|
-- this plugin replaces.
|
|
local enabled = GetVariable("numpad_movement") ~= "0"
|
|
set_numpad_bindings(enabled)
|
|
end
|
|
]]>
|
|
</script>
|
|
|
|
</muclient>
|