Example #1
0
def builtin_sound_import(name, args, pos):
    from nml.actions import action11
    if len(args) not in (2, 3):
        raise generic.ScriptError(name + "() must have 2 or 3 parameters", pos)
    grfid = parse_string_to_dword(args[0].reduce())
    sound_num = args[1].reduce_constant().value
    volume = args[2].reduce_constant().value if len(args) >= 3 else 100
    generic.check_range(volume, 0, 100, "sound volume", pos)
    return ConstantNumeric(action11.add_sound( (grfid, sound_num, volume), pos), pos)
Example #2
0
def builtin_sound_file(name, args, pos):
    from nml.actions import action11
    if len(args) not in (1, 2):
        raise generic.ScriptError(name + "() must have 1 or 2 parameters", pos)
    if not isinstance(args[0], StringLiteral):
        raise generic.ScriptError("Parameter for " + name + "() must be a string literal", pos)
    volume = args[1].reduce_constant().value if len(args) >= 2 else 100
    generic.check_range(volume, 0, 100, "sound volume", pos)
    return ConstantNumeric(action11.add_sound( (args[0].value, volume), pos), pos)