plugins/cheat: add game time for cheats which want a time delay (nw)

This commit is contained in:
cracyc 2016-04-13 11:40:06 -05:00
parent 3c774adb53
commit 94007d2887

View File

@ -66,6 +66,7 @@ function cheat.startplugin()
local cheats = {}
local output = {}
local line = 0
local start_time = 0
local function load_cheats()
local filename = emu.romname()
@ -146,6 +147,11 @@ function cheat.startplugin()
return result
end
local function time()
return emu.time() - start_time
end
local function parse_cheat(cheat)
cheat.cheat_env = { draw_text = draw_text,
draw_line = draw_line,
@ -154,6 +160,7 @@ function cheat.startplugin()
frombcd = frombcd,
pairs = pairs,
ipairs = ipairs,
time = time,
table =
{ insert = table.insert,
remove = table.remove } }
@ -422,6 +429,7 @@ function cheat.startplugin()
end, "Cheat")
emu.register_start(function()
start_time = emu.time()
cheats = load_cheats()
for num, cheat in pairs(cheats) do
parse_cheat(cheat)