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

how to fix too long without yielding

Started by Britizz, 19 April 2018 - 06:25 AM
Britizz #1
Posted 19 April 2018 - 08:25 AM
hello,

i need you'r help :

local reactor = peripheral.wrap("back")
local connect = reactor.getConnected()
rednet.open( "bottom" )
while true do
  if reactor.getConnected() == true then
   rednet.send(18 ,"reactor a is connected")
   print("rc")
   else
   rednet.send(18 , "reactor a is disconnected !!")
   print("rnc")
  end
end



thank's you
SquidDev #2
Posted 19 April 2018 - 10:50 AM
If a computer does something for too long, ComputerCraft will terminate it in order to avoid server lag. In order to prevent this, one must "yield". In this case, you can achieve this using sleep:


while true do
  if reactor.getConnected()then
    --# Current logic
  else
    --# Current logic
  end

  sleep(0.5) --# Wait half a second before checking again
end
Britizz #3
Posted 19 April 2018 - 11:12 AM
i test this.
Britizz #4
Posted 19 April 2018 - 05:27 PM
he don't work, :'( but i have renounced. now i have a other problem.
i connected directly my reactor (two in total) wraped, end store into variable and i checked if my reactors are active but i got error :
Edited by
Bomb Bloke #5
Posted 20 April 2018 - 12:40 AM
You're probably meaning to use "reactore.getConnected()", there on that fourth line.
Britizz #6
Posted 20 April 2018 - 10:07 AM
yes that's it