Showing the changes to TOOLS/lua/command-test.lua (1 of 2 files). Show all
Unified · Split
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | local utils = require("mp.utils") |
| 4 | 4 | |
| 5 | −function join(sep, arr, count) | |
| 5 | +local function join(sep, arr, count) | |
| 6 | 6 | local r = "" |
| 7 | 7 | if count == nil then |
| 8 | 8 | count = #arr |
| @@ -31,19 +31,19 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 22 unmodified lines | ||
| 31 | 31 | mp.set_property("screenshot-format", "png") |
| 32 | 32 | mp.set_property("screenshot-png-compression", "9") |
| 33 | 33 | |
| 34 | − timer = mp.add_periodic_timer(0.1, function() print("I'm alive") end) | |
| 34 | + local timer = mp.add_periodic_timer(0.1, function() print("I'm alive") end) | |
| 35 | 35 | timer:resume() |
| 36 | 36 | |
| 37 | 37 | print("Slow screenshot command...") |
| 38 | − res = mp.command_native({"screenshot"}) | |
| 39 | − print("done, res: " .. utils.to_string(res)) | |
| 38 | + local result = mp.command_native({"screenshot"}) | |
| 39 | + print("done, res: " .. utils.to_string(result)) | |
| 40 | 40 | |
| 41 | 41 | print("Slow screenshot async command...") |
| 42 | − res = mp.command_native_async({"screenshot"}, function(res) | |
| 42 | + result = mp.command_native_async({"screenshot"}, function(res) | |
| 43 | 43 | print("done (async), res: " .. utils.to_string(res)) |
| 44 | 44 | timer:kill() |
| 45 | 45 | end) |
| 46 | − print("done (sending), res: " .. utils.to_string(res)) | |
| 46 | + print("done (sending), res: " .. utils.to_string(result)) | |
| 47 | 47 | |
| 48 | 48 | print("Broken screenshot async command...") |
| 49 | 49 | mp.command_native_async({"screenshot-to-file", "/nonexistent/bogus.png"}, |
| @@ -51,7 +51,11 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 1 unmodified line | ||
| 51 | 51 | print("done err scr.: " .. join(" ", {res, val, err})) |
| 52 | 52 | end) |
| 53 | 53 | |
| 54 | − mp.command_native_async({name = "subprocess", args = {"sh", "-c", "echo hi && sleep 10s"}, capture_stdout = true}, | |
| 54 | + mp.command_native_async({ | |
| 55 | + name = "subprocess", | |
| 56 | + args = {"sh", "-c", "echo hi && sleep 10s"}, | |
| 57 | + capture_stdout = true | |
| 58 | + }, | |
| 55 | 59 | function(res, val, err) |
| 56 | 60 | print("done subprocess: " .. join(" ", {res, val, err})) |
| 57 | 61 | end) |
| @@ -105,7 +109,8 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 47 unmodified lines | ||
| 105 | 109 | playback_only = false, args = {"sleep", "inf"}}) |
| 106 | 110 | end) |
| 107 | 111 | |
| 108 | −function freeze_test(playback_only) | |
| 112 | +local counter | |
| 113 | +local function freeze_test(playback_only) | |
| 109 | 114 | -- This "freezes" the script, should be killed via timeout. |
| 110 | 115 | counter = counter and counter + 1 or 0 |
| 111 | 116 | print("freeze! " .. counter) |