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

computer.turnOn() only works part of the time

Started by Luanub, 30 September 2012 - 10:28 AM
Luanub #1
Posted 30 September 2012 - 12:28 PM
I have a program that I use to remotely turn off and on computers. When I switched to CC v1.42 i found that the comp.turnOn() functions performance is very flaky, sometimes it will work first try, others it can take 20+ attempts for it to work.

To make sure I put a fresh install of MC 1.32 with Forge 251, and CC 1.42 with nothing else installed, and I still have the problem.

To duplicate connect 2 computers, and run this code on one of them.


local sSide = ""
local tSides = {"right","left","front","back","top","bottom"}
for x=1, #tSides do
  if peripheral.isPresent(tSides[x]) and peripheral.getType(tSides[x]) == "computer" then
	sSide = tSides[x]
	break
  elseif x == #tSides then
	error("No Computers Attached, please attach a computer and try again.")
  end
end
local comp = peripheral.wrap(sSide)
while true do
if not comp.getID() then
  write("Waiting to get ID from computer.")
  repeat
  comp.turnOn()
  sleep(1)
  write(".")
  until comp.getID()
  local nID = comp.getID()
  print("\nID is "..nID)
  comp.shutdown()
end
end

It should give you the id about once a second, if it behaves like mine you'll see that its very random on when it will work.

Each dot printed is an attempt to turn the computer on.
Cloudy #2
Posted 30 September 2012 - 01:19 PM
Not a bug. There is a cooldown between startups - but I'll make the limit lower to be more inline with the reboot protection.
Luanub #3
Posted 01 October 2012 - 12:04 AM
Cool thanks Cloudy. I'll modify my script slighty to ensure the commands go through since I now know its not a bug.