Set Ruby's ARGV based on the command line

This commit is contained in:
Roza 2021-06-22 09:38:23 -04:00
parent 0770751e20
commit 7a9d60cdbc
4 changed files with 131 additions and 105 deletions

View file

@ -1077,6 +1077,13 @@ static void mriBindingExecute() {
#endif
#endif
VALUE rbArgv = rb_get_argv();
for (const auto &str : conf.launchArgs)
rb_ary_push(rbArgv, rb_utf8_str_new_cstr(str.c_str()));
// Duplicates get pushed for some reason
rb_funcall(rbArgv, rb_intern("uniq!"), 0);
VALUE lpaths = rb_gv_get(":");
if (!conf.rubyLoadpaths.empty()) {
/* Setup custom load paths */

View file

@ -324,4 +324,16 @@
//
// "execName": "Game"
// You can define alternate terminology for the different
// inputs recognized by RPG Maker. A, B, C, X, Y, Z, L, and R
// can all be set using this dictionary, and will be displayed
// on the F1 menu. This is only a cosmetic effect, so it will
// have no effect on the game's scripts.
//
// "bindingNames": {
// "c": "Confirm",
// "b": "Cancel",
// "x": ...
// }
}

View file

@ -236,6 +236,11 @@ try { exp } catch (...) {}
editor.debug = true;
else if (!strcmp(argv[1], "btest"))
editor.battleTest = true;
for (int i = 1; i < argc; i++) {
const char *arg = argv[i];
launchArgs.push_back(argv[i]);
}
}
if (mkxp_fs::fileExists(CONF_FILE)) {

View file

@ -78,6 +78,8 @@ struct Config {
bool useScriptNames;
std::string customScript;
std::vector<std::string> launchArgs;
std::vector<std::string> preloadScripts;
std::vector<std::string> rtps;