Showing posts with label computercraft. Show all posts
Showing posts with label computercraft. Show all posts

Tuesday, March 5, 2013

It sure has been a while

Wow, I've been so busy making videos and stuff that I've kinda neglected this place. I haven't really written any new turtle scripts, so I don't have anything to publish on that front. But what I do have is a topic to talk about, and that topic is FTB Ultimate pack. There is talk of wanting to switch the server from Mindcrack to Ultimate, and I almost think we should. I'm not sure what will happen when/if we do though. If I can change the server over without having to restart the world, I might do it. If we have to start over though, there's no way.
Not every player on the server has weighed in, but I think most will be ok going along with whatever I decide. I know I'd love to get Mystcraft back, even though I barely touched it back in beta. I've looked at the mods we'd gain and lose and I'm not sure what to think. There's still no release date on Ultimate, but there's a beta version out people can try. I'd love to hear your opinions on it if you have any.

Wednesday, January 9, 2013

Flooring

Don't you just hate having to fill in floors one block at a time? Well I have the solution for you! Get a turtle to do that for you. Just give him fuel and blocks and set him free! Here you go:


-- Clearing Terminal
term.clear()
term.setCursorPos(1,1)

-- Setting up Variables
local tArgs = { ... }
local fuel = 1

if #tArgs ~= 1 then
    -- Missing Height Argument
    print("Usage: Floor <area>")
    print("Slot 1: Fuel")
    print("Slot 2-16: Blocks")
    error()
end

local area = tArgs[1]

-- Fuel Checking Function
function tFuel(f)
    if turtle.getFuelLevel() < 10 then
        turtle.select(f)
        if not turtle.refuel(1) then
            print("Need Fuel")
            while turtle.getItemCount(f) < 2 do sleep(0.5) end
        end
    end
end

function place()
    if not turtle.detectDown() then
        for s = 2, 16 do
            if turtle.getItemCount(s) ~= 0 then
                turtle.select(s)
                break
            end
        end
        turtle.placeDown()
    end
end

print("Starting floor of " .. area .. " square blocks")

for gone = 1, area do
    for gtwo = 1, area do
        tFuel(fuel)
        turtle.forward()
        place()
    end
    turtle.forward()
    if( gone % 2) == 0 then
        turtle.turnRight()
        turtle.forward()
        turtle.turnRight()
    else
        turtle.turnLeft()
        turtle.forward()
        turtle.turnLeft()
    end
end

Tunnelling Turtle

I've got a new program for you today. This one creates 3x3 tunnels as long as you want. Again, it's not perfect, but it's great for making pathways in the nether. It also automatically places torches for you. So, here is "tunnels":


-- Clearing Terminal
term.clear()
term.setCursorPos(1,1)

-- Setting up Variables
local tArgs = { ... }
local fuel = 1
local torch = 2
local block = 3
local gone = 0

if #tArgs ~= 1 then
    -- Missing Length Argument
    print("Usage: Branch <length>")
    print("Slot 1: Fuel")
    print("Slot 2: Torches")
    print("Slot 3: Blocks")
    error()
end

local length = tArgs[1]

--Missing Items Check
if (turtle.getItemCount(fuel) < 1 or turtle.getItemCount(torch) < 1 or turtle.getItemCount(block) < 1) then
    print("Missing Critical Item")
    error()
end

-- Fuel Checking Function
function tFuel(moved,f)
    if turtle.getFuelLevel() < (moved + 20) then
        turtle.select(f)
        if not turtle.refuel(1) then
            print("Need Fuel")
            finished(moved)
        end
    end
end

-- Drop Items Function
function dump()
    print("Dumping Goods")
    for i = 4, 16 do
        turtle.select(i)
        turtle.drop()
    end
end

--Checks for full inventory
function slotCheck(moved)
    local slots = 0
    for i = 4, 16 do
        turtle.select(i)
        if turtle.getItemCount(i) > 0 then slots = slots + 1 end
    end
    if slots == 12 then finished(moved) end
