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

Computer.isturnedon

Started by LBPHacker, 08 September 2013 - 02:09 AM
LBPHacker #1
Posted 08 September 2013 - 04:09 AM
The "Computer peripheral" has four methods: turnOn, reboot, shutdown and getID. Well, this suggestion is about adding isTurnedOn. I know one could use rednet for that, but one could use rednet for reboot and shutdown as well. It just would make sense if we had isTurnedOn.
reububble #2
Posted 08 September 2013 - 06:16 AM
or "isOn" to shorten that
theoriginalbit #3
Posted 08 September 2013 - 07:02 AM
rednet really isn't a reliable situation to detect if a computer/turtle is on or not…

that being said this still isn't really needed… invoking turnOn, if it is on, does nothing. invoking shutdown, if it is off, does nothing. So if you're wanting to turn on a computer, just call turnOn, if it's off, it will turn on, if it's on it will stay on.
Mitchfizz05 #4
Posted 08 September 2013 - 07:44 AM
rednet really isn't a reliable situation to detect if a computer/turtle is on or not…

that being said this still isn't really needed… invoking turnOn, if it is on, does nothing. invoking shutdown, if it is off, does nothing. So if you're wanting to turn on a computer, just call turnOn, if it's off, it will turn on, if it's on it will stay on.
You might not want to turn on/off the computer, you might just want to know if it's on.
I support this idea.
theoriginalbit #5
Posted 08 September 2013 - 07:45 AM
You might not want to turn on/off the computer, you might just want to know if it's on.
In what use case would you want to know this, where you wouldn't then be then either turning it on or off after you have found out?
Engineer #6
Posted 08 September 2013 - 08:18 AM
In what use case would you want to know this, where you wouldn't then be then either turning it on or off after you have found out?

It is programming, there could be lots of cases where the programmer needs it.
Maybe that computer has a startup script that does something in the minecraft world and you can detect it with this then. Because it is on, not 100% reliable though.

I think it is a good idea to do this because you can check if a certain computer is on or not within a network etc.
theoriginalbit #7
Posted 08 September 2013 - 01:17 PM
It is programming, there could be lots of cases where the programmer needs it.
The only ones I can think of involve turning the computer on or off depending on whether it is on or off…

Maybe that computer has a startup script that does something in the minecraft world and you can detect it with this then. Because it is on, not 100% reliable though.
Detect what? If the computer is on? so you know if it's running that script? You mean just like if you were to invoke peripheral.call("name", "turnOn") and then know 100% that the script is running even if it wasn't before.

I think it is a good idea to do this because you can check if a certain computer is on or not within a network etc.
This is just part of the point I'm trying to make, so you know if a "computer is on or not"…. why? why would you possibly need to know that, that just simply couldn't be determined by using turnOn or shutdown.
Engineer #8
Posted 08 September 2013 - 01:20 PM
[
Maybe that computer has a startup script that does something in the minecraft world and you can detect it with this then. Because it is on, not 100% reliable though.
Detect what? If the computer is on? so you know if it's running that script? You mean just like if you were to invoke peripheral.call("name", "turnOn") and then know 100% that the script is running even if it wasn't before.

What if I want to detect if the script just is running and dont want it to be running?
theoriginalbit #9
Posted 08 September 2013 - 01:23 PM
What if I want to detect if the script just is running and dont want it to be running?
If you don't want the script to be running… Easy… peripheral.call("name", "shutdown") … now you know it is not running…
MudkipTheEpic #10
Posted 08 September 2013 - 01:25 PM
Back to the OP, if you need to know if a computer is on or not, use this:

peripheral.call(side,"getID")

It returns nil if the computer is off, and the ID if it's on.
LBPHacker #11
Posted 08 September 2013 - 02:36 PM
-snip-
Right. I didn't know that. Adding that to the Wiki.
Cloudy #12
Posted 08 September 2013 - 05:18 PM
Do not see much of a use case.
Lyqyd #13
Posted 08 September 2013 - 05:24 PM
Thread closed.