diff options
Diffstat (limited to 'plugins/cheat/init.lua')
-rw-r--r-- | plugins/cheat/init.lua | 456 |
1 files changed, 277 insertions, 179 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index 21824626977..302b86beeed 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -68,11 +68,13 @@ local exports = {} exports.name = "cheat" exports.version = "0.0.1" exports.description = "Cheat plugin" -exports.license = "The BSD 3-Clause License" +exports.license = "BSD-3-Clause" exports.author = { name = "Carl" } local cheat = exports +local reset_subscription, stop_subscription, frame_subscription + function cheat.set_folder(path) cheat.path = path end @@ -94,18 +96,14 @@ function cheat.startplugin() local function load_cheats() local filename = emu.romname() local newcheats = {} - local file = emu.file(manager:machine():options().entries.cheatpath:value():gsub("([^;]+)", "%1;%1/cheat") , 1) - if emu.softname() ~= "" then - if emu.softname():find(":") then - filename = emu.softname():gsub(":", "/") - else - for name, image in pairs(manager:machine().images) do - if image:exists() and image:software_list_name() ~= "" then - filename = image:software_list_name() .. "/" .. emu.softname() - end - end + local file = emu.file(manager.machine.options.entries.cheatpath:value():gsub("([^;]+)", "%1;%1/cheat") , 1) + + for name, image in pairs(manager.machine.images) do + if image.exists and image.software_list_name ~= "" then + filename = image.software_list_name .. "/" .. image.filename end end + cheatname = filename local function add(addcheats) if not next(newcheats) then @@ -134,7 +132,7 @@ function cheat.startplugin() local function load_hotkeys() local json = require("json") - local file = io.open(lfs.env_replace(manager:machine():options().entries.cheatpath:value():match("([^;]+)")) .. "/" .. cheatname .. "_hotkeys.json", "r") + local file = io.open(manager.machine.options.entries.cheatpath:value():match("([^;]+)") .. "/" .. cheatname .. "_hotkeys.json", "r") if not file then return end @@ -142,7 +140,7 @@ function cheat.startplugin() for num, val in ipairs(hotkeys) do for num, cheat in pairs(cheats) do if val.desc == cheat.desc then - cheat.hotkeys = {pressed = false, keys = manager:machine():input():seq_from_tokens(val.keys)} + cheat.hotkeys = {pressed = false, keys = manager.machine.input:seq_from_tokens(val.keys)} end end end @@ -152,15 +150,16 @@ function cheat.startplugin() local hotkeys = {} for num, cheat in ipairs(cheats) do if cheat.hotkeys then - local hotkey = {desc = cheat.desc, keys = manager:machine():input():seq_to_tokens(cheat.hotkeys.keys)} + local hotkey = {desc = cheat.desc, keys = manager.machine.input:seq_to_tokens(cheat.hotkeys.keys)} if hotkey.keys ~= "" then hotkeys[#hotkeys + 1] = hotkey end end end + local path = manager.machine.options.entries.cheatpath:value():match("([^;]+)") + local filepath = path .. "/" .. cheatname .. "_hotkeys.json" if #hotkeys > 0 then local json = require("json") - local path = lfs.env_replace(manager:machine():options().entries.cheatpath:value():match("([^;]+)")) local attr = lfs.attributes(path) if not attr then lfs.mkdir(path) @@ -169,7 +168,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? @@ -177,11 +176,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 @@ -193,8 +202,6 @@ function cheat.startplugin() return end - local function is_oneshot(cheat) return cheat.script and not cheat.script.run and not cheat.script.off end - local function run_if(cheat, func) if func then local stat, err = pcall(func) @@ -217,7 +224,7 @@ function cheat.startplugin() return end if type(x) == "string" then - y = y * mame_manager:ui():get_line_height() + y = y * mame_manager.ui.line_height end output[#output + 1] = { type = "text", scr = screen, x = x, y = y, str = str, color = color } end @@ -280,29 +287,29 @@ function cheat.startplugin() run_if(wp.cheat, wp.func) -- go in case a debugger other than "none" is enabled -- don't use an b/wpset action because that will supress the b/wp index - manager:machine():debugger().execution_state = "run" + manager.machine.debugger.execution_state = "run" end else local bp = breaks[point] if bp then run_if(bp.cheat, bp.func) - manager:machine():debugger().execution_state = "run" + manager.machine.debugger.execution_state = "run" end end end end local function bpset(cheat, dev, addr, func) - if is_oneshot(cheat) then + if cheat.is_oneshot then error("bpset not permitted in oneshot cheat") return end - local idx = dev:debug():bpset(addr) + local idx = dev.debug:bpset(addr) breaks[idx] = {cheat = cheat, func = func, dev = dev} end local function wpset(cheat, dev, space, wptype, addr, len, func) - if is_oneshot(cheat) then + if cheat.is_oneshot then error("wpset not permitted in oneshot cheat") return end @@ -310,22 +317,22 @@ function cheat.startplugin() error("bad space in wpset") return end - local idx = dev.debug():wpset(space, wptype, addr, len) + local idx = dev.debug:wpset(space, wptype, addr, len) watches[idx] = {cheat = cheat, func = func, dev = dev} end local function bwpclr(cheat) - if not manager:machine():debugger() then + if not manager.machine.debugger then return end for num, bp in pairs(breaks) do if cheat == bp.cheat then - bp.dev.debug():bpclr(num) + bp.dev.debug:bpclr(num) end end for num, wp in pairs(watches) do if cheat == wp.cheat then - wp.dev.debug():wpclr(num) + wp.dev.debug:wpclr(num) end end end @@ -333,7 +340,7 @@ function cheat.startplugin() local function input_trans(list) local xlate = { start = {}, stop = {}, last = 0 } local function errout(port, field) - cheat.enabled = false + cheat:set_enabled(false) error(port .. field .. " not found") return end @@ -342,7 +349,7 @@ function cheat.startplugin() if entry.port:sub(1, 1) ~= ":" then entry.port = ":" .. entry.port end - local port = manager:machine():ioport().ports[entry.port] + local port = manager.machine.ioport.ports[entry.port] if not port then errout(entry.port, entry.field) end @@ -369,33 +376,103 @@ function cheat.startplugin() end local function input_run(cheat, list) - if not is_oneshot(cheat) then + if not cheat.is_oneshot then cheat.enabled = false error("input_run only allowed in one shot cheats") return end - local _, screen = next(manager:machine().screens) + local _, screen = next(manager.machine.screens) list.begin = screen:frame_number() inputs[#inputs + 1] = list end + local function param_calc(param) + if param.item then + if not param.item[param.index] then -- uh oh + param.index = 1 + end + param.value = param.item[param.index].value + return + end + param.value = param.min + (param.step * (param.index - 1)) + if param.value > param.max then + param.value = param.max + end + end + + -- return is current state, ui change + local function set_enabled(cheat, state) + if cheat.is_oneshot then + if state then + if cheat.parameter and cheat.script.change and cheat.parameter.index ~= 0 then + param_calc(cheat.parameter) + cheat.cheat_env.param = cheat.parameter.value + cheat.script.change() + elseif not cheat.parameter and cheat.script.on then + cheat.script.on() + end + end + return false, false + end + if cheat.enabled == state then + return state, false + end + if not state then + cheat.enabled = false + run_if(cheat, cheat.script.off) + bwpclr(cheat) + else + cheat.enabled = true + run_if(cheat, cheat.script.on) + end + return state, true + end + + -- return is current index, ui change + local function set_index(cheat, index) + local param = cheat.parameter + local oldindex = param.index + if (index < 0) or (index > param.last) or (param.index == index) then + return param.index, false + end + param.index = index + if index == 0 then + cheat.cheat_env.param = param.min + cheat:set_enabled(false) + else + if oldindex == 0 then + cheat:set_enabled(true) + end + param_calc(param) + cheat.cheat_env.param = param.value + if not cheat.is_oneshot then + run_if(cheat, cheat.script.change) + end + end + return index, true + end + local function parse_cheat(cheat) - cheat.cheat_env = { draw_text = draw_text, - draw_line = draw_line, - draw_box = draw_box, - tobcd = tobcd, - frombcd = frombcd, - pairs = pairs, - ipairs = ipairs, - outputs = manager:machine():outputs(), - time = time, - input_trans = input_trans, - input_run = function(list) input_run(cheat, list) end, - os = { time = os.time, date = os.date, difftime = os.difftime }, - table = - { insert = table.insert, - remove = table.remove } } + cheat.cheat_env = { + draw_text = draw_text, + draw_line = draw_line, + draw_box = draw_box, + tobcd = tobcd, + frombcd = frombcd, + pairs = pairs, + ipairs = ipairs, + outputs = manager.machine.output, + time = time, + input_trans = input_trans, + input_run = function(list) input_run(cheat, list) end, + os = { time = os.time, date = os.date, difftime = os.difftime }, + table = { insert = table.insert, remove = table.remove }, + string = { format = string.format, char = string.char } + } cheat.enabled = false + cheat.set_enabled = set_enabled; + cheat.get_enabled = function(cheat) return cheat.enabled end + cheat.is_oneshot = cheat.script and not cheat.script.run and not cheat.script.off -- verify scripts are valid first if not cheat.script then @@ -416,9 +493,9 @@ function cheat.startplugin() if cheat.cpu then cheat.cpudev = {} for name, tag in pairs(cheat.cpu) do - if manager:machine():debugger() then - local dev = manager:machine().devices[tag] - if not dev or not dev:debug() then + if manager.machine.debugger then + local dev = manager.machine.devices[tag] + if not dev or not dev.debug then cheat_error(cheat, "missing or invalid device " .. tag) return end @@ -438,7 +515,7 @@ function cheat.startplugin() if cheat.space then for name, space in pairs(cheat.space) do local cpu, mem - cpu = manager:machine().devices[space.tag] + cpu = manager.machine.devices[space.tag] if not cpu then cheat_error(cheat, "missing device " .. space.tag) return @@ -458,17 +535,20 @@ function cheat.startplugin() end if cheat.screen then for name, screen in pairs(cheat.screen) do - local scr = manager:machine().screens[screen] - if not scr then + local scr = manager.machine.screens[screen] + if screen == "ui" then + scr = manager.machine.render.ui_container + elseif not scr then local tag - tag, scr = next(manager:machine().screens) -- get any screen + local nxt, coll = manager.machine.screens:pairs() + tag, scr = nxt(coll) -- get any screen end cheat.cheat_env[name] = scr end end if cheat.region then for name, region in pairs(cheat.region) do - local mem = manager:machine():memory().regions[region] + local mem = manager.machine.memory.regions[region] if not mem then cheat_error(cheat, "missing region " .. region) return @@ -478,7 +558,7 @@ function cheat.startplugin() end if cheat.ram then for name, tag in pairs(cheat.ram) do - local ram = manager:machine().devices[tag] + local ram = manager.machine.devices[tag] if not ram then cheat_error(cheat, "missing ram device " .. tag) return @@ -488,7 +568,7 @@ function cheat.startplugin() end if cheat.share then for name, tag in pairs(cheat.share) do - local share = manager:machine():memory().shares[tag] + local share = manager.machine.memory.shares[tag] if not share then cheat_error(cheat, "missing share " .. share) return @@ -500,6 +580,17 @@ function cheat.startplugin() if not param then return end + cheat.set_index = set_index; + cheat.set_value = function(cheat, value) + local idx = ((value - cheat.parameter.min) / cheat.parameter.step) + 1 + local chg = false + if math.integer(idx) == idx then + idx, chg = cheat:set_index(idx) + end + return cheat.parameter.value, chg + end + cheat.get_index = function(cheat) return cheat.parameter.index end + cheat.get_value = function(cheat) return cheat.parameter.value end param.min = tonumber(param.min) or 0 param.max = tonumber(param.max) or #param.item param.step = tonumber(param.step) or 1 @@ -508,7 +599,7 @@ function cheat.startplugin() if not item.value then item.value = (count * param.step) + param.min else - item.value = tonumber(item.value) + item.value = tonumber(item.value) end end param.last = #param.item @@ -522,35 +613,56 @@ function cheat.startplugin() local hotkeymenu = false local hotkeylist = {} + local commonui + local poller local function menu_populate() local menu = {} if hotkeymenu then + local ioport = manager.machine.ioport + local input = manager.machine.input + menu[1] = {_("Select cheat to set hotkey"), "", "off"} - menu[2] = {"---", "", "off"} + menu[2] = {string.format(_("Press %s to clear hotkey"), manager.ui:get_general_input_setting(ioport:token_to_input_type("UI_CLEAR"))), "", "off"} + menu[3] = {"---", "", "off"} hotkeylist = {} - local function hkcbfunc(cheat) - local input = manager:machine():input() - manager:machine():popmessage(_("Press button for hotkey or wait to clear")) - manager:machine():video():frame_update(true) - input:seq_poll_start("switch") - local time = os.clock() - while (not input:seq_poll()) and (os.clock() < time + 1) do end - cheat.hotkeys = {pressed = false, keys = input:seq_poll_final()} - manager:machine():popmessage() - manager:machine():video():frame_update(true) + local function hkcbfunc(cheat, event) + if poller then + if poller:poll() then + if poller.sequence then + cheat.hotkeys = { pressed = false, keys = poller.sequence } + end + poller = nil + return true + end + elseif event == "clear" then + cheat.hotkeys = nil + return true + elseif event == "select" then + if not commonui then + commonui = require('commonui') + end + poller = commonui.switch_polling_helper() + return true + end + return false end for num, cheat in ipairs(cheats) do if cheat.script then - menu[#menu + 1] = {cheat.desc, cheat.hotkeys and manager:machine():input():seq_name(cheat.hotkeys.keys) or _("None"), ""} - hotkeylist[#hotkeylist + 1] = function() return hkcbfunc(cheat) end + local setting = cheat.hotkeys and input:seq_name(cheat.hotkeys.keys) or _("None") + menu[#menu + 1] = {cheat.desc, setting, ""} + hotkeylist[#hotkeylist + 1] = function(event) return hkcbfunc(cheat, event) end end end menu[#menu + 1] = {"---", "", ""} menu[#menu + 1] = {_("Done"), "", ""} - return menu + if poller then + return poller:overlay(menu) + else + return menu + end end for num, cheat in ipairs(cheats) do menu[num] = {} @@ -562,9 +674,9 @@ function cheat.startplugin() end menu[num][2] = "" menu[num][3] = "off" - elseif is_oneshot(cheat) then + elseif cheat.is_oneshot then menu[num][2] = _("Set") - menu[num][3] = 0 + menu[num][3] = "" else if cheat.enabled then menu[num][2] = _("On") @@ -576,7 +688,7 @@ function cheat.startplugin() end else if cheat.parameter.index == 0 then - if is_oneshot(cheat) then + if cheat.is_oneshot then menu[num][2] = _("Set") else menu[num][2] = _("Off") @@ -595,22 +707,25 @@ function cheat.startplugin() end end end - menu[#menu + 1] = {"---", "", 0} - menu[#menu + 1] = {_("Set hotkeys"), "", 0} - menu[#menu + 1] = {_("Reset All"), "", 0} - menu[#menu + 1] = {_("Reload All"), "", 0} + menu[#menu + 1] = {"---", "", ""} + menu[#menu + 1] = {_("Set hotkeys"), "", ""} + menu[#menu + 1] = {_("Reset All"), "", ""} + menu[#menu + 1] = {_("Reload All"), "", ""} return menu end local function menu_callback(index, event) - manager:machine():popmessage() + manager.machine:popmessage() if hotkeymenu then - if event == "select" then - index = index - 2 + if event == "back" then + hotkeymenu = false + return true + else + index = index - 3 if index >= 1 and index <= #hotkeylist then - hotkeylist[index]() + hotkeylist[index](event) return true - elseif index == #hotkeylist + 2 then + elseif index == #hotkeylist + 2 and event == "select" then hotkeymenu = false return true end @@ -623,22 +738,14 @@ function cheat.startplugin() hotkeymenu = true elseif index == 3 then for num, cheat in pairs(cheats) do - if cheat.enabled then - run_if(cheat, cheat.script.off) - bwpclr(cheat) - end - cheat.enabled = false + cheat:set_enabled(false) if cheat.parameter then - cheat.parameter.value = cheat.parameter.min - cheat.parameter.index = 0 + cheat:set_index(0) end end elseif index == 4 then for num, cheat in pairs(cheats) do - if cheat.enabled then - run_if(cheat, cheat.script.off) - bwpclr(cheat) - end + cheat:set_enabled(false) end cheats = load_cheats() for num, cheat in pairs(cheats) do @@ -649,97 +756,49 @@ function cheat.startplugin() return true end - local function param_calc(param) - if param.item then - if not param.item[param.index] then -- uh oh - param.index = 1 - end - param.value = param.item[param.index].value - return - end - param.value = param.min + (param.step * (param.index - 1)) - if param.value > param.max then - param.value = param.max - end - end - local cheat = cheats[index] if not cheat then return false end if event == "up" or event == "down" or event == "comment" then if cheat.comment then - manager:machine():popmessage(string.format(_("Cheat Comment:\n%s"), cheat.comment)) + manager.machine:popmessage(string.format(_("Cheat Comment:\n%s"), cheat.comment)) end elseif event == "left" then if cheat.parameter then - local param = cheat.parameter - if param.index == 1 then - param.index = 0 - cheat.enabled = false - cheat.cheat_env.param = param.min - run_if(cheat, cheat.script.off) - bwpclr(cheat) - return true - elseif param.index == 0 then - return false - end - param.index = param.index - 1 - param_calc(param) - cheat.cheat_env.param = param.value - if not is_oneshot(cheat) then - run_if(cheat, cheat.script.change) - end - return true + local idx, chg = cheat:set_index(cheat:get_index() - 1) + return chg else - if cheat.enabled and not is_oneshot(cheat) then - cheat.enabled = false - run_if(cheat, cheat.script.off) - bwpclr(cheat) - return true + if not cheat.is_oneshot then + local state, chg = cheat:set_enabled(false) + return chg end return false end elseif event == "right" then if cheat.parameter then - local param = cheat.parameter - if param.index == 0 then - cheat.enabled = true - run_if(cheat, cheat.script.on) - elseif param.index == param.last then - return false - end - param.index = param.index + 1 - param_calc(param) - cheat.cheat_env.param = param.value - if not is_oneshot(cheat) then - run_if(cheat, cheat.script.change) - end - return true + local idx, chg = cheat:set_index(cheat:get_index() + 1) + return chg else - if not cheat.enabled and not is_oneshot(cheat) then - cheat.enabled = true - run_if(cheat, cheat.script.on) - return true + if not cheat.is_oneshot then + local state, chg = cheat:set_enabled(true) + return chg end return false end elseif event == "select" then - if is_oneshot(cheat) then - if cheat.parameter and cheat.script.change and cheat.parameter.index ~= 0 then - param_calc(cheat.parameter) - cheat.cheat_env.param = cheat.parameter.value - cheat.script.change() - local subtext + if cheat.is_oneshot then + cheat:set_enabled(true) + if cheat.parameter and cheat.script.change and cheat:get_index() ~= 0 then + local itemtext if cheat.parameter.item then - subtext = cheat.parameter.item[cheat.parameter.index] + itemtext = cheat.parameter.item[cheat.parameter.index].text else - subtext = cheat.parameter.value + itemtext = cheat.parameter.value end - manager:machine():popmessage(string.format(_("Activated: %s = %s"), cheat.desc, subtext)) + manager.machine:popmessage(string.format(_("Activated: %s = %s"), cheat.desc, itemtext)) elseif not cheat.parameter and cheat.script.on then - cheat.script.on() - manager:machine():popmessage(string.format(_("Activated: %s"), cheat.desc)) + manager.machine:popmessage(string.format(_("Activated: %s"), cheat.desc)) end end end @@ -753,7 +812,7 @@ function cheat.startplugin() return menu_populate() end, _("Cheat")) - emu.register_start(function() + reset_subscription = emu.add_machine_reset_notifier(function () if not stop then return end @@ -761,7 +820,7 @@ function cheat.startplugin() start_time = emu.time() cheats = load_cheats() local json = require("json") - local file = io.open(manager:machine():options().entries.cheatpath:value():match("([^;]+)") .. "/output.json", "w") + local file = io.open(manager.machine.options.entries.cheatpath:value():match("([^;]+)") .. "/output.json", "w") if file then file:write(json.stringify(cheats, {indent = true})) file:close() @@ -770,19 +829,19 @@ function cheat.startplugin() parse_cheat(cheat) end load_hotkeys() - if manager:machine():debugger() then - consolelog = manager:machine():debugger().consolelog + if manager.machine.debugger then + consolelog = manager.machine.debugger.consolelog consolelast = 0 end end) - emu.register_stop(function() + stop_subscription = emu.add_machine_stop_notifier(function () stop = true consolelog = nil save_hotkeys() end) - emu.register_frame(function() + frame_subscription = emu.add_machine_frame_notifier(function () if stop then return end @@ -791,22 +850,22 @@ function cheat.startplugin() run_if(cheat, cheat.script.run) end if cheat.hotkeys and cheat.hotkeys.keys then - if manager:machine():input():seq_pressed(cheat.hotkeys.keys) then + if manager.machine.input:seq_pressed(cheat.hotkeys.keys) then if not cheat.hotkeys.pressed then - if is_oneshot(cheat) then + if cheat.is_oneshot then if not run_if(cheat, cheat.script.change) then run_if(cheat, cheat.script.on) end - manager:machine():popmessage(string.format(_("Activated: %s"), cheat.desc)) + manager.machine:popmessage(string.format(_("Activated: %s"), cheat.desc)) elseif not cheat.enabled then cheat.enabled = true run_if(cheat, cheat.script.on) - manager:machine():popmessage(string.format(_("Enabled: %s"), cheat.desc)) + manager.machine:popmessage(string.format(_("Enabled: %s"), cheat.desc)) else cheat.enabled = false run_if(cheat, cheat.script.off) bwpclr(cheat) - manager:machine():popmessage(string.format(_("Disabled: %s"), cheat.desc)) + manager.machine:popmessage(string.format(_("Disabled: %s"), cheat.desc)) end end cheat.hotkeys.pressed = true @@ -816,7 +875,7 @@ function cheat.startplugin() end end for num, input in pairs(inputs) do - local _, screen = next(manager:machine().screens) + local _, screen = next(manager.machine.screens) local framenum = screen:frame_number() - input.begin local enttab = input.start[framenum] if enttab then @@ -853,7 +912,7 @@ function cheat.startplugin() elseif draw.type == "line" then draw.scr:draw_line(draw.x1, draw.y1, draw.x2, draw.y2, draw.color) elseif draw.type == "box" then - draw.scr:draw_box(draw.x1, draw.y1, draw.x2, draw.y2, draw.bgcolor, draw.linecolor) + draw.scr:draw_box(draw.x1, draw.y1, draw.x2, draw.y2, draw.linecolor, draw.bgcolor) end end output = {} @@ -865,11 +924,50 @@ function cheat.startplugin() function ce.inject(newcheat) cheats[#cheats + 1] = newcheat parse_cheat(newcheat) - manager:machine():popmessage(string.format(_("%s added"), newcheat.desc)) + manager.machine:popmessage(string.format(_("%s added"), newcheat.desc)) end function ce.get(index) - return cheats[index] + local cheat = cheats[index] + if not cheat then + return nil + end + local intf = { + get_enabled = function() return cheat:get_enabled() end, + set_enabled = function(status) return cheat:set_enabled(status) end, + desc = cheat.desc, + is_oneshot = cheat.is_oneshot, + comment = cheat.comment, + get_hotkeys = function() if cheat.hotkeys then return cheat.hotkeys.keys end return nil end, + set_hotkeys = function(seq) cheat.hotkeys = { pressed = false, keys = manager.machine.input:seq_clean(seq) } end + } + if cheat.script then + intf.script = {} + if cheat.script.on then intf.script.on = true end + if cheat.script.off then intf.script.off = true end + if cheat.script.run then intf.script.run = true end + if cheat.script.change then intf.script.change = true end + end + + if cheat.parameter then + intf.parameter = {} + intf.get_value = function() return cheat:get_value() end + intf.set_value = function(value) return cheat:set_value(value) end + intf.get_index = function() return cheat:get_index() end + intf.set_index = function(index) return cheat:set_index(index) end + intf.parameter.min = cheat.parameter.min + intf.parameter.max = cheat.parameter.max + intf.parameter.step = cheat.parameter.step + if cheat.parameter.item then + intf.parameter.item = {} + for idx, item in pairs(cheat.parameter.item) do + intf.parameter.item[idx] = {} + intf.parameter.item[idx].text = cheat.parameter.item[idx].text + intf.parameter.item[idx].value = cheat.parameter.item[idx].value + end + end + end + return intf end function ce.list() @@ -880,7 +978,7 @@ function cheat.startplugin() return list end - _G.ce = ce + _G.emu.plugin.cheat = ce end |