示例#1
0
def DefineLabel(label: Label | int):
    """Wrapper for generating any valid label (0-20, inclusive)."""
    if not 0 <= label <= 20:
        raise ValueError(
            f"Label for `DefineLabel` must be between 0 and 20, inclusive, not: {label}"
        )
    return base_compile_instruction(EMEDF_ALIASES, f"DefineLabel_{int(label)}")
示例#2
0
def RunCommonEvent(event_id, args=(0, ), arg_types="", event_layers=None):
    """Run the given `event_id`, which must be defined in `common_func.emevd`.

    You can omit `arg_types` if all the arguments are unsigned integers (which is usually the case).

    Note that you can also call the name of the event directly and pass in the given arguments normally.

    Note that `event_layers` is supported as an argument here for intellisense purposes, as this is the instruction
    it will most commonly be used with, but it can be used with any instruction. The EVS parser handles this keyword
    argument separately, so it will never actually be passed to an instruction function like this one.
    """
    if not arg_types:
        # Assume all signed integers, unless the only argument is zero.
        arg_types = "I" if args == (0, ) else "i" * len(args)
    if len(args) != len(arg_types):
        raise ValueError(
            "Number of event arguments does not match length of argument type string in RunEvent."
        )
    full_arg_types = "i" + str(arg_types[0])
    if len(arg_types) > 1:
        full_arg_types += f"|{arg_types[1:]}"
    return base_compile_instruction(EMEDF_ALIASES,
                                    "RunCommonEvent",
                                    event_id=event_id,
                                    args=args,
                                    arg_types=full_arg_types)
示例#3
0
def compile_instruction(instr_name: str, *args, **kwargs) -> list[str]:
    """Compile instruction using `COMPILER` function if available, or fall back to `_auto_compile` below with EMEDF."""
    if instr_name in COMPILER:
        return COMPILER[instr_name](*args, **kwargs)
    return base_compile_instruction(EMEDF_ALIASES, instr_name, *args, **kwargs)