Added new scripts and sorted things
This commit is contained in:
		
							
								
								
									
										49
									
								
								Stone_Factory/brickcrafter.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								Stone_Factory/brickcrafter.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
--[[Stone Brick Factory program by Al Sweigart
 | 
			
		||||
Gets stone from furnace to craft stone bricks, turtle 2 of 2]]
 | 
			
		||||
 | 
			
		||||
print('Starting stone brick crafting program')
 | 
			
		||||
 | 
			
		||||
local NUM_FURNACES = 5
 | 
			
		||||
local brickCount = 0
 | 
			
		||||
while true do
 | 
			
		||||
    -- check turtle's fuel
 | 
			
		||||
    if turtle.getFuelLevel() < (2 * NUM_FURNACES) then
 | 
			
		||||
        error('Turtle needs more fuel!')
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    turtle.select(1) -- put stone in slot 1
 | 
			
		||||
 | 
			
		||||
    -- start collecting stone from furnaces
 | 
			
		||||
    for i = 1, NUM_FURNACES do
 | 
			
		||||
        turtle.suckUp(64 - turtle.getItemCount(1)) -- get stone from furnace
 | 
			
		||||
        if turtle.getItemCount(1) == 64 then
 | 
			
		||||
            break -- stop once there are 64 stone blocks
 | 
			
		||||
        end
 | 
			
		||||
        if i ~= NUM_FURNACES then
 | 
			
		||||
            turtle.back() -- move to next furnace
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    -- craft stone bricks
 | 
			
		||||
    if turtle.getItemCount(1) == 64 then
 | 
			
		||||
        turtle.transferTo(2, 16) -- put in slot 2
 | 
			
		||||
        turtle.transferTo(5, 16) -- put in slot 5
 | 
			
		||||
        turtle.transferTo(6, 16) -- put in slot 6
 | 
			
		||||
        turtle.select(16) -- stone brick to go in slot 16
 | 
			
		||||
        turtle.craft() -- craft stone bricks
 | 
			
		||||
        brick.Count = brickCount + 64
 | 
			
		||||
        print('Total stone bricks: ' .. brickCount)
 | 
			
		||||
    else
 | 
			
		||||
        print('Not enough stones yet. Sleeping...')
 | 
			
		||||
        os.sleep(120) -- wait for 2 minutes
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    -- move back to chest (by first furnace)
 | 
			
		||||
    for i = 1, NUM_FURNACES - 1 do
 | 
			
		||||
        turtle.forward()
 | 
			
		||||
    end
 | 
			
		||||
    turtle.turnLeft() -- face chest
 | 
			
		||||
    turtle.select(16) -- select stone bricks
 | 
			
		||||
    turtle.drop() -- put stone bricks into chest
 | 
			
		||||
    turtle.turnRight() -- face generator again
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										46
									
								
								Stone_Factory/cobminer.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								Stone_Factory/cobminer.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
--[[Stone Brick Factory program by Al Sweigart
 | 
			
		||||
Mines cobblestone from a generator, trutle 1 of 2]]
 | 
			
		||||
 | 
			
		||||
os.loadAPI('hare') -- load the hare module
 | 
			
		||||
local numToDrop
 | 
			
		||||
local NUM_FURNACES = 5
 | 
			
		||||
 | 
			
		||||
print('Starting mining program...')
 | 
			
		||||
while true do
 | 
			
		||||
    -- mine cobblestone
 | 
			
		||||
    if turtle.detect() then
 | 
			
		||||
        print('Cobblestone detected. Mining...')
 | 
			
		||||
        turtle.dig() -- Mine cobblestone
 | 
			
		||||
    else
 | 
			
		||||
        print('No cobblestone detected. Sleeping...')
 | 
			
		||||
        os.sleep(0.5) -- half-second pause
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    -- check for a full stack of cobblestone
 | 
			
		||||
    hare.selectItem('minecraft:cobblestone')
 | 
			
		||||
    if turtle.getItemCount() == 64 then
 | 
			
		||||
        -- check turtle's fuel
 | 
			
		||||
        if turtle.getFuelLevel() < (2 * NUM_FURNACES) then
 | 
			
		||||
            error('Turtle needs more fuel!')
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        -- put cobblestone in furnaces
 | 
			
		||||
        print('Dropping off cobblestone...')
 | 
			
		||||
        for furnacesToFill = NUM_FURNACES, 1, -1 do
 | 
			
		||||
            turtle.back() -- move over furnace
 | 
			
		||||
            numToDrop = math.floor(turtle.getItemCount() / furnacesToFill)
 | 
			
		||||
            turtle.dropDown(numToDrop) -- put cobblestone in furnace
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        -- move back to cobblestone generator
 | 
			
		||||
        for moves = 1, NUM_FURNACES do
 | 
			
		||||
            turtle.forward()
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if turtle.getItemCount() > 0 then
 | 
			
		||||
            print('All furnaces full. Sleeping...')
 | 
			
		||||
            os.sleep(300) -- wait for five minutes
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user