Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/generators/genlua.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,7 @@ let generate com =

if has_feature ctx "Class" || has_feature ctx "Type.getClassName" then add_feature ctx "lua.Boot.isClass";
if has_feature ctx "Enum" || has_feature ctx "Type.getEnumName" then add_feature ctx "lua.Boot.isEnum";
if has_feature ctx "lua.Lib.getModuleVarargs" then add_feature ctx "use._hx_module_varargs";

let print_file path =
let file_content = Std.input_file ~bin:true path in
Expand Down Expand Up @@ -2168,6 +2169,7 @@ let generate com =
"use._hx_table", "lua/_lua/_hx_table.lua";
"use._hx_wrap_if_string_field", "lua/_lua/_hx_wrap_if_string_field.lua";
"use._hx_dyn_add", "lua/_lua/_hx_dyn_add.lua";
"use._hx_module_varargs", "lua/_lua/_hx_module_varargs.lua";
];

print_file (find_file "lua/_lua/_hx_handle_error.lua");
Expand Down
9 changes: 9 additions & 0 deletions std/lua/Lib.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class Lib {
return ret;
}

/**
Returns the module-level varargs (`...`) passed to the Lua chunk.
Useful in environments like ComputerCraft where script arguments
are only available via module-level varargs, not `_G.arg`.
**/
public static function getModuleVarargs():Table<Int, String> {
return untyped _hx_module_varargs;
}

/**
Simple test for the presence of an available shell.
**/
Expand Down
1 change: 1 addition & 0 deletions std/lua/_lua/_hx_module_varargs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_hx_module_varargs = {...}
Loading