end

-- Return Function
function finished(m)
    print("Returning after " .. m + 1 .. " blocks")
    turtle.turnRight()
    turtle.turnRight()
    for i = 1, m do
        turtle.forward()
    end
    dump()
    error()
end

print("Starting tunnel " .. length .. " blocks long")

for g = 1, length do
    tFuel(g, fuel)
    while turtle.detect() do
        turtle.dig()
        sleep(0.5)
    end
    turtle.forward()
    if not turtle.detectDown() then
        turtle.select(block)
        turtle.placeDown()
    end
    while turtle.detectUp() do
        turtle.digUp()
        sleep(0.5)
    end
    turtle.turnRight()
    while turtle.detect() do
        turtle.dig()
        sleep(0.5)
    end
    turtle.forward()
    if not turtle.detect() then
        turtle.select(block)
        turtle.place()
    end
    if not turtle.detectDown() then
        turtle.select(block)
        turtle.placeDown()
    end
    while turtle.detectUp() do
        turtle.digUp()
        sleep(0.5)
    end
    turtle.up()
    if g%5 == 0 then
        turtle.select(torch)
        turtle.placeDown()
    end
    if not turtle.detect() then
        turtle.select(block)
        turtle.place()
    end
    while turtle.detectUp() do
        turtle.digUp()
        sleep(0.5)
    end
    turtle.up()
    if not turtle.detect() then
        turtle.select(block)
        turtle.place()
    end
    if not turtle.detectUp() then
        turtle.select(block)
        turtle.placeUp()
    end
    turtle.turnRight()
    turtle.turnRight()
    while turtle.detect() do
        turtle.dig()
        sleep(0.5)
    end
    turtle.forward()
    if not turtle.detectUp() then
        turtle.select(block)
        turtle.placeUp()
    end
    while turtle.detect() do
        turtle.dig()
        sleep(0.5)
    end
    turtle.forward()
    if not turtle.detectUp() then
        turtle.select(block)
        turtle.placeUp()
    end
    if not turtle.detect() then
        turtle.select(block)
        turtle.place()
    end
    turtle.digDown()
    turtle.down()
    if not turtle.detect() then
        turtle.select(block)
        turtle.place()
    end
    turtle.digDown()
    turtle.down()
    if not turtle.detect() then
        turtle.select(block)
        turtle.place()
    end
    if not turtle.detectDown() then
        turtle.select(block)
        turtle.placeDown()
    end
    turtle.turnRight()
    turtle.turnRight()
    turtle.forward()
    turtle.turnLeft()
    gone = g
    slotCheck(gone)
end

finished(gone)

Thursday, January 3, 2013

Cactus Builder

So, this script is awesome, but it doesn't work completely. Luckily it works well enough to make it worth sharing. When i wrote it, I totally didn't think about the fact that the turtle has to place a cactus down. I may rewrite this one later if there is a need for it. but it builds the basic structure for you, and all you have to do is add the cactus manually.


-- Clearing Terminal
term.clear()
term.setCursorPos(1,1)

-- Setting up Variables
local tArgs = { ... }
local fuel = 1
local sand = 2
local block = 3
local cactus = 4
local gone = 0
local slots = {"fuel", "sand", "blocks", "cactus"}

if #tArgs ~= 1 then
    -- Missing Height Argument
    print("Usage: Cactus <layers>")
    print("Slot 1: Fuel")
    print("Slot 2: Sand")
    print("Slot 3: Blocks")
    print("Slot 4: Cactus")
    error()
end

local height = tArgs[1]

--Missing Items Check
if (turtle.getItemCount(fuel) < 1 or turtle.getItemCount(sand) < 1 or turtle.getItemCount(block) < 1 or turtle.getItemCount(cactus) < 1) then
    print("Missing Critical Item")
    error()
end

