Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Constants and Variables--
- SLOT_COUNT = 16
- unwantedItemsMenu = { cobble="minecraft:cobblestone",
- cobblestone="minecraft:cobblestone",
- dirt="minecraft:dirt",
- stone="minecraft:stone",
- smoothstone="minecraft:stone",
- andesite="minecraft:stone",
- diorite="minecraft:stone",
- granite="minecraft:stone",
- marble="PLACEHOLDER",
- slate= { "rustic:slate",
- "quark:slate"
- }
- }
- list = {}
- -- /Constants and Variables
- -- Command Line Args
- targs = {...}
- function elementIterator(collection)
- local index = 0
- local count = #collection
- return function()
- index = index + 1
- if index <= count then
- return collection[index]
- end
- end
- end
- function join(src,dest)
- if src == dest then
- local temp = {}
- join(src,temp)
- join(temp,dest)
- else
- for k,v in pairs(src) do
- -- print("src entry:",k,v)
- -- if #dest > 0 then print("dest@len:", #dest,dest[#dest]) end
- dest[#dest+1] = v
- -- print("dest@new len:", #dest,dest[#dest])
- -- os.sleep(5)
- end
- end
- end
- function selectFromTable(input, reference, output)
- local entries = {}
- for k,v in pairs(input) do
- if reference[input[k]]~=nil then
- -- print("entry found in input: ", input[i], " = ", reference[input[i]]) -- TEST CODE
- if type(reference[input[k]]) == "table" then
- -- print(#reference[input[k]]," entries found for",input[k]) -- TEST CODE
- join(reference[input[k]],entries)
- else
- join({reference[input[k]]},entries) --should be equivalent to the below, but using join
- --entries[(#entries+1)] = reference[input[k]]
- end
- end
- -- for k,v in ipairs(unwantedItems) do
- -- if targs[i]==k then entries = entries + v end
- -- end
- end
- join(entries,output)
- --return output
- end
- function listify(input, reference)
- local entries = {}
- for i=1,#input do
- if reference[input[i]]~=nil then
- -- print("entry found in input: ", input[i], " = ", reference[input[i]]) -- TEST CODE
- if type(reference[input[i]]) == "table" then
- print(#reference[input[i]]," entries found for ", input[i]) -- TEST CODE
- else
- entries[i] = reference[input[i]]
- end
- end
- -- for k,v in ipairs(unwantedItems) do
- -- if targs[i]==k then entries = entries + v end
- -- end
- end
- list = entries
- return list
- end
- function printList(list)
- for k,v in pairs(list) do
- print(k,v)
- end
- end
- function dropUnwanted(list)
- currSlot=turtle.getSelectedSlot()
- for i=1,SLOT_COUNT do
- for k,v in pairs(list) do
- if turtle.getItemCount(i) ~= 0 and turtle.getItemDetail(i).name == v then
- if turtle.getItemSpace(i) == 0 then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- end
- turtle.select(currSlot)
- end
- --run scripts to test here
- -- printList(unwantedItems)
- -- printList(listify(targs,unwantedItems))
- selectFromTable(targs, unwantedItemsMenu, list)
- printList(list)
- dropUnwanted(list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement