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

bundleAPI making RedPower bundle cables EASY!

Started by Andrakon, 26 February 2013 - 02:52 PM
Andrakon #1
Posted 26 February 2013 - 03:52 PM
Written to make using Redpower Bundles easy! Version 1.2

bundleAPI.getInput("side", "color") should now work properly!

This API sends and recieves Redstone signals through bundled cable.
Can handle 96 outputs or inputs! 16 from each side a bundle is connected to.
Use help() to read the directions for use.
Sides are defined with "back" or "left"
Uses standard color names such as "red" or "lightBlue"
Works with american and europeon versions of gray/grey
Will also accept lowercase multi-word colors such as "lightblue" instead of "lightBlue"
Make sure to include the following line in your program:


os.loadAPI ("bundleAPI")

UPDATED:
-Added proper error handling
-Added pulse("side", "color", time)

help() prints the help menu.
getVersion() returns version number of the API.
on("side", "color") turns ON the selected color on the selected side.
off("side", "color") turns OFF the selected color on the selected side.
toggle("side", "color") Toggles the selected color on the selected side.
getOutput("side", "color") returns a 0 or 1 depending on what has been turned off or on.
getInput("side", "color") returns a 0 or 1, reads an input or output as on.
resetAll() turns off all colors on all sides.
resetSide("side") turns off all colors on selected side.
resetColor("color") turns off all of selected color on all sides.

pulse("side", "color", time) toggles the side and color for the specified time for example 1 for one second or 0.5 for 1/2 a second.

example usage:
bundleAPI.toggle("back", "cyan") – toggles off or on the cyan cable on the back side.
bundleAPI.getInput("bottom", "lightGrey") – will return the current state of the lightGrey cable connected to the bottom of the computer.
bundleAPI.off("up", "lightgray") – Makes sure the lightgray cable is off on the Top side. Keeps track and knows if the cable has been turned off before, and will not turn it off again. This keeps the color signal from messing up. Accepts up or down as alternates for top and bottom as well as lightgrey/lightGrey/lightgray/lightGray as alternates for US/EU colors.

Type this in your computers console to download automatically!

pastebin get 9iYHAYq8 bundleAPI

or use the URL to look at the code: http://pastebin.com/9iYHAYq8

Also here is an example program that is also useful for signal testing.
Select a side and it will slowly toggle the colored cables one at a time on that side.

Type this in your computers console to download automatically!

pastebin get W3EihMr2 bundleAPI
or use the URL to look at the code: http://pastebin.com/W3EihMr2
FuuuAInfiniteLoop(F.A.I.L) #2
Posted 26 February 2013 - 04:08 PM
You should add sending msg with it because in 1.5 that function is deleted
Andrakon #3
Posted 27 February 2013 - 03:57 AM
I think this is what you are talking about:

am I right in saying that we can no longer use bundled cable, or is that just in terms of rednet usage? :huh:/>

Just in terms of rednet.

So bundled cables will still work, but you may not be able to send rednet signals through them anymore. Considering I have not yet played with rednet or looked in its code, I will have to do more research first. But that was not the intention of the API to begin with. All it is used for is setting and listening for redstone signals through bundled cable.
Andrakon #4
Posted 27 February 2013 - 04:08 AM
From the WIKI:
Before the creation of the in-game wireless networking API, the term "Rednet" referred to a system created by one of the ComputerCraft users based on bundled cables from a popular Minecraft mod - RedPower. It also allowed communication between computers, but the data was transferred slowly - every bit was converted to redstone signal, that lasted about 0,1 seconds. On the release of ComputerCraft 1.3, the system became useless, as the wireless networking was officially implemented to the mod.

I had no idea someone did this but I was just thinking of how to do this yesterday haha. Sounds like a fun thing to program from scratch even if it is "old technology". This would be much easier to do with bundleAPI now that I have it debugged and in a finalized state. But I don't know if I will do it.
LiLxXxMiNeR #5
Posted 28 February 2013 - 08:01 AM
Hey there, I've been trying to make a program to tell me the status of my reactor chambers but I'm not good with the rs.getInput API and All I want it to do is tell me the status of the cooing system for each core what cores are on and off reactor cores and and and if they are secure or overheating… If you would be able to help me let me know
martin509 #6
Posted 03 March 2013 - 03:08 AM
I might be sounding ignorant here, but can't you set the output in the redstone API, instead of true or false, to a colour?
The colours api used to be for bundled cables specifically.
Simtimzero #7
Posted 20 March 2013 - 06:09 PM
I use something similar to this in my programs. Not to hard to code for, so i never thought much of putting it into an api. Though i can see where this could save some time.
Kingdaro #8
Posted 21 March 2013 - 01:07 AM
This is actually a pretty nice API. Nice job.

