Jump to content




Computer.isturnedon


  • This topic is locked This topic is locked
12 replies to this topic

#1 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 08 September 2013 - 03: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.

#2 reububble

  • Members
  • 72 posts
  • LocationBehind you

Posted 08 September 2013 - 05:16 AM

or "isOn" to shorten that

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 September 2013 - 06: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.

#4 Mitchfizz05

  • Members
  • 125 posts
  • LocationAdelaide, Australia

Posted 08 September 2013 - 06:44 AM

View Posttheoriginalbit, on 08 September 2013 - 06:02 AM, said:

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.

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 September 2013 - 06:45 AM

View Postmitchfizz05, on 08 September 2013 - 06:44 AM, said:

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?

#6 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 08 September 2013 - 07:18 AM

View Posttheoriginalbit, on 08 September 2013 - 06:45 AM, said:

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.

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 September 2013 - 12:17 PM

View PostEngineer, on 08 September 2013 - 07:18 AM, said:

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...

View PostEngineer, on 08 September 2013 - 07:18 AM, said:

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.

View PostEngineer, on 08 September 2013 - 07:18 AM, said:

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.

#8 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 08 September 2013 - 12:20 PM

View Posttheoriginalbit, on 08 September 2013 - 12:17 PM, said:

[

View PostEngineer, on 08 September 2013 - 07:18 AM, said:

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?

#9 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 September 2013 - 12:23 PM

View PostEngineer, on 08 September 2013 - 12:20 PM, said:

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...

#10 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 08 September 2013 - 12: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.

#11 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 08 September 2013 - 01:36 PM

View PostMudkipTheEpic, on 08 September 2013 - 12:25 PM, said:

-snip-
Right. I didn't know that. Adding that to the Wiki.

#12 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 08 September 2013 - 04:18 PM

Do not see much of a use case.

#13 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 08 September 2013 - 04:24 PM

Thread closed.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users