mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Quest API] Add Entity Variable Methods to Perl/Lua. (#2579)
* [Quest API] Add Entity Variable Methods to Perl/Lua. # Perl - Add `$mob->GetEntityVariables()`. - Add `$object->GetEntityVariables()`. # Lua - Add `mob:GetEntityVariables()`. - Add `object:GetEntityVariables()`. # Notes - Convert all overloads and methods to use `std::string` for entity variables. - Allows operators to get a list of a Mob's entity variables. * Update loottables.cpp
This commit is contained in:
+25
-9
@@ -163,19 +163,34 @@ void Lua_Object::Close() {
|
||||
self->Close();
|
||||
}
|
||||
|
||||
const char *Lua_Object::GetEntityVariable(const char *name) {
|
||||
std::string Lua_Object::GetEntityVariable(std::string variable_name) {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetEntityVariable(name);
|
||||
return self->GetEntityVariable(variable_name);
|
||||
}
|
||||
|
||||
void Lua_Object::SetEntityVariable(const char *name, const char *value) {
|
||||
luabind::object Lua_Object::GetEntityVariables(lua_State* L) {
|
||||
auto t = luabind::newtable(L);
|
||||
if (d_) {
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
auto l = self->GetEntityVariables();
|
||||
auto i = 0;
|
||||
for (const auto& v : l) {
|
||||
t[i] = v;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void Lua_Object::SetEntityVariable(std::string variable_name, std::string variable_value) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetEntityVariable(name, value);
|
||||
self->SetEntityVariable(variable_name, variable_value);
|
||||
}
|
||||
|
||||
bool Lua_Object::EntityVariableExists(const char *name) {
|
||||
bool Lua_Object::EntityVariableExists(std::string variable_name) {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->EntityVariableExists(name);
|
||||
return self->EntityVariableExists(variable_name);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_object() {
|
||||
@@ -189,9 +204,10 @@ luabind::scope lua_register_object() {
|
||||
.def("Delete", (void(Lua_Object::*)(void))&Lua_Object::Delete)
|
||||
.def("DeleteItem", (void(Lua_Object::*)(int))&Lua_Object::DeleteItem)
|
||||
.def("Depop", (void(Lua_Object::*)(void))&Lua_Object::Depop)
|
||||
.def("EntityVariableExists", (bool(Lua_Object::*)(const char*))&Lua_Object::EntityVariableExists)
|
||||
.def("EntityVariableExists", (bool(Lua_Object::*)(std::string))&Lua_Object::EntityVariableExists)
|
||||
.def("GetDBID", (uint32(Lua_Object::*)(void))&Lua_Object::GetDBID)
|
||||
.def("GetEntityVariable", (const char*(Lua_Object::*)(const char*))&Lua_Object::GetEntityVariable)
|
||||
.def("GetEntityVariable", (std::string(Lua_Object::*)(std::string))&Lua_Object::GetEntityVariable)
|
||||
.def("GetEntityVariables", (luabind::object(Lua_Object::*)(lua_State*))&Lua_Object::GetEntityVariables)
|
||||
.def("GetHeading", (float(Lua_Object::*)(void))&Lua_Object::GetHeading)
|
||||
.def("GetID", (int(Lua_Object::*)(void))&Lua_Object::GetID)
|
||||
.def("GetIcon", (uint32(Lua_Object::*)(void))&Lua_Object::GetIcon)
|
||||
@@ -204,7 +220,7 @@ luabind::scope lua_register_object() {
|
||||
.def("IsGroundSpawn", (bool(Lua_Object::*)(void))&Lua_Object::IsGroundSpawn)
|
||||
.def("Repop", (void(Lua_Object::*)(void))&Lua_Object::Repop)
|
||||
.def("Save", (bool(Lua_Object::*)(void))&Lua_Object::Save)
|
||||
.def("SetEntityVariable", (void(Lua_Object::*)(const char*,const char*))&Lua_Object::SetEntityVariable)
|
||||
.def("SetEntityVariable", (void(Lua_Object::*)(std::string,std::string))&Lua_Object::SetEntityVariable)
|
||||
.def("SetHeading", (void(Lua_Object::*)(float))&Lua_Object::SetHeading)
|
||||
.def("SetID", (void(Lua_Object::*)(int))&Lua_Object::SetID)
|
||||
.def("SetIcon", (void(Lua_Object::*)(uint32))&Lua_Object::SetIcon)
|
||||
|
||||
Reference in New Issue
Block a user