Lua API: Delete the --script command-line option

This is basically superceded by --plugin
Though it's supposed to be a script that can control the client, that capability doesn't actually exist in the implementation.
This commit is contained in:
Celtic Minstrel 2024-09-23 09:06:43 -04:00
parent 4ce8e19697
commit 7d77acaccc
4 changed files with 4 additions and 38 deletions

View file

@ -232,11 +232,9 @@ uses
when connecting to a server, ignoring other preferences. Unsafe.
.TP
.BI --plugin \ script
(experimental) load a
load a
.I script
which defines a Wesnoth plugin. Similar to
.BR --script ,
but Lua file should return a function which will be run as a coroutine and periodically woken up with updates.
which defines a Wesnoth plugin. Lua file should return a function which will be run as a coroutine and periodically woken up with updates.
.TP
.BI -P,\ --patch \ base-file \ patch-file
applies a DiffWML patch to a WML file; does not preprocess either of the files.
@ -303,11 +301,6 @@ to
.I output
without initializing a screen.
.TP
.BI --script \ file
(experimental)
.I file
containing a Lua script to control the client.
.TP
.BI -s[ host ],\ --server[ =host ]
connects to the specified host if any, otherwise connect to the first server in preferences. Example:
.B --server

View file

@ -128,7 +128,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
, screenshot(false)
, screenshot_map_file()
, screenshot_output_file()
, script_file()
, plugin_file()
, script_unsafe_mode(false)
, strict_validation(false)
@ -196,13 +195,12 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
("nomusic", "runs the game without music.")
("nosound", "runs the game without sounds and music.")
("password", po::value<std::string>(), "uses <password> when connecting to a server, ignoring other preferences.")
("plugin", po::value<std::string>(), "(experimental) load a script which defines a wesnoth plugin. similar to --script below, but Lua file should return a function which will be run as a coroutine and periodically woken up with updates.")
("plugin", po::value<std::string>(), "load a script which defines a wesnoth plugin. Lua file should return a function which will be run as a coroutine and periodically woken up with updates.")
("render-image", po::value<two_strings>()->multitoken(), "takes two arguments: <image> <output>. Like screenshot, but instead of a map, takes a valid Wesnoth 'image path string' with image path functions, and writes it to a .png file." IMPLY_TERMINAL)
("generate-spritesheet", po::value<std::string>(), "generates a spritesheet from all png images in the given path, recursively (one sheet per directory)")
("report,R", "initializes game directories, prints build information suitable for use in bug reports, and exits." IMPLY_TERMINAL)
("rng-seed", po::value<unsigned int>(), "seeds the random number generator with number <arg>. Example: --rng-seed 0")
("screenshot", po::value<two_strings>()->multitoken(), "takes two arguments: <map> <output>. Saves a screenshot of <map> to <output> without initializing a screen. Editor must be compiled in for this to work." IMPLY_TERMINAL)
("script", po::value<std::string>(), "(experimental) file containing a Lua script to control the client")
("server,s", po::value<std::string>()->implicit_value(std::string()), "connects to the host <arg> if specified or to the first host in your preferences.")
("strict-validation", "makes validation errors fatal")
("translations-over", po::value<unsigned int>(), "Specify the standard for determining whether a translation is complete.")
@ -458,8 +456,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
screenshot_map_file = vm["screenshot"].as<two_strings>().first;
screenshot_output_file = vm["screenshot"].as<two_strings>().second;
}
if(vm.count("script"))
script_file = vm["script"].as<std::string>();
if(vm.count("unsafe-scripts"))
script_unsafe_mode = true;
if(vm.count("plugin"))

View file

@ -188,9 +188,7 @@ public:
utils::optional<std::string> screenshot_map_file;
/** Output file to put screenshot in. Second parameter given after --screenshot. */
utils::optional<std::string> screenshot_output_file;
/** File to load lua script from. */
utils::optional<std::string> script_file;
/** File to load a lua plugin (similar to a script) from. Experimental / may replace script. */
/** File to load a lua plugin script from. */
utils::optional<std::string> plugin_file;
/** Whether to load the "package" package for the scripting environment. (This allows to load arbitrary lua packages, and gives untrusted lua the same permissions as wesnoth executable) */
bool script_unsafe_mode;

View file

@ -338,27 +338,6 @@ bool game_launcher::init_lua_script()
plugins_manager::get()->get_kernel_base()->load_package();
}
// get the application lua kernel, load and execute script file, if script file is present
if(cmdline_opts_.script_file) {
filesystem::scoped_istream sf = filesystem::istream_file(*cmdline_opts_.script_file);
if(!sf->fail()) {
/* Cancel all "jumps" to editor / campaign / multiplayer */
jump_to_multiplayer_ = false;
jump_to_editor_ = false;
jump_to_campaign_.jump = false;
std::string full_script((std::istreambuf_iterator<char>(*sf)), std::istreambuf_iterator<char>());
PLAIN_LOG << "\nRunning lua script: " << *cmdline_opts_.script_file;
plugins_manager::get()->get_kernel_base()->run(full_script.c_str(), *cmdline_opts_.script_file);
} else {
PLAIN_LOG << "Encountered failure when opening script '" << *cmdline_opts_.script_file << '\'';
error = true;
}
}
if(cmdline_opts_.plugin_file) {
std::string filename = *cmdline_opts_.plugin_file;