def lint_play_generic(p, lint_play_music=lint_play_music): channel = eval(p["channel"]) if not renpy.music.channel_defined(channel): renpy.error("channel %r is not defined" % channel) lint_play_music(p, channel)
def parse_pause(l): delay = l.simple_expression() if not l.eol(): renpy.error("expected end of line.") return {"delay": delay}
def parse_play_music(l): file = l.simple_expression() if not file: renpy.error("play requires a file") fadeout = "None" fadein = "0" channel = None loop = None if_changed = False while True: if l.eol(): break if l.keyword('fadeout'): fadeout = l.simple_expression() if fadeout is None: renpy.error('expected simple expression') continue if l.keyword('fadein'): fadein = l.simple_expression() if fadein is None: renpy.error('expected simple expression') continue if l.keyword('channel'): channel = l.simple_expression() if channel is None: renpy.error('expected simple expression') continue if l.keyword('loop'): loop = True continue if l.keyword('noloop'): loop = False continue if l.keyword('if_changed'): if_changed = True continue renpy.error('could not parse statement.') return dict(file=file, fadeout=fadeout, fadein=fadein, channel=channel, loop=loop, if_changed=if_changed)
def parse_nvl_show_hide(l): rv = l.simple_expression() if rv is None: renpy.error('expected simple expression') if not l.eol(): renpy.error('expected end of line') return rv
def parse_jump_in(l): is_expr = False firstword = l.word() if firstword == "expression": label = l.simple_expression() is_expr = True else: label = firstword if not label: renpy.error("parse error when evaluating custom jump") return dict(label=label, is_expr=is_expr)
def parse_stop_generic(l, parse_stop_music=parse_stop_music): channel = l.name() if channel is None: renpy.error('stop requires a channel') rv = parse_stop_music(l) if rv["channel"] is None: rv["channel"] = repr(channel) return rv
def lint_play_music(p, channel="music"): file = _try_eval(p["file"], 'filename') if p["channel"] is not None: channel = _try_eval(p["channel"], 'channel') if not isinstance(file, list): file = [file] for fn in file: if isinstance(fn, basestring): try: if not renpy.music.playable(fn, channel): renpy.error("%r is not loadable" % fn) except: pass
def parse_queue_music(l): file = l.simple_expression() if not file: renpy.error("queue requires a file") channel = None loop = None while not l.eol(): if l.keyword('channel'): channel = l.simple_expression() if channel is None: renpy.error('expected simple expression') if l.keyword('loop'): loop = True continue if l.keyword('noloop'): loop = False continue renpy.error('expected end of line') return dict(file=file, channel=channel, loop=loop)
def parse_stop_music(l): fadeout = "None" if l.keyword("fadeout"): fadeout = l.simple_expression() channel = None if l.keyword('channel'): channel = l.simple_expression() if channel is None: renpy.error('expected simple expression') if not l.eol(): renpy.error('expected end of line') if fadeout is None: renpy.error('expected simple expression') return dict(fadeout=fadeout, channel=channel)
def parse_nvl_clear(l): if not l.eol(): renpy.error('expected end of line') return None
def lint_jump_in(p): label = p["label"] if not label: renpy.error("no target given to custom jump statement.") if not renpy.has_label(label) and not p["is_expr"]: renpy.error("custom jump to nonexistent label.")
def lint_screen(p): name = p["name"] if not renpy.has_screen(name): renpy.error("Screen %s does not exist." % name)
def _try_eval(e, what): try: return eval(e) except: renpy.error('unable to evaluate %s %r' % (what, e))
def parse_window(l): p = l.simple_expression() if not l.eol(): renpy.error('expected end of line') return p
def lint_stop_generic(p): channel = eval(p["channel"]) if not renpy.music.channel_defined(channel): renpy.error("channel %r is not defined" % channel)