Ulysses

General => Developers Corner => Topic started by: LuaTenshi on August 16, 2013, 09:23:45 PM

Title: Could Never Get This Working...
Post by: LuaTenshi on August 16, 2013, 09:23:45 PM
Lets say I have a table like this...

Code: [Select]
James = {"James", "loves", "pie", "but", "JamminR", "likes", "jam"}
What would I do to make this output in order with a 1 second delay between each output.

As in...

Code: [Select]
"James"
-- One Second Later
"loves"
-- One Second Later
"pie"
-- You get the idea...

The above used to be easy to do but long ago an update to the timers broke my method of doing that. Any ideas?
Title: Re: Could Never Get This Working...
Post by: JamminR on August 16, 2013, 09:39:22 PM
No idea what's broken in timers.
If simple.timer works;
Code: [Select]
for i, blah in ipairs( James )
  timer.Simple ( i, <print/msg/say/whatever code to display>( blah ) )
end
Title: Re: Could Never Get This Working...
Post by: LuaTenshi on August 16, 2013, 10:27:00 PM
No idea what's broken in timers.
If simple.timer works;
Code: [Select]
for i, blah in ipairs( James )
  timer.Simple ( i, <print/msg/say/whatever code to display>( blah ) )
end

Here is the problem though...

Attempt to concatenate local 'v' (a nil value)
Code: [Select]
for i, v in ipairs( James ) do
  timer.Simple ( i, function(v) print("Value: " .. v) end)
end
Title: Re: Could Never Get This Working...
Post by: 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)
Title: Re: Could Never Get This Working...
Post by: LuaTenshi on August 16, 2013, 10:37:41 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)

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