Jump to content




bundleAPI making RedPower bundle cables EASY!

api lua

  • You cannot reply to this topic
23 replies to this topic

#1 Andrakon

  • Members
  • 37 posts

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


#2 FuuuAInfiniteLoop(F.A.I.L)

  • Banned
  • 435 posts
  • LocationThe left part of this post

Posted 26 February 2013 - 04:08 PM

You should add sending msg with it because in 1.5 that function is deleted

#3 Andrakon

  • Members
  • 37 posts

Posted 27 February 2013 - 03:57 AM

I think this is what you are talking about:

View PostaracnossOS, on 16 February 2013 - 11:57 PM, said:

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

View PostCloudy, on 17 February 2013 - 12:21 AM, said:

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.

#4 Andrakon

  • Members
  • 37 posts

Posted 27 February 2013 - 04:08 AM

From the WIKI:

Quote

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.

#5 LiLxXxMiNeR

  • New Members
  • 1 posts

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

#6 martin509

  • Members
  • 53 posts

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.

#7 Simtimzero

  • Members
  • 3 posts

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.

#8 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

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?

#9 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 March 2013 - 01:09 AM

View PostKingdaro, on 21 March 2013 - 01:07 AM, said:

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.

#10 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

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.

#11 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 March 2013 - 01:23 AM

ooh oops. i thought this thread was plain redstone. nvm me.

#12 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 21 March 2013 - 07:22 PM

RedPower has 0-255.

#13 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 21 March 2013 - 10:01 PM

View Postimmibis, on 21 March 2013 - 07:22 PM, said:

RedPower has 0-255.
In bundled input/output, yes, but signal strength?

#14 Zet0r

  • Members
  • 3 posts

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! :)

#15 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 23 March 2013 - 01:33 PM

View PostKingdaro, on 21 March 2013 - 10:01 PM, said:

View Postimmibis, on 21 March 2013 - 07:22 PM, said:

RedPower has 0-255.
In bundled input/output, yes, but signal strength?
... Yes, signal strength is 0-255. For each colour.

#16 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 23 March 2013 - 03:10 PM

View Postimmibis, on 23 March 2013 - 01:33 PM, said:

... Yes, signal strength is 0-255. For each colour.
Since when? o.O

#17 theoctagon

  • Members
  • 15 posts

Posted 10 April 2013 - 07: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)

#18 theoctagon

  • Members
  • 15 posts

Posted 10 April 2013 - 07: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

#19 Jaitt

  • New Members
  • 1 posts

Posted 10 April 2013 - 11:12 AM

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

#20 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 10 April 2013 - 08: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users