Help with Rednet programming.

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • 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

Darkstar.Industries

New Member
Jul 29, 2019
4
0
0
I've got a complicated problem which I've been trying to solve for hours now.
I will try to explain the setup best I can.
We have a set of drawbridges on the side of our base, which raise and lower based on the daylight sensor, this is easy enough. But we want to add a manual toggle button to raise and lower as we need to. The problem is of course is it remembers the last state. If we close it up during the day, it will open at night, but we want it closed at night and open during the day.
We are using a redstone pulse, with a t-flipflop currently to get the button and daylight sensors to work using variables, but our brains are fried.

In short, we need it to raise when the daylight sensor goes off, no matter what, if its up it stays up, if its down it goes up and visa versa for daytime too but also be toggled. If I toggle it up during the day, when night comes it will stay up and not go down which it currently does. Any help on this would be appreciated.
 

Someone Else 37

Forum Addict
Feb 10, 2013
1,876
1,440
168
While it's been a long time since I've messed with RedNet, I think you're massively overcomplicating things by messing with pulses and toggles.

If I correctly understand what you're trying to do, it can be summed up by this statement:
extendDrawbridge = (NOT DaylightSensorOn) OR LeverOn
This means that the drawbridge should be extended whenever it's nighttime or when your override lever is on, or both. So, flipping the lever will switch between "Extend the drawbridge all the time" and "Extend and retract based on time of day".

You could actually pull this off pretty compactly with a redstone torch or two- no need for an expensive RedNet controller at all. Just stick a redstone torch on the block underneath your sensor (or a block otherwise powered by the sensor during the daytime), and the lever somewhere on the redstone line leading from there to your drawbridges.

If you really insist on using the RedNet controller, though, you could NOT the signal from the sensor and store the result in a variable, then OR that with the signal from your lever, and send the output to the drawbridges. If, however, this extends the drawbridge too late in the evening for your liking, you could replace the NOT with something like "8 - AnalogSignalFromSensor".
 

jordsta95

New Member
Jul 29, 2019
5,056
-4
1
Well you could probably have a NOT gate. So if a daylight sensor does NOT produce a redstone signal, then the drawbridge will close.
You could also use a wave (timer) function in the PRC to make it so that there is a 30 second delay. Why? Well lets say someone goes out at night for some reason, they are gonna want to lower the drawbridge, if they click to lower it, the PRC will auto-raise it again. So, if there is that 30 second wait, then there is a delay for players to lower it and walk through.
 

Darkstar.Industries

New Member
Jul 29, 2019
4
0
0
I don't think that would help me. I've tried it on a small scale and I am still hitting problems.
Basically I need the daylight sensor to override everything. But I can't work out how to do that. Getting the rednet controller to activate the drawbridge when a button is pressed (no lever) is easy enough. As I said I have it set up to a pulse, which triggers a flip flop switch which changes the drawbridge. But I want the daylight sensor to override it and I need for when the daylight sensor turns off, it "removes" the buttons flip flop so the drawbridge can go back.
Sorry I can't explain it better, it really is difficult.
 

jordsta95

New Member
Jul 29, 2019
5,056
-4
1
I can't remember exactly how PRCs work, but I believe they look at page 1, then 2, etc.
So if you have something on page 1 that overrides page 2 (e.g. the NOT) then everything else doesn't work as it would if the NOT is active
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
Why not just lead the Daylight sensors signal directly to the Drawbridges and then in parallel add a toggle latch activated by the button(s)? DLS will then always activate DB and you can then manually put them up during the day with the buttons.

tWx7R4r.png

Just used a NOT gate to invert the signal from the DL sensor.

If you want the Drawbridge to be retracted during the night, just add a second NOT gate between the intersection and the Drawbridge.
 
Last edited:

Darkstar.Industries

New Member
Jul 29, 2019
4
0
0
That looks interesting, but I think the problem is during the day in your example, if we want to bring it down, we can't since there is a constant signal from the DLS. Or have I missed something?
 

jordsta95

New Member
Jul 29, 2019
5,056
-4
1
What that shows is that during the day it will open, only when it has the t flip-flop button signal thing
And at night it will be FORCED shut
But there needs to be an and gate
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
That looks interesting, but I think the problem is during the day in your example, if we want to bring it down, we can't since there is a constant signal from the DLS. Or have I missed something?
The NOT gate means that during the day the DL sensor will not be sending out a signal. So you can overwrite the drawbridge with the toggle(button) by turning on the signal. But at night the DL sensor will activate the Drawbridge even if the toggle is too.

I basically just made the DL sensor output signal during the night instead of the day. This means that it is the signal and not lack of that is the acting signal. It is easier to overwrite no signal with a signal, than a signal with no signal :p

But it is too simple to allow you to bring down the drawbridges during the night. If you want that(you did not mention this in the description), you will need something more creative.
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
What that shows is that during the day it will open, only when it has the t flip-flop button signal thing
And at night it will be FORCED shut
But there needs to be an and gate
Actually on the picture it is day and the Drawbridge is being extended by the Toggle latch after I pushed the button(You can see that it is not the NOT gate by it being red on both sides). If I clicked the button the drawbridge would go down and up again on once it got dark.

I dont really know if the OP wants a bridge retracted during the night or a skylight closed. Hence why I mentioned you could invert the action with the extra NOT gate.
 

CaseyRobinson

New Member
Jul 29, 2019
50
0
0
It sounds like you're almost there, you just need to check the current state at dawn/dusk and don't toggle the state if it's already where you want it. Of course that assumes you can differentiate the two.
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
Honestly the simplest solution would be to just write a small CC script. Make the DL sensor always toggle the drawbridge no matter buttons, and then buttons would either retract/extend drawbridge based on state of DL sensor. That way you could get overwrite control both during the day and night with the same button and all in one block.
 

Darkstar.Industries

New Member
Jul 29, 2019
4
0
0
Thanks for the idea, I will look into it and report any findings.
I should of explained it a bit better. Our base has a high wall, we have 7 drawbridges on the top and 7 on the bottom. One set deploys wood, the other glass. So we get a huge window during the day and a wood wall at night. We have inverted the signal from one so when one goes on the other goes off, this is all rigged up to one input, so we can toggle it using a switch on wireless redstone, which it is currently set up to do.
I will try the suggestions here to see what happens. In our testing, we couldn't find a way to do it, but I will experiment further.