Jump to content

Help with computer-craft master computer script


zaper270

Recommended Posts

I have set up a system that allows me to activate or dis-activate any of my machines in my house on tekkit. The problem is though is that when i activate one it just turns off all the others. Can someone figure out whats wrong and show me what i need to do?

while true do

term.clear()

term.setCursorPos(1,1)

write("    Input command here: ")

local input = read()

if input == "sorter_on" then

  rs.setBundledOutput("bottom" , colors.white)

  print("Item sorter turned on")

  sleep(2)

  term.clear()

  term.setCursorPos(1,1)

end

if input == "sorter_off" then

  rs.setBundledOutput("bottom" , colors.white)

  print("Item sorter turned off")

  sleep(2)

  term.clear()

  term.setCursorPos(1,1)

end

if input == "block_on" then

  rs.setBundledOutput("bottom" , colors.red)

  print("Block condenser turned on")

  sleep(2)

  term.clear()

  term.setCursorPos(1,1)

end

if input == "block_off" then

  rs.setBundledOutput("bottom" , colors.red)

  print("Block condenser turned off")

  sleep(2)

  term.clear()

  term.setCursorPos(1,1)

end

if input == "music_on" then

  rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.blue)

end

if input == "commands" then

print("sortert_on")

print("sorter_off")

print("block_on")

print("block_off")

print("commands")

sleep(4)

term.clear()

term.setCursorPos(1,1)

end

end

Link to comment
Share on other sites

The problem is with colored cable. Currently computercraft website is down so i don't remember the exact function to call. But you have to do something like this for colored cables:

local c = {}

c = colors.combine( c, colors.red )

So for your code it should look like this (Once again i am not sure if the syntax or usage is correct as i can't refer to computercraft.info right now (its down) and this is from the top of my head)


if input == "sorter_on" then

  c = colors.combine( c, colors.white )

  ...

end

if input == "sorter_off" then

  c = colors.subtract( c, colors.white )

end

 

-- end of code

rs.setBundledOutput( "bottom", c )

Link to comment
Share on other sites

Just got home, checked my old program. Here is the correct sample code:


local outputSide = "bottom"

 

-- if you set rs.setBundledOutput( side, 0 ), it will close all colors off.

-- You can name this anything you want

local activeColors = 0 

 

...

 

if input == "redOn" then

  activeColors = colors.combine( activeColors, colors.red )

end

 

if input == "redOff" then

  activeColors = colors.subtract( activeColors, colors.red )

end

 

if input == "blueOn" then

  activeColors = colors.combine( activeColors, colors.blue )

end

 

if input == "blueOff" then

  activeColors = colors.subtract( activeColors, colors.blue )

end

 

...

 

-- end of code

rs.setBundledOutput( outputSide, activeColors )

Hope it helped! [:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...