Script showing on screen speed values
--PSX Wild Arms (USA) speed hud lua script v1.0 by ThunderAxe31
max_lines = 20 --maximum amount of lines of values that will be displayed at the same time
x_pos_addr = 0x133EC0
y_pos_addr = 0x133EC4
x_sub_pos_addr = 0x133ECC
y_sub_pos_addr = 0x133ED0
framecount = 16640000
player_x = 0
player_y = 0
player_x_sub = 0
player_y_sub = 0
player_x_old = 0
player_y_old = 0
player_x_spe = 0
player_y_spe = 0
player_xy_spe = 0
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 > max_lines 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_s32_le(x_pos_addr)+(memory.read_u32_le(x_sub_pos_addr)/4096)
player_y = memory.read_s32_le(y_pos_addr)+(memory.read_u32_le(y_sub_pos_addr)/4096)
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
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
player_x_spe_all = ""
player_y_spe_all = ""
player_xy_spe_all = ""
end
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.pixelText(0, 0, "X Speed Y Speed XY Speed")
gui.pixelText(0, 8, player_x_spe_all)
gui.pixelText(69, 8, player_y_spe_all)
gui.pixelText(138, 8, player_xy_spe_all)
player_x_old = player_x
player_y_old = player_y
framecount = emu.framecount()
emu.frameadvance()
end