From e1ef52ad6939fc78888ec486e37c17f9ee17f796 Mon Sep 17 00:00:00 2001 From: Tangent Date: Tue, 5 Nov 2024 21:54:00 -0700 Subject: [PATCH] Fix #20 --- 2pdf.lua | 8 +++++++- 2webm.lua | 9 ++++++++- 720p.lua | 9 ++++++++- test.lua | 10 +++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/2pdf.lua b/2pdf.lua index b8f09b9..e6d2ee6 100644 --- a/2pdf.lua +++ b/2pdf.lua @@ -3,7 +3,13 @@ -- The first time this is run (on Windows), a dialog will appear. -- Uncheck the "always show this" thing and click Install. -local error_occurred, utility = pcall(function() return dofile(arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)") .. "utility-functions.lua") end) if not error_occurred then error("\n\nThis script is installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") end +local success, utility = pcall(function() + return dofile((arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "utility-functions.lua") +end) +if not success then + print("\n\n" .. tostring(utility)) + error("\n\nThis script may be installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") +end local for_files = utility.ls() os.execute("mkdir 2pdf-output") diff --git a/2webm.lua b/2webm.lua index e95ad93..57aa395 100644 --- a/2webm.lua +++ b/2webm.lua @@ -16,7 +16,14 @@ if arg[1] and arg[1]:find("help") then return false end -local error_occurred, utility = pcall(function() return dofile(arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)") .. "utility-functions.lua") end) if not error_occurred then error("\n\nThis script is installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") end +local success, utility = pcall(function() + return dofile((arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "utility-functions.lua") +end) +if not success then + print("\n\n" .. tostring(utility)) + error("\n\nThis script may be installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") +end + utility.required_program("ffmpeg") local threads = tonumber(arg[1]) or arg[1] or 1 diff --git a/720p.lua b/720p.lua index a61749b..6bcfe23 100644 --- a/720p.lua +++ b/720p.lua @@ -19,7 +19,14 @@ if arg[1] and arg[1]:find("help") then return false end -local error_occurred, utility = pcall(function() return dofile(arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)") .. "utility-functions.lua") end) if not error_occurred then error("\n\nThis script is installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") end +local success, utility = pcall(function() + return dofile((arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "utility-functions.lua") +end) +if not success then + print("\n\n" .. tostring(utility)) + error("\n\nThis script may be installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") +end + utility.required_program("ffmpeg") local tune diff --git a/test.lua b/test.lua index e0e11a4..d4ca384 100644 --- a/test.lua +++ b/test.lua @@ -1,8 +1,12 @@ #!/usr/bin/env luajit --- if utility-functions.lua has an error, this won't show it, so for testing purposes, I don't use it here --- local error_occurred, utility = pcall(function() return dofile(arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)") .. "utility-functions.lua") end) if not error_occurred then error("\n\nThis script is installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") end -utility = dofile(arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)") .. "utility-functions.lua") +local success, utility = pcall(function() + return dofile((arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "utility-functions.lua") +end) +if not success then + print("\n\n" .. tostring(utility)) + error("\n\nThis script may be installed improperly. Follow instructions at:\n\thttps://github.com/TangentFoxy/.lua-files#installation\n") +end print("---")