(orig_ast, package_lua)
return lua.Lua.from_lines(new_code, version=game.DEFAULT_VERSION)
Prepend all the require() material to an AST.

    Args:
        orig_ast: The lua.Lua object for the original code.
        package_lua: A mapping of require() strings to lua.Lua objects.

    Returns:
        The new lua.Lua object with the package code and preamble prepended.
        If package_lua is empty, returns orig_ast.
Prepend all the require() material to an AST.
Prepend all the require () material to an AST .
def _prepend_package_lua(orig_ast, package_lua):
    """Prepend all the require() material to an AST.

    Args:
        orig_ast: The lua.Lua object for the original code.
        package_lua: A mapping of require() strings to lua.Lua objects.

    Returns:
        The new lua.Lua object with the package code and preamble prepended.
        If package_lua is empty, returns orig_ast.
    """
    if not package_lua:
        return orig_ast

    package_header = []
    package_header.extend(REQUIRE_LUA_PREAMBLE_PACKAGE)
    for pth, ast in package_lua.items():
        escaped_pth = pth.replace(b'"', b'\\"')
        package_header.append(
            b'package._c["' + escaped_pth + b'"]=function()\n')
        package_header.extend(ast.to_lines())
        package_header.append(b'end\n')
    package_header.extend(REQUIRE_LUA_PREAMBLE_REQUIRE)
    new_code = package_header + list(orig_ast.to_lines())

    return lua.Lua.from_lines(new_code, version=game.DEFAULT_VERSION)
def _prepend_package_lua ( orig_ast , package_lua ) : if not package_lua : return orig_ast package_header = [ ] package_header . extend ( REQUIRE_LUA_PREAMBLE_PACKAGE ) for pth , ast in package_lua . items ( ) : escaped_pth = pth . replace ( b'"' , b'\\"' ) package_header . append ( b'package._c["' + escaped_pth + b'"]=function()\n' ) package_header . extend ( ast . to_lines ( ) ) package_header . append ( b'end\n' ) package_header . extend ( REQUIRE_LUA_PREAMBLE_REQUIRE ) new_code = package_header + list ( orig_ast . to_lines ( ) ) return lua . Lua . from_lines ( new_code , version = game . DEFAULT_VERSION )