User File #11121845087737973

Upload All User Files

#11121845087737973 - PSX Bugs Bunny - Lost in Time lua v1

bugsbunny.lua
922 downloads
Uploaded 12/5/2013 8:34 PM by Warepire (see all 18)
--position and speed
local Xpos
local XposOld = 0
local Ypos
local YposOld = 0
local Zpos
local ZposOld = 0
local Xspeed = 0
local Yspeed = 0
local Zspeed = 0
--not really a need to look at Y-speed as it seems to be independent of XZ speed, might still be useful for jumping.
local XZspeed

--stats
local health
local inlvlCarrots
local inlvlGoldenCarrots
local inlvlClocks
local inlvlACME
local totalCarrots
local totalGoldenCarrots
local totalClocks
local abilities
local jump = false
local music = false
local sesame = false
local fan = false

local function hud()
	--Actual speed vector addresses, not very good as they show speed even when you're blocked by a wall etc.
	--addr 00069D30 X Speed [signed word]
	--addr 00069D34 Y Speed(?)  [signed word]
	--addr 00069D38 Z Speed [signed word]
	Xpos = memory.readdwordsigned(0x00069DC0)
	Ypos = memory.readdwordsigned(0x00069DC4)
	Zpos = memory.readdwordsigned(0x00069DC8)
	--will not show the proper speed on the first frame of a level
	--the game only runs at 30 fps.
	local tempXspeed = math.abs(Xpos - XposOld)
	local tempYspeed = math.abs(Ypos - YposOld)
	local tempZspeed = math.abs(Zpos - ZposOld)
	if tempXspeed ~= 0 or tempYspeed ~= 0 or tempZspeed ~= 0 then
		Xspeed = tempXspeed
		Yspeed = tempYspeed
		Zspeed = tempZspeed
	end
	
	XZspeed = Xspeed + Zspeed

	health = memory.readbyte(0x00010041)
	inlvlCarrots = memory.readbyte(0x00069525)
	inlvlGoldenCarrots = memory.readbyte(0x00069574)
	inlvlClocks = memory.readbyte(0x00069514)
	inlvlACME = memory.readbyte(0x00010044)
	totalCarrots = memory.readbyte(0x00010043)
	totalGoldenCarrots = (memory.readbyte(0x0001013C)*256) + memory.readbyte(0x00010047)
	totalClocks = memory.readbyte(0x00010045)
	abilities = memory.readbyte(0x00010048) --0x08 == SuperJump
	if abilities >= 0x08 then
		jump = true
		abilities = abilities - 0x08
	end
	-- TODO: The rest of the abilities
	
	gui.opacity(1.0)
	gui.text(0,0,string.format("Pos (%6d,%6d,%6d)\n",Xpos,Ypos,Zpos)
		..string.format("Speed XZ: %3d\n",XZspeed)
		..string.format("Speed  Y: %3d\n\n",Yspeed)
		..string.format("Health: %d\n",health)
		..string.format("Carrots: %d\n",totalCarrots)
		..string.format("LVL Golden: %2d  Total Golden: %3d\n",inlvlGoldenCarrots,totalGoldenCarrots)
		..string.format("LVL Clocks: %2d  Total Clocks: %3d\n",inlvlClocks,totalClocks)
		..string.format("ACME boxes: %d\n\n",inlvlACME)
		..string.format("Jump:   %s\n",tostring(jump))
		..string.format("Music:  %s\n",tostring(music))
		..string.format("Sesame: %s\n",tostring(sesame))
		..string.format("Fan:    %s\n",tostring(fan)))

	XposOld = Xpos
	YposOld = Ypos
	ZposOld = Zpos
end

gui.register(hud)