PDA

View Full Version : Using the Lua event_hate_list


irongut_av
12-14-2018, 03:43 PM
I thought I'd share this snippet of code to help anyone struggling with the hatelist and event_hate_list in lua

function event_hate_list(e)

local hate_list = e.self:GetHateList().entries

if(hate_list == nil) then
e.self:Shout("hate_list is nil")
return;
else
e.self:Shout("hate_list is OK")
end

for hate_entry in hate_list do
local hate_entry_mob = hate_entry.ent -- C++ Lua_HateEntry::GetEnt is bound to 'ent' property
local hate_value = hate_entry.hate
e.self:Shout("Hate list includes " .. hate_entry_mob:GetCleanName() .. " who has a hate value of ".. hate_value )
end

end

Also a question: how do I get the lua equivalent of Perl $hate_state?

demonstar55
12-14-2018, 04:52 PM
It would be e.joined

https://github.com/EQEmu/Server/wiki/Lua-Parser#npc-events has the entries into the event table listed.

irongut_av
12-14-2018, 09:02 PM
Thanks for the link