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

Redstone In Motion Computercraft Quarry

Started by frostthejack, 27 September 2013 - 11:30 AM
frostthejack #1
Posted 27 September 2013 - 01:30 PM
So I have been working on a program to make a quarry with redstone in motion and I have written a program for computer craft that works with the redstone in motion controller

when launched it asks how far you would like to go and in which direction you would like to move

for the distance you can enter any number and it will move that many blocks assuming it does not run into any obstructions

for direction it excepts north south east west up and down

it will error out if you enter a non number in the distance or if you enter a direction other then north south east west up or down in the direction spot.



The startup needs to read


sleep(time) -- for fastest speed use 0.8 but i recomend useing between 1-4 if on a server
shell.run("program name") -- whatever you named the program

because blocks update at a speed of 0.8 seconds you can not have anything less then 0.8 for the sleep time on startup or it will not startup properly and will fail to move however i do not recomend useing 0.8 unless on singleplayer or on a server running with minimal lag.

here is the code for the quarry


--this is a simple redstone in motion
--quarry script and can be used
--for many purposes
--your startup file should read
-- first line
-- sleep(4)
--second line
-- shell.run("this script")
-- you can reduce the sleep time but
-- i dont recomend anything less then 2

-- these are for direction
local down = 0
local up = 1
local north = 2
local south = 3
local west = 4
local east = 5
-- function to read from file
function readFile(filename)
  local rv
  local h = fs.open(filename, "r")
  if h then
    rv = h.readLine()
    h.close()
  end
  return rv
end
--function to save to file
function variableSave(fileName, variable)
h = fs.open(fileName, "w")
h.write(variable)
h.close()
end
-- lets check if we are already doing something
if
fs.exists("count")
then
count = readFile("count")
distance = readFile("distance")
direction = readFile("direction")

else
-- looks like we are not doing anything yet
-- what do we want to do
while true do
-- how many blocks to dig
print("How far shall i dig master?")
distance = read()
distance = tonumber(distance)
if
type(distance) == "number"
then
variableSave("distance", distance)
break
else
-- a number was not entered
print("I am terribly sorry sir but that is not a number")
end
end
while true do
-- which direction we going
print("what direction")
direction = read()
if
-- list of choices
(direction == "down") or
(direction == "up") or
(direction == "north") or
(direction == "south") or
(direction == "west") or
(direction == "east")
then
variableSave("direction", direction)
print("You have 10 seconds to get off the rig")
sleep(10)
break
else
-- entered an incorrect direction
print("not a correct direction")
end
end
--create the count file then continue
variableSave("count", "0")
count = 0
end


-- check count file to see how many
-- times we have moved in chosen
-- direction
if
count == distance
then
-- done with moving delete count file
-- to start over
print("quarry done")
fs.delete("count")
else
-- we are not done move in direction
-- then add one to count and start over
drive = peripheral.wrap("top")
drive.move(direction, false, false)
count = count + "1"
variableSave("count", count)
end


I added in comments to help people trying to learn what i did better understand how it works.

You can download this useing pastebin get 0znM4b1c RiMQuarry (RiMQuarry can be changed to what ever you want to name the program just remember when trying to run it with shell.run it is cap sensitive)


http must be enabled in order to use pastebin. If you are playing single player you can simply go to the config folder in your minecraft folder and open the computercraft config and finding http and setting it to true. If you are playing on a server you will need to ask the owner to enable it.


If you have any question or suggestions please post below. Also on a side note I will be working on adding features to this to allow more functionality such as automatic quarry that will go to bedrock then back up move over and do it again so you can set it and forget about it while it runs its course clearing out large areas
frostthejack #2
Posted 27 September 2013 - 09:45 PM
pastebin code is at bottom and ill have to add some screenies
gicon #3
Posted 16 October 2013 - 03:28 PM
http://prntscr.com/1xqyqm
CCJJSax #4
Posted 13 February 2014 - 03:49 PM
Sorry for bringing this post back from the dead, but since I was researching it and I found this post, I'm sure other people will find it too. There is currently a bug with Redstone in Motion that turns your computer off while moving, so your program can only get to the first move. I'm trying to find the Redstone In Motion bug report page to report this.
CometWolf #5
Posted 13 February 2014 - 04:58 PM
I don't even think you bothered to look at his program, or the original post at all for that matter,,,
He uses the startup file to rerun his program everytime it's rebooted, then it reads from a file how many more moves to perform, subtracts 1, saves it, and moves. This "bug" won't affect his program.
Bomb Bloke #6
Posted 13 February 2014 - 06:29 PM
To be clear, RiM is supposed to reboot the computer with each move. The bug is that, on occasion, it simply turns the computer off, meaning you need to sit there right clicking the computer over and over. The mod author is aware of it, but has been for months now, so I'm doubtful there'll be a fix.
cant_delete_account #7
Posted 13 February 2014 - 07:17 PM
To be clear, RiM is supposed to reboot the computer with each move. The bug is that, on occasion, it simply turns the computer off, meaning you need to sit there right clicking the computer over and over. The mod author is aware of it, but has been for months now, so I'm doubtful there'll be a fix.
You could try the Truss Mod.