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

[Lua][Question] Bundled Cable Controls

Started by Woodsworth, 25 April 2012 - 02:22 AM
Woodsworth #1
Posted 25 April 2012 - 04:22 AM
My goal is to be able to use a console to control a series of wireless transmitters (which in turn are controlling an automated solar panel factory). The factory and transmitters work but I want to be more sophisticated than just using levers. Right now I have different colored wires running out of each of the transmitters into a bundled wire. The bundled wire is run to the bottom of the console. Here is the code I have so far:

Spoiler
term.clear()

term.setCursorPos(1,1)
write("Please select which transmitter to toggle.")

term.setCursorPos(1,4)
write("Enter the appropriate number.")

term.setCursorPos(1,6)
write("1. Solar Panel Sorting Machines") -- White

term.setCursorPos(1,7)
write("2. Advanced Machines") -- Black

term.setCursorPos(1,8)
write("3. Feeder") -- Green

term.setCursorPos(1,9)
write("4. ATC Pumps) -- Red, Blue, Yellow

term.setCursorPos(1,10)
write("5. Everything")

term.setCursorPos(1,12)
toggle = io.read()

if toggle == "1" then
     if redstone.testBundledInput("bottom", colors.white) == false then
     rs.setBundledOutput("bottom", colors.white)
     else
     rs.setBundledOutput("bottom", 0)

elseif toggle == "2" then
     advm()

elseif toggle == "3" then
     feeder()

elseif toggle == "4" then
     pumps()

elseif toggle == "5" then
     all()

else
term.clear()
term.setCursorPos(17,9)
write("Incorrect input!")
sleep (2)
os.reboot()
end


This is in the startup so that anyone on our server can use it without having to know how to run a console. The problem I'm having is with the redstone.testBundledInput and rs.setBundleOutput. It is not sending the signal to the white wire. I tried using the redset (redset bottom white true) comand byitself but that was not working either. I'm not sure if it is a code thing or if the wires are in the wrong spot. Appreciate any help.
Luanub #2
Posted 25 April 2012 - 05:13 AM
Lets try this and see if it will help..

First add this at the top of your code

c = rs.getBundledOutput("bottom")

Then change this:

if toggle == "1" then
     if redstone.testBundledInput("bottom", colors.white) == false then
     rs.setBundledOutput("bottom", colors.white)
     else
     rs.setBundledOutput("bottom", 0)
to

if toggle == "1" then
 	if redstone.testBundledInput("bottom", colors.white) == false then
	c = colors.combine( c, colors.white )
	rs.setBundledOutput("bottom", c )
	else
	c = colors.subtract( c, colors.white )
	rs.setBundledOutput("bottom", c )
Woodsworth #3
Posted 25 April 2012 - 06:48 AM
That seemed to clear up the logic knot in my head so thanks :)/>/>. But the console still doesn't seem to be communicating with the wires.
Luanub #4
Posted 25 April 2012 - 07:22 AM
Is it all of the wires or just the white one at this point? Have you tried going into the lua shell and manually turning some of the colors off and on? You can also try to place the bundled cable directly on the bottom of the computer by holding shift while placing it.
Woodsworth #5
Posted 25 April 2012 - 08:31 AM
None of the colors seem to be working. I have the cable on the bottom of the comp already. I have tried two methods of manually turning the wires on. Using the redset function in the root directory and going into lua and using the getBundledOutput and setBundledOutput options. Either way gives me the same result, the wires do not get power. However, I have noticed that the getBundledOutput does change no matter which method I use (example: the number given after turning red on is 16384). So both seem to be doing something.

Here is a pic of my setup: http://imgur.com/TDUaE
Luanub #6
Posted 25 April 2012 - 08:52 AM
Yeah it must be a connection thing, if you have it on the bottom and its been there the whole time try taking it off and just have it on the connecting block underneath the computer. I'm getting ready to head home. I'll try setting this up and see if I can duplicate the error.
Woodsworth #7
Posted 25 April 2012 - 09:34 AM
I tired that and just for fun, I tried the left and right side as well (both just connecting and having a wire on the computer itself). Same thing. I also tested without a cable touching the machine at all. The computer gave the same results I said before when manually switching the "wires". It is almost as if the computer doesn't know the bundled wire is even there.
Luanub #8
Posted 25 April 2012 - 09:42 AM
Much easier when at home. I didn't notice but there was and end missing from the if statement that controlled the redstone and another typo further up in the script. I then tested with the cable in multiple positions on the computer and they all turned on the white light. This should fix your issue unless your experiencing some sort of bug.

Spoiler

c = rs.getBundledOutput("bottom")

term.clear()

term.setCursorPos(1,1)
write("Please select which transmitter to toggle.")

term.setCursorPos(1,4)
write("Enter the appropriate number.")

term.setCursorPos(1,6)
write("1. Solar Panel Sorting Machines") -- White

term.setCursorPos(1,7)
write("2. Advanced Machines") -- Black

term.setCursorPos(1,8)
write("3. Feeder") -- Green

term.setCursorPos(1,9)
write("4. ATC Pumps") -- Red, Blue, Yellow

term.setCursorPos(1,10)
write("5. Everything")

term.setCursorPos(1,12)
toggle = io.read()

if toggle == "1" then
	    if redstone.testBundledInput("bottom", colors.white) == false then
	    c = colors.combine( c, colors.white )
	    rs.setBundledOutput("bottom", c )
	    else
	    c = colors.subtract( c, colors.white )
	    rs.setBundledOutput("bottom", c )
        end
elseif toggle == "2" then
	 advm()

elseif toggle == "3" then
	 feeder()

elseif toggle == "4" then
	 pumps()

elseif toggle == "5" then
	 all()

else
term.clear()
term.setCursorPos(17,9)
write("Incorrect input!")
sleep (2)
os.reboot()
end

Woodsworth #9
Posted 25 April 2012 - 10:23 AM
Yup that code works like a charm … in single player mode lol. Looks like it is a bug with Computer Craft on the multiplayer server side. Gonna have to get the admin to mess around with that part on his side. Thanks a lot for the help!

You wouldn't happen to have any thoughts on what it might be on the multi side, would you?
Luanub #10
Posted 25 April 2012 - 10:47 AM
Do you know what type of server it is? Vanilla SMP, Bukkit, tekkit?

If it's tekkit I would read this thread. It's probably due to Redpower not loading before ComputerCraft. It's correctable just will take some work.

http://www.computercraft.info/forums2/index.php?/topic/574-tekkitcomputercraft-no-bundled-cables/
Woodsworth #11
Posted 25 April 2012 - 11:19 AM
It is a tekkit server but not 100% sure what system it is running on (windows or linux). That is great information tho. I'll pass it on to the admin.

Side note:

I was able to complete all of the code and it is working flawlessly in single player mode. I had to break up the "everything" option into "all on" and "all off" to make it easier :)/>/>. Can't thank you enough man.