Jump to content




Farming Programme

turtle computer utility

6 replies to this topic

#1 Paullie

  • Members
  • 20 posts
  • LocationDorset, England

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.


Posted Image

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.

Posted Image

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 by Paullie, 02 March 2015 - 09:17 PM.


#2 Quintuple Agent

  • Members
  • 107 posts
  • LocationThis page

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 by Lyqyd, 03 March 2015 - 01:09 AM.


#3 Paullie

  • Members
  • 20 posts
  • LocationDorset, England

Posted 02 March 2015 - 09:41 PM

Now I am getting this problem :P

Posted Image

--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


#4 Quintuple Agent

  • Members
  • 107 posts
  • LocationThis page

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 by Quintuple Agent, 02 March 2015 - 09:43 PM.


#5 Paullie

  • Members
  • 20 posts
  • LocationDorset, England

Posted 02 March 2015 - 09:43 PM

Ahahahaha

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 03 March 2015 - 01:10 AM

I've cleaned this thread up and removed a bunch of non-useful images.

#7 Paullie

  • Members
  • 20 posts
  • LocationDorset, England

Posted 03 March 2015 - 08:27 AM

Aha ok, just thought they were funny





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users