[Bots] Add Bot scripting capabilities to the source. (#1378)

- This will allow server operators to interact with bots within a script in Perl or Lua.
This commit is contained in:
Alex
2021-06-11 14:46:30 -04:00
committed by GitHub
parent d54cd08560
commit d9d6a64941
14 changed files with 338 additions and 0 deletions
+15
View File
@@ -12,6 +12,10 @@
#include "lua_object.h"
#include "lua_door.h"
#ifdef BOTS
#include "lua_bot.h"
#endif
bool Lua_Entity::IsClient() {
Lua_Safe_Call_Bool();
return self->IsClient();
@@ -118,6 +122,14 @@ Lua_Door Lua_Entity::CastToDoor() {
return Lua_Door(m);
}
#ifdef BOTS
Lua_Bot Lua_Entity::CastToBot() {
void *d = GetLuaPtrData();
Bot *b = reinterpret_cast<Bot*>(d);
return Lua_Bot(b);
}
#endif
luabind::scope lua_register_entity() {
return luabind::class_<Lua_Entity>("Entity")
.def(luabind::constructor<>())
@@ -138,6 +150,9 @@ luabind::scope lua_register_entity() {
.def("IsBot", &Lua_Entity::IsBot)
.def("GetID", &Lua_Entity::GetID)
.def("CastToClient", &Lua_Entity::CastToClient)
#ifdef BOTS
.def("CastToBot", &Lua_Entity::CastToBot)
#endif
.def("CastToNPC", &Lua_Entity::CastToNPC)
.def("CastToMob", &Lua_Entity::CastToMob)
.def("CastToCorpse", &Lua_Entity::CastToCorpse)