This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xTotalG's profile picture

Help with redstone input and computers

Started by xTotalG, 02 April 2013 - 04:26 AM
xTotalG #1
Posted 02 April 2013 - 06:26 AM
First things first: Yes I am fully aware that I am a complete noob to computercraft and I'm sure there is a very easy answer to my question and all help is appreciated. :)/>

I was wondering if there was anyway that if I ran a redstone input (briefly powered repeater) to a computer that in turn it would run a command.

For example: Computer receives a redstone input and it runs the program Readbee.
All help is appreciated!
SuicidalSTDz #2
Posted 02 April 2013 - 06:31 AM
while true do
 local ev = os.pullEvent() --fire an event
 if ev == "redstone" then --if the returned event is a "redstone" event
  --run your script here. In your case: shell.run("ReadBee")
 end
end
No question is stupid, that is, unless you are asking what mod this is..
xTotalG #3
Posted 02 April 2013 - 06:50 AM
while true do
local ev = os.pullEvent() --fire an event
if ev == "redstone" then --if the returned event is a "redstone" event
  --run your script here. In your case: shell.run("ReadBee")
end
end
No question is stupid, that is, unless you are asking what mod this is..

Its says in return "bee:2: attempt to call nil"
SuicidalSTDz #4
Posted 02 April 2013 - 07:05 AM
Are you using different code or code combined with the above code? If so, please post it. I don't see any problem with the script above.
LBPHacker #5
Posted 02 April 2013 - 07:06 AM
while true do
local ev = os.pullEvent() --fire an event
if ev == "redstone" then --if the returned event is a "redstone" event
  --run your script here. In your case: shell.run("ReadBee")
end
end
No question is stupid, that is, unless you are asking what mod this is..

Its says in return "bee:2: attempt to call nil"

If the 2nd line is the one with .pullEvent: No way, you've done something wrong.

EDIT: Okay, Suicidal is online, I've realized…
SuicidalSTDz #6
Posted 02 April 2013 - 07:07 AM
EDIT: Okay, Suicidal is online, I've realized…
Heh, I was replying to another post so I just noticed this one. A ninja I am :ph34r:/>
xTotalG #7
Posted 02 April 2013 - 07:10 AM
Are you using different code or code combined with the above code? If so, please post it. I don't see any problem with the script above.
while true do
local ev = os.pullEvent() --fire an event
if ev == "redstone" then --if the returned event is a "redstone" event
  --run your script here. In your case: shell.run("ReadBee")
end
end
No question is stupid, that is, unless you are asking what mod this is..

Its says in return "bee:2: attempt to call nil"

If the 2nd line is the one with .pullEvent: No way, you've done something wrong.

EDIT: Okay, Suicidal is online, I've realized…

I have no code besides the code you have provided. I have triple checked for any errors on my end.
SuicidalSTDz #8
Posted 02 April 2013 - 07:12 AM
Well.. I use CC-Emu which does not support redstone (Obviously) so I cannot test this.
Are you using Tekkit or any sort of Technic modpack? What version of CC are you using?

EDIT: Maybe someone else can test this code. I am almost positive it should work.
xTotalG #9
Posted 02 April 2013 - 07:15 AM
Well.. I use CC-Emu which does not support redstone (Obviously) so I cannot test this.
Are you using Tekkit or any sort of Technic modpack? What version of CC are you using?

EDIT: Maybe someone else can test this code. I am almost positive it should work.
Im using the MindCrack FTB modpack. The current version of CC that im running is 1.5
SuicidalSTDz #10
Posted 02 April 2013 - 07:18 AM
Im using the MindCrack FTB modpack. The current version of CC that im running is 1.5
It should work flawlessly if it is 1.5.. Umm, I can't really help any further. If someone wants to test this out on a singleplayer world, that would be great.
xTotalG #11
Posted 02 April 2013 - 07:25 AM
Im using the MindCrack FTB modpack. The current version of CC that im running is 1.5
It should work flawlessly if it is 1.5.. Umm, I can't really help any further. If someone wants to test this out on a singleplayer world, that would be great.
And my quest for an answer continues! hahaha Anyway thanks for the help
SuicidalSTDz #12
Posted 02 April 2013 - 07:32 AM
I really hate not being able to answer your question. I just can't see anything wrong (atm) with the script provided. If you want you can post your code, as is, so I can take a look at it. Maybe something got lost or wasn't copied correctly. It's worth a shot.
LBPHacker #13
Posted 02 April 2013 - 08:01 AM
Tested. Works.
SuicidalSTDz #14
Posted 02 April 2013 - 08:19 AM
Well.. Then I have nothing more to say. If it works (i'm assuming you used 1.5 as well to test it) for LBPHacker, then it should work for you.
SuicidalSTDz #15
Posted 02 April 2013 - 08:21 AM
Another thing you can try is this:

while true do
 local _,p1 = os.pullEvent("redstone") --we put the event param out for garbage collection since we don't need it
 --do stuff here
end
This will wait for a redstone event to be returned, then will run your stuff. It won't run if the event is not redstone
xTotalG #16
Posted 02 April 2013 - 08:40 AM
Another thing you can try is this:

while true do
local _,p1 = os.pullEvent("redstone") --we put the event param out for garbage collection since we don't need it
--do stuff here
end
This will wait for a redstone event to be returned, then will run your stuff. It won't run if the event is not redstone
Yep I figured it out now. Thanks for everything!
SuicidalSTDz #17
Posted 02 April 2013 - 09:10 AM
Lol, no problem ^_^/>

(The second method in theory is better for your case since it is waiting for a returned event being "redstone")