PDA

View Full Version : Input recording and playback



Saffith
11-05-2013, 09:06 PM
Some stuff for recording and playing back input. Useful for cutscenes, and maybe for testing some things.

First, a few functions:
-=SPOILER=-

GetInput() and GetPressed() return numbers representing the state of Link->Input* and Link->Press* for all standard keys (directions, start, map, A/B/L/R/Ex*). SetInput() takes those same numbers as arguments and sets each Input and Press variable accordingly.
ReplayInput() takes two arrays. The first is a series of Input*, and the second is a series of Press*. The arrays consist of pairs of input states and durations. For instance:
int inputArr[] = { CRKEY_DOWN, 30, CRKEY_DOWN | CRKEY_A, 10, CRKEY_UP, 15 };
That represents down being held for 30 frames, down+A for 10 frames, and up for 15 frames. The Press* array works the same way, even though keys aren't normally newly pressed for consecutive frames.

Hit the character limit. Continued below.

Saffith
11-05-2013, 09:07 PM
Rather than writing out such arrays manually, you can use this script to record input:

-=SPOILER=-

D0 controls whether it waits for input before it starts recording (0=yes, 1=no).
This will draw some text over the passive subscreen; set IR_LAYER correctly or it won't appear. Click on the text to do whatever it says; it should be self-explanatory.
With input recorded, it can write the resulting arrays to allegro.log to copy and paste into scripts. It can also output a complete FFC script that will do nothing but play back the input. The script's name will include the current map and screen, so you should do the recording on the same screen where you want to use it.

Note that the way ZC handles Link's position can lead to the same input producing slightly different results sometimes. This is more likely to be significant if diagonal movement is disabled. Be sure to test more than once.

Gleeok
11-05-2013, 09:51 PM
Interesting. Now we just need a script binding for "void Game->SeedRand(int value);".