Advertisement
Miguzepinu

bisrng.lua

Apr 30th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. rng_address = 0x0205BAC2
  2. lucky_chance = 5 --(out of 100)
  3. lucky_chance_high = 6
  4. v_space = 9
  5. yorng = 55555
  6.  
  7. function BitAND(a,b)--Bitwise and
  8.     p,c = 1,0
  9.     while a>0 and b>0 do
  10.         local ra, rb = a%2, b%2
  11.         if ra+rb > 1 then
  12.             c = c+p
  13.         end
  14.         a, b, p = (a-ra)/2, (b-rb)/2, p*2
  15.     end
  16.     return c
  17. end
  18.  
  19. function nextRNG(seed)--RNG algorithm
  20.     return BitAND(math.floor(seed*20.5), 0x7fff) + seed%2*0x8000
  21. end
  22.  
  23. function fn()
  24.     rng = memory.readword(rng_address)--get current (most recently used) RNG
  25.     gui.text(0, -190, rng, "red")--display current RNG
  26.     for i = 1,20 do --for each next 20 RNG values
  27.         rng = nextRNG(rng)-- find next RNG value
  28.        
  29.         color = ""
  30.         if rng%100 < lucky_chance then
  31.             color = "#FFFF00"
  32.         elseif rng%100 < lucky_chance_high then
  33.             color = "#FFAA00"
  34.         end
  35.         gui.text(0, i*v_space-190, rng, color)
  36.         if rng == yorng then
  37.             gui.text(69, i*v_space-190, "yoooo")
  38.         end
  39.     end
  40. end
  41.  
  42. gui.register(fn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement