Editor, Skilled player (1537)
Joined: 7/9/2010
Posts: 1319
So, I created a lua script that automatically assigns input in TAS Editor depending on the current game state and setting. The player is no longer controlled by drawing into the input roll, but by setting properties into markers or using a hotkey or the small provided window. The marker can have the following strings in it which set the properties:
    start: Sets a flag that allows the script to do automatic input modification end: Unsets the flag and prevents the script from doing automatic input modification mov r: Sets the direction to right mov l: Sets the direction to left jmp n: Sets the jump height, where n is the jump height provided from a table fjf: Forces the frame that will modify the jump height, normally it's the frame from the last jump. Unforced if a marker doesn't contain that string.
The window has three different buttons, that allow switching direction, changing jump height or disabling jumping alltogether, the player will then walk on the ground. There's also a label with the current direction and one the jump height and the jump pattern coded into decimal representation, it's a 12 bit long number. The automatic input for left/right movement works as follows:
    Get the currently pressed buttons, except B, L, R and store them into a variable Get B, L, R and store them into another variable Check game state. Depending on the game state the input will be modified differently Check wheter input needs to be modified. Not doing it slows the script massively down, because it would always modify the input. If it needs to modified, then modify the input
So here is part of the inputMovement function in the script as an example: Note that correctly assigning the input can be quite the challenge.
Language: lua

local preInput = AND(taseditor.getinput(movie.framecount(), 1), 61) -- A, S, T, U, D, local i = AND(taseditor.getinput(movie.framecount(), 1), 194) -- B,L, R if groundflag == 0 then if XSpeed < 405 then if XSpeed < 304 then if AND(i,2)==2 or AND(i,192)==192 or AND(i,64)*left==0 and AND(i,128)*(1-left)==0 -- check pressed B, L, R buttons then taseditor.submitinputchange(movie.framecount(), 1, 128-left*64+preInput); taseditor.applyinputchanges(); end else if AND(i,2)==0 or AND(i,192)==192 or AND(i,64)*left==0 and AND(i,128)*(1-left)==0 then taseditor.submitinputchange(movie.framecount(), 1, 130-left*64+preInput); taseditor.applyinputchanges(); end end
The jumping does mostly the same logic as the movement, except when changing the jump height it modifies multiple frames at once. The jump pattern is created by modifing into into a table which contain either one or zero, for pressing a or not. Like converting a decimal number into binary. So here's part of the changeJumpPattern function:
Language: lua

while (x > 0) do local y = math.floor((x / 2)) local z = x % 2 x = y inputT[i] = z i = i + 1 end local m = i-1 for i = 0, m, 1 do preInput = AND(taseditor.getinput(jf+11-i,1), 254) taseditor.submitinputchange(jf+11-i, 1, inputT[i]*1+preInput) end taseditor.applyinputchanges()
feos asked me if there are more lua functions needed to make that easier. There are:
    Get the string of the current marker where the playback courser is. It is the string that is visible at the top in TAS Editor Get the index of the current marker where the playback courser is. Get the string of the current marker where the selection courser is. It is the string that is visible at the bottom in TAS Editor Get the index of the current marker where the selection courser is. int taseditor.markedframe(int index) returns the the frame number of a marker with the corresponding index, nil if the index doesn't exist
My goal is to make such script expandable for all different kinds of games. Right now it's just a playfield to research the usability of semi-automatic tools. There are many things that could be many things to be added to make it easier.
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Post subject: Re: TAS Editor lua demonstration
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11495
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Done!
TASeditor wrote:
Get the string of the current marker where the playback courser is. It is the string that is visible at the top in TAS Editor
emu.framecount() http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getmarker http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getnote
TASeditor wrote:
Get the index of the current marker where the playback courser is.
emu.framecount() http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getmarker
TASeditor wrote:
Get the string of the current marker where the selection courser is. It is the string that is visible at the bottom in TAS Editor
http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getselection http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getmarker http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getnote
TASeditor wrote:
Get the index of the current marker where the selection courser is.
http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getselection http://www.fceux.com/web/help/taseditor/index.html?LuaAPI.html#getmarker
TASeditor wrote:
int taseditor.markedframe(int index) returns the the frame number of a marker with the corresponding index, nil if the index doesn't exist
http://www.fceux.com/web/help/taseditor/LuaAPI.html#markedframe
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Editor, Skilled player (1537)
Joined: 7/9/2010
Posts: 1319
From the documentation I don't find it obvious that taseditor.getmarker() can be applied outside a marked frame and still return a valid index. And for my request taseditor.markedframe(), whose function name already exist whoops, I want to get the frame number of a marker with a given index. It would be equivalent to taseditor.getnote(int index), but would return the frame number instead.
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11495
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
But does getmarker() behave the way you want?
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Editor, Skilled player (1537)
Joined: 7/9/2010
Posts: 1319
Yes, it works fine. I changed the marker control a lot. Added a routine that checks for all markers that contain "start" on script load, so the script always knows when it should do auto input. The control string "fjf" is removed, now when incrementing/decrementing jump height, the frame where the jump will be applied is first frame of selection. A free speed-up for the script would be to use taseditor.submitinsertframes() and taseditor.submitdeleteframes() when input is shifted after landing earlier/later, but that would require an output log to see changes. The marker controls for setting properties could be columns in TAS Editor instead, so that properties can be set quicker and easier, but that wont happen.
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11495
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Do you think you could add these features yourself? Right to fceux code. Since you understand what does what, it should not be hard to add new functions by looking at the old ones.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Editor, Skilled player (1537)
Joined: 7/9/2010
Posts: 1319
I probably can do the one lua function, but definitaly not output log and costum columns, I don't know any C++ unfortunately. Something I would like to try out is to have a window where the user can set game-rules in a intuitive way, so programming wouldn't be needed...
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Editor, Skilled player (1537)
Joined: 7/9/2010
Posts: 1319
Today I made some tests with branch lua functions I added. I implemented functions that can save and load branches, I changed a lua script that I originally wrote for NESPack and replaced clicking on a button with saving the current branch. Saves clicking five times on a button, but not the best solution, better would be to have seperate emulation threats for the input testing. The actual input assignment for this is pretty primitive, simply counting up. Many multiple equal valued input sets will apear. Video for people interessted what's happening. Link to video Ingore the rerecords; It's from month ago from when I used the script to optimize the game.
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11495
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
I'd be more interested in seeing the diff. I think you can speed things up if you add a lua option to cancel greenzone saving for given frames.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.