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

Turn On/Off a Bundled Cable - Code worked but nothing happens

Started by Eledhrim, 07 June 2016 - 10:54 AM
Eledhrim #1
Posted 07 June 2016 - 12:54 PM
Hey Community,

I've started to control my Buildcraft Engines on Tekkit Legends with ComputerCraft. I want to control them with an adv. Computer und an adv. Monitor as Touchscreen.
You can Click ON to power one of the engines and OFF to stop it. My Problem is, I can start each engine without any problems. But when i try to stop them, the code works (no errors) but the redstone signal is still powered.
I think the "ON Code" overwrite the "OFF" Code, so the redstone cant be deactivated, but the code itself worked.

Here is the code.
ComputerCraft 1.74 in the Tekkit Legends Modpack


local function addcol(col, side)
  rs.setBundledOutput(side, colours.combine(rs.getBundledOutput(side),col))
end
local function remcol(col, side)
  rs.setBundledOutput(side, colours.subtract(rs.getBundledOutput(side),col))
end
term.clear()
local monitor = peripheral.wrap("top")
monitor.setTextScale(1)
term.setTextColour(1)
term.setCursorPos(1,1)
print("Engine I:")
term.setCursorPos(1,2)
print("Engine II:")
term.setCursorPos(1,3)
print("Engine III:")
term.setCursorPos(1,4)
print("Engine IV:")
term.setTextColour(32)
term.setCursorPos(15,1)
print("O [OFF]")
term.setCursorPos(15,2)
print("O [OFF]")
term.setCursorPos(15,3)
print("O [OFF]")
term.setCursorPos(15,4)
print("O [OFF]")
term.setTextColour(16384)
term.setCursorPos(25, 1)
print("O [ON]")
term.setCursorPos(25, 2)
print("O [ON]")
term.setCursorPos(25, 3)
print("O [ON]")
term.setCursorPos(25, 4)
print("O [ON]")
term.setTextColour(1)
term.setCursorPos(37,4)
print("X")
local sSide = "back"

while true do
event,side,x,y = os.pullEvent()
  if event == "monitor_touch" then
	if x == 37 and y == 4 then
	  redstone.setBundledOutput(sSide, 0)
	  term.setTextColour(16384)
	  term.setCursorPos(25,1)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,1)
	  print("O [OFF]")
	  term.setTextColour(16384)
	  term.setCursorPos(25,2)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,2)
	  print("O [OFF]")
	  term.setTextColour(16384)
	  term.setCursorPos(25,3)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,3)
	  print("O [OFF]")
	  term.setTextColour(16384)
	  term.setCursorPos(25,4)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,4)
	  print("O [OFF]")
	end
	if x == 15 and y == 1 then
	  remcol(colours.lime, sSide)
	  term.setTextColour(16384)
	  term.setCursorPos(25,1)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,1)
	  print("O [OFF]")
	end
	if x == 25 and y == 1 then
	  addcol(colours.lime, sSide)
	  term.setTextColour(32)
	  term.setCursorPos(25,1)
	  print("O [ON]")
	  term.setTextColour(16384)
	  term.setCursorPos(15,1)
	  print("O [OFF]")
	end
	if x == 25 and y == 2 then
	  addcol(colours.yellow, sSide)
	  term.setTextColour(32)
	  term.setCursorPos(25,2)
	  print("O [ON]")
	  term.setTextColour(16384)
	  term.setCursorPos(15,2)
	  print("O [OFF]")
	end
	if x == 15 and y == 2 then
	  remcol(colours.yellow, sSide)
	  term.setTextColour(16384)
	  term.setCursorPos(25,2)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,2)
	  print("O [OFF]")
	end
	if x == 25 and y == 3 then
	  addcol(colours.orange, sSide)
	  term.setTextColour(32)
	  term.setCursorPos(25,3)
	  print("O [ON]")
	  term.setTextColour(16384)
	  term.setCursorPos(15,3)
	  print("O [OFF]")
	end
	if x == 15 and y == 3 then
	  remcol(colours.orange, sSide)
	  term.setTextColour(16384)
	  term.setCursorPos(25,3)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,3)
	  print("O [OFF]")
	end
	if x == 25 and y == 4 then
	  addcol(colours.white, sSide)
	  term.setTextColour(32)
	  term.setCursorPos(25,4)
	  print("O [ON]")
	  term.setTextColour(16384)
	  term.setCursorPos(15,4)
	  print("O [OFF]")
	end
	if x == 15 and y == 4 then
	  remcol(colours.white, sSide)
	  term.setTextColour(16384)
	  term.setCursorPos(25,4)
	  print("O [ON]")
	  term.setTextColour(32)
	  term.setCursorPos(15,4)
	  print("O [OFF]")
	end
  end
end

i hope you can help me. i tried it the whole night with different ways, but im out of ideas.
Edited on 07 June 2016 - 11:41 AM
Bomb Bloke #2
Posted 07 June 2016 - 01:29 PM
Which version of ComputerCraft are we talking about?
Eledhrim #3
Posted 07 June 2016 - 01:40 PM
Sry, i forgot that. ComputerCraft 1.74 in the Tekkit Legends Modpack
Bomb Bloke #4
Posted 07 June 2016 - 02:05 PM
colours.subtract() is broken in that build. Either try this workaround or update to CC 1.75.