Jump to content




Help with a mining machine.

computer

  • You cannot reply to this topic
4 replies to this topic

#1 Chaos_Therum

  • Members
  • 5 posts

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


#2 Himself12794

  • Members
  • 56 posts

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.

#3 OReezy

  • Members
  • 91 posts

Posted 07 February 2014 - 12:04 AM

View PostHimself12794, on 06 February 2014 - 10:57 PM, said:

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().

#4 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

Posted 07 February 2014 - 12:13 AM

But you should really just use term.clear().

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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 by Bomb Bloke, 07 February 2014 - 01:40 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users