Files
Mush-Soundpack/cosmic rage/worlds/plugins/NumpadMovement.xml

121 lines
3.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="NumpadMovement"
author="The Cosmic Rage hosting team"
id="3f8a1c6e7b2d49f0a5c8e6d1"
save_state="y"
language="Lua"
purpose="Toggleable numpad movement, with Ctrl for up-movement and Ctrl+Alt for down-movement."
requires="4.82"
version="1.1"
>
</plugin>
<!-- Aliases -->
<aliases>
<alias
match="toggle_numpad"
enabled="y"
script="toggle_numpad"
omit_from_output="y"
omit_from_log="y"
omit_from_command_history="y"
send_to="12"
sequence="100"
>
</alias>
</aliases>
<!-- 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
Execute("tts_interrupt Numpad movement enabled.")
else
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>