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

[Question]: I/O peripherals

Started by Monsieurlefou, 13 March 2013 - 09:44 AM
Monsieurlefou #1
Posted 13 March 2013 - 10:44 AM
Hi,

I discoverd computercraft via Tekkit and I love it! I got a question and can't find the answer too it. As I said, I'm using computercraft via the Tekkit modpack, so if I'm not mistaken it is version 1.3.

My question: as far as I can tell the basis computer unit only got 3 I/O (inputs/outputs): left, right and back. Is there a way to increase the amount of I/O's, while still using tekkit?
I'm sorry if the answer tot this question is obivious, but I had no succes finding the answer.

Thanks in advance,
Monsieurlefou
Lyqyd #2
Posted 13 March 2013 - 03:24 PM
Split into new topic.

Available sides are: top, bottom, front, back, left, right.
Bubba #3
Posted 13 March 2013 - 04:19 PM
The best way to deal with I/O sides is by using the table provided by rs.getSides(). Here's an example:


local modem = false
local function attachToModem()
  for i,v in pairs(rs.getSides()) do
	if peripheral.getType(v) == "modem" then
	  modem = peripheral.wrap(v)
          return true
	end
  end
  return false
end

attachToModem()

With the above code, I will never have to worry about defining a peripheral in a hardcoded manner. It will cycle through all the available peripheral sides (which are the same as rednet sides) and check if it is the type of peripheral I want to attach to. If so, then it will attach automatically.

I believe that there is a "wireless peripherals" peripheral in the forums if you take a look there, which could extend the number of I/O you have. There is also a wired peripherals mod that does the same thing.
Monsieurlefou #4
Posted 13 March 2013 - 10:58 PM
Thanks, this is all very helpfull!

I started increasing I/O's with logic circuits (AND, NOT), but your method will save me a lot of time, effort, recourses and space. Also didn't know about all sides being able to input/output.