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

How to code a passthrough with a subtractor?

Started by shournk, 18 May 2014 - 08:59 PM
shournk #1
Posted 18 May 2014 - 10:59 PM
I would like to program a computer to do the following:

Using rednet, I have a door that accepts colors.orange and a switch for the door that outputs colors.white. I want the switch (colors.white) to cause the computer to output (colors.orange), but not if an override variable is true. With a rednet controller, this would be as simple as making a subtractor. I'm not sure where to start with Lua for this.
With my layman knowledge of lua, I would probably try something like:

if switch_signal then
	if door_signal then
		if override then
			door_signal = false
		end
	else
		if not override then
			door_signal = true
		end
	end
end

But that seems pretty sketchy. What method should I use? Any help is appreciated.
Edited on 18 May 2014 - 09:28 PM
CCGrimHaxor #2
Posted 19 May 2014 - 02:42 PM
Are you using redstone or redpower(project red) or rednet
awsmazinggenius #3
Posted 19 May 2014 - 02:48 PM
First of all, what is your cc version? CC1.6x makes it the responsibility of other modders to make their bundled cables work (MFR "RedNet" cables are "bundled" for the purposes of cc), not cc's, and I don't think anyone has made their cables work yet (maybe Project: Red in the latest version, but I don't think so)