Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --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
Advertisement
Add Comment
Please, Sign In to add comment