add some nil checks, and make lssi work with eatit changes

This commit is contained in:
2023-10-17 22:24:49 -04:00
parent 6f091a7648
commit 878f0faaf7

View File

@ -27,7 +27,7 @@ Takes an input file and code then, it outputs a file with your code in there.
local mp = require('mp') local mp = require('mp')
mod = { mod = {
version = 'ALPHA 1', -- the current version of lssi version = 'ALPHA 1.1', -- the current version of lssi
author = 'squibid', author = 'squibid',
} }
@ -58,6 +58,7 @@ local function openlog()
fn = mp.command_native({'expand-path', opts.logging.logfile}) fn = mp.command_native({'expand-path', opts.logging.logfile})
f = io.open(fn, 'a') -- open file buffer f = io.open(fn, 'a') -- open file buffer
if not f then return end
io.output(f) -- set it as default io.output(f) -- set it as default
end end
end end
@ -109,13 +110,12 @@ local function checkandinject()
openlog() openlog()
for i = 1, tablelength(plugins) do for i = 1, tablelength(plugins) do
-- check if the plugin has been configured with lssi
if plugins[i]['lssi'] ~= nil then
-- get the file we want to inject our code into -- get the file we want to inject our code into
local f = mp.command_native({'expand-path', '~~/'}) .. local f = mp.command_native({'expand-path', '~~/'}) ..
'/' .. plugins[i]['dir'] .. '/'..(plugins[i]['dir'] or 'scripts') ..
'/'..plugins[i]['file'] '/'..plugins[i]['file']
-- check if the plugin has been configured with lssi
if plugins[i]['lssi'] then
-- and the file we are trying to modify actually exists -- and the file we are trying to modify actually exists
if fileexists(f) then if fileexists(f) then
-- inject it! no going back now -- inject it! no going back now