SHOW:
|
|
- or go back to the newest paste.
1 | - | -- Function to check if an item is in the discard list |
1 | + | |
2 | - | local function isItemToDiscard(itemName) |
2 | + | |
3 | - | local discardList = {"minecraft:cobblestone", "minecraft:andesite", "minecraft:granite", "minecraft:stone", "minecraft:diorite", "minecraft:redstone", "minecraft:dirt"} |
3 | + | |
4 | - | local lowercaseItemName = itemName:lower() -- Convert to lowercase for case-insensitive comparison |
4 | + | |
5 | - | for _, item in ipairs(discardList) do |
5 | + | |
6 | - | if lowercaseItemName == item then |
6 | + | |
7 | - | return true |
7 | + | |
8 | local item = turtle.getItemDetail(slot) | |
9 | if item and turtle.select(slot) and turtle.refuel(1) then | |
10 | - | return false |
10 | + | |
11 | turtle.select(1) | |
12 | return | |
13 | end | |
14 | slot = slot + 1 | |
15 | end | |
16 | print("No fuel found. Please refuel the turtle.") | |
17 | os.shutdown() | |
18 | end | |
19 | end | |
20 | ||
21 | -- Parse the command line argument for the length of the mining area | |
22 | local args = {...} | |
23 | local length = tonumber(args[1]) or 0 | |
24 | ||
25 | print("Length of Mining Area:", length) -- Print the parsed length | |
26 | ||
27 | if length <= 0 then | |
28 | print("Usage: myprogram <length>") | |
29 | return | |
30 | end | |
31 | ||
32 | ||
33 | - | local function dropUselessItems() |
33 | + | |
34 | - | for slot = 1, 16 do |
34 | + | |
35 | - | local item = turtle.getItemDetail(slot) |
35 | + | |
36 | - | if item and isItemToDiscard(item.name) then |
36 | + | |
37 | - | turtle.select(slot) |
37 | + | |
38 | - | turtle.drop() |
38 | + | turtle.forward() |
39 | turtle.digUp() | |
40 | ||
41 | - | turtle.select(1) |
41 | + | blocksMined = blocksMined + 1 |
42 | ||
43 | -- Check if we've reached the specified length | |
44 | if blocksMined >= length then | |
45 | break | |
46 | end | |
47 | end | |
48 |