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

Farming Programme

Started by Paullie, 02 March 2015 - 08:12 PM
Paullie #1
Posted 02 March 2015 - 09:12 PM
Hello Community
I am trying to code a variable Farming Programme for the base, which too begin with started out as a set size, but I wanted to try and make it so I could input two variables, length and width.




All well and good for when it comes to the appearance but not however when it comes to the practical side.
I have the code I have coded, obviously and programmed, and it is confusing me with the error I have.



The code which I am using I cannot get my head around it hopefully one of you can. Especially Bomb Bloke.

Anyways Here the Code


--Automatic Farmer using farming turtle in minecraft
--Coded and produced by Paullie
--www.Youtube.com/user/AllGamesWide
------------------------------------
--Programme Name: Automatic Farmer
--Version: 1.0
--Release Date: 02/03/2015
------------------------------------
--Comments: Place the turtle on the same level as you want the farm, as the turtle will rise up one block to start the farming process

--Place Fuel in slot 16
--Place Seeds in slot 15
--Place WaterBucket in slot 14

local waterBucket = "14"
local seeds = "15"
local fuell = "16"
local fuel = turtle.getFuelLevel()
term.clear()

--Menu inputting of X,Y Lengths to figure out how big the farm will be

term.setCursorPos(3,3)
term.setTextColor(colors.blue)
textutils.slowPrint("Automatic Farming Programme")
term.setCursorPos(5,5)
term.setTextColor(colors.white)
textutils.slowPrint("Farm Length: ")
term.setTextColor(colors.green)
term.setCursorPos(20,5)
xLength = io.read()
term.setCursorPos(5,6)
term.setTextColor(colors.white)
textutils.slowPrint("Farm Width: ")
term.setTextColor(colors.green)
term.setCursorPos(20,6)
yWidth = io.read()
term.setCursorPos(3,8)
term.setTextColor(colors.red)
tB = xLength * yWidth
wB = 8
mB = 1

--Functions

function xLen(xLength)
  for i = 0 do
	turtle.forward
	turtle.digDown()
	turtle.select(seeds)
	turtle.placeDown()
  end --End For
end--End Function
function yWid(yWidth)
  for i = 0 do
	xLen(xLength)
	turtle.turnRight()
	turtle.forward()
	turtle.turnRight()
	turtle.forward(xLength)
	turtle.turnRight()
	turtle.turnRight()
  end --For Function
end --End Function

--Beginning of the main section of code

if fuel < tB then
  textutils.slowPrint("Cannot Complete Task, Fuel Level too Low")
else
  textutils.slowPrint("Fuel Level Good, Beginning Task!")
  sleep(1)
  turtle.up()
  yWid(yWidth)
end
Edited on 02 March 2015 - 08:17 PM
Quintuple Agent #2
Posted 02 March 2015 - 09:21 PM
For loops, like the ones on 46 and 54 only have i = 0. For loops need two variables, the first is the number it will change, in your case 'i' which you have set to 0, then you need another variable for i to increment up (or down) to
Ex:

for i=0,9 do
--code
end
Would start and 0, run the code and loop again increasing i by 1 until i equals 9

Here is some more information on For Loops
Edited on 03 March 2015 - 12:09 AM
Paullie #3
Posted 02 March 2015 - 09:41 PM
Now I am getting this problem :P/>




--Automatic Farmer using farming turtle in minecraft
--Coded and produced by Paullie
--www.Youtube.com/user/AllGamesWide

------------------------------------
--Programme Name: Automatic Farmer
--Version: 1.0
--Release Date: 02/03/2015
------------------------------------

--Comments: Place the turtle on the same level as you want the farm, as the turtle will rise up one block to start the farming process
--Place Fuel in slot 16
--Place Seeds in slot 15
--Place WaterBucket in slot 14

local waterBucket = "14"
local seeds = "15"
local fuell = "16"
local fuel = turtle.getFuelLevel()

term.clear()
--Menu inputting of X,Y Lengths to figure out how big the farm will be
term.setCursorPos(3,3)
term.setTextColor(colors.blue)
textutils.slowPrint("Automatic Farming Programme")
term.setCursorPos(5,5)
term.setTextColor(colors.white)
textutils.slowPrint("Farm Length: ")
term.setTextColor(colors.green)
term.setCursorPos(20,5)
xLength = io.read()
term.setCursorPos(5,6)
term.setTextColor(colors.white)
textutils.slowPrint("Farm Width: ")
term.setTextColor(colors.green)
term.setCursorPos(20,6)
yWidth = io.read()
term.setCursorPos(3,8)
term.setTextColor(colors.red)

tB = xLength * yWidth


--Functions
function xLen(xLength)
for i = 0, xLength do
turtle.forward
turtle.digDown()
turtle.select(seeds)
turtle.placeDown()
end --End For
end--End Function

function yWid(yWidth)
for i = 0, yWidth do
xLen(xLength)
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.forward(xLength)
turtle.turnRight()
turtle.turnRight()
end --For Function
end --End Function


--Beginning of the main section of code
if fuel < tB then
textutils.slowPrint("Cannot Complete Task, Fuel Level too Low")
else
textutils.slowPrint("Fuel Level Good, Beginning Task!")
sleep(1)
turtle.up()
yWid(yWidth)
end
Quintuple Agent #4
Posted 02 March 2015 - 09:42 PM
Also, just noticed, on line 47 you have turtle.forward without parenthesis.

And as I post this you post a problem that I posted the fix for!
Edited on 02 March 2015 - 08:43 PM
Paullie #5
Posted 02 March 2015 - 09:43 PM
Ahahahaha
Lyqyd #6
Posted 03 March 2015 - 01:10 AM
I've cleaned this thread up and removed a bunch of non-useful images.
Paullie #7
Posted 03 March 2015 - 08:27 AM
Aha ok, just thought they were funny