summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/autofire/autofire_save.lua6
-rw-r--r--plugins/autofire/init.lua13
-rw-r--r--plugins/inputmacro/inputmacro_persist.lua10
3 files changed, 17 insertions, 12 deletions
diff --git a/plugins/autofire/autofire_save.lua b/plugins/autofire/autofire_save.lua
index 52586c461ad..f863b003f4d 100644
--- a/plugins/autofire/autofire_save.lua
+++ b/plugins/autofire/autofire_save.lua
@@ -75,9 +75,7 @@ end
function lib:save_settings(buttons)
local path = get_settings_path()
local attr = lfs.attributes(path)
- if not attr then
- lfs.mkdir(path)
- elseif attr.mode ~= 'directory' then
+ if attr and (attr.mode ~= 'directory') then
emu.print_error(string.format('Error saving autofire settings: "%s" is not a directory', path))
return
end
@@ -85,6 +83,8 @@ function lib:save_settings(buttons)
if #buttons == 0 then
os.remove(filename)
return
+ elseif not attr then
+ lfs.mkdir(path)
end
local json = require('json')
local settings = serialize_settings(buttons)
diff --git a/plugins/autofire/init.lua b/plugins/autofire/init.lua
index 9e4743718cb..ab5e7b11f47 100644
--- a/plugins/autofire/init.lua
+++ b/plugins/autofire/init.lua
@@ -23,13 +23,12 @@ function autofire.startplugin()
-- 'counter' - position in autofire cycle
local buttons = {}
+ local input_manager
local menu_handler
local function process_frame()
- local input = manager.machine.input
-
local function process_button(button)
- local pressed = input:seq_pressed(button.key)
+ local pressed = input_manager:seq_pressed(button.key)
if pressed then
local state = button.counter < button.on_frames and 1 or 0
button.counter = (button.counter + 1) % (button.on_frames + button.off_frames)
@@ -65,6 +64,8 @@ function autofire.startplugin()
if loader then
buttons = loader:load_settings()
end
+
+ input_manager = manager.machine.input
end
local function save_settings()
@@ -74,6 +75,7 @@ function autofire.startplugin()
end
menu_handler = nil
+ input_manager = nil
buttons = {}
end
@@ -87,7 +89,10 @@ function autofire.startplugin()
local function menu_populate()
if not menu_handler then
- menu_handler = require('autofire/autofire_menu')
+ local status, msg = pcall(function () menu_handler = require('autofire/autofire_menu') end)
+ if not status then
+ emu.print_error(string.format('Error loading autofire menu: %s', msg))
+ end
if menu_handler then
menu_handler:init_menu(buttons)
end
diff --git a/plugins/inputmacro/inputmacro_persist.lua b/plugins/inputmacro/inputmacro_persist.lua
index 6519f3a048a..b8670800fa4 100644
--- a/plugins/inputmacro/inputmacro_persist.lua
+++ b/plugins/inputmacro/inputmacro_persist.lua
@@ -101,7 +101,7 @@ end
local lib = { }
function lib:load_settings()
- filename = settings_path() .. '/' .. settings_filename()
+ local filename = settings_path() .. '/' .. settings_filename()
local file = io.open(filename, 'r')
if not file then
return { }
@@ -127,17 +127,17 @@ end
function lib:save_settings(macros)
local path = settings_path()
local stat = lfs.attributes(path)
- if not stat then
- lfs.mkdir(path)
- elseif stat.mode ~= 'directory' then
+ if stat and (stat.mode ~= 'directory') then
emu.print_error(string.format('Error saving input macros: "%s" is not a directory', path))
return
end
- filename = path .. '/' .. settings_filename()
+ local filename = path .. '/' .. settings_filename()
if #macros == 0 then
os.remove(filename)
return
+ elseif not stat then
+ lfs.mkdir(path)
end
local json = require('json')