User File #48040953679364406

Upload All User Files

#48040953679364406 - SNES Addams Family hud v1.2

SNES Addams Family hud v1.2.lua
834 downloads
Uploaded 6/25/2018 12:29 PM by ThunderAxe31 (see all 111)
Lua script that displays useful addresses on screen, with the addition of real speed and absolute position.
--SNES Addams Family - hud script v1.2 by ThunderAxe31

local addr_relative_x   = 0x00006E
local addr_relative_y   = 0x000070
local addr_camera_x     = 0x00009B
local addr_camera_y     = 0x00009D
local addr_to_2_pixels  = 0x000004
local addr_to_3_pixels  = 0x000006
local addr_to_4_pixels  = 0x000008
local addr_sword_weapon = 0x0000EE
local addr_ball_weapon  = 0x0000EF

local old_relative_x = 0
local old_relative_y = 0
local old_camera_x   = 0
local old_camera_y   = 0
local old_absolute_x = 0
local old_absolute_y = 0

local framecount = -1

if memory.usememorydomain("WRAM") then
	while true do
		local relative_x = memory.read_s16_le(addr_relative_x)
		local relative_y = memory.read_s16_le(addr_relative_y)
		local camera_x   = memory.read_s16_le(addr_camera_x)
		local camera_y   = memory.read_s16_le(addr_camera_y)
		local absolute_x = relative_x + camera_x
		local absolute_y = relative_y + camera_y
		
		local speed_relative_x = relative_x - old_relative_x
		local speed_relative_y = relative_y - old_relative_y
		local speed_camera_x   = camera_x   - old_camera_x
		local speed_camera_y   = camera_y   - old_camera_y
		local speed_absolute_x = absolute_x - old_absolute_x
		local speed_absolute_y = absolute_y - old_absolute_y
		
		if speed_relative_x > 0 then speed_relative_x = "+" .. speed_relative_x end
		if speed_relative_y > 0 then speed_relative_y = "+" .. speed_relative_y end
		if speed_camera_x   > 0 then speed_camera_x   = "+" .. speed_camera_x   end
		if speed_camera_y   > 0 then speed_camera_y   = "+" .. speed_camera_y   end
		if speed_absolute_x > 0 then speed_absolute_x = "+" .. speed_absolute_x end
		if speed_absolute_y > 0 then speed_absolute_y = "+" .. speed_absolute_y end
		
		if framecount ~= emu.framecount()-1 then
			speed_relative_x = ""
			speed_relative_y = ""
			speed_camera_x   = ""
			speed_camera_y   = ""
			speed_absolute_x = ""
			speed_absolute_y = ""
		end
		
		old_relative_x = relative_x
		old_relative_y = relative_y
		old_camera_x   = camera_x
		old_camera_y   = camera_y
		old_absolute_x = absolute_x
		old_absolute_y = absolute_y
		
		local to_2_pixels = memory.read_s8(addr_to_2_pixels)
		local to_3_pixels = memory.read_s8(addr_to_3_pixels)
		local to_4_pixels = memory.read_s8(addr_to_4_pixels)
		
		local sword_weapon = memory.read_s8(addr_sword_weapon)
		local ball_weapon  = memory.read_s8(addr_ball_weapon)
		
		local hud_y_offset = 0
		if relative_y < 28 then hud_y_offset = 196 end
		
		gui.pixelText(0, hud_y_offset, "           X Pos X Spe |  Y Pos Y Spe || Countdown to|| Weapon\nRelative:" .. string.format("%7s", relative_x) .. string.format("%6s", speed_relative_x) .. " |" .. string.format("%7s", relative_y) .. string.format("%6s", speed_relative_y) .. " || 2 pixel: " .. string.format("%2s", to_2_pixels) .. " || Sword:" .. sword_weapon .. "\n  Camera:" .. string.format("%7s", camera_x) .. string.format("%6s", speed_camera_x) .. " |" .. string.format("%7s", camera_y) .. string.format("%6s", speed_camera_y) .. " || 3 pixel: " .. string.format("%2s", to_3_pixels) .. " || Ball: " .. ball_weapon .. "\nAbsolute:" .. string.format("%7s", absolute_x) .. string.format("%6s", speed_absolute_x) .. " |" .. string.format("%7s", absolute_y) .. string.format("%6s", speed_absolute_y) .. " || 4 pixel: " .. string.format("%2s", to_4_pixels) .. " ||")
		
		framecount = emu.framecount()
		
		emu.frameadvance()
	end
end