All pastes #1361844 Raw Edit

sonic_levelcontrol.lua

public lua v1 · immutable
#1361844 ·published 2009-03-16 00:46 UTC
rendered paste body
addr_zone = 0xfffe10addr_act = 0xfffe11addr_restartflag = 0xfffe02input_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	endend)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_valueendinput.registerhotkey(1, function()	memory.writebyte(addr_zone, memory.readbyte(addr_zone) - 1)	memory.writebyte(addr_restartflag, 1)end)input.registerhotkey(2, function()	memory.writebyte(addr_zone, memory.readbyte(addr_zone) + 1)	memory.writebyte(addr_restartflag, 1)end)input.registerhotkey(3, function()	memory.writebyte(addr_act, memory.readbyte(addr_act) - 1)	memory.writebyte(addr_restartflag, 1)end)input.registerhotkey(4, function()	memory.writebyte(addr_act, memory.readbyte(addr_act) + 1)	memory.writebyte(addr_restartflag, 1)end)