Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Tables ]]--
- local tArgs = { ... }
- --[[ Functions ]]--
- function cs()
- term.clear()
- term.setCursorPos(1, 1)
- end
- function returnToStart(psize)
- if psize % 2 == 1 then
- turtle.turnLeft()
- for i=1, psize-1 do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1, psize-1 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- else
- turtle.turnRight()
- for i=1, psize-1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- function centerT(text)
- local mx, my = term.getSize()
- local cx, cy = term.getCursorPos()
- term.setCursorPos(math.floor((mx-string.len(text))/2), cy)
- print(text)
- end
- function checkFuel()
- if turtle.getFuelLevel() < 50 then
- cs()
- print("I needz somez foodz bruh!")
- repeat
- for i=1, 16 do
- if turtle.getItemCount(i) > 0 then
- if turtle.refuel(1) then
- repeat
- turtle.refuel(1)
- until turtle.getFuelLevel > 100
- end
- end
- end
- until turtle.getFuelLevel > 100
- end
- end
- function plantRow(psize, pslot)
- for i=1, psize do
- turtle.select(pslot)
- if turtle.getItemCount(pslot) == 1 then
- cs()
- print("It appears I am running out of supplies...")
- print("I will now scan my inventory for more supplies...")
- textutils.slowPrint("Scanning...")
- for a=1, 16 do
- if a ~= pslot then
- if turtle.getItemCount(a) > 0 then
- turtle.select(a)
- if turtle.compareTo(pslot) then
- turtle.transferTo(pslot)
- turtle.select(pslot)
- break
- end
- end
- end
- end
- end
- turtle.placeDown()
- if i < psize then
- turtle.forward()
- end
- end
- end
- function plantFarm(psize, pslot)
- for i=1, psize do
- plantRow(psize, pslot)
- if bit.band(i,1) == 1 and i < psize then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- elseif bit.band(i,1) == 0 and i < psize then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- end
- function tillRow(psize)
- for i=1, psize do
- turtle.digDown()
- if i < psize then
- turtle.forward()
- end
- end
- end
- function tillFarm(psize)
- for i=1, psize do
- tillRow(psize)
- if bit.band(i,1) == 1 and i < psize then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- elseif bit.band(i,1) == 0 and i < psize then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- end
- function harvestRow(psize)
- for i=1, psize do
- turtle.digDown()
- if i < psize then
- turtle.forward()
- end
- end
- end
- function harvestFarm(psize)
- for i=1, psize do
- harvestRow(psize)
- if bit.band(i,1) == 1 and i < psize then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- elseif bit.band(i, 1) == 0 and i < psize then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- end
- function menu()
- cs()
- centerT("What is the size of this farm?")
- centerT("Please remember, this is size^2")
- write("> ")
- local psize = tonumber(read())
- cs()
- centerT("Which slot shall be my supply slot?")
- write("> ")
- local pslot = tonumber(read())
- cs()
- centerT("The last thing I need is:")
- print("Am I 1 block above the soil?")
- print("(Y/N)")
- write("> ")
- local soil = read()
- if string.lower(soil) == "n" then
- turtle.up()
- end
- cs()
- print("Thank you for giving me my necessary information!")
- sleep(2)
- while true do
- cs()
- centerT("Random Industrial Farming Inc.")
- centerT("Made by RandomShovel")
- centerT("-------")
- term.setCursorPos(1, 5)
- print("1) Till Farm")
- print("2) Plant Crops")
- print("3) Harvest Crops")
- print("4) Exit")
- print("")
- write("> ")
- local response = tonumber(read())
- if response == 1 then
- tillFarm(psize)
- returnToStart(psize)
- elseif response == 2 then
- plantFarm(psize, pslot)
- returnToStart(psize)
- elseif response == 3 then
- harvestFarm(psize)
- turtle.turnLeft()
- turtle.turnLeft()
- plantFarm(psize, pslot)
- turtle.turnLeft()
- turtle.turnLeft()
- elseif response == 4 then
- cs()
- textutils.slowPrint("Exiting FarmSimulator 2014...")
- sleep(1)
- cs()
- break
- end
- sleep(0.1)
- end
- end
- --[[ Main ]]--
- menu()
Advertisement
Add Comment
Please, Sign In to add comment