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

Help with a mining machine.

Started by Chaos_Therum, 06 February 2014 - 04:39 PM
Chaos_Therum #1
Posted 06 February 2014 - 05:39 PM
So I am working on building a mining machine using a combination of computercraft, redstone in motion, and thermal expansion. I have written the code in the startup file assuming that since redstone in motion restarts the computer everytime it runs that it would run. I can get it to run once the I have to rerun the control computer's script again to get it to run. Would love some help here is my code.


Mining Machine

while true do
local modem = peripheral.wrap("right")
modem.open(1)
local event, modemSide, senderChannel, replyChannel, message, SenderDistance = os.pullEvent("modem_message")
shell.run("clear")
if message == "on" then
  print("Miner ON")
  os.sleep(2)
  shell.run("moveNorth")
else
  print ("Miner OFF")
end
os.pullEvent("redstone")
end

Control Computer

while true do
   shell.run("clear")
   if rs.getInput("left") == true then
	  print("redstone ON")
	  peripheral.call("right", "transmit", 1, 1, "on")
   else
	  peripheral.call("right", "transmit", 1, 1, "off")
	  print("redstone OFF")
   end
   os.pullEvent("redstone")
end
Himself12794 #2
Posted 06 February 2014 - 10:57 PM
I think it's because you used shell.run(), which, if I remember correctly, exits the current program when it runs, so your while loop does no good.
OReezy #3
Posted 07 February 2014 - 12:04 AM
I think it's because you used shell.run(), which, if I remember correctly, exits the current program when it runs, so your while loop does no good.

I don't know much about redstone in motion, but his program will continue after using shell.run().
awsmazinggenius #4
Posted 07 February 2014 - 12:13 AM
But you should really just use term.clear().
Bomb Bloke #5
Posted 07 February 2014 - 01:38 AM
Your "control" script sends one modem transmission when it starts, then one for every change in its redstone input. I assume the control system isn't being automatically restarted? And that that's because you haven't put it on the mobile rig?

If you start both scripts, the "miner" will be told to call your "moveNorth" script once, and will then sit and wait for another modem message to come in (assuming calling "moveNorth" DOES cause it to reboot - if not, it'll also get hung up waiting for redstone input).

Unless the control system is getting redstone pulses (as opposed to a solid signal), that means not much else is going to happen. You could perhaps program it to send one message every second or so as long as the redstone signal is on.

If you're still not getting it, then I suggest posting some images of the setup.

It may be worth noting that sometimes RiM doesn't fully reboot computers it moves.
Edited on 07 February 2014 - 12:40 AM