mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-11-09 16:41:21 +08:00
AP_Scripting: allow loading moduels from ROMFS
This commit is contained in:
1 parent
ac769014c4
commit
b7dd432409
4 files changed
+36
No files matched your search
@@ -920,6 +920,33 @@ int lua_get_current_ref()
|
||||
return scripting->get_current_ref();
|
||||
}
|
||||
|
||||
// This is used when loading modules with require, lua must only look in enabled directory's
|
||||
const char* lua_get_modules_path()
|
||||
{
|
||||
#define LUA_PATH_ROMFS "@ROMFS/scripts/modules/?.lua;" "@ROMFS/scripts/modules/?/init.lua"
|
||||
#define LUA_PATH_SCRIPTS LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua"
|
||||
|
||||
uint16_t dir_disable = AP_Scripting::get_singleton()->get_disabled_dir();
|
||||
dir_disable &= uint16_t(AP_Scripting::SCR_DIR::SCRIPTS) | uint16_t(AP_Scripting::SCR_DIR::ROMFS);
|
||||
if (dir_disable == 0) {
|
||||
// Both directory's are enabled, return both, ROMFS takes priority
|
||||
return LUA_PATH_ROMFS ";" LUA_PATH_SCRIPTS;
|
||||
}
|
||||
|
||||
if ((dir_disable & uint16_t(AP_Scripting::SCR_DIR::SCRIPTS)) == 0) {
|
||||
// Only scripts enabled
|
||||
return LUA_PATH_SCRIPTS;
|
||||
}
|
||||
|
||||
if ((dir_disable & uint16_t(AP_Scripting::SCR_DIR::ROMFS)) == 0) {
|
||||
// Only ROMFS enabled
|
||||
return LUA_PATH_ROMFS;
|
||||
}
|
||||
|
||||
// Nothing enabled?
|
||||
return "";
|
||||
}
|
||||
|
||||
// Simple print to GCS or over CAN
|
||||
int lua_print(lua_State *L) {
|
||||
// Only support a single argument
|
||||
|
||||
Reference in new issue
Block a user