User File #31488030838422103

Upload All User Files

#31488030838422103 - Mega Man ZX XY speed Lua + velocity change thing

Mega Man ZX speed.lua
1087 downloads
Uploaded 6/10/2016 1:18 AM by ALAKTORN (see all 34)
Helpful when you’re jumping over walls to make sure you don’t clip them.
local XAddr = memory.readdwordsigned(0x0214FB64)
local YAddr = memory.readdwordsigned(0x0214FB68)
local speedAddr = memory.readwordsigned(0x0214FB6C)
local prevX = nil
local prevY = nil
local X = "N/A"
local Y = "N/A"
local realspeed = "N/A"
local speed = nil
local prevSpeed = nil

function fn()
	XAddr = memory.readdwordsigned(0x0214FB64)
	YAddr = memory.readdwordsigned(0x0214FB68)
	speedAddr = memory.readwordsigned(0x0214FB6C)
	local currentX = XAddr
	local currentY = YAddr
	local currentSpeed = speedAddr
	if prevX ~= nil and prevY ~= nil then
		X = currentX - prevX
		Y = currentY - prevY
		realspeed = X
	end
	if prevSpeed ~= nil then
		speed = currentSpeed - prevSpeed
		if speed ~= 0 or lastSpeed ~= 0 then
			print("Speed difference: " .. speed)
		end
	end
	prevX = currentX
	prevY = currentY
	prevSpeed = currentSpeed
	lastSpeed = speed
end

function fm()
	gui.text(0, 2, "Real X Speed: " .. X)
	gui.text(0, 12, "Real Y Speed: " .. Y)
	gui.text(0, 22, "RAM    Speed: " .. speedAddr)
	gui.text(0, 32, "Real   Speed: " .. realspeed)
end

emu.registerafter(fn)
gui.register(fm)