When I use this it doesn't wait 5 seconds at all. What am I doing wrong?
[CODE]timer.Simple( 5, function() a[0] = a[1] end)
timer.Simple( 5, function() a[1] = a[2] end)[/CODE]
EDIT: I'm trying to assign a new value to table 'a'.
Well, you could, for instance, show us your whole code so we can put it into context and point out your obvious flaws.
I'm only trying to assign a variable within a timer. Is there a better way?
[QUOTE=gary23548;42393553]I'm only trying to assign a variable within a timer. Is there a better way?[/QUOTE]
where is the full code, if that is all you have so far it's going to throw errors back
[QUOTE=gary23548;42393553]I'm only trying to assign a variable within a timer. Is there a better way?[/QUOTE]
Well for one, I don't see why you're splitting your operations into 2 functions. There's not much more to say.
So far we only know that what you're doing [I]"doesn't work"[/I], but there's nothing from about the 2 lines in the OP apart from the variable 'a' that is missing, but I suppose you defined it in your full code which is again why we need to see your full code.
It's for a custom chatbox. All it's doing is sliding the variable from different "slots" on the screen. I'm using a PaintHUD hook for surface.drawtext. I only want to know is how to redefine a table within a timer.Simple() function.
[CODE]
local i = 0
a = {}
a[0] = ""
a[1] = ""
a[2] = ""
a[3] = "player died" -- Test
while i > 1 do
timer.Simple( 5, function() a[0] = a[1] end)
timer.Simple( 5, function() a[1] = a[2] end)
timer.Simple( 5, function() a[2] = a[3] end)
end[/CODE]
[QUOTE=gary23548;42393717][CODE]
local i = 0
a = {}
a[0] = ""
a[1] = ""
a[2] = ""
a[3] = "player died" -- Test
while i > 1 do
timer.Simple( 5, function() a[0] = a[1] end)
timer.Simple( 5, function() a[1] = a[2] end)
timer.Simple( 5, function() a[2] = a[3] end)
end[/CODE][/QUOTE]
You're running a loop based on the condition if the variable "i" is bigger than 1, which it isn't because you just set it to 0.
This is why you always post the full code...
[QUOTE=EvacX;42393766]You're running a loop based on the condition if the variable "i" is bigger than 1, which it isn't because you just set it to 0.
This is why you always post the full code...[/QUOTE]
The code isn't the problem. I know that it's a endless loop. I'm only trying to define a table within the timer.Simple() function.
[QUOTE=gary23548;42393780]The code isn't the problem. I know that it's a endless loop. I'm only trying to define a table within the timer.Simple() function.[/QUOTE]
It isn't an endless loop... the loop never runs because i is never greater than 1.
[QUOTE=MakeR;42393797]It isn't an endless loop... the loop never runs because i is never greater than 1.[/QUOTE]
Ok, that's my bad.
[CODE]local i = 0
a = {}
a[0] = ""
a[1] = ""
a[2] = ""
a[3] = "player died" -- Test
while i < 1 do
timer.Simple( 5, function() a[0] = a[1] end)
timer.Simple( 5, function() a[1] = a[2] end)
timer.Simple( 5, function() a[2] = a[3] end)
end[/CODE]
What is actually happening? Are the timers running at all? How are you checking if they are running?