9 posts
Posted 03 December 2012 - 12:02 PM
So I want to make a sign above my door that says "Closed" when the computer is not getting a redstone input, and when the computer does get a redstone input the sign changes from saying closed to open. Can you please write me a program for this as I get completely lost with the redstone input part as i've never done that before.
1688 posts
Location
'MURICA
Posted 03 December 2012 - 12:59 PM
This is actually pretty simple, though saying "can you please write a program for me" doesn't really resonate well with users here, who are here to help you with your scripts, and not make them for you.
Nonetheless, hopefully you'll learn something from this.
while true do -- keep doing this forever
-- stop the script until a redstone input has changed
os.pullEvent('redstone')
-- get a monitor object, and then clear the screen
-- "top" is if the monitor is on the top of the computer, change this if it's different for you.
local monitor = peripheral.wrap('top')
monitor.clear()
monitor.setCursorPos(1,1)
-- we're going to see if the computer is receiving power from the back of the computer.
-- if it is, write "open" to the monitor, and write "closed" otherwise.
if rs.getInput('back') then
monitor.write('OPEN')
else
monitor.write('CLOSED')
end
end
9 posts
Posted 04 December 2012 - 11:54 AM
Thanks for replying, I am sorry for bothering you again about this because I feel bad about having you fix things for me but I can't seem to get it to work still. This is my code after reading your post:
while true do
os.pullEvent('redstone')
local monitor = peripheral.wrap('right')
monitor.clear()
monitor.setCursorPos(1,1)
if rs.getInput('front') then
monitor.write('OPEN')
else
monitor.write('CLOSED')
end
end
1190 posts
Location
RHIT
Posted 04 December 2012 - 01:52 PM
Thanks for replying, I am sorry for bothering you again about this because I feel bad about having you fix things for me but I can't seem to get it to work still. This is my code after reading your post:
while true do
os.pullEvent('redstone')
local monitor = peripheral.wrap('right')
monitor.clear()
monitor.setCursorPos(1,1)
if rs.getInput('front') then
monitor.write('OPEN')
else
monitor.write('CLOSED')
end
end
What errors are you getting? The code should be valid.
2005 posts
Posted 04 December 2012 - 04:16 PM
Why is "local monitor = peripheral.wrap('right') " inside the loop?
Anyway, which side is the monitor actually on? Where does the redstone actually flow into the computer? And, of course what exactly constitutes "not work"?
134 posts
Posted 05 December 2012 - 06:14 AM
The code works pretty well :)/>
- if u have ur minecraft connected up to pastebin i made a pastebin
http://pastebin.com/qEinWLBF
9 posts
Posted 08 December 2012 - 01:40 PM
I have the redstone going into the front of the computer, and the monitor is on the left of the computer.
The error is:
"startup:4: attempt to index ? (a nil value)
1190 posts
Location
RHIT
Posted 08 December 2012 - 02:12 PM
I have the redstone going into the front of the computer, and the monitor is on the left of the computer.
The error is:
"startup:4: attempt to index ? (a nil value)
Well there's your problem. Monitor is on left, but in the program it says peripheral.wrap('right'). Change 'right' to 'left' and it should be good.