-- Fuel Checking Function
function tFuel(f)
    if turtle.getFuelLevel() < 60 then
        turtle.select(f)
        if not turtle.refuel(1) then
            print("Need Fuel")
            while turtle.getItemCount(f) < 2 do sleep(0.5) end
        end
    end
end

--Place Row
function row(slot)
    for p = 1, 4 do
        turtle.select(slot)
        if turtle.getItemCount(slot) < 3 then
            print("Need more " .. slots[slot])
            while turtle.getItemCount(slot) < 3 do sleep(0.5) end
        end
        turtle.forward()
        turtle.turnLeft()
        turtle.place()
        turtle.turnRight()
        turtle.turnRight()
        turtle.place()
        turtle.turnLeft()
        if slot == cactus then
            turtle.select(block)
            if turtle.getItemCount(block) < 3 then
                print("Need more " .. slots[block])
                while turtle.getItemCount(block) < 3 do sleep(0.5) end
            end
            turtle.placeUp()
        end
        turtle.forward()
        end
end

print("Starting cactus farm of " .. height .. " layers")

for g = 1, height, 2 do
    tFuel(fuel)
    turtle.up()
    row(block)
    turtle.up()
    turtle.turnRight()
    turtle.turnRight()
    row(sand)
    turtle.up()
    turtle.turnRight()
    turtle.turnRight()
    row(cactus)
    turtle.turnRight()
    turtle.turnRight()
    turtle.up()
    turtle.up()
    turtle.up()
    row(block)
    turtle.up()
    turtle.turnRight()
    turtle.turnRight()
    row(sand)
    turtle.up()
    turtle.turnRight()
    turtle.turnRight()
    row(cactus)
    turtle.turnRight()
    turtle.turnRight()
    turtle.up()
    turtle.up()
end

Wednesday, January 2, 2013

More turtle fun!

So here's another script for the turtle, this one is made to mine those giant fur trees. You place your turtle facing the tree with a chest at his back. he should be on the left side of two trunk blocks. I took SethBling's original "Fell" script and rewrote it to be a little more fuel efficient as well as add some safety and error checking.

-- Clearing Terminal
term.clear()
term.setCursorPos(1,1)

-- Setting up Variables
local fuel = 1
local gone = 0

turtle.select(fuel)

-- Checking for Fuel before start
if ( not turtle.refuel(1) or turtle.getItemCount(fuel) < 1 ) then
    print("Missing Fuel in Slot 1")
    error()
end

-- Drop Items Function
function dump()
    print("Dumping Goods")
    for i = 2, 16 do
        turtle.select(i)
        turtle.drop()
    end
    turtle.turnLeft()
    turtle.turnLeft()
end

-- Fuel Checking Function
function tFuel(moved,f)
    if turtle.getFuelLevel() < (moved + 10) then
        turtle.select(f)
        if not turtle.refuel(1) then
            print("Need Fuel")
            finished(moved)
        end
    end
end

-- Return Function
function finished(m)
    print("Returning after " .. m + 1 .. " blocks")
    turtle.turnRight()
    turtle.turnRight()
    for i = 0, m do
        turtle.down()
    end
    dump()
    error()
end

print("Felling Tree")

turtle.dig()
turtle.forward

while turtle.digUp() do
    turtle.dig()
    tFuel(gone,fuel)
    turtle.up()
    gone = gone + 1
end

turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()

for i = 0, gone do
    turtle.digDown()
    turtle.down()
    turtle.dig()
end

turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
dump()

Friday, December 28, 2012

New Turtle Script

So I've been doing some work with turtles since the update of Feed The Beast and I have what appears to be a fairly decent script worked out. It has many possible uses. I originally intended to use it to do branches for my mine, but it also works as a tunnel maker or bridge builder. It digs a 2 tall tunnel and makes sure there's walls, floors, and ceilings. You feed it with fuel, torches and blocks and it will go as far as it can. If it runs out of blocks it could have some issues. Below is the code.


-- Clearing Terminal
term.clear()
term.setCursorPos(1,1)

-- Setting up Variables
local tArgs = { ... }
local fuel = 1
local torch = 2
local block = 3
local gone = 0

if #tArgs ~= 1 then
    -- Missing Length Argument
    print("Usage: Branch <length>")
    print("Slot 1: Fuel")
    print("Slot 2: Torches")
    print("Slot 3: Blocks")
    error()
end

local length = tArgs[1]

--Missing Items Check
if (turtle.getItemCount(fuel) < 1 or turtle.getItemCount(torch) < 1 or turtle.getItemCount(block) < 1) then
    print("Missing Critical Item")
    error()
end

-- Fuel Checking Function
function tFuel(moved,f)
    if turtle.getFuelLevel() < (moved + 10) then
        turtle.select(f)
        if not turtle.refuel(1) then
            print("Need Fuel")
            finished(moved)
        end
    end
end

-- Drop Items Function
function dump()
    print("Dumping Goods")
    for i = 4, 16 do
        turtle.select(i)
        turtle.drop()
    end
end

--Checks for full inventory
function slotCheck(moved)
    local slots = 0
    for i = 4, 16 do
        turtle.select(i)
        if turtle.getItemCount(i) > 0 then slots = slots + 1 end
    end
    if slots == 12 then finished(moved) end
end

-- Return Function
function finished(m)
    print("Returning after " .. m + 1 .. " blocks")
    turtle.up()
    turtle.turnRight()
    turtle.turnRight()
    for i = 0, m do
        turtle.forward()
    end
    turtle.down()
    dump()
    error()
end

--Check for Walls
function wallCheck(b)
    turtle.turnRight()
    if not turtle.detect() then
        turtle.select(b)
        turtle.place()
    end
    turtle.turnLeft()
    turtle.turnLeft()
    if not turtle.detect() then
        turtle.select(b)
        turtle.place()
    end
    turtle.turnRight()
end

print("Starting tunnel " .. length .. " blocks long")

for g = 1, length, 2 do
    tFuel(g, fuel)
    while turtle.detect() do
        turtle.dig()
        sleep(0.5)
    end
    turtle.forward()
    if not turtle.detectDown() then
        turtle.select(block)
        turtle.placeDown()
    end
    wallCheck(block)
    while turtle.detectUp() do
        turtle.digUp()
        sleep(0.5)
    end
    turtle.up()
    wallCheck(block)
    if g%5 == 0 then
        turtle.select(torch)
        turtle.placeDown()
    end
    while turtle.detectUp() do
        turtle.digUp()
        sleep(0.5)
    end
    turtle.up()
    wallCheck(block)
    if not turtle.detectUp() then
        turtle.select(block)
        turtle.placeUp()
    end
    while turtle.detect() do
        turtle.dig()
        sleep(0.5)
    end
    turtle.forward()
    wallCheck(block)
    if not turtle.detectUp() then
        turtle.select(block)
        turtle.placeUp()
    end
    turtle.digDown()
    turtle.down()
    wallCheck(block)
    turtle.digDown()
    turtle.down()
    wallCheck(block)
    if not turtle.detectDown() then
        turtle.select(block)
        turtle.placeDown()
    end
    gone = g
    slotCheck(gone)
end

finished(gone)

Thursday, December 13, 2012

Computercraft Turtle Program

Just figured I'd share my turtle programs with you as I get them made. This first one is just a simple loop that you can use when the turtle is stationary and hooked up to a pipe or something feeding him with fuel. I use it as my startup script and have him hooked up to a cactus farm. It refuels him and when his fuel level goes up, he prints his current amount of fuel.

while true do                                                                   
  local current = turtle.getFuelLevel()                                         
  turtle.refuel()                                                               
  if current ~= turtle.getFuelLevel() then                                      
    print(turtle.getFuelLevel())                                                
  end                                                                           
end