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

Ender lily automation

Started by Hellreaper, 18 March 2016 - 09:17 AM
Hellreaper #1
Posted 18 March 2016 - 10:17 AM
Good day to all of you guys. I m trying to make a automatic farmiing system for ender pearls using ender lilys,
Since there isnt really any other way to do it that I found… (FTB Infinity evolved 2.3.5 for MC 1.7.10)

But it isnt working. Im trying to move the turtle over end stone using the pistons blocking the water to constrain it so it doesnt go too far. and glass on the other side.
I might be making it too long to but I couldnt find a script so I had to try…

Its saying the "end" is missing for the "while" at line 22 (probably some more errors too but I cant see them because this one is blocking the rest)

A screenshot will be provided of the setup when im home and have access to the server

Thx for the help ^^


init = false
finished = false
function flip()
turtle.turnLeft()
turtle.turnLeft()
end
while true do
if(turtle.getFuelLevel() < 1000) then
  turtle.refuel()
end
while not init do
  if(rs.getInput("top")) then
   switch = true
   init = true
  end
end
startingPosition = false
while switch do
  --set turtle to correct position
  turtle.forward()
  turtle.turnLeft()
  while not startingPosition do
   local succes, data = turtle.inspect()
   if succes then
    if not data.name == "minecraft:piston" then
	 turtle.forward()
    else
	 turtle.turnRight()
	 turtle.turnRight()
	 startingPosition = true
    end
   end
  end
  --place ender pearl on empty spot (best on endstone)
  while startingPosition do
   local succes, data = turtle.inspect()
   if not succes then -- if "air" then
   turtle.forward()
   else if succes and data.name == "ExtraUtilities:etherealglass" then -- Check name of block in front / Check ingame dont know the name
    turtle.turnLeft()
    if not turtle.detect() then
	 turtle.forward()
	 turtle.turnLeft()
    else
	 switch = false
	 finished = true
	 startingPosition = true
    end
   else if succes and data.name == "minecraft:piston" then
    turtle.turnRight()
    if not turtle.detect() then
	 turtle.forward()
	 turtle.turnRight()
    else
	 switch = false
	 finished = true
	 startingPosition = false
    end
   end
  end
  --go back to docking station
  while finished do
   flip()
   local movingBackToStartLocation = true
   while movingBackToStartLocation do
    turtle.forward()
    succes, data = turtle.inspectDown()
    if succes then
	 if data.name == "minecraft:chest" then
	  movingBackToStartLocation = false;
	 else if not data.name == "minecraft:chest" then
	  turtle.turnLeft()
	  if turtle.detect() then
	   flip()
	   while not data.name == "minecraft:chest"
	    turtle.forward()
	   end
	  end
	 end
    end
   end
  end
end
end

http://pastebin.com/FHQmVc8F
Lupus590 #2
Posted 18 March 2016 - 12:34 PM
the else if's after line 43 may be causing problems
and again on line 78


--#change this
else if
--#to this
elseif --#no space


will edit post as I find more issues


yep, definitly your else if, elseif thing
notice how your indentation is messed up when I collapse the scopes in my editor

Edited on 18 March 2016 - 11:42 AM
Hellreaper #3
Posted 18 March 2016 - 12:42 PM
Was it treating it like this the way I wrote it than?
else
if(a == B)/> then c = a end
end
Edited on 18 March 2016 - 11:44 AM
Lupus590 #4
Posted 18 March 2016 - 01:14 PM
Was it treating it like this the way I wrote it than?
else
if(a == B)/>/>/> then c = a end
end


kind of, except you we an end short for each else
Edited on 18 March 2016 - 12:14 PM
Hellreaper #5
Posted 18 March 2016 - 03:28 PM
Ok I dont know what it is this time but I get a red output that just saids 35. i think apart from that it works


init = false
finished = false
function flip()
turtle.turnLeft()
turtle.turnLeft()
end
while true do
if(turtle.getFuelLevel() < 1000) then
  for i = 1, 16, 1 do
   local data = turtle.getItemDetail(i)
   if data then
    if data.name == "minecraft:coal" then
	 turtle.select(i)
	 turtle.refuel()
    end
   end
  end
end
while not init do
  if(rs.getInput("left")) then
   switch = true
   init = true
  end
