Author Topic: Could Never Get This Working...  (Read 2254 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Could Never Get This Working...
« 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?
I cry every time I see that I am not a respected member of this community.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Could Never Get This Working...
« Reply #1 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
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Could Never Get This Working...
« Reply #2 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
I cry every time I see that I am not a respected member of this community.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Could Never Get This Working...
« Reply #3 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)

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Could Never Get This Working...
« Reply #4 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...
I cry every time I see that I am not a respected member of this community.