12 posts
Posted 24 February 2013 - 09:48 AM
Title: redstone input = command
Just a quick question I would like to ask.
So basically I would like it so if a powered redstone signal went into say the back of my computer it makes my computer run a program like startup or 'monitor top help' something like that? Can you do that?
1511 posts
Location
Pennsylvania
Posted 24 February 2013 - 10:21 AM
You could do this:
side = --side the redstone is touching the computer
while true do
event = os.pullEvent()
if event == "redstone" and rs.getInput(side) == true then
--run program
end
end
EDIT: The side also must be defined as a string like so: side = "back"
12 posts
Posted 24 February 2013 - 11:13 PM
Thanks!
1511 posts
Location
Pennsylvania
Posted 25 February 2013 - 04:14 AM
No problem :)/>
12 posts
Posted 25 February 2013 - 01:33 PM
S I have this program here an it works fine :)/> but I messed around for about an hour… Derp and couldn't figure out how to add a seccond event thing. So if a signal hits the top not the side for say it does a different command. So I will have 2 options?
side = –side the redstone is touching the computer
while true do
event = os.pullEvent()
if event == "redstone" and rs.getInput(side) == true then
–run program
end
end
1511 posts
Location
Pennsylvania
Posted 25 February 2013 - 01:53 PM
Try this:
side = --side the redstone is touching the computer
tSide = --another side where redstone touches the computer
while true do
event = os.pullEvent()
if event == "redstone" and rs.getInput(side) == true then
--run program
elseif event == "redstone" and rs.getInput(tSide) == true then
--run other program
end
Just cleaned the code a bit:
side = --side the redstone is touching the computer
tSide = --another side where redstone touches the computer
while true do
event = os.pullEvent()
if event == "redstone" then
if rs.getInput(side) == true then
--run program
elseif rs.getInput(tSide) == true then
--run other program
end
end
end
671 posts
Location
That place over there. Y'know. The one where I am.
Posted 25 February 2013 - 01:53 PM
side = "right"
side2 = "top"
while true do
event = os.pullEvent()
if event == "redstone" and rs.getInput(side) == true then
--do stuff
elseif event == "redstone" and rs.getInput(side2) == true then
--do other stuff
end
end
DAMNIT! NINJA'D!
1511 posts
Location
Pennsylvania
Posted 25 February 2013 - 01:59 PM
side = "right"
side2 = "top"
while true do
event = os.pullEvent()
if event == "redstone" and rs.getInput(side) == true then
--do stuff
elseif event == "redstone" and rs.getInput(side2) == true then
--do other stuff
end
end
Lol, cleaned that up ;)/>
Also, remember that you could have SIX!.. programs that run if a redstone input is detected. The event = os.pullEvent() will wait for any event and store the result in the variable "event" as defined. The event is then compared to the event "redstone", if they don't match then it restarts the loop. Otherwise it will check if a defined side is being given a redstone input. Obviously a side must be powered or else the event would not be defined as a "redstone" event and would not reach this part of the program. If you have any questions regarding more input sides, events, or anything just ask and anyone here will be glad to help.
12 posts
Posted 26 February 2013 - 04:50 AM
Cheers for all the help guys!
8543 posts
Posted 26 February 2013 - 07:05 AM
I don't know why you thought you couldn't find this post, but it is right here.
1511 posts
Location
Pennsylvania
Posted 26 February 2013 - 09:14 AM
No problem. Glad to help anytime.
37 posts
Posted 26 February 2013 - 10:23 AM
This is going to be quite useful! Thanks SuicidalSTDz!
1511 posts
Location
Pennsylvania
Posted 26 February 2013 - 10:30 AM
This is going to be quite useful! Thanks SuicidalSTDz!
No problem! ;)/> I went more in depth in the other thread labeled: Redstone Input = Command (advanced)
8543 posts
Posted 26 February 2013 - 11:01 AM
Threads merged. Please stick to a single topic for a single question.
1511 posts
Location
Pennsylvania
Posted 26 February 2013 - 11:18 AM
Threads merged. Please stick to a single topic for a single question.
Knew that was going to happen ;)/>
I guess he made a new thread asking a "similar" question since he couldn't find this thread (Which is odd)