timer.Simple not working?

Hey, I haven’t been scripting in GLua for a while so forgive me if I look like an idiot.

I’ve been trying to use
[lua]
timer.Simple(1, self.ActuallyCreatePortal, self)
[/lua]
in my code, and “Attempt to index local ‘self’ (nil value)” Shows up in console. This happens for any timer.Simple I try to use.

So, I’m wondering, has Garry removed the timer.Simple functionality?

No Garry did not remove timer.Simple. Whether or not he changed how they are used I am not sure. Here try this instead:



        timer.Simple(1, function()
			self.ActuallyCreatePortal
		end)


Actually try this…


timer.simple(1, function() self.ActuallyCreatePortal() end)

He forgot one thing. ^^

Thanks :stuck_out_tongue:

[lua]timer.Simple(1, function() self:ActuallyCreatePortal() end)[/lua]

[LUA]timer.Simple(1, function() self:ActuallyCreatePortal() end)[/LUA]

Oh, I copy pasted the above code and the S seemed correct :v:

I’m having the same problem I can’t get my timer to work either:


timer.Simple(20, function() self:map_changing() end)

Based off what I read here but it doesn’t do anything. Here’s my function:


function map_changing()
end

[lua]timer.Simple(20, function() map_changing() end)[/lua]

I’ll try it I’ve tried so many different methods to get it to work and not having any luck today.

There’s only one way, because of the syntax…

This worked before the latest update:


timer.Simple(20, map_changing)

LOL, that was way back for GMOD12.

Here’s all the changes since you don’t seem to know about them.

https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit

brandonj4 I’m not kidding before the latest update that code worked perfectly fine.

basically

[lua]timer.Simple(20, function() map_changing() end)[/lua]

The second argument to timer.Simple is a function.


timer.Simple(20, function() map_changing() end)

and


timer.Simple(20, map_changing)

will each have the same outcome.

The change with timer.Simple is that you can no longer pass arguments directly to the function that the timer module calls, map_changing is an argument-less function so this is no issue.

Funny how simple questions seem to take a few posts to finally get the right answer. Happened both times and I’ve seen it plenty of times before.

It’s caused by what seems to be general misunderstanding that quite a lot of people around here seem to have and I believe it creates a problem for new (or any) developers with questions

Well, my timer problem is fixed, thanks guys.