SubKt
SubKt copied to clipboard
Predicate function for MergeSpecification.incrementLayer
Sometimes, it's desirable to be able to only increment a merge specification's lines' layers if they satisfy certain criteria. For instance, if chapter markers are placed in the dialogue file as comments, you might not want to increment their layers along with the actual dialogue.
To achieve this, you currently need something like this:
val dialogue by task<ASS> {
from(get("dialogue"))
ass {
for (line in events.lines) {
if (!line.comment) {
line.layer += 100
}
}
}
}
merge {
from(dialogue.item())
// ...
}
I propose adding an argument of type (Line) -> Boolean
, with a default value of { true }
or whatever, to describe the conditions under which lines should be incremented.
With this change, the above example could be simplified to:
merge {
from(get("dialogue")) {
incrementLayer(100, { !it.comment })
}
// ...
}