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

Easy Bundled Cable Control Api [Discontinued]

Started by SuPeRMiNoR2, 29 November 2012 - 03:22 PM
SuPeRMiNoR2 #1
Posted 29 November 2012 - 04:22 PM
Since I no longer use ComputerCraft, I will not be updating this program anymore.
I do not recommend using it, but if you want to, I am leaving the original post in a spoiler here.

Spoiler

Easy Bundled Cable Control API, is what it says… :)/>
Have you ever been annoyed by the complexity of controlling redpower bundled cable output from a computercraft computer?
If so, you may want to try this API, which from here on is called the "output api"

Please let me know of any errors in the output api, or features you would like added.

Function List
Spoiler
  • output.setside(String Side) Set the bundled cable side (Defaults to back) possible sides are: top, bottom, back, front, left, and right. You can change the side anytime
  • output.set(String Color, state) Set output for a color. state is true or false, with true meaning on and false meaning off.
  • output.get(String Color) Gets input from a bundled cable for color
  • output.alloff() Turn all outputs off.
  • output.toggle(String Color) Toggles the state of that color


Example Programs
Spoiler

To run this program you need the output api installed and a bundled cable conected to the back of the computer you run it on.
Conect a white, orange, and magenta colored wire to the bundled cable, and conect something to each of the colored wires.
The the colored wires will be turned on from white to magenta, then turned off.

os.loadAPI("output")
output.set("white", true)
sleep(1)
output.alloff()
output.set("orange" , true)
sleep(1)
output.alloff()
output.set("magenta", true)
sleep(1)
output.alloff()

This program will turn on the white wire if you give power to the red wire (useless yes, but it is just showing how to use the api)

os.loadAPI("output")
redwire = false
while true do
redwire = output.get("red")
if redwire == true then
output.set("white", true)
end
if redwire == false then
output.alloff()
end
sleep(.1)
end
This program toggles white on and off every second

os.loadApi("output")
while true do
output.toggle("white")
sleep(1)
end


The full list of colors you can use is:
white, orange, magenta, lightBlue, yellow, lime, pink, gray, lightGray, cyan, purple, blue, brown, green, red, and black.

Installation:
To get the output API simply run this command in a computer with the http api enabled.


pastebin get fDvvvy0L output

Then the output API will be ready for use on that computer (as a file called output) if you want to use it on other computers run the command on them too.

If you dont have/want the http api enabled you can download it from here http://pastebin.com/fDvvvy0L.

IRC Channel at Esper/#BundledCableAPI

Planned:
Spoiler
  • Improve this post
  • allow true and false in the place of 1 and 0 in output.set("color", 1 or 0) Done
  • Add information about the beta
  • Add requested features + updates
Changelog:
Spoiler
  • 2.0 Beta: In progress
  • 1.5 (This version) Made alot smaller with help from immibis, and added a toggle function.
  • 1.4 (This version) You no longer need to use output.init() at the begining of your program :)/>(And it doesnt exist anymore), Made most of the variables local.
  • 1.3 Fixed magenta wires not turning on when they are suposed to.
  • 1.2 Added output.get(string color) which reads input on color and returns true or false.
  • 1.1 Allowed true or false in the place of 1 and 0 in output.set("color", 1 or 0).
  • 1.0 The beginning.

LICENSE
http://creativecommo.../3.0/deed.en_US
This license only applies to THIS PROGRAM, not to minecraft, computercraft, or redpower.
You may edit, and/or use this program/API in your own programs/APIS. You do not have to leave the license comment in, but you can if you want :)/>
JGreen1996 #2
Posted 30 November 2012 - 07:53 AM
Wooooo go you! this will help me greatly :D/>
Lithia #3
Posted 09 December 2012 - 08:41 PM
I wrote a little Script that uses this API, Plus your API is wounderfull! Very easy to use

Here's my script http://pastebin.com/zE1fCt3D
SuPeRMiNoR2 #4
Posted 14 December 2012 - 01:37 PM
I wrote a little Script that uses this API, Plus your API is wounderfull! Very easy to use

Here's my script http://pastebin.com/zE1fCt3D
Thanks!
immibis #5
Posted 14 December 2012 - 02:09 PM
http://pastebin.com/TXbJ0B7k is much shorter (untested)
SuPeRMiNoR2 #6
Posted 18 December 2012 - 03:26 PM
http://pastebin.com/TXbJ0B7k is much shorter (untested)
Wow thats great! May I use it in my api?
I had originally wanted to make it smaller using something like what you did, but the api worked fine, so I decided not to.
Also, I tested it and it worked great (except at the end, where output_side was used where side should have been). Other then that, it worked great!
Arimus #7
Posted 12 August 2013 - 02:08 PM
Thanks for sharing this. I am using it and it works great but I am wondering, can I still use it if I have 2 bundled cables connected to the same computer? Sorry its such a n00b question but I don't quite understand how to use it like this. Still learning programming. Thanks!
Dave-ee Jones #8
Posted 14 August 2013 - 04:05 AM
Nice :D/>

Never really liked the idea of using the redstone API (in-built one) to control bundled cables. This makes things so simple.

Thanks!
Mitchfizz05 #9
Posted 28 August 2013 - 08:19 AM
I do hate the default API for manipulating bundled cable, I still don't understand it to this day. I think this API is a brilliant idea.
However, I have one request: you should make the color parameters use the color API (eg. colors.red) rather than strings. The color API we all know and love.
theoriginalbit #10
Posted 28 August 2013 - 11:05 AM
This is a good start to a wrapper around an API, I have some suggestions to make this wrapper a little better (read the comments).

Improvements to your code
How I would do this wrapper
robotica34 #11
Posted 18 September 2013 - 01:34 PM
This helped me out very much :D/> thanks SuPeRMiNoR2!
SuPeRMiNoR2 #12
Posted 24 October 2013 - 08:30 PM
Hey everone, thanks for the input. I have been busy and never got around to doing any of the things that were suggested.
Redpower has not updated in a while, so this program is pretty much useless.
However, if you are playing on minecraft 1.4.6 I suppose you could still use it :)/>
I changed the license terms to this http://creativecommons.org/licenses/by/3.0/deed.en_US, now you can do whatever you want with it.
theoriginalbit #13
Posted 24 October 2013 - 11:02 PM
Redpower has not updated in a while, so this program is pretty much useless.
ComputerCraft also works with MineFactory Reloaded's RedNet cables in the same way as RedPower2's bundled cables. So this is in no way useless.
SuPeRMiNoR2 #14
Posted 25 October 2013 - 06:52 PM
ComputerCraft also works with MineFactory Reloaded's RedNet cables in the same way as RedPower2's bundled cables. So this is in no way useless.

Well then, I will have to look mine at factory reloaded :D/>
pogof #15
Posted 07 December 2013 - 02:48 PM
Thanks for this simple API. I use it in my "Farm master computer" (BTW I use RedNet cables from Mine factory reloaded)

-pogof

And bundled cables are replaced with ProjectRed, but don't work with CC :(/>
Lyqyd #16
Posted 07 December 2013 - 02:52 PM
Use MFR's rednet cables instead. Dan won't add support for either Project Red or Red Logic until one of them "wins".