This is a small Lua script which is used for Mega Man games that use the "MMX RNG". In case you don't know what I mean by this, it's a 16-bit period-43534 RNG starting with the value 0xD37 and governed by the following formula:
local function nextrng(rng)
local rngh=(math.floor(rng*3/256))%256
local rngl=(rngh+rng)%256
rng=rngh*256+rngl
return rng
end
This Lua script uses a reverse lookup to display the index of the RNG (0xD37 = index 0, 0x275E = index 1, etc.).
This Lua script also displays the R-F value for X-X6, which is (RNG index minus current framecount) mod 43534. When inside a stage, a ROM subroutine auto-runs the RNG at one cycle per frame without using it, so this value can be used to detect unusual RNG advances which *are* used by the game. MM7 has similarly a "R-2F" value (since RNG runs at two cycles per frame), whereas R&F does not run the RNG except when needed and so does not need to display such a value.
This Lua script also displays the current RNG value, the 3 RNG values before it, and the 6 RNG values after it.