User File #11431017349789927

Upload All User Files

#11431017349789927 - PSX Bugs Bunny - Lost in Time lua v2

bugsbunny.lua
886 downloads
Uploaded 12/19/2013 6:44 PM by Warepire (see all 18)
New lua script for PSX Bugs Bunny - Lost in Time NTSC (SLUS-00838).
New: Displays Angle (Thanks FatRatKnight), fixed Speed so it shows correctly.
--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
local XZdirection = 0

--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 = Xpos - XposOld
	local tempYspeed = Ypos - YposOld
	local tempZspeed = Zpos - ZposOld
	local tempXZdirection = ((math.atan2(tempZspeed, tempXspeed) / math.pi) * 180)
	if tempXspeed ~= 0 or tempYspeed ~= 0 or tempZspeed ~= 0 then
		Xspeed = math.abs(tempXspeed)
		Yspeed = math.abs(tempYspeed)
		Zspeed = math.abs(tempZspeed)
		XZdirection = tempXZdirection
	end
	
	XZspeed = math.sqrt(Xspeed*Xspeed + Zspeed*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    Angle: %3d\n",XZspeed,XZdirection)
		..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)