Advertisement
MrCheeze

mm_position_tracker.lua

Nov 16th, 2019
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. goalpos_x = 2590.9775
  2. goalpos_z = -157.1325
  3.  
  4. while true do
  5.     link_x = mainmemory.readfloat(0x3FFDD4, true)
  6.     link_z = mainmemory.readfloat(0x3FFDDC, true)
  7.     link_angle = mainmemory.read_u16_be(0x3FFE6E) * 2 * math.pi / 0x10000
  8.    
  9.     x_dist = goalpos_x-link_x
  10.     z_dist = goalpos_z-link_z
  11.    
  12.     h = z_dist / math.cos(link_angle)
  13.    
  14.     x2 = z_dist*math.tan(link_angle) - x_dist
  15.    
  16.     forward_distance = h - (x2 * math.sin(link_angle))
  17.     right_distance = x2 * math.cos(link_angle)
  18.    
  19.     gui.text(0, 200, string.format("Forward: %f", forward_distance))
  20.     gui.text(0, 215, string.format("Right: %f", right_distance))
  21.    
  22.     emu.frameadvance()
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement