Ask a simple question, get a simple answer

  • 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

un worry

New Member
Jul 29, 2019
384
0
1
nono i have a wireless remote hooked up to a wireless reciever and computer. I want it so that if they press the wireless remote quickly then it will do something but if it is held down, that it would do something else. I am just looking for some code that can find the time that the redstone signal has been active. I am also refraining from using redpower because i wanted it to be compatible with a 1.5 world when the 1.5.2 version of WR-CBE comes out. And no I'm not giving up on RedPower being released, id just prefer if it was compatible with 1.5.2 earlier

assume say redstone signal from rear of computer, try something like this:

while true do
event = os.pullEvent("redstone")

if rs.getInput("back") then
-- redstone ON event at at rear
timeStart = os.clock() -- time signal received
signalOn = true
elseif signalOn and not rs.getInput("back") then
timeEnd = os.clock()
interval = math.floor( 833300 / (timeEnd-timeStart) )
-- << Do Something , based on interval >>
signalOn = false
end -- if

end -- while


Im on my way home, so typed in how i recall coding something similar last week. Treat it as pseudocode and hopefully it gives you some ideas. :)

edit to add: sorry for crappy formatting and syntax. PullEvent() is cool.
 

Ember Quill

Well-Known Member
Nov 2, 2012
350
119
68
Is there a way to time how long a redstone signal has been active on computercraft. I want it to do one thing if there was a redstone signal that lasted less than one second and another if it was on longer and go back to checking once the redstone signal is off
You could use os.pullevent("redstone") to wait for the redstone signal to go on, then have the computer sleep for a second and then check to see if the signal turned off.
 

PhilHibbs

Forum Addict
Trusted User
Jan 15, 2013
3,174
1,128
183
Birmingham, United Kingdom
assume say redstone signal from rear of computer, try something like this:
... code code code ...
Im on my way home, so typed in how i recall coding something similar last week. Treat it as pseudocode and hopefully it gives you some ideas. :)
I think that might end up being cancelled by the OS for not yielding.[DOUBLEPOST=1371718778][/DOUBLEPOST]
You could use os.pullevent("redstone") to wait for the redstone signal to go on, then have the computer sleep for a second and then check to see if the signal turned off.
That would be fooled by two quick pulses. In fact, any system that involves polling would be fooled by pulses. Hm, maybe you could use a different computer to do the timing! Wait for a redstone event, then send a "begin timer" rednet signal to another computer. It sends a "timer done" rednet signal 1 second later, which then triggers the first computer to do whatever needs doing after a 1 second of constant signal. If the redstone input turns off, then you set a flag to ignore the timer. One drawback with this is a quick pulse will start the timer, and lock out the timing system for 1 second so if you pulse then hold down, the timer won't be timing from the right time.

*EDIT* D'oh, http://computercraft.info/wiki/Os.startTimer! No idea how to use it, though, maybe the event gives the timer ID for comparison purposes.
 

un worry

New Member
Jul 29, 2019
384
0
1
I think that might end up being cancelled by the OS for not yielding.

it yields fine -- and I believe is the preferred method over sleep()

Vikes requirement is to "find the time that the redstone signal has been active." i.e measure the interval
 

PhilHibbs

Forum Addict
Trusted User
Jan 15, 2013
3,174
1,128
183
Birmingham, United Kingdom
I figured out how to do it, here is the pastebin code that I am using for those looking for something similar.
http://pastebin.com/bsb9wYgc
That's pretty neat. Is there any danger of a pulse happening so quickly that you miss the "off" event, and then get the the time to the next "on" event by accident? Also I guess you'd have to be pretty sure that there aren't any redstone signals accidentally coming in from different sides. Insulate your cables! Careful with those red torches!
 

VikeStep

New Member
Jul 29, 2019
1,117
0
0
That's pretty neat. Is there any danger of a pulse happening so quickly that you miss the "off" event, and then get the the time to the next "on" event by accident? Also I guess you'd have to be pretty sure that there aren't any redstone signals accidentally coming in from different sides. Insulate your cables! Careful with those red torches!
there is absolutely no chance of other redstone interfering with it with my setup. And as long as I press the wireless remote, the redstone pulse goes on, even if it's the time of 1 tick, it will still work. I actually don't have any cables haha it's just wireless receivers right next to the computer
 

