summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/cheat/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/cheat/init.lua')
-rw-r--r--plugins/cheat/init.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index f8f15b652f4..896fc1e101b 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -154,9 +154,10 @@ function cheat.startplugin()
end
end
end
+ local path = emu.subst_env(manager.machine.options.entries.cheatpath:value():match("([^;]+)"))
+ local filepath = path .. "/" .. cheatname .. "_hotkeys.json"
if #hotkeys > 0 then
local json = require("json")
- local path = emu.subst_env(manager.machine.options.entries.cheatpath:value():match("([^;]+)"))
local attr = lfs.attributes(path)
if not attr then
lfs.mkdir(path)
@@ -165,7 +166,7 @@ function cheat.startplugin()
end
if cheatname:find("/", 1, true) then
local softpath = path .. "/" .. cheatname:match("([^/]+)")
- local attr = lfs.attributes(softpath)
+ attr = lfs.attributes(softpath)
if not attr then
lfs.mkdir(softpath)
elseif attr.mode ~= "directory" then -- uhhh?
@@ -173,11 +174,21 @@ function cheat.startplugin()
end
end
- local file = io.open(path .. "/" .. cheatname .. "_hotkeys.json", "w+")
+ local file = io.open(filepath, "w+")
if file then
file:write(json.stringify(hotkeys, {indent = true}))
file:close()
end
+ else
+ local attr = lfs.attributes(filepath)
+ if attr and (attr.mode == "file") then
+ local json = require("json")
+ local file = io.open(filepath, "w+")
+ if file then
+ file:write(json.stringify(hotkeys, {indent = true}))
+ file:close()
+ end
+ end
end
end