| 194 | } |
| 195 | |
| 196 | int lua_mavlink_block_command(lua_State *L) { |
| 197 | |
| 198 | // Allow : and . access |
| 199 | const int arg_offset = (luaL_testudata(L, 1, "mavlink") != NULL) ? 1 : 0; |
| 200 | |
| 201 | binding_argcheck(L, 1+arg_offset); |
| 202 | |
| 203 | const uint16_t id = get_uint16_t(L, 1+arg_offset); |
| 204 | |
| 205 | // Check if ID is already registered |
| 206 | if (AP::scripting()->is_handling_command(id)) { |
| 207 | lua_pushboolean(L, true); |
| 208 | return 1; |
| 209 | } |
| 210 | |
| 211 | // Add new list item |
| 212 | AP_Scripting::command_block_list *new_item = NEW_NOTHROW AP_Scripting::command_block_list; |
| 213 | if (new_item == nullptr) { |
| 214 | lua_pushboolean(L, false); |
| 215 | return 1; |
| 216 | } |
| 217 | new_item->id = id; |
| 218 | |
| 219 | { |
| 220 | WITH_SEMAPHORE(AP::scripting()->mavlink_command_block_list_sem); |
| 221 | new_item->next = AP::scripting()->mavlink_command_block_list; |
| 222 | AP::scripting()->mavlink_command_block_list = new_item; |
| 223 | } |
| 224 | |
| 225 | lua_pushboolean(L, true); |
| 226 | return 1; |
| 227 | } |
| 228 | #endif // HAL_GCS_ENABLED |
| 229 | |
| 230 | #if AP_MISSION_ENABLED |
nothing calls this directly
no test coverage detected