From 52a95d91bd46ffffbded9c5440db6bdd4dcada65 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 29 Mar 2025 08:58:28 +0100 Subject: [PATCH] positioning.lua: validate that an amount is passed Instead of crashing, show the correct usage when running pan-x, pan-y or cursor-centric with script-message, or with script-binding but no argument. --- player/lua/positioning.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/player/lua/positioning.lua b/player/lua/positioning.lua index 611eec67c5..b486115177 100644 --- a/player/lua/positioning.lua +++ b/player/lua/positioning.lua @@ -27,6 +27,11 @@ local function clamp(value, min, max) end mp.add_key_binding(nil, "pan-x", function (t) + if t.arg == nil or t.arg == "" then + mp.osd_message("Usage: script-binding positioning/pan-x ") + return + end + if t.event == "up" then return end @@ -42,6 +47,11 @@ mp.add_key_binding(nil, "pan-x", function (t) end, { complex = true, scalable = true }) mp.add_key_binding(nil, "pan-y", function (t) + if t.arg == nil or t.arg == "" then + mp.osd_message("Usage: script-binding positioning/pan-y ") + return + end + if t.event == "up" then return end @@ -114,6 +124,11 @@ end, { complex = true }) mp.add_key_binding(nil, "cursor-centric-zoom", function (t) + if t.arg == nil or t.arg == "" then + mp.osd_message("Usage: script-binding positioning/cursor-centric-zoom ") + return + end + local amount = t.arg * t.scale local command = (options.suppress_osd and "no-osd " or "") ..