i tried to write this script by searching in api s that i can use (i just started learning lua) so here is my code
Code:
local name = GetUnitName("target")
print(name.." is locked!)
local frame = CreateFrame("FRAME", "FooAddonFrame")
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
local function eventHandler(self, event, ...)
print("function called!")
frame:UnregisterEvent("PLAYER_TARGET_CHANGED")
print("unregistered")
TargetLastTarget()
InteractUnit("target")
print("looted!")
end
frame:SetScript("OnEvent", eventHandler)
why the result is some thing like this?
Serpentrix is locked!
function called!
unregistered!
loot done!
function called!
unregistered!
loot done!
it calls my func 2x while i want to call it once (o.0)