Computercraft and MFRs RedNet Cable Interaction Help!?

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Richard104

New Member
Jul 29, 2019
13
0
0
So I've gotten to a point in my world where I would like to use turtles and/or computers to carry out some automation for me. I get the basics of the whole ComputerCraft coding (barely, but I'm managing) but that's simply through trial and error and Direwolf20's ComputerCraft coding series thus I understand around 5% of what half of it means, I just understand if I type in code "X" I get a certain output. I am however stuck with MFRs RedNet Cables and how to code them with computers and I was wondering if anyone would be willing to explain to me how to do it or if they could point me in the right direction, I have been searching the web and forums for around 3 hours now and have had barely any luck. I simply would like to know how to make a computer that is hooked up to a RedNet cable system how to emit signals through the several, separate colours and how to terminate said signal after a certain amount of time.
I am not sure if I am posting this in the right forums area or anything, I apologise in advance if I have. Also I would like to thank anybody in advance who is able to help me.

thanks
 

draeath

New Member
Jul 29, 2019
456
0
0
Have a look at the bit API as well, since some of those operations work extremely well with rednet colors (the colors are actually bit positions, and you can specify a color in place of a bit and the API will handle it correctly!)
 

zilvarwolf

New Member
Jul 29, 2019
541
0
0
As iarspider and draeath say, you want to use setBundledOutput with the different colors collectively to get the effect you're looking for.

If you want to activate blue and green on the back side of the computer, then you'd want to include 'redstone.setBundledOutput("back",colors.blue+colors.green)', and then later if you want to add black to the list, you could do 'redstone.setBundledOutput("back",redstone.getBundledOutput("back")+colors.black)'. Or you could turn off a color with 'redstone.setBundledOutput("back",redstone.getBundledOutput("back")-colors.grey)'

Turning them all off is easy enough. You set the output to 0. And to turn them all on, you use 65535.
 

iarspider

New Member
Jul 29, 2019
65
0
0
Or you could turn off a color with 'redstone.setBundledOutput("back",redstone.getBundledOutput("back")-colors.grey)'
From my experience one should use proper ways to manipulate bits - bitwise operations. So, setting a bit (color) is done like this:
Code:
redstone.setBundledOutput(bit.bor(redstone.getBundledOutput("back"), colors.black))
and resetting (un-setting) a bit is done like this:
Code:
redstone.setBundledOutput(bit.bxor(redstone.getBundledOutput("back"), colors.grey))
 

draeath

New Member
Jul 29, 2019
456
0
0
Wouldn't the last one (bit.bxor) toggle the grey, not unset it? (eg if it's off (0) it will turn on (1) but if it's on (1) it will turn off (0). Other colors will be unchanged.)
 

zilvarwolf

New Member
Jul 29, 2019
541
0
0
colors.combine and colors.subtract will also work, but are probably just wrappers for those same bitwise functions.
 

draeath

New Member
Jul 29, 2019
456
0
0
It doesn't really matter which you use. Whatever makes sense to you. I see colors as the bitmap they are, so it makes more sense to me to handle them as such. The "colors" API is simply an equivalent of an ENUM struct giving the bitmap a friendly name.
 

iarspider

New Member
Jul 29, 2019
65
0
0
Wouldn't the last one (bit.bxor) toggle the grey, not unset it? (eg if it's off (0) it will turn on (1) but if it's on (1) it will turn off (0). Other colors will be unchanged.)
Yep. If the initial state of grey line could be "off", then the proper way would be:
Code:
redstone.setBundledOutput(bit.band(redstone.getBundledOutput("back"), bit.bnot(colors.grey)))
 

Richard104

New Member
Jul 29, 2019
13
0
0
Thanks guys, I haven't had chance to give any of this a go seeing as I've been busy all day but when I get round to it I can't imagine I'll have any trouble.
Thanks again.
 

Veryance

New Member
Jul 29, 2019
33
0
0
Hi guys, I am a total noob at programming, but I'm trying to get my computer to interact with some rednet as a timer. Currently I have:
s = 0
repeat
redstone.setbundledoutput("back", colors.white)
sleep (1)
redstone.setbundledoutput("back",colors.grey)
sleep (10)
until
s == 1

Obviously I am just trying to send a pulse through the rednet, but I'm not sure how to turn off the signal to the wire. It turns on and just stays that way haha. FYI it only has 1 cable, and i only need to interact with 1 color. It's just a simple on/off pulsar. Thanks in advance!
 

Scarecrow560

New Member
Jul 29, 2019
31
0
0
Hi guys, I am a total noob at programming, but I'm trying to get my computer to interact with some rednet as a timer. Currently I have:
s = 0
repeat
redstone.setbundledoutput("back", colors.white)
sleep (1)
redstone.setbundledoutput("back",colors.grey)
sleep (10)
until
s == 1

Obviously I am just trying to send a pulse through the rednet, but I'm not sure how to turn off the signal to the wire. It turns on and just stays that way haha. FYI it only has 1 cable, and i only need to interact with 1 color. It's just a simple on/off pulsar. Thanks in advance!


You dont need to use the rednet cable directly on the computer, just use plan redstone or redstone wire. Would be alot simple..