Double post. A useful double post, though. ;)
Updated OP with third revision. Just a couple minor changes.
Also, been messing around with other things. Here's a script that lets you change the zone/act in Sonic 1/2/3/K via clickable buttons:
addr_zone = 0xfffe10
addr_act = 0xfffe11
addr_restartflag = 0xfffe02
input_state = {}
gui.register( function()
input_state = input.get()
local zone = memory.readbyte(addr_zone)
local act = memory.readbyte(addr_act)
local restartflag = memory.readbyte(addr_restartflag)
gui.text(0, 217, string.format("Zone %X", zone))
if restartflag == 0 then
if do_button("-", 32, 216, 6, 7) then
memory.writebyte(addr_zone, zone - 1)
memory.writebyte(addr_restartflag, 1)
end
if do_button("+", 39, 216, 6, 7) then
memory.writebyte(addr_zone, zone + 1)
memory.writebyte(addr_restartflag, 1)
end
end
gui.text(52, 217, string.format("Act %X", act))
if restartflag == 0 then
if do_button("-", 80, 216, 6, 7) then
memory.writebyte(addr_act, act - 1)
memory.writebyte(addr_restartflag, 1)
end
if do_button("+", 87, 216, 6, 7) then
memory.writebyte(addr_act, act + 1)
memory.writebyte(addr_restartflag, 1)
end
end
if restartflag == 0 then
if do_button("Restart", 100, 216, 30, 7) then
memory.writebyte(addr_restartflag, 1)
end
end
end)
function do_button(text, x, y, width, height)
local return_value, fill_color, outline_color
if (input_state.xmouse >= x and input_state.ymouse >= y) and
(input_state.xmouse <= x + width and input_state.ymouse <= y + height) then
outline_color = {255, 255, 255, 255}
if input_state.leftclick then
return_value = true
fill_color = {127, 0, 0, 255}
else
fill_color = {0, 0, 192, 255}
end
else
fill_color = {0, 0, 127, 255}
outline_color = {0, 0, 255, 255}
end
gui.box(x, y, x + width, y + height, fill_color, outline_color)
gui.text(x + 2, y + 2, text, {255, 255, 255, 255}, {0, 0, 0, 0})
return return_value
end
Screenshot: