Anti repeat table?

Post Reply
ella
Posts: 33
Joined: Sun Feb 28, 2010 5:46 pm

Anti repeat table?

Post by ella »

ok, so lets say I made a trigger that says hi to everyone using their name when they arrive. is there some way I can store that name on a table AND keep it from firing off again?

wieczo
Posts: 11
Joined: Mon Jan 25, 2010 12:04 pm

Re: Anti repeat table?

Post by wieczo »

You could use something like the following.(not tested)
Code: [show] | [select all] lua
greeter = greeter or {}
greeter.people = greeter.people or {}

function greeter.sayHi(person)
  if greeter.people[person] then
    return true
  end
  greeter.people[person] = true
  send("say to " .. person .. " hello!")
end
Call it in your trigger with, e.g. "^(\w+) entered the room\.$" with
Code: [show] | [select all] lua
greeter.sayHi(matches[2])
This will work per session; meaning when you close the game window, the persons list will clear.

If you want to clear the list every time you log off, call
Code: [show] | [select all] lua
greeter.people = {}
upon logout.

Post Reply