Post subject: macrolua and AutoMacro scripts for everything
Active player (293)
Joined: 12/16/2008
Posts: 458
Location: Houston
http://code.google.com/p/macrolua/ Dammit just finished working on a couple scripting tools, mainly for use by combo video makes but people here may find a use for them MacroLua works in any emulator that supports lua. It takes in a .mis file (it's a format used by some combo video makers chosen because it's easy to write) and plays it back. Supports savestates in most emulators. It also has a record mode that converts all inputs into a .mis format and can be used to convert an emulator move file. AutoMacro is an autoit script that takes a .mis file and plays it back, letting you use it in any application not just emulators. It has some timing issues that are expected when your not dealing with emulators but it's much easier to use then autoit by itself for gaming purposes
Editor, Skilled player (1202)
Joined: 9/27/2008
Posts: 1085
At a glance at a few of the pages, I spot that FCEUX is listed as an emulator that doesn't accept hotkeys while paused. It's true that I didn't see input.registerhotkey in this emulator, but for some reason, FCEUX's gui.register is called repeatedly while paused. Odd as it may be, but the fact it's called at all while the emulation is paused will allow a way to catch a key and process it without advancing any frames. Should be good to know about when attempting to try this script on FCEUX. Try this bit of code in FCEUX:
function Fn()
    local T= input.get()
    local Count= 0
    for k,v in pairs(T) do
        Count= Count+ 1
        gui.text(1,8*Count,k)
    end
end
gui.register(Fn)
Pause FCEUX, and push various keys. The script should still react even though FCEUX is paused. I'm not sure what other emulators have a gui.register like this one, however, other than the fact Snes9x doesn't seem to. With this knowledge, it should be possible to create a variant of input.registerhotkey. It eats up gui.register, but it should hopefully allow one more emulator to deal with input for MacroLua while paused. Good to see us getting a new script to play around with. I'll be looking at this and see if I can get use out of it. Most likely yes. I'll try to be a source of ideas in case you need a few from me.
Joined: 1/26/2009
Posts: 558
Location: Canada - Québec
Use hotkey, while unpaused? Nice! I tried the Dammit script and it work fine here. But on my keyboard(cf layout) the "quote" hotkey is "#" instead. Also, it would be nice to have an another hotkey that load the last saved macro, rather than playbackfile = "myMacro.mis" in macro-options.lua everytime you record something. Thought, I'm somewhat confuse how you manage to do this... Could you post a sample script where I can trigger a part of my code when some key is pressed. (emulator used: pcsxrr) Example: I press the "w" hotkey and it print in the console "You pressed the 'w' hotkey."
Experienced player (591)
Joined: 1/11/2007
Posts: 103
FatRatKnight wrote:
for some reason, FCEUX's gui.register is called repeatedly while paused.
Good job finding that. I went ahead and tested some more: Works in: FCEUX, PCSX, FBA Doesn't work in: Gens, snes9x, VBA It doesn't work in Gens so it must not be the intended behavior. I'm going to work with the assumption that no one is fixing the broken, missing, or wrongly implemented Lua things, so I put out a new version exploiting it. Beware that input.get catches keys even when the emu is out of focus. There was another problem: FBA cannot run a register function more than once or else the new call overrides the old. But "input-display.lua" is already using gui.register. I had to make a small change to it to deal with this.
BadPotato wrote:
Use hotkey, while unpaused? Nice! I tried the Dammit script and it work fine here. But on my keyboard(cf layout) the "quote" hotkey is "#" instead.
It looks like the emulua hotkey naming was designed without any regard for non-US keyboards. I can't do anything about that but it shouldn't be a serious problem.
Also, it would be nice to have an another hotkey that load the last saved macro, rather than playbackfile = "myMacro.mis" in macro-options.lua everytime you record something.
It's doable but that would be another hotkey for the user to worry about. Can you record the macro then just rename the file to myMacro.mis? All this would be easier if there was a filepicker function in Lua.
Thought, I'm somewhat confuse how you manage to do this... Could you post a sample script where I can trigger a part of my code when some key is pressed. (emulator used: pcsxrr) Example: I press the "w" hotkey and it print in the console "You pressed the 'w' hotkey."
FatRatKnight's trick also works in PCSX so try this:
local key="W"
local lastframe=nil

function Fn()
		local now=input.get()[key]
		if now and not lastframe then
			print("You pressed the '" .. key .. "' hotkey.")
		end
		lastframe=now
end
gui.register(Fn)

while true do
	emu.frameadvance()
end