Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is the computer component to the automated farm. The turtle portion is named Turtle Plant and can be found in my pastebin.
- --Table Variables
- t = {
- {text = "Harvest" , x = 4, y = 10, txtCol = colors.green, bgCol = colors.black},
- {text = "Plant Carrots" , x = 22, y = 10, txtCol = colors.orange , bgCol = colors.black},
- {text = "Plant Potatoes" , x = 4, y = 12, txtCol = colors.white, bgCol = colors.black},
- {text = "Plant Wheat" , x = 22, y = 12, txtCol = colors.yellow , bgCol = colors.black}
- }
- --Logo for the Server
- local Logo = {
- [[ __________ _____ ]],
- [[ /_ __/ __/__________ _/ _/ /_]],
- [[ / / _\ \/ __/ __/ _ `/ _/ __/]],
- [[ /_/ /___/\__/_/ \_,_/_/ \__/ ]],
- [[ ]],
- }
- --Monitor Variables
- mon = peripheral.wrap("top")
- function draw()
- mon.clear()
- term.redirect(mon)
- mon.setBackgroundColor(colors.black)
- --mon.setCursorPos(2,1)
- for i = 1, #Logo do --Printing ASCII Logo
- mon.setTextColor(colors.white)
- mon.setCursorPos(3,i)
- print(Logo[i])
- end
- mon.setCursorPos(9,6)
- mon.setTextColor(colors.white)
- mon.write("TSCraft Server Autofarm")
- mon.setCursorPos(10,7)
- mon.setTextColor(colors.white)
- mon.write("By Griffen8280")
- mon.setCursorPos(9,8)
- mon.setTextColor(colors.white)
- mon.write("Select Farm Action Below")
- end
- --Functions
- function writeButtons(_table)
- for i, v in pairs(_table) do
- mon.setCursorPos(v.x, v.y)
- mon.setTextColor(v.txtCol)
- mon.setBackgroundColor(v.bgCol)
- mon.write(v.text)
- end
- end
- function isValidClick(_table, mx, my)
- for i, v in pairs(_table) do
- if mx >= v.x and mx <= (v.x + #v.text) and my == v.y then
- return true, v.text
- end
- end
- return false, nil
- end
- function harvest()
- rs.setOutput("back", true)
- sleep(18)
- rs.setOutput("back", false)
- sleep(10)
- rs.setOutput("bottom", true)
- sleep(12)
- rs.setOutput("bottom", false)
- os.reboot()
- end
- function carrots() --For planting the carrots with the turtle.
- rednet.open("right")
- rednet.send(1, "carrots") --Be sure to set the number to the id number of your turtle
- while true do
- id, msg = rednet.receive(1) --Be sure to set the number to the id number of your turtle
- if msg == "fuel" then
- mon.clear()
- mon.setCursorPos(9,6)
- mon.write("The turtle is out of fuel")
- mon.setCursorPos(9,7)
- mon.write("Please add more coal/charcoal")
- mon.setCursorPos(9,8)
- mon.write("To any open slot on the turtle")
- elseif msg == "full" then
- mon.clear()
- mon.setCursorPos(3,8)
- mon.write("Good for gas, will alert if fuel is needed!")
- elseif msg == "done" then
- rednet.close("right")
- os.reboot()
- end
- end
- end
- function potatoes() --For planting the potatoes with the turtle.
- rednet.open("right")
- rednet.send(1, "potatoes") --Be sure to set the number to the id number of your turtle
- while true do
- id, msg = rednet.receive(1) --Be sure to set the number to the id number of your turtle
- if msg == "fuel" then
- mon.clear()
- mon.setCursorPos(9,6)
- mon.write("The turtle is out of fuel")
- mon.setCursorPos(9,7)
- mon.write("Please add more coal/charcoal")
- mon.setCursorPos(9,8)
- mon.write("To any open slot on the turtle")
- elseif msg == "full" then
- mon.clear()
- mon.setCursorPos(3,8)
- mon.write("Good for gas, will alert if fuel is needed!")
- elseif msg == "done" then
- rednet.close("right")
- os.reboot()
- end
- end
- end
- function wheat() --For planting the wheat with the turtle.
- rednet.open("right")
- rednet.send(1, "wheat") --Be sure to set the number to the id number of your turtle
- while true do
- id, msg = rednet.receive(1) --Be sure to set the number to the id number of your turtle
- if msg == "fuel" then
- mon.clear()
- mon.setCursorPos(9,6)
- mon.write("The turtle is out of fuel")
- mon.setCursorPos(9,7)
- mon.write("Please add more coal/charcoal")
- mon.setCursorPos(9,8)
- mon.write("To any open slot on the turtle")
- elseif msg == "full" then
- mon.clear()
- mon.setCursorPos(3,8)
- mon.write("Good for gas, will alert if fuel is needed!")
- elseif msg == "done" then
- rednet.close("right")
- os.reboot()
- end
- end
- end
- --Program
- draw()
- writeButtons(t)
- while true do
- _, but, x, y = os.pullEvent("monitor_touch")
- bClick, option = isValidClick(t, x, y)
- if bClick then
- -- Yes, it's a valid click. Now let's do something with the returned text 'option'
- if option == "Harvest" then
- harvest()
- elseif option == "Plant Carrots" then
- carrots()
- elseif option == "Plant Potatoes" then
- potatoes()
- elseif option == "Plant Wheat" then
- wheat()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement