Jump to content




stops on its own


  • You cannot reply to this topic
5 replies to this topic

#1 JackPS9

  • Members
  • 7 posts

Posted 18 June 2013 - 04:26 PM

How can I get this to stop
It is stopping with the message "Too long without yielding"
local mon = peripheral.wrap("top")
p = peripheral.wrap("bottom")


while true do
  PR = p.getEnergyReceive()
  PS = p.getEnergySend()
  PL = p.getPowerProvider()


  mon.clear()
  mon.setCursorPos(1,1)
  mon.write("Receives: "..PR)


  cY = 2
  mon.setCursorPos(1,cY)
  mon.write("Sends:	"..PS)


  cY = 3
  mon.setCursorPos(1,cY)
  mon.write("Energy:   "..PL.energyStored)
end


#2 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 18 June 2013 - 04:28 PM

Right before the last end, put a sleep(0.5) or any other reasonable time. To exit a loop, use the keyword: break .

Example of break :

--#Prints cake 10 times
x=1
while true do
if x>10 then
break
end
print("cake")
x=x+1
end



#3 JackPS9

  • Members
  • 7 posts

Posted 18 June 2013 - 04:31 PM

alright gonna have to keep that sleep time in mind while using loops from now on.
As for stopping it, I dont want it to stop so :P

#4 jakemg

  • Members
  • 88 posts

Posted 18 June 2013 - 06:15 PM

you can just add sleep(0) every where there is a loop wether it be a while loop or for i=1,.... loop

#5 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 18 June 2013 - 07:27 PM

View Postjakemg, on 18 June 2013 - 06:15 PM, said:

you can just add sleep(0) every where there is a loop wether it be a while loop or for i=1,.... loop

That may be bad practice.

You don't need to go through a loop every 0.05 seconds to see if a condition has changed most of the time.

#6 apemanzilla

  • Members
  • 1,421 posts

Posted 19 June 2013 - 05:10 PM

You would want to add a short sleep delay as said above, but I wouldn't reccommend anything shorter than .1 seconds because that could cause an annoying flickering on the screen from rewriting so quickly, or, if your IRL computer isn't the best, could lag other computers a good amount.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users