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.