MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / lua_get_modules_path

Function lua_get_modules_path

libraries/AP_Scripting/lua_bindings.cpp:1095–1119  ·  view source on GitHub ↗

This is used when loading modules with require, lua must only look in enabled directory's

Source from the content-addressed store, hash-verified

1093
1094// This is used when loading modules with require, lua must only look in enabled directory's
1095const char* lua_get_modules_path()
1096{
1097#define LUA_PATH_ROMFS "@ROMFS/scripts/modules/?.lua;" "@ROMFS/scripts/modules/?/init.lua"
1098#define LUA_PATH_SCRIPTS LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua"
1099
1100 uint16_t dir_disable = AP_Scripting::get_singleton()->get_disabled_dir();
1101 dir_disable &= uint16_t(AP_Scripting::SCR_DIR::SCRIPTS) | uint16_t(AP_Scripting::SCR_DIR::ROMFS);
1102 if (dir_disable == 0) {
1103 // Both directory's are enabled, return both, ROMFS takes priority
1104 return LUA_PATH_ROMFS ";" LUA_PATH_SCRIPTS;
1105 }
1106
1107 if ((dir_disable & uint16_t(AP_Scripting::SCR_DIR::SCRIPTS)) == 0) {
1108 // Only scripts enabled
1109 return LUA_PATH_SCRIPTS;
1110 }
1111
1112 if ((dir_disable & uint16_t(AP_Scripting::SCR_DIR::ROMFS)) == 0) {
1113 // Only ROMFS enabled
1114 return LUA_PATH_ROMFS;
1115 }
1116
1117 // Nothing enabled?
1118 return "";
1119}
1120
1121// Simple print to GCS or over CAN
1122int lua_print(lua_State *L) {

Callers 1

luaopen_packageFunction · 0.85

Calls 2

get_singletonFunction · 0.85
get_disabled_dirMethod · 0.80

Tested by

no test coverage detected