Advertisement
Guest User

Ape Escape direction and speed

a guest
May 19th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. ---PSX Ape Escape (USA) direction and speed hud lua script v1.0 by ThunderAxe31
  2.  
  3. camera_dir_addr = 0x0EC334
  4. player_dir_addr = 0x0EC21C
  5. x_pos_addr = 0x0EC204
  6. y_pos_addr = 0x0EC20C
  7.  
  8. framecount = 16640000
  9.  
  10. player_x = 0
  11. player_y = 0
  12. player_x_old = 0
  13. player_y_old = 0
  14. player_x_spe = 0
  15. player_y_spe = 0
  16.  
  17. camera_dir_all = ""
  18. player_dir_all = ""
  19. player_x_spe_all = ""
  20. player_y_spe_all = ""
  21. player_xy_spe_all = ""
  22.  
  23. function string_trim(trim_me)
  24.     last_found = 0
  25.     occurences = 0
  26.     while last_found ~= nil do
  27.         occurences = occurences + 1
  28.         if occurences > 17 then
  29.             trim_me = string.sub(trim_me, 0, last_found)
  30.         end
  31.         last_found = string.find(trim_me, "\n", last_found+1)
  32.     end
  33.     return trim_me
  34. end
  35.  
  36. while true do
  37.     player_x = memory.read_s16_le(x_pos_addr)
  38.     player_y = memory.read_s16_le(y_pos_addr)
  39.  
  40.     player_x_spe = player_x - player_x_old
  41.     player_y_spe = player_y - player_y_old
  42.     player_xy_spe = (player_x_spe^2+player_y_spe^2)^0.5
  43.  
  44.     camera_dir_all = memory.read_s16_le(camera_dir_addr) .. "\n" .. camera_dir_all
  45.     player_dir_all = memory.read_s16_le(player_dir_addr) .. "\n" .. player_dir_all
  46.     player_x_spe_all = player_x_spe .. "\n" .. player_x_spe_all
  47.     player_y_spe_all = player_y_spe .. "\n" .. player_y_spe_all
  48.     player_xy_spe_all = player_xy_spe .. "\n" .. player_xy_spe_all
  49.  
  50.     if framecount > emu.framecount() then
  51.         camera_dir_all = ""
  52.         player_dir_all = ""
  53.         player_x_spe_all = ""
  54.         player_y_spe_all = ""
  55.         player_xy_spe_all = ""
  56.     end
  57.  
  58.     camera_dir_all = string_trim(camera_dir_all)
  59.     player_dir_all = string_trim(player_dir_all)
  60.     player_x_spe_all = string_trim(player_x_spe_all)
  61.     player_y_spe_all = string_trim(player_y_spe_all)
  62.     player_xy_spe_all = string_trim(player_xy_spe_all)
  63.  
  64.     gui.text(0, 0, "Camera Player X spe Y spe XY spe")
  65.     gui.text(0, 15, camera_dir_all)
  66.     gui.text(70, 15, player_dir_all)
  67.     gui.text(140, 15, player_x_spe_all)
  68.     gui.text(200, 15, player_y_spe_all)
  69.     gui.text(260, 15, player_xy_spe_all)
  70.  
  71.     player_x_old = player_x
  72.     player_y_old = player_y
  73.     player_z_old = player_z
  74.  
  75.     framecount = emu.framecount()
  76.     emu.frameadvance()
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement