Computercraft (Not Rednet) Timer

  • 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

hyper1on

New Member
Jul 29, 2019
23
0
0
Hello folks,

I could use a bit of help with some rednet setup. I would like to send a signal that stays on for X amount of time, and then turns off for the same amount of time.

I know this is probably pretty simple but the RNC has a staggering amount of options and I have thus far been unsuccessful in my attempts to create this circuit.

Thanks for any help =)
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Use the square wave. When you select it you will be asked to set your duration in ticks on the left, and you can set it to an output on the right (of the circuit menu that is). There is a bit more to it if you want to be able to to switch the timer on and off but if all you want is a timer that runs forever then you only need that one circuit.
 

hyper1on

New Member
Jul 29, 2019
23
0
0
Thanks for your reply! I think I have that figured out... However, I need about a 110 second timer, and the maximum I can set using this method is about 13 seconds (255 ticks). Is there any way to lengthen the amount of time?
 

Zaflis

New Member
Jul 29, 2019
184
0
0
Don't know about rednet, but have to offer alternative from project-red (i think). Using timer set to your specific time on a toggle latch, you can toggle redstone signal repeatedly on and off.
 

hyper1on

New Member
Jul 29, 2019
23
0
0
Unfortunately I don't have project red installed on this server. I'm pretty sure that RedNet can do this, and do it well. But I don't know how to make it happen ;)
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Thanks for your reply! I think I have that figured out... However, I need about a 110 second timer, and the maximum I can set using this method is about 13 seconds (255 ticks). Is there any way to lengthen the amount of time?
To do this with a Rednet controller, you will probably need a toggle latch which is toggled by a pulse that goes through a bunch of repeaters (possibly called delayers) like this

Toggle latch
^
|
^-------------> repeater (255) ---------> repeater (255) ---> ... ----> |
| Variable 0 |
| <----------------------------------------------------------------------------

Trigger that with a single pulse and it will act like a vanilla torch repeater clock.

To be honest, it is not a good way to do it because you need loads of circuits, it is very easy to make mistakes when setting it up and you will probably need so many circuits that you need to use expensive upgrades on the controller to get enough space.

The timer from project red is very good although you will also have to combine that with a toggle latch if you want a square wave. Alternatively, this is very easy to do with computercraft using redstone api and the sleep function
 

hyper1on

New Member
Jul 29, 2019
23
0
0
I think you are right, I will have to read up on ComputerCraft and see if I can figure out how to make a program. I can't imagine it would be too complex.
 

Zaflis

New Member
Jul 29, 2019
184
0
0
Perhaps something like:
Code:
signal = true
while true do
  signal = not signal
  rs.setOutput("front", signal)
  sleep(110) -- Time in seconds
end
 

hyper1on

New Member
Jul 29, 2019
23
0
0
Thank you, that is exactly what I needed. I have been trying to figure it out on my own for the past hour not realizing you replied. It's a good thing you did, because my program didnt seem to do anything ;)
 

hyper1on

New Member
Jul 29, 2019
23
0
0
That bit o code is working pretty well, but I am trying to refine it a bit; Basically redstone on for 110 seconds, redstone off for 40. It's probably my lack of knowledge when it comes to LUA, but figuring out something like this will help me greatly in understanding how LUA works.

Here's what I have right now. What happens is the first while works fine, then the second while kicks in and just stays going. I don't understand why.

Code:
signal = true
while true do
  signal = not signal
  rs.setOutput("left", signal)
  sleep(110) -- Time in seconds
end
  while false do
  signal = true
  rs.setOutput("left", signal)
  sleep(40)
end

Any ideas?
 

immibis

New Member
Jul 29, 2019
884
0
0
Here's a simpler way:

Code:
while true do
  rs.setOutput("left", true)
  sleep(110)
  rs.setOutput("left", false)
  sleep(40)
end

It should be fairly easy to see how that works even if you don't know anything about programming. Super-basic hint: each line runs in turn, from top to bottom, unless otherwise specified. "while true do" and "end" makes everything in between run forever - when it gets to the bottom of the stuff in the middle, it goes back to the top.
 

Zaflis

New Member
Jul 29, 2019
184
0
0
Here's what I have right now. What happens is the first while works fine, then the second while kicks in and just stays going. I don't understand why.
This is a classic infinite loop:
Code:
while true do
...
end
You can't say that "second while kicks in", because it never leaves the first one. If you do "while false do", it would never even enter it. True is a boolean value, for example it's same as 1 = 1 is always true, but 1 = 2 is false. But it's simpler to write than "while 1=1 do", but it wouldn't make a difference.
 

hyper1on

New Member
Jul 29, 2019
23
0
0
Here's a simpler way:

Code:
while true do
  rs.setOutput("left", true)
  sleep(110)
  rs.setOutput("left", false)
  sleep(40)
end

It should be fairly easy to see how that works even if you don't know anything about programming. Super-basic hint: each line runs in turn, from top to bottom, unless otherwise specified. "while true do" and "end" makes everything in between run forever - when it gets to the bottom of the stuff in the middle, it goes back to the top.

Thanks immibis, I figured I was over-complicating things. The extent of my programming is PHP and it was been a decade since I have done any programming. That program makes sense to me. Thanks again.

Zaflis, thanks for your reply.
 

Matt Bootw

New Member
Jul 29, 2019
4
0
0
And is it possible to move my entire world and save file from unleashed to monster????

Sent from my Nexus 5 using Tapatalk
 

Sidorion

New Member
Jul 29, 2019
192
0
0
At this point, I'd like to quote Terry Pratchett: 'Multiple exclamation marks, he thought, are a sure sign of a dieseased mind.':D
 
  • Like
Reactions: immibis

Matt Bootw

New Member
Jul 29, 2019
4
0
0
At this point I'd like to quote Matt Boote "they are question marks not exclamation marks".

Sent from my Nexus 5 using Tapatalk
 

Zeeth_Kyrah

New Member
Jul 29, 2019
307
0
0
Guys is the ftb unleashed going to be updated to 1.6????

Sent from my Nexus 5 using Tapatalk
Why ask here?[DOUBLEPOST=1398284286][/DOUBLEPOST]
That bit o code is working pretty well, but I am trying to refine it a bit; Basically redstone on for 110 seconds, redstone off for 40. It's probably my lack of knowledge when it comes to LUA, but figuring out something like this will help me greatly in understanding how LUA works.

Here's what I have right now. What happens is the first while works fine, then the second while kicks in and just stays going. I don't understand why.

Code:
signal = true
while true do
  signal = not signal
  rs.setOutput("left", signal)
  sleep(110) -- Time in seconds
end
  while false do
  signal = true
  rs.setOutput("left", signal)
  sleep(40)
end

Any ideas?
"while true" doesn't do any comparisons with external values. It just checks to see that Boolean True is still true. If you were checking signal, it would be
"while signal==true", but then the code wouldn't repeat after the first full cycle, and since "while false" sees the result is false, the second loop won't run.

So the other examples where the irrelevant bits are removed from your program are good.