Add toggleable numpad movement (Alt+Enter)

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.
This commit is contained in:
OlegTheSnowman
2026-07-11 00:14:52 +03:00
parent c3d85360c1
commit 5f43e111be
3 changed files with 157 additions and 13 deletions

View File

@@ -312,44 +312,38 @@
date_saved="2026-07-10 23:31:00"
>
<!-- Numbers, *, -, and + are handled by NumpadMovement.xml (Accelerator-
based, toggleable with Alt+Enter) rather than here, so the two
systems can't double-send. Left blank rather than removed so the
keypad dialog still shows the full grid. -->
<key name="0" >
<send>exits</send>
</key>
<key name="1" >
<send>sw</send>
</key>
<key name="2" >
<send>south</send>
</key>
<key name="3" >
<send>se</send>
</key>
<key name="4" >
<send>west</send>
</key>
<key name="5" >
<send>look</send>
</key>
<key name="6" >
<send>east</send>
</key>
<key name="7" >
<send>nw</send>
</key>
<key name="8" >
<send>north</send>
</key>
<key name="9" >
<send>ne</send>
</key>
<key name="." >
@@ -361,15 +355,12 @@
</key>
<key name="*" >
<send>score</send>
</key>
<key name="-" >
<send>up</send>
</key>
<key name="+" >
<send>down</send>
</key>
<key name="Ctrl+0" >
@@ -457,6 +448,7 @@
<include name="Reconnecter.xml" plugin="y" />
<include name="Repeat_Command.xml" plugin="y" />
<include name="GagManager.xml" plugin="y" />
<include name="NumpadMovement.xml" plugin="y" />
<include name="LuaAudio.xml" plugin="y" />
<include name="CosmicRage.xml" plugin="y" />
</muclient>

View File

@@ -0,0 +1,107 @@
<?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>