Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function searchString(bigString, searchString)
- if bigString ~= nil and searchString ~= nil then
- if bigString.match(bigString, searchString) == nil then
- return false
- else
- return true
- end
- else
- return false
- end
- end
- function forwardMine()
- turtle.select(1)
- while turtle.getFuelLevel() == 0 do
- OSName()
- print("I need more fuel in slot 16")
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- sleep(2.5)
- end
- tf, data = turtle.inspect()
- name = data.name
- if searchString(name, "sugar") == true then
- dug = turtle.dig()
- elseif searchString(name, "glass") == true then
- turtle.turnRight()
- elseif searchString(name, "redstone") == true then
- print("")
- elseif name == nil then
- print("")
- else
- print("Something unexpected is here, im gonna wait for a human to hit enter just incase\nBlock Detected: ".. tostring(name))
- read()
- print("Restarting")
- end
- if dug == true then
- dug = false
- local mined = tonumber(load("total"))
- mined = mined+1
- save("total", mined)
- end
- moved = turtle.forward()
- if redstone.getInput("front") == true then
- print("Initiate deposit boogie")
- for slot = 1,15 do
- turtle.select(slot)
- turtle.dropUp(64)
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- end
- function OSName()
- shell.run("clear")
- local total = load("total")
- print("ProSugarPlantation v1.1\nCollected a total of "..total.." sugar cane")
- end
- function save(filename, data)
- local file,err = io.open(filename .. ".txt",'w')
- if file then
- file:write(tostring(data))
- file:close()
- else
- print("error:", err)
- end
- end
- function load(filename)
- local file = io.open(filename .. ".txt", "r")
- if file then
- local firstLine = file:read("*l")
- io.close(file)
- return firstLine
- else
- print(filename .. ".txt")
- return nil
- end
- end
- while true do
- OSName()
- forwardMine()
- end
- shell.run("reboot")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement