3 posts
Posted 20 July 2015 - 09:53 PM
Hello!
I would like to know of there is a way to check if a door next to a computer is open or closed by that computer. If not, is there a solution in Open Peripherals or Open Computers?
3057 posts
Location
United States of America
Posted 20 July 2015 - 11:34 PM
Well, you could check the output by using
redstone.getOutput(side)
It will return true if the computer is emitting a redstone signal on the given side, false if it is not.
3 posts
Posted 21 July 2015 - 02:45 AM
Well, you could check the output by using
redstone.getOutput(side)
It will return true if the computer is emitting a redstone signal on the given side, false if it is not.
Thank you for the reply, but I wanted to just check the door, the user will open the door. I'm trying to work on an alarm system.
957 posts
Location
Web Development
Posted 21 July 2015 - 05:52 AM
Well, you could check the output by using
redstone.getOutput(side)
It will return true if the computer is emitting a redstone signal on the given side, false if it is not.
Thank you for the reply, but I wanted to just check the door, the user will open the door. I'm trying to work on an alarm system.
A turtle may be able to use 'turtle.inspect' to get the metadata for the door
10 posts
Posted 21 July 2015 - 06:19 AM
Not that I know of with a computer, but with a turtle you can use inspect().
Say you have a set up like this:
!_<
With the door ( _ ) on the south edge of the block and the turtle ( < ) facing the door to the east and a lever ( ! ) on the west side.Running
turtle.inspect() returns
true
{
name = "minecraft:wooden_door",
metadata = 7,
}
If you flip the lever and call it again, you get:
true
{
name = "minecraft:wooden_door",
metadata = 3,
}
Now, two points:
- Those metadata values will change based on the way the door faces, so you'll need to experiment.
- This only seems to work with doors opened by redstone, opening it by hand and calling the function seems to cause a block update of some sort causing the door to close and the "closed" metadata value to be returned. The turtle never 'sees' the door as open. So this would probably only work for your purpose with a iron door.
That said, if you're using a redstone signal to open/close the door, you can just use a regular computer to read that signal with
redstone.getOutput(side).
Edited on 21 July 2015 - 04:30 AM
3 posts
Posted 21 July 2015 - 05:15 PM
Not that I know of with a computer, but with a turtle you can use inspect().
Say you have a set up like this:
!_<
With the door ( _ ) on the south edge of the block and the turtle ( < ) facing the door to the east and a lever ( ! ) on the west side.Running
turtle.inspect() returns
true
{
name = "minecraft:wooden_door",
metadata = 7,
}
If you flip the lever and call it again, you get:
true
{
name = "minecraft:wooden_door",
metadata = 3,
}
Now, two points:
- Those metadata values will change based on the way the door faces, so you'll need to experiment.
- This only seems to work with doors opened by redstone, opening it by hand and calling the function seems to cause a block update of some sort causing the door to close and the "closed" metadata value to be returned. The turtle never 'sees' the door as open. So this would probably only work for your purpose with a iron door.
That said, if you're using a redstone signal to open/close the door, you can just use a regular computer to read that signal with
redstone.getOutput(side).
Hm, Not totally what I wanted, but may have to use it.
Have you used OpenComputers or OpenPeripherals?
10 posts
Posted 22 July 2015 - 12:12 AM
Goodluck. Sorry I couldn't provide what you wanted. :(/>
Neither, I'm afraid. My current project I'm trying to keep entirely Vanilla CC.
1080 posts
Location
In the Matrix
Posted 22 July 2015 - 07:49 AM
Short of the turtle approach, if you do just add a button, you can get the input with
rs.getInput("side")
true is on, false is off. So if you have it setup right, you can detect the changes with that, but only if a button or whatnot is used.
53 posts
Location
Minecraft
Posted 22 July 2015 - 01:14 PM
You can try to use that:
side = "right" -- Change to the side of you Door
if redstone.getInput(side) then
-- Do stuff here
end
In Order with a loop you can check the status every X Ticks :)/>