schyman

New Member
Jul 29, 2019
267
0
0
Is there a compact way to use standard Generators? I've got a fat charcoal surplus after my boiler and was thinking of a 20-generator setup for some renewable energy.

I naively believed fuel could be inserted from the back but it seems to be bottom only, which makes it really hard for me to think of a compact way to use them (the 3x3 tower i first thought of won't work).

I don't have redpower (playing 1.52 beta pack) but do have logistic pipes.

Any ideas?
 

schyman

New Member
Jul 29, 2019
267
0
0
Factorization routers? One should be able to service the entire bunch.
Thanks a lot, works like a charm!

Follow-up question: Is there a good way to turn off generators when they're not really needed? So not all of them starts up when the batbox loses a few hundred EU, wasting charcoal?

I was thinking if either batboxes or generators are affected by redstone currents but it does not seem that way. Tried messing around with splitter cables and the EU output on batboxes but didn't really seem to help.

EDIT: To clarify what I want to do, I want the batbox to fill up, then stop the generators, and when it's emptied out start them again.
 

PhilHibbs

Forum Addict
Trusted User
Jan 15, 2013
3,174
1,128
183
Birmingham, United Kingdom
Follow-up question: Is there a good way to turn off generators when they're not really needed? So not all of them starts up when the batbox loses a few hundred EU, wasting charcoal?
I don't think they will waste fuel. If the batbox requests 32EU, then one of the generators will supply it from its buffer. When its buffer is empty, it will consume a charcoal and store the energy in its buffer. If it requests 128EU, then four generators will supply it 32EU each and they all might fire up to replenish their buffers. It won't cause your whole bank of generators all to burn one charcoal each, they only burn a charcoal when they have space in their internal buffer to hold the EU that it generates.
 

schyman

New Member
Jul 29, 2019
267
0
0
I don't think they will waste fuel. If the batbox requests 32EU, then one of the generators will supply it from its buffer. When its buffer is empty, it will consume a charcoal and store the energy in its buffer. It won't cause your whole bank of generators all to burn one charcoal each, they only burn a charcoal when they have space in their internal buffer to hold the EU that it generates.
It seems they'll burn charcoal as long as their internal buffer is not completely full. I have them set up in a tower now, with batboxes in the middle (and mfe's on the sides but those aren't in use yet). Right now the drain is just 32 EU/t from the top batbox, yet most of the time, at least 7-8 of the 14 generators are running.

EDIT: This is my setup. As you can see 9 of them are active while the output is just 32 EU/t
EDIT2: The glass fibre cable in front left is for further expansion, so you're not confused why it's there and not connected to anything xD
 
  • Like
Reactions: Kevun1

PhilHibbs

Forum Addict
Trusted User
Jan 15, 2013
3,174
1,128
183
Birmingham, United Kingdom
You're using 32EU/t, so 640 EU per second, it takes 20 seconds to burn a charcoal and generate 4000. So 8 generators burning are generating 32,000 EU in 20 seconds, you're using 12,800 in that time. Are you sure it's 7-8 consistently? I'd expect an average of 3-4 generators going at any time to supply that. If you are seeing twice that, then it does seem like about half your power is being lost. What's the cabling like between the generators and the batbox?
*Edit* I think the glow persists for a while after the burning has finished, maybe that explains why more seem to be generating simultaneous than the power draw would explain.
 

schyman

New Member
Jul 29, 2019
267
0
0
You're using 32EU/t, so 640 EU per second, it takes 20 seconds to burn a charcoal and generate 4000. So 8 generators burning are generating 32,000 EU in 20 seconds, you're using 12,800 in that time. Are you sure it's 7-8 consistently? I'd expect an average of 3-4 generators going at any time to supply that. If you are seeing twice that, then it does seem like about half your power is being lost. What's the cabling like between the generators and the batbox?
Yes, they flicker on and off between different generators sometimes but it's consistently about that many. 32 EU/t should be about little more than 4 generators (also part of the reason why I'd like an on-off method with the batboxes, so 4 doesn't have to be running constantly even if it worked like one would assume.

The cabling isn't much at all really. The generators are put directly to the batboxes (as in the picture) and the bottom batbox has the output side into glass fibre cable that goes to the machines.
 

Omicron

New Member
Jul 29, 2019
2,974
0
0
Generators unfortunately have always had this issue. They output at 8 EU/t, but even if you only run a single slow machine on it (like say, a macerator at 2 EU/t), the generator will constantly run at full burn.

You could maybe devise a system that only runs the generator if there is space for energy. For example, have an extra batbox between your usual energy net and the stack of generators. The batbox gets configured to output a redstone signal when empty. This redstone signal will then trigger the slow but steady dispensing of charcoal into the router, which should distribute it randomly among the generators. As long as the batbox is empty, more charcoal will be dispensed, but as soon as it is no longer empty (because it has nowhere to send energy) the signal goes dark and the dispensing of charcoal stops. The generators will burn through their remaining charcoal supplies, charging the toggling batbox and the batboxes that are part of the tower until they run out. And then they will not receive any more charcoal until all the batboxes that are part of the tower and the toggling batbox are completely empty again.
 

schyman

New Member
Jul 29, 2019
267
0
0
Actually I might have come up with a better idea, though it will have to be tested in creative first.

If I could hook up a few batboxes after each other, let's call them A, B, C and D between the tower and the machines (A being closest to machines, D closest to tower), and set B to output a redstone signal if empty and C to output if full, and then make a switch gate (a bit of a hastle in 1.52 but not that bad), and connect that redstone signal to D and have D set to not output energy when supplied with a redstone signal. That should mean when those batboxes (ABC) are at 33% (B being empty) energy production should start until they reach 100% (C being full).
 

PhilHibbs

Forum Addict
Trusted User
Jan 15, 2013
3,174
1,128
183
Birmingham, United Kingdom
Generators unfortunately have always had this issue. They output at 8 EU/t, but even if you only run a single slow machine on it (like say, a macerator at 2 EU/t), the generator will constantly run at full burn.
I can believe it if the generator is connected directly to the macerator. But I don't believe it if you have a batbox in between. Should be simple to test. Set up a Generator, Batbox, Macerator. Put a stack of ore in the Macerator, and 10 Charcoal in the Generator. When the ore is all macerated (64x625=40000=10 Charcoal), the charcoal should be used up, and the batbox should be empty. This should hold true regardless of how many generators and how many batboxes and how many macerators you connect and share the stack among, so long as you aren't incurring any cable losses.

*Edit* It should also hold true that if the batbox is full at the start, it will be full at the end - I see Omicron disputes this. I might test it tonight, I'm prepared to believe it if it's true, and I consider it a bug if it is.
 

Omicron

New Member
Jul 29, 2019
2,974
0
0
Yeah, your example works because the batbox is empty and acts as a buffer.

Now repeat the experiment: make sure the batbox is full, the generator's internal storage is full and it has a stack of charcoal available. Now insert a stack of ore to be macerated and see how much charcoal gets consumed. You'll be unpleasantly surprised, I guarantee you.

The generator consumes a full unit of charcoal as soon as its internal buffer is any number other than 4,000. And it will burn that unit of charcoal up at 8 EU/t, no matter how much is actually requested from the e-net. If the macerator requests 2 EU/t, the generator will constantly consume charcoal at 8 EU/t, send out 2 EU/t, and waste 6 EU/t into nirvana. You'll end up needing around 40 charcoal for a stack of ore instead of 10.
 

Avengor

New Member
Jul 29, 2019
9
0
0
Hi guys,

Is it possible to set up a pulverizer to take items automatically out of a chest and then redirect them to a series of electric furnaces? I am using MindCrack pack. IF so, which mod would allow me to get this done?

Thanks