Posted 23 May 2013 - 09:06 AM
It's been some ages since I actually had to code anything. I started out on an island and wanted to make a simple turtle program to extend to island in a simple way (without having to be in water all the time)
It's supposed to start on the dry bit and just fill up everything ahead and to the right of it.
And I'm just starting myself blank on my program. It 'works' with one tiny flaw. Every odd line, is one too short.
http://pastebin.com/Q6TMibZa
The Code
It's supposed to start on the dry bit and just fill up everything ahead and to the right of it.
And I'm just starting myself blank on my program. It 'works' with one tiny flaw. Every odd line, is one too short.
http://pastebin.com/Q6TMibZa
The Code
Spoiler
-- Fills any area, returning for
-- materials and fuel
local tArg = {...}
local ToMoveForward
local ToMoveRight
local locX = 0
local locY = 0
local locZ = 0
local SlotIs = 0
function PlaceBlock()
while not turtle.placeDown() do
SlotIs = (SlotIs + 1)%16
turtle.select(SlotIs + 1)
end
end
function MoveForward()
while not turtle.forward() do end
end
function MoveUp()
while not turtle.up() do end
end
function MoveDown()
while not turtle.down() do end
end
function FillLine()
locY = ToMoveForward
for Forward = 1, locY do
while not turtle.detectDown() do
MoveDown()
locZ = locZ + 1
end
for Upward = 1, locZ do
MoveUp()
PlaceBlock()
locZ = locZ - 1
end
MoveForward()
end
end
function FillingItUp()
locX = ToMoveRight
for PlottingAlong = 1, locX do
FillLine()
locX = locX + 1
TurnWhere = locX%2
if TurnWhere == 0 then
turtle.turnLeft()
MoveForward()
turtle.turnLeft()
else
turtle.turnRight()
MoveForward()
turtle.turnRight()
end
end
end
if #tArg ~= 2 then
print("Usage: filler <forward> <right> (positives only)")
return
end
ToMoveForward = tonumber(tArg[1])
ToMoveRight = tonumber(tArg[2])
FillingItUp()