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

Computer is on?

Started by Cycomantis, 19 November 2014 - 11:15 PM
Cycomantis #1
Posted 20 November 2014 - 12:15 AM
I used to use the following method to determine if a wrapped computer was already on. It seems like in one of the recent updates h.getID() will always return the computers ID even if it is off. Does anyone know of another method to check to see if the computer is on without using rednet? I would like to do this as a peripheral to avoid having to modify any/all programs that may be running on the computers I'm wanting to use as peripherals as well.


local function isOn(side)
if peripheral.isPresent(side) then
  comp = peripheral.wrap(side)
  if not comp.getID() then
	sState = "Off"
  else
	sState = "On"
  end
  return sState
end
end
Dragon53535 #2
Posted 20 November 2014 - 12:29 AM
If I'm not mistaken, if you attempt to turn said computer on, then if it's already on, it won't do anything. However they don't return values, perhaps you might make a suggestion for that?
Bomb Bloke #3
Posted 20 November 2014 - 01:36 AM
No method comes to mind, outside of network/redstone communications.

The easiest method I can think of is to have each system rednet.open() their modems on boot, then register themselves with rednet.host(). Other computers can then determine if they're running via rednet.lookup().
Cycomantis #4
Posted 20 November 2014 - 03:24 AM
That's what I was afraid of.

Thanks for the Suggestion Bomb Bloke, seems to be a reasonable to solution. I'll go a head and implement that for the time being.
subzero22 #5
Posted 20 November 2014 - 08:49 AM
What about using os.getComputerLabel() or will it still show a label if the computer is off? If oyu are using wired modems you can force the other computers to turn on. by using c = peripheral.wrap("side") c.turnOn()
Bomb Bloke #6
Posted 20 November 2014 - 09:22 AM
The idea is for one system to be able to detect whether a different system is booted up; os.getComputerLabel() cannot be applied to a remote computer.