mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 16:38:26 +00:00
[Quest API] Add Entity Variable Events to Perl/Lua (#4092)
* [Quest API] Add Entity Variable Events to Perl/Lua - Add `EVENT_ENTITY_VARIABLE_DELETE`. - Add `EVENT_ENTITY_VARIABLE_SET`. - Add `EVENT_ENTITY_VARIABLE_UPDATE`. - All export `$variable_name` and `$variable_value`. - Add `event_entity_variable_delete`. - Add `event_entity_variable_set`. - Add `event_entity_variable_update`. - All export `e.variable_name` and `e.variable_value`. - Allows operators to perform operations when entity variables are cleared, deleted, set, or updated. * Update mob.cpp * Cleanup. * Cleanup * Update mob.cpp * Update lua_general.cpp * Update embparser_api.cpp
This commit is contained in:
@@ -584,6 +584,36 @@ void handle_npc_timer_stop(
|
||||
lua_setfield(L, -2, "timer");
|
||||
}
|
||||
|
||||
void handle_npc_entity_variable(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
)
|
||||
{
|
||||
if (extra_pointers) {
|
||||
if (extra_pointers->size() == 2) {
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(0)).c_str());
|
||||
lua_setfield(L, -2, "variable_name");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(1)).c_str());
|
||||
lua_setfield(L, -2, "variable_value");
|
||||
} else if (extra_pointers->size() == 3) {
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(0)).c_str());
|
||||
lua_setfield(L, -2, "variable_name");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(1)).c_str());
|
||||
lua_setfield(L, -2, "old_value");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(2)).c_str());
|
||||
lua_setfield(L, -2, "new_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player
|
||||
void handle_player_say(
|
||||
QuestInterface *parse,
|
||||
@@ -1596,6 +1626,35 @@ void handle_player_alt_currency_gain_loss(
|
||||
lua_setfield(L, -2, "total");
|
||||
}
|
||||
|
||||
void handle_player_entity_variable(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
)
|
||||
{
|
||||
if (extra_pointers) {
|
||||
if (extra_pointers->size() == 2) {
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(0)).c_str());
|
||||
lua_setfield(L, -2, "variable_name");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(1)).c_str());
|
||||
lua_setfield(L, -2, "variable_value");
|
||||
} else if (extra_pointers->size() == 3) {
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(0)).c_str());
|
||||
lua_setfield(L, -2, "variable_name");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(1)).c_str());
|
||||
lua_setfield(L, -2, "old_value");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(2)).c_str());
|
||||
lua_setfield(L, -2, "new_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Item
|
||||
void handle_item_click(
|
||||
QuestInterface *parse,
|
||||
@@ -2577,4 +2636,34 @@ void handle_bot_timer_stop(
|
||||
lua_setfield(L, -2, "timer");
|
||||
}
|
||||
|
||||
void handle_bot_entity_variable(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Bot* bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
)
|
||||
{
|
||||
if (extra_pointers) {
|
||||
if (extra_pointers->size() == 2) {
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(0)).c_str());
|
||||
lua_setfield(L, -2, "variable_name");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(1)).c_str());
|
||||
lua_setfield(L, -2, "variable_value");
|
||||
} else if (extra_pointers->size() == 3) {
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(0)).c_str());
|
||||
lua_setfield(L, -2, "variable_name");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(1)).c_str());
|
||||
lua_setfield(L, -2, "old_value");
|
||||
|
||||
lua_pushstring(L, std::any_cast<std::string>(extra_pointers->at(2)).c_str());
|
||||
lua_setfield(L, -2, "new_value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user