That code was to give you the basic function, but I wouldn't advise trying to build upon it. Here's something more usable:
--ff2macro.lua
function frameadvance(frames)
for i = 0, frames or 1 do
joypad.set(1, joy)
FCEU.frameadvance()
joy = {}
end
end
function press(button, frames)
joy[button] = true
frameadvance(30)
end
joy = {}
FCEU.speedmode("maximum")
for loop = 1, 100 do
press("down")
press("down")
press("A")
frameadvance(20)
press("A")
press("A")
frameadvance(55)
press("B")
end
FCEU.speedmode("normal")
This script selects the topmost spell in a character's magic collection, targets something with it, cancels the next character's turn, and repeats.
As you can probably guess, the "press" function taps any button, and waits for a half-second. A half-second is usually enough of a delay to let the game get ready for more input, but sometimes you need to add more delay with 'frameadvance'.
You should be able to use these functions to construct a wide variety of macros. Don't forget to comment out the speedmode("maximum") line when testing.