User File #39122375574814107

Upload All User Files

#39122375574814107 - Ape Escape - direction and speed hud

Ape Escape - direction and speed hud.lua
Game: Ape Escape ( PSX, see all files )
632 downloads
Uploaded 5/19/2017 8:52 PM by ThunderAxe31 (see all 111)
Script I made that shows on game screen direction and speed values of last and priors frames. This will make micro optimizations much easier.
---PSX Ape Escape (USA) direction and speed hud lua script v1.0 by ThunderAxe31

camera_dir_addr = 0x0EC334
player_dir_addr = 0x0EC21C
x_pos_addr = 0x0EC204
y_pos_addr = 0x0EC20C

framecount = 16640000

player_x = 0
player_y = 0
player_x_old = 0
player_y_old = 0
player_x_spe = 0
player_y_spe = 0

camera_dir_all = ""
player_dir_all = ""
player_x_spe_all = ""
player_y_spe_all = ""
player_xy_spe_all = ""

function string_trim(trim_me)
	last_found = 0
	occurences = 0
	while last_found ~= nil do
		occurences = occurences + 1
		if occurences > 17 then
			trim_me = string.sub(trim_me, 0, last_found)
		end
		last_found = string.find(trim_me, "\n", last_found+1)
	end
	return trim_me
end

while true do
	player_x = memory.read_s16_le(x_pos_addr)
	player_y = memory.read_s16_le(y_pos_addr)

	player_x_spe = player_x - player_x_old
	player_y_spe = player_y - player_y_old
	player_xy_spe = (player_x_spe^2+player_y_spe^2)^0.5

	camera_dir_all = memory.read_s16_le(camera_dir_addr) .. "\n" .. camera_dir_all
	player_dir_all = memory.read_s16_le(player_dir_addr) .. "\n" .. player_dir_all
	player_x_spe_all = player_x_spe .. "\n" .. player_x_spe_all
	player_y_spe_all = player_y_spe .. "\n" .. player_y_spe_all
	player_xy_spe_all = player_xy_spe .. "\n" .. player_xy_spe_all

	if framecount > emu.framecount() then
		camera_dir_all = ""
		player_dir_all = ""
		player_x_spe_all = ""
		player_y_spe_all = ""
		player_xy_spe_all = ""
	end

	camera_dir_all = string_trim(camera_dir_all)
	player_dir_all = string_trim(player_dir_all)
	player_x_spe_all = string_trim(player_x_spe_all)
	player_y_spe_all = string_trim(player_y_spe_all)
	player_xy_spe_all = string_trim(player_xy_spe_all)

	gui.text(0, 0, "Camera Player X spe Y spe XY spe")
	gui.text(0, 15, camera_dir_all)
	gui.text(70, 15, player_dir_all)
	gui.text(140, 15, player_x_spe_all)
	gui.text(200, 15, player_y_spe_all)
	gui.text(260, 15, player_xy_spe_all)

	player_x_old = player_x
	player_y_old = player_y
	player_z_old = player_z

	framecount = emu.framecount()
	emu.frameadvance()
end