Skip to content

Commit bed5a38

Browse files
committed
Allow --simplifystate and --runtime to be specified as timecodes
1 parent dd56646 commit bed5a38

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

docs/install.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ begin again fresh.
186186

187187
`--simplifystate` *SECONDS*
188188
: Sets the period after which the [language
189-
simplifier](language.md#simplification) will simplify on static state values.
190-
The default is 10 seconds. Set this to `0` to disable simplifying on state.
189+
simplifier](language.md#simplification) will simplify on static state values, in
190+
seconds (may be specified as a [time-code](language.md#time-codes)). The default
191+
is 10 seconds. Set this to `0` to disable simplifying on state.
191192

192193
`--nosimplify`
193194
: Completely disable the language simplifier. Generally there is no reason to
@@ -204,7 +205,8 @@ output from non-interactive programs. It also has a specific [effect on how the
204205
physics system runs](physics.md#non-realtime-mode).
205206

206207
`--runtime` *SECONDS*
207-
: Run for a specific period of time and then exit automatically. This is
208+
: Run for a specific period of time and then exit automatically, in seconds
209+
(may be specified as a [time-code](language.md#time-codes)). This is
208210
particularly useful for capturing videos of a specific length unattended. In
209211
`--lockstep` mode, this is a period of the internal frame clock not the wall
210212
clock.

src/flitter/engine/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def main():
4646
parser.add_argument('--state', type=str, help="State save/restore file")
4747
parser.add_argument('--resetonswitch', action='store_true', default=False, help="Reset state when switching pages")
4848
parser.add_argument('--nosimplify', action='store_true', default=False, help="Disable the language simplifier")
49-
parser.add_argument('--simplifystate', type=float, default=10, help="Simplify on state after stable period")
49+
parser.add_argument('--simplifystate', type=convert_timecode_to_float, default=10, help="Simplify on state after stable period")
5050
parser.add_argument('--lockstep', action='store_true', default=False, help="Run clock in non-realtime mode")
5151
parser.add_argument('--define', '-D', action='append', default=[], type=keyvalue, dest='defines', help="Define name for evaluation")
5252
parser.add_argument('--vmstats', action='store_true', default=False, help="Report VM statistics")
53-
parser.add_argument('--runtime', type=float, help="Seconds to run for before exiting")
53+
parser.add_argument('--runtime', type=convert_timecode_to_float, help="Seconds to run for before exiting")
5454
parser.add_argument('--offscreen', action='store_true', default=False, help="Swap windows for offscreens")
5555
parser.add_argument('--opengles', action='store_true', default=False, help="Use OpenGL ES")
5656
parser.add_argument('program', nargs='+', help="Program(s) to load")

src/flitter/language/parser.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ def __init__(self, msg, line, column, context):
4343

4444
def convert_timecode_to_float(t):
4545
parts = t.split(':')
46-
if len(parts) not in (2, 3):
46+
if not 1 <= len(parts) <= 3:
4747
raise ValueError("Incorrect format")
48-
seconds = 60*int(parts[-2]) + float(parts[-1])
49-
if len(parts) == 3:
48+
seconds = float(parts[-1])
49+
if len(parts) > 1:
50+
seconds += 60*int(parts[-2])
51+
if len(parts) > 2:
5052
seconds += 3600*int(parts[-3])
5153
return seconds
5254

0 commit comments

Comments
 (0)