One question: why does getInput and getOutput return 0 and 1 instead of true or false?
theoriginalbit #9
Posted 21 March 2013 - 01:09 AM
One question: why does getInput and getOutput return 0 and 1 instead of true or false?
Well it makes it nice for getting the strength in MC 1.5.
Kingdaro #10
Posted 21 March 2013 - 01:13 AM
Except, to my knowledge, signal strength doesn't exist when dealing with RedPower. It's on or off.
theoriginalbit #11
Posted 21 March 2013 - 01:23 AM
ooh oops. i thought this thread was plain redstone. nvm me.
immibis #12
Posted 21 March 2013 - 07:22 PM
RedPower has 0-255.
Kingdaro #13
Posted 21 March 2013 - 10:01 PM
RedPower has 0-255.
In bundled input/output, yes, but signal strength?
Zet0r #14
Posted 23 March 2013 - 10:15 AM
I'm having a problem with this API. Whenever I try to get input information from a bundled cable hooked up to multiple colors. It will return 1 even though which color I power. I may have misunderstood somthing, as this is my very first real programming project. This is the code I use to test it:


if getInput("front", "yellow") == 1
then
print("Yay!")
end
In this code I get no response from the computer. If I add something that will print when it's not 1, then it'll print that every single time, no matter how many, or what color wire is powered through the bundled cable.

I have also tried this code:

if getInput("front", "yellow") ~= 0
then
print("Yay!")
end

This code prints Yay! as long as any wire is powered. If nothing is powered, it will not print it. If any color other than yellow is lit, then it will still print Yay! as if the yellow is powered.

Am I doing something wrong here, or is it a bug of some sort? Also, if I just misunderstood the function, are there any other way to detect what color is powered from a single bundled cable, or at least from one side of the computer, with a current total of 4 colors? (I have wires on all other sides than the front currently)
Thanks in advance! :)/>
immibis #15
Posted 23 March 2013 - 01:33 PM
RedPower has 0-255.
In bundled input/output, yes, but signal strength?
… Yes, signal strength is 0-255. For each colour.
theoriginalbit #16
Posted 23 March 2013 - 03:10 PM
… Yes, signal strength is 0-255. For each colour.
Since when? o.O
theoctagon #17
Posted 10 April 2013 - 08:37 AM
Found an interesting bug using this. Lets say you have a couple of advanced monitors stacked up, sharing an advanced monitor on their right, like this: (O = comp, X = monitor)

OXXXXXX
OXXXXXX

If you run a bundled cable along the BACK of the monitor from either computer, because lets say you wanted to run a different bundle from the other computer in another direction. The cable that is attached to the monitor will NOT send any signals at all. If you detach the part of the bundle connected to the monitor and rerun it so its not touching the monitor, everything works fine. Any part that touches the monitor will fail to transmit a signal.

Fascinating ….

(btw, awesome API's, thanks. Just learning bundled cabling, etc, so it was very very helpful)
theoctagon #18
Posted 10 April 2013 - 08:47 AM
Addendum: It also appears that the two computers cannot share the same bundled cable. Using the previous 'diagram', if you run the bundle from the top computer down to the bottom one, then to the floor and on out, only the bottom computer has control of the bundle. The top computer, although it recognizes the cable as being there, does not transmit or receive. Only the bottom computer does. Of course with me being the noob doing the testing, I'm sure you all already knew this. :D/>
Jaitt #19
Posted 10 April 2013 - 12:12 PM
Hi,

I have also been experiencing problems with reading individual input colours. Through experimenting I found it will return the total summed value of all the inputs not the individual line. 1 or 0

I believe the problem is on line 206 of the API. You are using

redstone.getBundledInput(string side)

If you were to use

redstone.testBundledInput(string side, int color value)

Instead you will get the actual on or off of an individual line.. worked for me

Tks
immibis #20
Posted 10 April 2013 - 09:23 PM
@theoriginalbit: Since they were created.
@theoctagon: Bundled cables don't connect to the thing they're stuck to. The cable has to go into the thing.
theoriginalbit #21
Posted 10 April 2013 - 09:25 PM
@theoriginalbit: Since they were created.
I didn't think Eloraam had a 'strength' to it. I know it only lasted for 256 blocks, but I never knew there was a 'strength'
immibis #22
Posted 11 April 2013 - 09:34 PM
Did you know vanilla redstone had a strength, from 0 to 15?
Andrakon #23
Posted 19 April 2013 - 09:41 PM
Well then… This was my first bit of programming so I am surprised it had as few bugs in it as it did! I haven't even thought look at this thread in a month! I do know there are some bugs with getting the input from certain sides. For instance listening for input on the bottom from a bundled cable is supposed to return a 0 or 1 but returns some large number instead. To compensate in my program using the api I just looked for one of the two huge numbers it returns and assumed it ment 1 or 0. Seems to be a Computer craft bug since the exact same command returns a 1 or 0 on the other sides..

Why does it use 1 or 0 instead of true or false? Because I built a calculator in vanilla minecraft before and think in terms of 0's and 1's instead of trues or falses XD


Oh… now i realize that huge number was all the other inputs and outputs I had on the bottom at the time… DERP!

Glad I am more experienced with this now!
Andrakon #24
Posted 19 April 2013 - 09:45 PM
Hi,

I have also been experiencing problems with reading individual input colours. Through experimenting I found it will return the total summed value of all the inputs not the individual line. 1 or 0

I believe the problem is on line 206 of the API. You are using

redstone.getBundledInput(string side)

If you were to use

redstone.testBundledInput(string side, int color value)

Instead you will get the actual on or off of an individual line.. worked for me

Tks

Great tip! In one fell swoop you probably squashed the majority of problems people were having! TYVM! :D/>

Now version 1.2!