add standard components test

This commit is contained in:
MihailRis
2024-06-28 18:57:40 +03:00
parent e0e5faa4a8
commit c54be7b2b1
6 changed files with 46 additions and 11 deletions
+2 -2
View File
@@ -49,8 +49,8 @@ static void create_libs(lua::State* L) {
openlib(L, "world", worldlib);
// components
openlib(L, "Rigidbody", rigidbodylib);
openlib(L, "Transform", transformlib);
openlib(L, "__rigidbody", rigidbodylib);
openlib(L, "__transform", transformlib);
addfunc(L, "print", lua::wrap<l_print>);
}
+3 -6
View File
@@ -230,24 +230,21 @@ bool scripting::on_item_break_block(Player* player, const ItemDef* item, int x,
bool scripting::on_entity_spawn(const EntityDef& def, entityid_t eid) {
std::string name = def.name + ".spawn";
return lua::emit_event(lua::get_main_thread(), name, [eid] (auto L) {
lua::pushinteger(L, eid);
return 1;
return lua::pushinteger(L, eid);
});
}
bool scripting::on_entity_despawn(const EntityDef& def, entityid_t eid) {
std::string name = def.name + ".despawn";
return lua::emit_event(lua::get_main_thread(), name, [eid] (auto L) {
lua::pushinteger(L, eid);
return 1;
return lua::pushinteger(L, eid);
});
}
bool scripting::on_entity_grounded(const EntityDef& def, entityid_t eid) {
std::string name = def.name + ".grounded";
return lua::emit_event(lua::get_main_thread(), name, [eid] (auto L) {
lua::pushinteger(L, eid);
return 1;
return lua::pushinteger(L, eid);
});
}