end
startingPosition = false
while switch do
  --set turtle to correct position
  turtle.forward()
  turtle.turnLeft()
  while not startingPosition do
   local succes, data = turtle.inspect()
   if not succes then
    turtle.forward()
   elseif succes and data.name == "minecraft:piston" then
    flip()
    startingPosition = true
   end
  end
  --place ender pearl on empty spot (best on endstone)
  while startingPosition do
   local succes, data = turtle.inspect()
   if not succes then -- if "air" then
   turtle.placeDown()
   turtle.forward()
	 for i = 1, 16, 1 do
   local data = turtle.getItemDetail(i)
   if data then
    if data.name == "ExtraUtilities:plant/ender_lilly" then
	 turtle.select(i)
    end
   end
  end
   elseif succes and data.name == "ExtraUtilities:etherealglass" then
    turtle.turnLeft()
    if not turtle.detect() then
	 turtle.forward()
	 turtle.turnLeft()
    else
	 switch = false
	 finished = true
	 startingPosition = false
    end
   elseif succes and data.name == "minecraft:piston" then
    turtle.turnRight()
    if not turtle.detect() then
	 turtle.forward()
	 turtle.turnRight()
    else
	 switch = false
	 finished = true
	 startingPosition = false
    end
   end
  end
  --go back to docking station
  while finished do
   flip()
   local movingBackToStartLocation = true
   while movingBackToStartLocation do
    turtle.forward()
    succes, data = turtle.inspectDown()
    if succes then
	 if data.name == "minecraft:chest" then
	  for i = 1, 4, 1 do
	   local bool, sand = turtle.inspect()
	   if bool then
	    movingBackToStartLocation = false;
	    if sand == "minecraft:sand" then flip() end
	   end
	  end
	 elseif data.name == "minecraft:stone" then
	  turtle.turnRight()
	 elseif data.name == "minecraft:dirt" then
	  turtle.turnLeft()
	 end
    end
   end
  end
end
end
Lupus590 #6
Posted 18 March 2016 - 04:32 PM
line 62 you have an end followed by an elseif

also, this may be because of the forum software, but your indentation looks a bit messed up
Edited on 18 March 2016 - 03:33 PM
Hellreaper #7
Posted 18 March 2016 - 06:46 PM
yeah its ok in sublime text. also how am i nto spotting those mistakes jeezus xd
Lupus590 #8
Posted 18 March 2016 - 07:36 PM
how am I not spotting those mistakes

sometime you just need a fresh pair of eyes, it's why pair programming is a thing

If you have any other problems then feel free to ask another question, hopefully you won't need to as your code will now be working
Hellreaper #9
Posted 18 March 2016 - 07:51 PM
ye it kinda works now, Im looking for a way to make it check the block under it if the ender lilys are done growing but im afraid that might be impossible
Lupus590 #10
Posted 18 March 2016 - 11:11 PM
try this http://computercraft.info/wiki/Turtle.inspectDown
Hellreaper #11
Posted 19 March 2016 - 12:20 AM
I was just going out from the assumption that wouldnt work since ender lilys arent vanilla (silly me…)
That should take care of that.

But than how would I go about checking it to be ok on fuel because making it move all the time could be expensive since im on a server
Lupus590 #12
Posted 19 March 2016 - 12:28 AM
Have a look on the wiki and see if a function looks like it will do what you need: http://computercraft.info/wiki/Turtle_%28API%29
Bomb Bloke #13
Posted 19 March 2016 - 10:24 AM
also, this may be because of the forum software, but your indentation looks a bit messed up

The rich text editor isn't that great for indented content. The lightswitch up the top left of the posting box can be used to disable it.
Hellreaper #14
Posted 20 March 2016 - 11:24 PM
Yeah the inspectDown and check for metadata in that way work. Just need a fuel efficient way of doing things now
H4X0RZ #15
Posted 21 March 2016 - 12:58 AM
Depending on your setup you could check the first lily only. If it finished growing harvest it and continue until it reaches the it (or untill it reaches a lily which isn't "done")
Dragon53535 #16
Posted 21 March 2016 - 01:05 AM
If you're wanting to harvest the area in an efficient way, lets say you start at the bottom left of the square, what most would probably try to do would be to go towards the top right by just zig-zagging through the rows. A better way would be to go forward until you hit the back, then zig-zag back to the start, since you're going to have to use the fuel for each individual block itself, as well as your way back, if you end right next to where you started, then you have less fuel to consume going back to start.
Hellreaper #17
Posted 26 March 2016 - 01:41 PM
If you're wanting to harvest the area in an efficient way, lets say you start at the bottom left of the square, what most would probably try to do would be to go towards the top right by just zig-zagging through the rows. A better way would be to go forward until you hit the back, then zig-zag back to the start, since you're going to have to use the fuel for each individual block itself, as well as your way back, if you end right next to where you started, then you have less fuel to consume going back to start.

thats a very good point I just adjusted the pathing algorithm so it works that way