Posted 07 June 2013 - 04:21 PM
I have made a platform program that does what the name implies.
Thougt I could share it with thoose that want it.
Update (13-08-04): Changed it's moving pattern. It now don't move outside the area you specify, as if you say 5x5, it will move 5x5.
Update (13-06-25): Added to it should return to the start when done.
Changelog:
Changed the moving pattern so it dosent move outside the area you give it.
1.1
Added a function that moves the turtle back when it is done
Added a function that handles moving backwards.
1.0:
Initial release
Expand the spoiler if you want to read what it checks before and while it runs.
How to use:
Pastbin link (Version 1.2): http://pastebin.com/2fMcYvGQ
For thoose that want and can use pastebin to input the code into a mining turtle, use this command: pastebin get 2fMcYvGQ platform
Older versions:
Platform maker 1.1: http://pastebin.com/s6VEHF9h
And here is the code if you can't download the code with the above method:
– * Made by: Acuena
– * Usage: platform length width
– Variables
curslot = 2
fuelused = 0
blocksplaced = -1
totalnrblocks = 0
– Functions
function moveforward()
while not turtle.forward() do
checkfuel()
end
end
function moveback()
while not turtle.back() do
checkfuel()
end
end
function checkfuel()
if turtle.getFuelLevel() < 1 then
turtle.select(1)
if not turtle.refuel(1) then
print("No fuel in slot 1, awaiting fuel")
while not turtle.refuel(1) do
end
print("Successfully refueld, continuing")
end
fuelused = fuelused + 1
turtle.select(curslot)
end
end
function turnright()
turtle.turnRight()
moveforward()
turtle.turnRight()
end
function turnleft()
turtle.turnLeft()
moveforward()
turtle.turnLeft()
end
function checkblockcount()
if turtle.getItemCount(curslot) == 0 then
selnextslot()
end
end
function selnextslot()
curslot = curslot + 1
if curslot > 16 then
print("Out of blocks, terminating")
error()
end
turtle.select(curslot)
end
function place()
checkblockcount()
turtle.placeDown()
blocksplaced = blocksplaced + 1
end
function countblocks()
for i = 2,16 do
turtle.select(i)
totalnrblocks = totalnrblocks + turtle.getItemCount(i)
end
if not totalnrblocks == 0 then
totalnrblocks = totalnrblocks + 1
end
turtle.select(curslot)
end
function returntostart()
if orient == true then
turtle.turnRight()
for i = 1, width - 1 do
moveforward()
end
turtle.turnRight()
moveback()
elseif orient == false then
turtle.turnLeft()
for i = 1, width - 1 do
moveforward()
end
turtle.turnRight()
for i = 1, length do
turtle.back()
end
end
end
– Code
local args = {…}
orient=false
if #args ~= 2 then
print("Usage: platform length width")
return
end
length = tonumber(args[1])
width = tonumber(args[2])
countblocks()
need = length * width
if need > 960 then
print("Unable to carry more than 960 block's")
print("A platform with the size of:")
print(length.."x"..width.." will need "..need.." blocks")
print("Aborting run")
error()
end
if totalnrblocks < need then
print("Not enough blocks, aborting")
print("Need: "..need)
print("Have: "..totalnrblocks.." block's")
error()
end
moveforward()
place()
for xx = 1,width - 1 do
for x = 1, length-1 do
moveforward()
place()
end
if orient == false then – Should turn right
turnright()
place()
else – Should turn left
turnleft()
place()
end
orient = not orient
end
for x = 1, length-1 do
moveforward()
place()
end
print("Orient: "..tostring(orient))
returntostart()
print("Platform done")
print("Block's placed: "..blocksplaced)
print("Fuel used: "..fuelused)
Thougt I could share it with thoose that want it.
Update (13-08-04): Changed it's moving pattern. It now don't move outside the area you specify, as if you say 5x5, it will move 5x5.
Update (13-06-25): Added to it should return to the start when done.
Changelog:
Spoiler
1.2Changed the moving pattern so it dosent move outside the area you give it.
1.1
Added a function that moves the turtle back when it is done
Added a function that handles moving backwards.
1.0:
Initial release
Expand the spoiler if you want to read what it checks before and while it runs.
Spoiler
- It checks if something is in the way and keeps trying to move forward until it can, and then resumes making the platform.
- It checks it's current fuel level and if needed, it refuels from slot 1. If there is no fuel in slot 1 it will wait until fuel is placed in slot 1.
- It checks if there is any builiding block in the selected slot, and if not it selects the next slot and moves on.
- It counts how many blocks the user has provided it with and checks if it is enughe to build the platform, if not it aborts and informing the player.
- It checks if the size of the platform requiers more than 960 block and aborts if it does. This is bacause it can't hold more than 960 blocks (15 slots)
- Returns to the block it started
How to use:
- Place fuel in slot 1
- Fill the rest of the slots with the block you want to use, you don't have to fill them all
- Use the command: platform <length> <width>
- Watch it go
Pastbin link (Version 1.2): http://pastebin.com/2fMcYvGQ
For thoose that want and can use pastebin to input the code into a mining turtle, use this command: pastebin get 2fMcYvGQ platform
Older versions:
Spoiler
Platform maker 1.0: http://pastebin.com/Bt9u65cgPlatform maker 1.1: http://pastebin.com/s6VEHF9h
And here is the code if you can't download the code with the above method:
Spoiler
– * Platform maker 1.2– * Made by: Acuena
– * Usage: platform length width
– Variables
curslot = 2
fuelused = 0
blocksplaced = -1
totalnrblocks = 0
– Functions
function moveforward()
while not turtle.forward() do
checkfuel()
end
end
function moveback()
while not turtle.back() do
checkfuel()
end
end
function checkfuel()
if turtle.getFuelLevel() < 1 then
turtle.select(1)
if not turtle.refuel(1) then
print("No fuel in slot 1, awaiting fuel")
while not turtle.refuel(1) do
end
print("Successfully refueld, continuing")
end
fuelused = fuelused + 1
turtle.select(curslot)
end
end
function turnright()
turtle.turnRight()
moveforward()
turtle.turnRight()
end
function turnleft()
turtle.turnLeft()
moveforward()
turtle.turnLeft()
end
function checkblockcount()
if turtle.getItemCount(curslot) == 0 then
selnextslot()
end
end
function selnextslot()
curslot = curslot + 1
if curslot > 16 then
print("Out of blocks, terminating")
error()
end
turtle.select(curslot)
end
function place()
checkblockcount()
turtle.placeDown()
blocksplaced = blocksplaced + 1
end
function countblocks()
for i = 2,16 do
turtle.select(i)
totalnrblocks = totalnrblocks + turtle.getItemCount(i)
end
if not totalnrblocks == 0 then
totalnrblocks = totalnrblocks + 1
end
turtle.select(curslot)
end
function returntostart()
if orient == true then
turtle.turnRight()
for i = 1, width - 1 do
moveforward()
end
turtle.turnRight()
moveback()
elseif orient == false then
turtle.turnLeft()
for i = 1, width - 1 do
moveforward()
end
turtle.turnRight()
for i = 1, length do
turtle.back()
end
end
end
– Code
local args = {…}
orient=false
if #args ~= 2 then
print("Usage: platform length width")
return
end
length = tonumber(args[1])
width = tonumber(args[2])
countblocks()
need = length * width
if need > 960 then
print("Unable to carry more than 960 block's")
print("A platform with the size of:")
print(length.."x"..width.." will need "..need.." blocks")
print("Aborting run")
error()
end
if totalnrblocks < need then
print("Not enough blocks, aborting")
print("Need: "..need)
print("Have: "..totalnrblocks.." block's")
error()
end
moveforward()
place()
for xx = 1,width - 1 do
for x = 1, length-1 do
moveforward()
place()
end
if orient == false then – Should turn right
turnright()
place()
else – Should turn left
turnleft()
place()
end
orient = not orient
end
for x = 1, length-1 do
moveforward()
place()
end
print("Orient: "..tostring(orient))
returntostart()
print("Platform done")
print("Block's placed: "..blocksplaced)
print("Fuel used: "..fuelused)