So, timer object?

In a garry’s mod release back in June, garry announced that creating timers should now give us timer objects - very exciting! However, nowhere in the gmod wiki is this mentioned. Not giving up so easily, I checked my server’s timer module (which more or less matches the one in github), and sure enough, the code for the create function should return this newfangled timer object. Yet, for what ever reason, calling timer.Create on my server still returns nil.

Any idea why it’s doing this? Has anyone gotten this new OOP timer working?


Interesting… After I ran lua_openscript, the debug info changed for timer.Create since I had set the metatable in my lua script calling timer.Create. Is there any official way for running lua_openscript from a script? (calling module(“timer”) makes gmod forget about the hook library, and include() says it doesn’t exist)

Has anyone gotten this to work and could clarify the instructions for me?

FPTje, has gotten them to work, but his instructions were too unclear for me to fix/additional errors still exist

Any chance you could post a link? I only saw FPTje’s tutorial, which didn’t work for me (possibly because I didn’t follow it correctly).

Sorry, I meant FPTje, not flapadar.

I believe I may have found a (temporary) solution.

Adding the line

local setmetatable = setmetatable

to timer.lua, then adding the line


at the top of one of my own files seems to get the correct timer library loaded, at which point calling timer.Create returns a table instead of nil. For now I have a bug report posted here.