ardupilot/libraries/AP_Scripting/lua_bindings.cpp

27 lines
580 B
C++
Raw Normal View History

2018-10-03 17:37:43 -03:00
#include <AP_Common/AP_Common.h>
#include <GCS_MAVLink/GCS.h>
#include "lua_bindings.h"
int lua_gcs_send_text(lua_State *state) {
const char* str = lua_tostring(state, 1);
gcs().send_text(MAV_SEVERITY_INFO, str);
return 0;
}
static const luaL_Reg gcs_functions[] =
{
{"send_text", lua_gcs_send_text},
{NULL, NULL}
};
void load_lua_bindings(lua_State *state) {
luaL_newlib(state, gcs_functions);
lua_setglobal(state, "gcs");
}
void hook(lua_State *L, lua_Debug *ar) {
gcs().send_text(MAV_SEVERITY_INFO, "got a debug hook");
lua_error(L);
}