This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Computer.isturnedon
Started by LBPHacker, 08 September 2013 - 02:09 AMPosted 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.
Posted 08 September 2013 - 06:16 AM
or "isOn" to shorten that
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.
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.
Posted 08 September 2013 - 07:44 AM
You might not want to turn on/off the computer, you might just want to know if it's on.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.
I support this idea.
Posted 08 September 2013 - 07:45 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?You might not want to turn on/off the computer, you might just want to know if it's on.
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.
Posted 08 September 2013 - 01:17 PM
The only ones I can think of involve turning the computer on or off depending on whether it is on or off…It is programming, there could be lots of cases where the programmer needs it.
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.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.
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.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.
Posted 08 September 2013 - 01:20 PM
[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.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.
What if I want to detect if the script just is running and dont want it to be running?
Posted 08 September 2013 - 01:23 PM
If you don't want the script to be running… Easy… peripheral.call("name", "shutdown") … now you know it is not running…What if I want to detect if the script just is running and dont want it to be running?
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.
peripheral.call(side,"getID")
It returns nil if the computer is off, and the ID if it's on.
Posted 08 September 2013 - 02:36 PM
Right. I didn't know that. Adding that to the Wiki.-snip-
Posted 08 September 2013 - 05:18 PM
Do not see much of a use case.
Posted 08 September 2013 - 05:24 PM
Thread closed.