This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lewisholcombe's profile picture

Loop a message

Started by lewisholcombe, 24 March 2013 - 02:24 PM
lewisholcombe #1
Posted 24 March 2013 - 03:24 PM
Hey people
Just a quick questions

So i have a "server room" for my admin building on my server and i want a few monitors to be running fake programs.
So what i want to achieve is to make a program like this

mon=peripheral.set("back")
mon.setTextScale(2)
mon.setCursorPos(1,1)
print"Running FTP on port 21"
print"Running Main servers on ports 43-28849"
(Print loads of other things)
But then when it gets to the bottom of writing all that (It will have some sleeps in it) it just repeats it again and again and again and never stops until i tell it to?
Thanks for anyone who responds!
SuicidalSTDz #2
Posted 24 March 2013 - 03:26 PM
While true do
–Yourstuffhere
end
Shnupbups #3
Posted 24 March 2013 - 03:27 PM
Can you please post the entire code on pastebin and post the pastebin link here so we can see everything?
While true do
–Yourstuffhere
end
He doesn't WANT it to loop, it is and he's asking how to stop it.
lewisholcombe #4
Posted 24 March 2013 - 03:28 PM
Can you please post the entire code on pastebin and post the pastebin link here so we can see everything?
While true do
–Yourstuffhere
end
He doesn't WANT it to loop, it is and he's asking how to stop it.
Will do it tomorrow when its finished! :)/>
lewisholcombe #5
Posted 24 March 2013 - 03:30 PM
While true do
–Yourstuffhere
end
What exactly do you mean
Where you say –Yourstuffhere could i do this


While true do
--mon=peripheral.set("back")
print"iudhfosdiuh"
print"dilfhvdfio"
print"fdivhfiuhdifuhdofuv"
end
and it would just infinity loop it?
lewisholcombe #6
Posted 24 March 2013 - 03:32 PM
Ohh OOPSSorry about that. No i want to know how to loop it.
I can just do Ctrl+T to stop it
LuaEclipser #7
Posted 24 March 2013 - 04:14 PM
you can do this


for i=1, x do
--your looped program
end
replace x with number of loops you want it to do
theoriginalbit #8
Posted 24 March 2013 - 04:27 PM
Hey people
Just a quick questions

So i have a "server room" for my admin building on my server and i want a few monitors to be running fake programs.
So what i want to achieve is to make a program like this

mon=peripheral.set("back")
mon.setTextScale(2)
mon.setCursorPos(1,1)
print"Running FTP on port 21"
print"Running Main servers on ports 43-28849"
(Print loads of other things)
But then when it gets to the bottom of writing all that (It will have some sleeps in it) it just repeats it again and again and again and never stops until i tell it to?
Thanks for anyone who responds!

a nice way to do it is


mon=peripheral.set("back")
mon.setTextScale(2)
mon.setCursorPos(1,1)
print"Running FTP on port 21"
print"Running Main servers on ports 43-28849"
(Print loads of other things)

while true do
  local e, p = os.pullEvent()
  if e == 'key' and p == keys.enter then
    break
  end
end
that will print all the code to the monitor and then just wait at the end of the program for you to press enter to quit it… this method is good as you aren't doing unnecessary refreshing of the screen and causing lag.
SuicidalSTDz #9
Posted 24 March 2013 - 04:42 PM
Hey people
Just a quick questions

So i have a "server room" for my admin building on my server and i want a few monitors to be running fake programs.
So what i want to achieve is to make a program like this

mon=peripheral.set("back")
mon.setTextScale(2)
mon.setCursorPos(1,1)
print"Running FTP on port 21"
print"Running Main servers on ports 43-28849"
(Print loads of other things)
But then when it gets to the bottom of writing all that (It will have some sleeps in it) it just repeats it again and again and again and never stops until i tell it to?
Thanks for anyone who responds!

a nice way to do it is


mon=peripheral.set("back")
mon.setTextScale(2)
mon.setCursorPos(1,1)
print"Running FTP on port 21"
print"Running Main servers on ports 43-28849"
(Print loads of other things)

while true do
  local e, p = os.pullEvent()
  if e == 'key' and p == keys.enter then
	break
  end
end
that will print all the code to the monitor and then just wait at the end of the program for you to press enter to quit it… this method is good as you aren't doing unnecessary refreshing of the screen and causing lag.
This is how I was trying to explain it. I was on my phone so I wasn't about to write ten paragraphs when TOBIT could just do it.