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

[MC 1.7.10][CC 1.73] Redstone I/O

Started by FireHead996, 03 August 2015 - 08:16 AM
FireHead996 #1
Posted 03 August 2015 - 10:16 AM
Redstone I/O

What is this?
Redstone I/O is a peripheral for ComputerCraft that is meant to be connected to a LAN cable and can be used for various things like:
- reading a redstone signal (with strength)
- sending a redstone signal (with strength)
- throwing an Lua event when detects any change in redstone signal
Redstone signal can be placed only from side which is indicated by red cross.

Recipe
Recipe is the same as in older version made by Nuchaz.
Redstone block in the middle and smooth stones on the outside.


Code

redio = peripheral.wrap("io_1")

redio.setOutput(true)	-- enables a redstone signal with strength 15
redio.setOutput(false)   -- disables the redstone signal
redio.setOutput(10)	 -- outputs a redstone signal of 10
redio.setOutput(0)	 -- disables the redstone signal
redio.getInput()	 -- returns true/false if there is a redstone signal or not (any strength)
redio.getAnalogInput()   -- returns an integer from 0-15 of the redstone strength


event, state, strength, id = os.pullEvent("redstone")  -- pulls an event with 4 return values
-- event returns:  redstone
-- state returns true/false if there is redstone
-- strength returns an integer from 0-15 indicating the redstone strength
-- id returns the id of the peripheral the threw the event

How to install it?
Simply put the .jar file to your mods folder.

Download
V1.01 [MC 1.7.10][CC 1.73]: Click!

V1.0 [MC 1.7.10][CC 1.73]: Click!
Source code soon…

Changelog
- V1.0: Rebuild the original code and ported to MC 1.7.10.
- V1.01: Changed methods and event name for more matching Redstone API.

Thanks for NuchaZ
I put here a link to the old version if someone want the original source code. :)/>
Click!


Now this block is a part of FirePeripherals pack. See here: http://www.computercraft.info/forums2/index.php?/topic/24542-mc-1710cc-173-fireperipherals-v10/
Edited on 01 September 2015 - 12:06 AM
SquidDev #2
Posted 03 August 2015 - 07:16 PM
I like this: +1. It would be nice though if this followed method names to the default redstone API. So for instance, I think it should queue a redstone event as well - allowing both old and redstone API style methods would support backwards compatibility and similarity to vanilla CC. You might be able to use bundled cables as well if you hook into CC's methods with reflection.
FireHead996 #3
Posted 04 August 2015 - 12:02 AM
V1.01: Changed methods and event name for more matching Redstone API.

I like this: +1. It would be nice though if this followed method names to the default redstone API. So for instance, I think it should queue a redstone event as well - allowing both old and redstone API style methods would support backwards compatibility and similarity to vanilla CC. You might be able to use bundled cables as well if you hook into CC's methods with reflection.
I think about adding a bundled support but not in this block. I can add aditional block with ProjectRed API support. What you think?