Hey all, sorry if this is the wrong forum to post it in, seemed like the closest (or at least most active) part of the Lua scripting forums for my question.

I'm writing my first plugin, and I'm still quite a newbie when it comes to programming in general (no formal training) but I've been able to nearly finish my plugin until I ran into a problem trying to write a timer. Essentially I'm trying to write a simple timer that will call a function, wait 60 seconds, and then call another function. I've tried a few ways to get this to work using Turbine.Engine.GetGameTime(), something along the lines of:
function timer(duration,startTime)
    local completed = false
    local timestamp = Turbine.Engine.GetGameTime()
    if timestamp >= startTime + duration then
        completed = true
        return completed
curTime = Turbine.Engine.GetGameTime()
if timer(60,curTime) == true then
        <do more stuff>
that particular one got " \Main.lua:199: stack overflow" but it was a bit of a shot in the dark to begin with

I've also tried using while loops which crashed the client (such as: while timestamp <= duration do <stuff> timestamp = Turbine.Engine.GetGameTime() else <more stuff> )

anyway, I'm wondering if there is a way to accomplish this that I'm not seeing,or maybe if there's a way to fix my nubby little code there to make it work.

Thanks in advance