mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-09 22:20:24 +00:00
[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:
+33
-4
@@ -1057,14 +1057,34 @@ void Object::SetHeading(float heading)
|
||||
safe_delete(app2);
|
||||
}
|
||||
|
||||
void Object::SetEntityVariable(std::string variable_name, std::string variable_value)
|
||||
bool Object::ClearEntityVariables()
|
||||
{
|
||||
o_EntityVariables[variable_name] = variable_value;
|
||||
if (o_EntityVariables.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
o_EntityVariables.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Object::DeleteEntityVariable(std::string variable_name)
|
||||
{
|
||||
if (o_EntityVariables.empty() || variable_name.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto v = o_EntityVariables.find(variable_name);
|
||||
if (v == o_EntityVariables.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
o_EntityVariables.erase(v);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Object::GetEntityVariable(std::string variable_name)
|
||||
{
|
||||
if (variable_name.empty()) {
|
||||
if (o_EntityVariables.empty() || variable_name.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -1092,7 +1112,7 @@ std::vector<std::string> Object::GetEntityVariables()
|
||||
|
||||
bool Object::EntityVariableExists(std::string variable_name)
|
||||
{
|
||||
if (variable_name.empty()) {
|
||||
if (o_EntityVariables.empty() || variable_name.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1103,3 +1123,12 @@ bool Object::EntityVariableExists(std::string variable_name)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Object::SetEntityVariable(std::string variable_name, std::string variable_value)
|
||||
{
|
||||
if (variable_name.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
o_EntityVariables[variable_name] = variable_value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user