Created
January 21, 2019 16:33
-
-
Save EvilAsh25/8590b462dac5f2b8f580f81a72c7d18d to your computer and use it in GitHub Desktop.
DW2 Dew's Yarn Lua test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--This script is designed to work with Bizhawk | |
--This script assumes a pre-made state on Quicksave Slot 0 | |
--Set the correct memory domain | |
memory.usememorydomain("System Bus") | |
--define variables | |
found = 0 | |
fail = 0 | |
total = 0 | |
save_state_slot = 0 -- which quickload slot to load from | |
--Wait function for advancing 1 frame and displaying results on the screen | |
function Wait(number) | |
for i=0,number-1 do | |
emu.frameadvance() | |
gui.text(10,228,'Total: '..total) | |
--gui.text(350,40,'Total: '..total) | |
if(total ~= 0) then | |
gui.text(10,244,'Success : '..found..' ('..(math.floor(1000 * found / (total)) / 10)..'%)') | |
gui.text(10,260,'Fail: '..fail..' ('..(math.floor(1000 * fail / (total)) / 10)..'%)') | |
end | |
end | |
end | |
--the main loop | |
while total < 10000 do | |
--load the savestate | |
savestate.loadslot(save_state_slot); | |
Wait(math.random(5)+1); --wait a random number of frames | |
savestate.saveslot(save_state_slot); | |
joypad.set({A=true}, 1) | |
--wait for the search to resolve | |
Wait(50); | |
--read the variables we need to record data | |
value = memory.readbyte(0x060D); | |
if value ~= 0 then | |
--Success | |
found = found + 1; | |
else | |
--Fail | |
fail = fail + 1; | |
end | |
total = total + 1; | |
Wait(1); | |
end | |
while true do | |
Wait(1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment