Also, add the function mp.get_script_directory() to let scripts know if they're loaded as a directory and where.
Showing the changes to player/javascript/defaults.js (1 of 4 files). Show all
Unified · Split
| @@ -463,6 +463,8 @@ function process_timers() { · 462 unmodified lines | |||
| 463 | *********************************************************************/ | 463 | *********************************************************************/ |
| 464 | 464 | ||
| 465 | mp.module_paths = []; // global modules search paths | 465 | mp.module_paths = []; // global modules search paths |
| 466 | if (mp.script_path !== undefined) // loaded as a directory | ||
| 467 | mp.module_paths.push(mp.utils.join_path(mp.script_path, "modules")); | ||
| 466 | 468 | ||
| 467 | // Internal meta top-dirs. Users should not rely on these names. | 469 | // Internal meta top-dirs. Users should not rely on these names. |
| 468 | var MODULES_META = "~~modules", | 470 | var MODULES_META = "~~modules", |
| @@ -645,6 +647,7 @@ mp.options = { read_options: read_options }; · 176 unmodified lines | |||
| 645 | g.print = mp.msg.info; // convenient alias | 647 | g.print = mp.msg.info; // convenient alias |
| 646 | mp.get_script_name = function() { return mp.script_name }; | 648 | mp.get_script_name = function() { return mp.script_name }; |
| 647 | mp.get_script_file = function() { return mp.script_file }; | 649 | mp.get_script_file = function() { return mp.script_file }; |
| 650 | mp.get_script_directory = function() { return mp.script_path }; | ||
| 648 | mp.get_time = function() { return mp.get_time_ms() / 1000 }; | 651 | mp.get_time = function() { return mp.get_time_ms() / 1000 }; |
| 649 | mp.utils.getcwd = function() { return mp.get_property("working-directory") }; | 652 | mp.utils.getcwd = function() { return mp.get_property("working-directory") }; |
| 650 | mp.dispatch_event = dispatch_event; | 653 | mp.dispatch_event = dispatch_event; |