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

According to Bundled Cables...

Started by Malakai030, 07 August 2012 - 04:07 PM
Malakai030 #1
Posted 07 August 2012 - 06:07 PM
Hey Folks!

I need some help with these bundled cables.

I'm trying to make a script that asks a machine if it is working atm, and when it is working, it should ask me if I want to turn the machine (or more precise: a redstone signal) off.
And otherwise, I want the script to ask me to turn on the machine, if it is off.

Well, this is not my problem ;)/>/>

My problem is: How do I get the state of a certain redstone signal on a bundled cable?

I tried



red = rs.getBundledInput("back", colors.red)
if red == "true" then

but there he told me "attempt to call number"

This code actually works for normal red alloy wire, if u use
rs.getInput("side")


I tried things like


if rs.getBundledInput("back", colors.red) == true then

but that didn't do anything.


I tried some other things, but nothing seemed to work. Everything works fine using the normal alloy wire, but I dont get any in- or output of the bundled cables :(/>/>


so pleeeze help out a german :(/>/>
KFAFSP #2
Posted 07 August 2012 - 06:13 PM
Also, du machst folgendes :


local Red = rs.testBundledInput("back", colors.red)

1. local : um Global-Write errors vorzubeugen
2. testBundledInput : um zu ermitteln, ob eine Farbe an ist.

Mit getBundledInput müsste es so aussehen :


local Input = rs.getBundledInput("back")
local Red = colors.test(Input, colors.red)

und dann kannst du mit Red ein if-statement anfangen.

Ich hoffe, das hilft ;)/>/>

ENGLISH :

Put the following :


local Red = rs.testBundledInput("back", colors.red)

into the code.

1. local : to avoid Global-Write errors
2. testBundledInput : to determine, if a color is on.

With getBundledInput it had to look like this :


local Input = rs.getBundledInput("back")
local Red = colors.test(Input, colors.red)
and then you can start an if-statement with Red.

Hope that helps :(/>/>
ardera #3
Posted 07 August 2012 - 06:14 PM
Edit:
German:
Der da oben war schneller ;)/>/> Und ich habe sowieso nicht alles entdeckt was er für probleme gefunden hat.

English:
^ was faster, and I also didn't find all issues that he found.
KFAFSP #4
Posted 07 August 2012 - 06:33 PM
Edit:
German:
Der da oben war schneller ;)/>/> Und ich habe sowieso nicht alles entdeckt was er für probleme gefunden hat.

Hihihi…

Aber das mit dem local ist ja nur eine Frage von gutem Programmier- bzw. Skriptstil :(/>/>
Malakai030 #5
Posted 08 August 2012 - 02:52 PM
Danke für die netten Antworten ;)/>/>

But both of your codes didn't seem to work. After your code I just wrote

 if Red == "true" then ...
else ...

and so on. But the PC keeps believing that that my designated cable is off, no matter what its state is.

Any ideas?
Lyqyd #6
Posted 08 August 2012 - 03:42 PM
You're using true as a string instead of a Boolean. Remove the quotes and it should work. In fact, you can simply use 'if Red then' since it checks to see if Red is not nil or false.