General > Developers Corner

Could Never Get This Working...

(1/1)

LuaTenshi:
Lets say I have a table like this...


--- Code: ---James = {"James", "loves", "pie", "but", "JamminR", "likes", "jam"}
--- End code ---

What would I do to make this output in order with a 1 second delay between each output.

As in...


--- Code: ---"James"
-- One Second Later
"loves"
-- One Second Later
"pie"
-- You get the idea...
--- End code ---

The above used to be easy to do but long ago an update to the timers broke my method of doing that. Any ideas?

JamminR:
No idea what's broken in timers.
If simple.timer works;

--- Code: ---for i, blah in ipairs( James )
  timer.Simple ( i, <print/msg/say/whatever code to display>( blah ) )
end

--- End code ---

LuaTenshi:

--- Quote from: JamminR on August 16, 2013, 09:39:22 PM ---No idea what's broken in timers.
If simple.timer works;

--- Code: ---for i, blah in ipairs( James )
  timer.Simple ( i, <print/msg/say/whatever code to display>( blah ) )
end

--- End code ---

--- End quote ---

Here is the problem though...

Attempt to concatenate local 'v' (a nil value)

--- Code: ---for i, v in ipairs( James ) do
  timer.Simple ( i, function(v) print("Value: " .. v) end)
end

--- End code ---

MrPresident:
take v out of your function()

You're not passing anything through it, you don't need it.

At that point it's trying to find what v is equal to when it goes to print the value using the value that is passing through the function (which doesn't exist)

LuaTenshi:

--- Quote from: MrPresident on August 16, 2013, 10:30:40 PM ---take v out of your function()

You're not passing anything through it, you don't need it.

At that point it's trying to find what v is equal to when it goes to print the value using the value that is passing through the function (which doesn't exist)

--- End quote ---

Thanks MrPresident, I knew I was missing some thing...

Navigation

[0] Message Index

Go to full version