Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- colors = {"white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "light_gray", "cyan", "purple", "blue", "brown", "green", "red", "black"}
- currentColor = 1
- colorMap = {}
- waitTime = 0
- function UpdateLog()
- file = fs.open("log", "w")
- file.writeLine(currentColor)
- for i = 1, 16, 1 do
- if colorMap[i] == nil then
- file.writeLine()
- else
- file.writeLine(colorMap[i])
- end
- end
- file.close()
- end
- function ReadFile()
- if arg[2] ~= nil then
- currentColor = tonumber(arg[1])
- UpdateLog()
- else
- file = fs.open("log", "r")
- if file == nil then
- UpdateLog()
- else
- currentColor = tonumber(file.readLine())
- for i = 1, 16, 1 do
- x = file.readLine()
- if x ~= nil and x ~= "" then
- colorMap[i] = tonumber(x)
- end
- end
- file.close()
- end
- end
- end
- function CheckColor(color)
- item = turtle.getItemDetail()
- if item ~= nil and item.name == "minecraft:"..colors[color].."_wool" then
- return true
- end
- return false
- end
- function FindColor(color)
- if CheckColor(color) then
- return true
- end
- if colorMap[color] ~= nil then
- turtle.select(colorMap[color])
- if CheckColor(color) then
- return true
- end
- end
- for i = 1, 16, 1 do
- turtle.select(i)
- if CheckColor(color) then
- colorMap[color] = i
- return true
- end
- end
- return false
- end
- if arg[1] ~= nil then
- waitTime = tonumber(arg[1])
- end
- ReadFile()
- while FindColor(currentColor) do
- turtle.dropDown(1)
- currentColor = currentColor + 1
- if currentColor > 16 then
- currentColor = 1
- end
- UpdateLog()
- if waitTime > 0 then
- sleep(waitTime)
- end
- end
- print("Need more "..colors[currentColor].." wool")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement