Posted 12 February 2014 - 10:41 AM
I'm in a single player game, and this is strictly for my use, although anyone is welcome to use or adapt it into whatever they want without giving credit.
This program should plant seedlings. I'm getting an error from the compiler that I don't understand:
"bios:338: [string "Plant"]:1: '=' expected"
Please feel free to give advice on the actual program as well. Thank you!
This program should plant seedlings. I'm getting an error from the compiler that I don't understand:
"bios:338: [string "Plant"]:1: '=' expected"
Please feel free to give advice on the actual program as well. Thank you!
-- The purpose of this program is to plant oak seedlings
-- in every dirt patch in four 5x5 (25 seedlings each) squares.
-- The dirt squares are two spaces apart from each other in a
-- square. It will then return the turtle to a chest, dump its
-- remaining inventory and return to a "home" position, ready
-- for the next planting.
-- rom/programs/http/pastebin get um2XtCPL Plant
-- turtle position must be 361, 278 facing north
-- LOOP COUNTERS
i = 5
k = 1
rowcount = 1
rowscounted = 0
-- VARIABLES
seedstock = 16
slotempty = false
-- FUNCTIONS
-- plantrow() plants one entire length of both squares, 5
-- seedlings (five iterations of plant down -> move forward), a
-- gap of 2 squares, then 5 more seedlings. After each square
-- it makes sure it has enough seedlings to plant another square,
-- (seedstock) and if not it switches inventory spots.
function plantrow()
i = 5
turtle.select(seedstock)
while (i > 0) do
turtle.forward()
turtle.placeDown()
i = i-1
end
if turtle.getItemCount(seedstock) < 10 then
seedstock = seedstock - 1
end
turtle.forward()
turtle.forward()
i = 5
turtle.select(seedstock)
while (i > 0) do
turtle.forward()
turtle.placeDown()
i = i-1
end
if turtle.getItemCount(seedstock) < 5 then
seedstock = seedstock - 1
end
end
-- endofrow() turns the turtle left or right depending on which
-- direction it just planted (rowcount), and positions it on
-- the next row. It also determines when it has reached the gap
-- between squares (rowsplanted) and skips over it.
function endofrow()
turtle.forward()
if rowcount == 1 then
turtle.turnLeft()
if rowscounted == 5 then
turtle.forward()
turtle.forward()
end
turtle.forward()
turtle.turnLeft()
end
if rowcount == 2 then
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
if rowcount == 1 then
rowcount = 2
else rowcount = 1
end
end
-- dumpinventory() puts the turtle's entire inventory in a chest
-- below it.
function dumpinventory()
while k < 17 do
turtle.select(k)
turtle.dropDown()
k = k+1
end
end
-- Main Program
turtle.select(1)
turtle.refuel()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.up()
while rowsplanted < 10 do
plantrow()
endofrow()
rowsplanted = rowsplanted + 1
end
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
dumpinventory()
turtle.forward()
turtle.down()
turtle.turnRight()