Here are some sample scripts that I made.
The first one keys in second-player input based on first-player input. Select key changes the symmetry. This allows the two players to sync with each other. Motivated by the game Strike Gunner: S.T.G. (SNES autoscroller), but can be done with any game.
local d=0
local e=0
local key={}
while true do
key=joypad.read(1)
if key.select==1 then
d=d+1
end
if d==4 then
d=0
end
if d==1 or d==2 then
e=key.left
key.left=key.right
key.right=e
end
if d==2 or d==3 then
e=key.up
key.up=key.down
key.down=e
end
joypad.set(2,key)
if d==0 then
gui.text(1,20,"normal")
end
if d==1 then
gui.text(1,20,"hmirror")
end
if d==2 then
gui.text(1,20,"rotate")
end
if d==3 then
gui.text(1,20,"vmirror")
end
snes9x.frameadvance()
end
The second one is a bot. This particular one is specific to Vegas Stakes (SNES) and tries to find combinations for the slot machine. It must be run from a .000 (F1) savestate which is in "The 2020" casino and points at the game option "Slots". This bot requires manual monitoring.
The first line is a commented line. It is a list of timings.
-- 0 A 150 v_v_v_A 300 A_A 320 X
local c=savestate.create(1)
local d=0
local offset=0
local e=0
local ak={}
local vk={}
local xk={}
ak.A=1
vk.down=1
xk.X=1
savestate.load(c)
while true do
while e>0 do
e=e-1
snes9x.frameadvance()
end
if d==0 or d==156 or d==300 or d==302 then
joypad.set(1,ak)
end
if d==150 or d==152 or d==154 then
joypad.set(1,vk)
end
if d==320 then
joypad.set(1,xk)
end
d=d+1
snes9x.frameadvance()
if d==1200 then
d=0
offset=offset+1
savestate.load(c)
e=offset
end
end