Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mdword=memory.readdwordunsigned
- mbyte=memory.readbyte
- rshift=bit.rshift
- -- Initialize on Script Startup
- local frame = 0
- local iframe = 0
- local seed = 0
- local initial = 0
- memory.registerwrite(0x021D15AC, function() frame = frame + 1 end)
- memory.registerwrite(0x0210F6CC, function() iframe = iframe + 1 end)
- function buildseed()
- delay=mdword(0x021D1138)
- timehex=mdword(0x023FFDEC)
- datehex=mdword(0x023FFDE8)
- hour=string.format("%02X",(timehex%0x100)%0x40) -- memory stores as decimal, but Lua reads as hex. Convert.
- minute=string.format("%02X",(rshift(timehex%0x10000,8)))
- second=string.format("%02X",(mbyte(0x02FFFDEE)))
- year=string.format("%02X",(mbyte(0x02FFFDE8)))
- month=string.format("%02X",(mbyte(0x02FFFDE9)))
- day=string.format("%02X",(mbyte(0x02FFFDEA)))
- ab=(month*day+minute+second)%256 -- Build Seed
- cd=hour
- cgd=delay%65536 +1 -- can tweak for calibration
- abcd=ab*0x100+cd
- efgh=(year+cgd)%0x10000
- nextseed=ab*0x1000000+cd*0x10000+efgh -- Seed is built
- return nextseed
- end
- function main()
- currseed = mdword(0x021D15A8)
- seed = mdword(0x021D15AC)
- -- Detect initial seeding
- if mdword(0x021D15AC) == currseed then
- initial = mdword(0x021D15A8)
- if currseed ~= 0x00000000 then
- iframe = 0
- frame = 0
- end
- end
- if mdword(0x021D15A8) == 0 then -- if seed is 0, reset everything
- iframe = 0
- frame = 0
- end
- -- Print variables in corner of bottom screen
- if frame == 0 then
- gui.text(0,-10,string.format("Next Seed: %08X", buildseed()))
- end
- gui.text(0,180,string.format("Initial Seed: %08X", initial))
- gui.text(0,170,string.format("Current Seed: %08X", currseed))
- gui.text(0,160,string.format("IRNG Frame: %d", iframe))
- gui.text(0,150,string.format("PRNG Frame: %d", frame))
- gui.text(0,140,string.format("Delay: %d", mdword(0x021D1138)))
- end
- gui.register(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement