Created
January 21, 2019 16:37
-
-
Save EvilAsh25/a1c6967b611cb1e7f4ad1f401211939e to your computer and use it in GitHub Desktop.
DW2 Lottery Ticket Lua
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,'Ticket: '..found..' ('..(math.floor(1000 * found / (total)) / 10)..'%)') | |
gui.text(10,260,'Nothing: '..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); | |
--wait for the purchase to resolve | |
for i=0,60 do | |
joypad.set({A=true}, 1) | |
Wait(1) | |
end | |
--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