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?

Information: http://forum.facepunch.com/showthread.php?t=1276264&p=41362545&viewfull=1#post41362545

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).

http://forum.facepunch.com/showthread.php?t=1276264&p=41362545&viewfull=1#post41362545

Sorry, I meant FPTje, not flapadar.

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

Adding the line

[lua]
local setmetatable = setmetatable
[/lua]

to timer.lua, then adding the line

[lua]
include(“includes/modules/timer.lua”)
[/lua]

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.