Brand new to lua as of a few hours ago, I have some moderate background in C++ and Java but nothing amazing.
I'm trying to work on an addon for a game that checks for players around me, and if so(within 10 yards) greets them.
It works great, except I ONLY want it to run once per player, as it would be spammy and annoying to constantly greet people.
I figured the best way to do this was to store their character name in an array, but I'm struggling to understand the syntax of arrays.
function Wave()
local totalObjects = GetObjectCount()
local shouldMessage = false
local player = GetActivePlayer()
arrayNames = {}
for i = 1, totalObjects do
local object = GetObjectWithIndex(i)
if object ~= player and UnitIsPlayer(object) == true and UnitIsDead(object) == false then
local yards = GetDistanceBetweenObjects(player, object)
local name = ObjectName(object)
----------------- The beginning of my issue ----------------
if yards < 10 and arrayNames[i] ~= name then -- if name isnt in array already?
arrayNames[i] = name -- trying to add the name to array
print(arrayNames[i])
break
end
end
end
if storeName then
end
end