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

Redpulse And Bundled Cable

Started by enforcer4100, 29 October 2013 - 10:25 AM
enforcer4100 #1
Posted 29 October 2013 - 11:25 AM
Hey all,
I am making my first steps in automating my reactor (and possibly other installations) in tekkit
But currently I am stuck while trying to utilize bundled cable instead of standard red alloy wire
So I can make my reactor more compact.

My first code looked like this:
function flush()
shell.run("redpulse", "right", "64", "0.5")
end

function rebuild()
shell.run("redpulse", "top", "46", "0.5")
sleep(5)
shell.run("redpulse", "left", "7", "1")
sleep(5)
shell.run("redpulse", "top", "1", "5")
end

while true do
if rs.getInput("bottom") then
rs.setOutput("back", true)
flush()
rebuild()
rs.setOutput("back", false)
end
shell.run("redpulse", "left", "1", "0.5")
end

Now my goal is to replace the red alloy wire with insulated wires and bundled cable and only use the back side of the computer so I can hide it in a wall.
My adapted code looks like this:
Function flush()
XXXXXXXXX
End

Function rebuild()
XXXXXXXXX
Sleep(5)
XXXXXXXXX
Sleep(5)
XXXXXXXXX
End

While true do
If rs.testBundledInput (“back”, 1) then
Rs.setBundledOutput(“back”, colors.lightBlue, true)
Flush()
Rebuild()
rs.setBundledOutput(“back”, colors.lightBlue, false)
end
XXXXXXXXX
end

Now as you can see I haven’t found a suitable replacement for shell.run(“redpulse”,….) (places where XXXXXXXXX). I did some research on google and on this forum and I came across some other topics but from what I can see they all want to send a constant signal instead of pulses like I need.
I also had a look at the wiki but it doesn’t mention anything about pulses.

Am I missing some way to do this? Or am I forced to use a bunch of sleep commands between me turning the signal on and off?

Kind regards,
Enforcer4100
Lyqyd #2
Posted 30 October 2013 - 09:41 AM
Split into new topic.
enforcer4100 #3
Posted 30 October 2013 - 10:49 AM
Quickly adding some other info that might be relevant.
My entire setup contains 5 wires, white, orange, magenta, light blue and yellow.

White is connected to my filter that is responsible for flushing the reactor. White is also connected to the reset for my rs latch (next to the item detector).
orange is connected to a filter that pumps in ice.
magenta does the same but for uranium cells.
light blue is my shutdown wire.
yellow is connected to my rs latch (on the item detector), and is responsible for initiating my program when it receives a signal.

I use white bundled cable but I don't think that matters.
OReezy #4
Posted 30 October 2013 - 11:42 AM
I'm not totally sure what you are trying to accomplish but here is a function you can use to do bundled cable pulses:



function pulse(color, amount, length)
  for i = 1, amount do
	rs.setBundledOutput("back", colors[color])
	os.sleep(length)
	rs.setBundledOutput("back", 0)
	os.sleep(length)
  end
end

pulse("lightBlue", 5, 1)

This would create five one second pulses with one second between pulses. The pulse length and time between pulses would always match but if you wanted to make the delay shorter you would just need to change the second 'os.sleep()' to a number. I'm fairly new so this may not be the most efficient way but its what I came up with.
TekkitwithRiley #5
Posted 30 October 2013 - 12:56 PM
I would normally use:

rs.setBundledOutput(side, color)
os.sleep(1)
rs.setBundledOutput(side, color)
but after looking this would be the best way to do it as you wouldn't need to keep repeating yourself


function pulse(color, amount, length)
  for i = 1, amount do
	rs.setBundledOutput("back", colors[color])
	os.sleep(length)
	rs.setBundledOutput("back", 0)
	os.sleep(length)
  end
end

pulse("lightBlue", 5, 1)
enforcer4100 #6
Posted 30 October 2013 - 01:41 PM
Thank you everyone for your input, really appreciated.
Sens managed to fix my issue via pm.
I will post the solution tomorrow so others can see it.
darksideinc #7
Posted 16 December 2013 - 01:20 PM
I know this topic is old, but I have used his idea and the ideas given here to try and make this code. I am trying to make a program that runs and maintains my nuclear reactor, in tekkit 3.1.2 (computercraft 1.33). I keep getting an error on line 5 (rs.setBundledOutput(side, rs.getBundledOutput(side) +colors.) error is: bios:206: [string "reactor"]:5: '<name>' expected. Any help I can get, I would be very greatful, I have been wrapping my head around this for 3 days now. Maybe a fresh set of eyes will see something I missed.

Spoiler
local side = "back"

function pulse(color, amount, length)
for i = 1, amount do
   rs.setBundledOutput(side, rs.getBundledOutput(side) +colors.[color])
   os.sleep(length)
   rs.setBundledOutput(side, rs.getBundledOutput(side) -colors.[color])
   os.sleep(length)
   end
end

funtion flush()
print("Flushing system.....")
pulse(white, 64, 0.5)
end

function rebuild()
print("Putting in 46 Uranium")
pulse(green, 46, 0.5)
sleep(2)
print("Putting in Ice Blocks")
pulse(blue, 7, 1)
sleep(2)
print("Putting in last Uranium")
pulse(green, 1, 5)
end

while true do
if rs.testBundledInput(side, colors.orange) == true then
rs.setBundledOutput(side, rs.getBundledOutput(side) +colors.red)
print("Preparing to Flush")
flush()
print("Preparing to Rebuild")
rebuild()
rs.setBundledOutput(side, rs.getBundledOutput(side) -colors.red)
end
pulse(blue, 1, 0.5)
end
Lyqyd #8
Posted 16 December 2013 - 01:55 PM
For future reference, you probably should have made a new topic and just added a link to this topic for reference.