Script that randomly produces inputs to change the configuration of the board
local filePath = "manipframes.txt"
local file = io.open(filePath, "r")
if not file then
error("Could not open file " .. filePath)
end
local fileContent = file:read("*all")
file:close()
-- Convert the comma-separated string into a table of numbers
local framesToPressUp = {}
for frame in string.gmatch(fileContent, "%d+") do
table.insert(framesToPressUp, tonumber(frame))
end
-- Function to check if a value exists in a table
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
-- Function to press UP for player 1
local function pressUp()
joypad.set({["Key Left Arrow"]=true})
end
-- Main loop
while true do
local frameNumber = emu.framecount()
-- Check if the current frame is in the list of frames to press UP
if table.contains(framesToPressUp, frameNumber) then
pressUp()
end
emu.frameadvance()
end