-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pause command #17
Comments
+1 |
@paulk-asert I have a groovy script that can pause some lines. It might be slightly confusing as it also can "type" a line - add a delay to every char on given line. import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import java.math.RoundingMode
// Take a line and "type it" with given time
File file = "recording.asci" as File
JsonSlurper slurper = new JsonSlurper()
// pretends to type a line with given number, useful when recording is driven by a pasted script
Integer lineToType = 0
BigDecimal typeDelay = 0.03
// accumulator for increasing delays of a line
BigDecimal delay = 0
// lines to pause
Map<Integer, BigDecimal> pause = [
:
// 188: 2,
// 121: 2
]
def output = []
BigDecimal lastTime = 0
file.readLines().eachWithIndex { line, i ->
def lineNumber = i+1 // as in editor - starting with 1
def parsed = slurper.parseText(line)
if(parsed instanceof List) {
// round timestamp to 3 decimal places
def newTime = BigDecimal.valueOf(parsed[0]).setScale(3, RoundingMode.HALF_UP)
if(pause.containsKey(lineNumber)) {
delay += pause[lineNumber]
}
// add delay
parsed[0] = newTime + delay
}
if(lineNumber == lineToType) {
assert parsed instanceof List
assert parsed[1] == "o"
def text = parsed[2]
assert text instanceof String
// don't do anything if one character or less
if(text.size() > 1) {
text.each { c ->
// increase total delay X ms per character
delay += typeDelay
def newTime = parsed[0] + delay
def newLine = [newTime, "o", c]
output << JsonOutput.toJson(newLine)
}
}
} else {
output << JsonOutput.toJson(parsed)
}
}
file.text = output.join("\n") |
Nice! I was in the process of creating almost the same Groovy script. You've saved me the effort! :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice to have dedicated command for pausing after a frame
pause --at 3 for --0.3
The text was updated successfully, but these errors were encountered: