Beispiel #1
0
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)
Beispiel #2
0
def parse_pause(l):

    delay = l.simple_expression()

    if not l.eol():
        renpy.error("expected end of line.")

    return {"delay": delay}
Beispiel #3
0
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)
Beispiel #4
0
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
Beispiel #5
0
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)
Beispiel #6
0
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
Beispiel #7
0
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
Beispiel #8
0
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)
Beispiel #9
0
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)
Beispiel #10
0
def parse_nvl_clear(l):
    if not l.eol():
        renpy.error('expected end of line')

    return None
Beispiel #11
0
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.")
Beispiel #12
0
def lint_screen(p):
    name = p["name"]
    if not renpy.has_screen(name):
        renpy.error("Screen %s does not exist." % name)
Beispiel #13
0
def _try_eval(e, what):
    try:
        return eval(e)
    except:
        renpy.error('unable to evaluate %s %r' % (what, e))
Beispiel #14
0
def parse_window(l):
    p = l.simple_expression()
    if not l.eol():
        renpy.error('expected end of line')

    return p
Beispiel #15
0
def lint_stop_generic(p):
    channel = eval(p["channel"])

    if not renpy.music.channel_defined(channel):
        renpy.error("channel %r is not defined" % channel)