Last active
April 24, 2018 23:01
-
-
Save sagnew/2d9db4061236a4f6978402ca5fcf98e4 to your computer and use it in GitHub Desktop.
pokemon
This file contains hidden or 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
function read_file(name) | |
local input = io.open(name, 'r') | |
if input ~= nil then | |
io.input(input) | |
content = io.read() | |
io.close(input) | |
return content | |
end | |
return nil | |
end | |
function file_exists(name) | |
local f = io.open(name, 'r') | |
local exists = f ~= nil | |
io.close(f) | |
return exists | |
end | |
function press_button(button) | |
input_table = {} | |
input_table[button] = true | |
joypad.set(1, input_table) | |
end | |
while true do | |
local button = read_file('button.txt') | |
if button ~= nil then | |
press_button(button) | |
emu.message('Pressing: ' .. button) | |
os.remove('button.txt') | |
end | |
emu.frameadvance() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment