Jump to content

Weird Loop Conditional Question

3 replies to this topic

#1 BlueZero

  • Members
  • 41 posts

Posted 20 June 2016 - 01:29 PM

Ohi thar!

I've kind of had an idea so I can prevent coding noise and repeatedly typing the same bloody thing over and over, so here's my question with something I found I was doing a lot; can something like this be done:

while text in print() do

Now with my somewhat flunky logic here, I am expecting an outcome to be something like an output like "Herp." being printed before "Derp." is printed 'cause it's looking for the print function to be called. Is there a way to do this? I'm wanting to apply this kind of logic to a sleep function so when printing a lot of text on the screen, it doesn't just simply flash across the screen in 0.5/^8 seconds. Instead of having to write "sleep(0.5)" when I print something out, I could just simply have it as a "make shift" condition applying to the print function. Anyone get what I'm layin' down here or is there another way of doing this?

Tried googling but couldn't get the right search terms if something like this is already out there, so as far as I know nothing seems to be covering this.

Edited by BlueZero, 20 June 2016 - 01:39 PM.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 June 2016 - 03:02 PM

Not entirely sure what you're asking for (I don't see how the while loop comes into it?), but it sounds like you could just do something like this:

local function printSleep(text)


... though it may be that textutils.pagedPrint() covers your needs.

#3 eniallator

  • Members
  • 56 posts

Posted 20 June 2016 - 07:09 PM

Or you could use something like this:

local tableOfPrintMessages = {"line1","line2","line3"}

for i=1, #tableOfPrintMessages do
  if i > 1 then

  end -- #This is to make it only sleep when there are multiple values in the tableOfPrintMessages table

  print(tableOfPrintMessages[i]) -- #This prints the current value in the table that i corresponds to

#4 BlueZero

  • Members
  • 41 posts

Posted 21 June 2016 - 12:02 AM

Oh wow, Eniallator nailed it. That's pretty much what I was wanting to do. I think maybe I'll set a bunch of different text to work with within a table and just call upon them like that when I need to. Either that or flush the table every time I get to a new section and apply specific text for each section to call upon?

I don't know, too many ways to do this, lol. Thanks a lot you two. Very much helps.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users