Advertisement
Miguzepinu

pitspd.lua

May 9th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. x1 = 0
  2. x2 = 0
  3. z1 = 0
  4. z2 = 0
  5. t1 = 0
  6. t2 = 0
  7. rp = 0x022077CC --room pointer address (E: 0x0220A264)
  8. srp  = 0x0232E7CC --subroom pointer address
  9.  
  10. ctrl = 1 --0 for adults, 1 for babies
  11. in_a_subroom = 1
  12. --TODO: find addresses for these
  13.  
  14. if in_a_subroom == 1 then rp = srp ctrl = 0 end
  15.  
  16. destx = 215 --destination x-coordinate
  17. destz = 256 --destination z-coordinate
  18. local xv,zv,dt,parity
  19.  
  20. function fn()
  21.     parity = memory.readbyte(0x023FFC3C)%2
  22.     offset = ctrl*0x3100+0x00F4
  23.     xa = memory.readdword(rp)+offset
  24.     za = xa+4
  25.     x = memory.readdword(xa)/0x1000
  26.     z = memory.readdword(za)/0x1000
  27.     if parity == 0 then
  28.         x1 = x
  29.         xv = x1-x2
  30.         z1 = z
  31.         zv = z1-z2
  32.     end
  33.     if parity == 1 then
  34.         x2 = x
  35.         xv = x2-x1
  36.         z2 = z
  37.         zv = z2-z1
  38.     end
  39.     --x = string.format("%x", x)
  40.     --z = string.format("%x", z)
  41.     gui.text(0,0,"Velocity:")
  42.     gui.text(10,0,"X")
  43.     gui.text(20,0,"Z")
  44.     gui.text(40,0,"Position")
  45.     gui.text(0,40,x)
  46.     gui.text(0,50,z)
  47.     --gui.text(0,60,z-x)
  48.     if math.abs(xv) < 30 then
  49.         gui.text(10,0,xv)
  50.     else
  51.         gui.text(10,0,"??")
  52.     end
  53.     if math.abs(zv) < 14 then
  54.         gui.text(0,10,zv)
  55.     else
  56.         gui.text(0,10,"??")
  57.     end
  58. end
  59. function fcn()
  60.     parity = memory.readbyte(0x023FFC3C)%2
  61.     offset = ctrl*0x3100+0x00F4
  62.     xa = memory.readdword(rp)+offset
  63.     --xa = 0x02315FE8
  64.     za = xa+4
  65.     x = memory.readdword(xa)/0x1000
  66.     z = memory.readdword(za)/0x1000
  67.     t = Time(x, z, destx, destz)
  68.     if parity == 0 then
  69.         t1 = t
  70.         dt = t1-t2
  71.     end
  72.     if parity == 1 then
  73.         t2 = t
  74.         dt = t2-t1
  75.     end
  76.     gui.text(0,0,-dt)
  77.     gui.text(0,20,t)
  78. end
  79. function Time(xi,zi,xf,zf)
  80.     x = math.abs(xf-xi)
  81.     z = math.abs(zf-zi)
  82.     output = x/1.5
  83.     if x > z then
  84.         output = x/2 + z/6
  85.     end
  86.     if x < z then
  87.         output = x/6 + z/2
  88.     end
  89.     return output
  90. end
  91. gui.register(fn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement