Thank you, stoneharry. Very much appreciate your help! If I'm completely honest I don't even know how to code an addon, I'm (as you can probably tell) quite new to modding!
Anyway, I managed to get the addon to run, and then I created an XML button linked to the function. However I will most likely need to learn some of the basics before I can make use of your code snippet, as so far I've had no luck... not that lucks involved, just actual knowledge/skill
Nevertheless you've inspired me to continue; as long as I know it's possible then I have good reason to!
Thanks.
/Cuana
When you create a frame (you don't have to use a button I just did in that code snippet, you could create a empty frame in Lua), you can give it various functionality.
The OnUpdate function in WoW is called constantly. The Lua engine will have a while loop that loops around until shutdown that consistently goes through all the events, fires them, and returns to the start after firing all the events. The OnUpdate function is called every loop. So usually every 0.00001 seconds or something stupid depending on computer speed.
What I am doing in this snippet is hooking OnUpdate and then checking for time passed.
To check time pass, I store the current time of the computer in a variable. Then every loop I check if the current time + X seconds is more than the current system time. When system time is greater than old stored time + X, then we can execute our function.
The function just increments a variable (which will be displayid), and sends the message with that variable.
I use a boolean so that the function does one of two things every call. Either send the message and increment the counter or take a screenshot.
Feel free to ask more questions.
E.g:
local frame = CreateFrame("Frame")
frame:SetScript('OnUpdate', 'test')
function test(self, elapsed)
print("TEST!")
end