[Quest API] Add Entity Variable Methods to Perl/Lua. (#2609)

* [Quest API] Add Entity Variable Methods to Perl/Lua.

# Perl
- Add `$mob->ClearEntityVariables()`.
- Add `$mob->DeleteEntityVariable(variable_name)`.
- Add `$object->ClearEntityVariables()`.
- Add `$object->DeleteEntityVariable(variable_name)`.

# Lua
- Add `mob:ClearEntityVariables()`.
- Add `mob:DeleteEntityVariable(variable_name)`.
- Add `object:ClearEntityVariables()`.
- Add `object:DeleteEntityVariable(variable_name)`.

# Notes
- Allows operators to clear all entity variables or delete one by name, previously you just had to set to an empty value to clear after being set.

* Cleanup.
This commit is contained in:
Alex King
2022-12-04 12:18:27 -05:00
committed by GitHub
parent 5d5c2a4194
commit 7abc084cd1
10 changed files with 126 additions and 4 deletions
+12
View File
@@ -183,6 +183,16 @@ luabind::object Lua_Object::GetEntityVariables(lua_State* L) {
return t;
}
bool Lua_Object::ClearEntityVariables() {
Lua_Safe_Call_Bool();
return self->ClearEntityVariables();
}
bool Lua_Object::DeleteEntityVariable(std::string variable_name) {
Lua_Safe_Call_Bool();
return self->DeleteEntityVariable(variable_name);
}
void Lua_Object::SetEntityVariable(std::string variable_name, std::string variable_value) {
Lua_Safe_Call_Void();
self->SetEntityVariable(variable_name, variable_value);
@@ -198,10 +208,12 @@ luabind::scope lua_register_object() {
.def(luabind::constructor<>())
.property("null", &Lua_Object::Null)
.property("valid", &Lua_Object::Valid)
.def("ClearEntityVariables", (bool(Lua_Object::*)(void))&Lua_Object::ClearEntityVariables)
.def("ClearUser", (void(Lua_Object::*)(void))&Lua_Object::ClearUser)
.def("Close", (void(Lua_Object::*)(void))&Lua_Object::Close)
.def("Delete", (void(Lua_Object::*)(bool))&Lua_Object::Delete)
.def("Delete", (void(Lua_Object::*)(void))&Lua_Object::Delete)
.def("DeleteEntityVariable", (bool(Lua_Object::*)(std::string))&Lua_Object::DeleteEntityVariable)
.def("DeleteItem", (void(Lua_Object::*)(int))&Lua_Object::DeleteItem)
.def("Depop", (void(Lua_Object::*)(void))&Lua_Object::Depop)
.def("EntityVariableExists", (bool(Lua_Object::*)(std::string))&Lua_Object::EntityVariableExists)