Posted 20 January 2013 - 10:02 AM
getting the ArrayIndexOutOfBoundsException and I'm certain it is happening at line 176
Easier read with line numbers
I have been over this several times and it worked fine before i added the few lines before it to make it go 1 block farther.
Can you see it?
it happens after 175 in a function up front. Using the ctrl+h to replace the turtle.place commands i removed some needed "turtle."s so i gots it now.
Easier read with line numbers
I have been over this several times and it worked fine before i added the few lines before it to make it go 1 block farther.
Can you see it?
it happens after 175 in a function up front. Using the ctrl+h to replace the turtle.place commands i removed some needed "turtle."s so i gots it now.
Spoiler
-- Build or Maintain?
-- ask if player is building a new farm
-- or just moveing the turtle back to start
-- places instead of turtle.place()
local function place()
if not turtle.detect() then
turtle.place()
end
end
local function placeUp()
if not turtle.detectUp() then
placeUp()
end
end
local function placeDown()
if not turtle.detectDown() then
placeDown()
end
end
-- refueling do this again much l8r when there's coal
local function fueling()
if turtle.getFuelLevel() < 4 then
turtle.select(6)
turtle.refuel(4)
end
end
-- how many and instruction
local function clear()
term.clear()
term.setCursorPos(1,1)
end
clear() print() print() print() print() print() print()
print (" Welcome to Andale's LumberJack")
sleep(2) clear()
--write ("Is this a new farm? [y/n] ") newfarm = read()
print ("Place items in the following") print ("order into turtle:")
print ("A log, Saplings, Torches, Dirt, xxxx")
print ("The fifth material will be the border")
print ()
print ("Place an oven on the left and") print("a chest to the right of turtle")
print ()
repeat
print ("How many saplings long") write ("should the farm be? ")
flength = tonumber(read())
until flength > 2
-- dig forward
local function digf()
fueling()
while turtle.detect() do
turtle.dig()
end
turtle.forward()
end
-- clear a line
local function clearline()
line=flength
repeat
digf()
line = line - 1
until line == 1
end
-- rise and rotate
local function rr()
while turtle.detectUp() do
turtle.digUp()
end
turtle.up()
turtle.turnRight()
turtle.turnRight()
end
-- clear a vertical space
local function clrvert()
clear() print ("Clearing a vertical space")
vert = 1
repeat
clearline()
if vert < 8 then
rr()
end
vert = vert + 1
until vert == 9
repeat
vert = vert - 1
turtle.down()
until vert == 1
turtle.turnRight()
end
-- clear the area then build the farm!!
local function newarea()
digf()
turtle.turnRight()
digf()
digf()
turtle.turnLeft()
clrvert()
for r = 1,4 do
digf()
turtle.turnRight()
clrvert()
end
end
-- putting together the floor
local function dirt()
turtle.select(4)
if turtle.compareDown() then
turtle.back()
else
turtle.digDown()
placeDown()
end
end
local function floorline()
local t = 0
for r = 1,flength do
dirt()
turtle.back()
end
dirt()
t = t + 1
if t == 5 then
turtle.select(3)
place()
t = 0
end
end
local function fs()
if turtle.getItemCount(5) < 1 then
turtle.select(6)
else
turtle.select(5)
end
end
-- build the border above to prevent branches
local function border()
turtle.turnRight()
for r=1,9 do -- move to top
turtle.up()
end
digf()
turtle.turnRight()
turtle.turnRight()
for r=1,flength+2 do -- place top row
fs()
placeUp()
digf()
end
placeUp()
turtle.back()
for r=1,9 do -- place back wall
fs()
place()
turtle.down()
end
place()
for r=1,flength do -- return and turn around for front wall
turtle.back()
end
turtle.turnLeft()
turtle.turnLeft()
turtle.up()
for r=1,8 do
fs()
turtle.up()
place()
end
turtle.turnLeft()
turtle.turnLeft()
for r=1,8 do
turtle.down()
end
turtle.back()
turtle.turnRight()
fs()
turtle.dig()
place()
turtle.turnLeft()
turtle.turnLeft()
fs()
turtle.dig()
place()
turtle.down()
digf()
fs()
turtle.dig()
place()
turtle.turnLeft()
turtle.turnLeft()
digf()
digf()
fs()
turtle.dig()
place()
turtle.back()
turtle.turnLeft()
end
local function floor()
turtle.turnLeft()
floorline() -- line 1
turtle.turnRight()
turtle.back()
turtle.turnRight()
floorline() -- line 2
turtle.turnLeft()
turtle.back()
sleep(0.1)
turtle.back()
sleep(0.1)
turtle.back()
sleep(0.1)
turtle.turnLeft()
floorline() -- line 5
turtle.turnLeft()
turtle.back()
turtle.turnLeft()
floorline() -- line 4
turtle.turnRight()
turtle.back()
end
--if newfarm == y then
--newarea()
--floor()
border()
--end