Bugfixes and print for puke function
This commit is contained in:
parent
e8d03a1211
commit
d7226d2cac
@ -1,7 +1,6 @@
|
|||||||
--[[Function Module program by Al Sweigart
|
--[[Function Module program by Al Sweigart
|
||||||
Provides useful utility functions.]]
|
Provides useful utility functions.]]
|
||||||
|
|
||||||
|
|
||||||
-- selectItem() selects the inventory
|
-- selectItem() selects the inventory
|
||||||
-- slot with the named item, returns
|
-- slot with the named item, returns
|
||||||
-- true if found and false if not
|
-- true if found and false if not
|
||||||
@ -35,7 +34,6 @@ function select_emptySlot()
|
|||||||
return false -- couldn't find empty space
|
return false -- couldn't find empty space
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- countInventory() returns the total
|
-- countInventory() returns the total
|
||||||
-- number of a given minecraft id item in the inventory
|
-- number of a given minecraft id item in the inventory
|
||||||
function count_inventory(minecraft_id, times)
|
function count_inventory(minecraft_id, times)
|
||||||
@ -50,7 +48,6 @@ function count_inventory(minecraft_id, times)
|
|||||||
return total
|
return total
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- selectAndPlaceDown() selects a slot with given
|
-- selectAndPlaceDown() selects a slot with given
|
||||||
-- minecraft id and places a block from it under the turtle
|
-- minecraft id and places a block from it under the turtle
|
||||||
function select_and_place_down(minecraft_id)
|
function select_and_place_down(minecraft_id)
|
||||||
@ -110,7 +107,6 @@ function build_wall(length, height)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- build_room() constructs four walls
|
-- build_room() constructs four walls
|
||||||
-- and a ceiling
|
-- and a ceiling
|
||||||
function build_room(length, width, height)
|
function build_room(length, width, height)
|
||||||
@ -135,7 +131,6 @@ function build_room(length, width, height)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- sweepField() moves acress the rows
|
-- sweepField() moves acress the rows
|
||||||
-- and columns of an area in front and
|
-- and columns of an area in front and
|
||||||
-- to the right of the turtle, calling
|
-- to the right of the turtle, calling
|
||||||
@ -186,7 +181,6 @@ function sweepField(length, width, sweepFunc)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--findBlock() spins around searching
|
--findBlock() spins around searching
|
||||||
--for the named block next to the turtle
|
--for the named block next to the turtle
|
||||||
function findBlock(name)
|
function findBlock(name)
|
||||||
@ -202,18 +196,18 @@ function findBlock(name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- puke() puke everything that is in the turtles
|
-- puke() puke everything that is in the turtles
|
||||||
-- inventory out in front of it (hopefully there is
|
-- inventory out in front of it (hopefully there is
|
||||||
-- a chest
|
-- a chest
|
||||||
function puke()
|
function puke()
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
turtle.select(i)
|
turtle.select(i)
|
||||||
|
result, block = turtle.inspect()
|
||||||
|
print("Puking out: " .. block['name'])
|
||||||
turtle.drop()
|
turtle.drop()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Check Fuel checks if the turtle has enough fuel.
|
-- Check Fuel checks if the turtle has enough fuel.
|
||||||
-- if not, it asks for fuel in slot 1 and refuels.
|
-- if not, it asks for fuel in slot 1 and refuels.
|
||||||
function check_fuel()
|
function check_fuel()
|
||||||
@ -229,20 +223,3 @@ function check_fuel()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- sort_items() stacks all items of the same ID
|
|
||||||
-- into one stack
|
|
||||||
function sort_items()
|
|
||||||
for i = 1, 16 do
|
|
||||||
turtle.select(i)
|
|
||||||
item1 = turtle.getItemDetail()
|
|
||||||
for j = i+1, 16 do
|
|
||||||
item2 = turtle.getItemDetail(j)
|
|
||||||
if item1 ~= nil and item2 ~= nil and item1['name'] == item2['name'] then
|
|
||||||
turtle.select(j)
|
|
||||||
turtle.transferTo(i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user