Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function charToColor(code)
- if code == "0" then
- return colors.white
- elseif code == "1" then
- return colors.orange
- elseif code == "2" then
- return colors.magenta
- elseif code == "3" then
- return colors.lightBlue
- elseif code == "4" then
- return colors.yellow
- elseif code == "5" then
- return colors.lime
- elseif code == "6" then
- return colors.pink
- elseif code == "7" then
- return colors.gray
- elseif code == "8" then
- return colors.lightGray
- elseif code == "9" then
- return colors.cyan
- elseif code == "a" then
- return colors.purple
- elseif code == "b" then
- return colors.blue
- elseif code == "c" then
- return colors.brown
- elseif code == "d" then
- return colors.green
- elseif code == "e" then
- return colors.red
- elseif code == "f" then
- return colors.black
- else
- return nil
- end
- end
- function drawPixel(x,y,color)
- term.setCursorPos(x,y)
- term.setBackgroundColor(color)
- write(" ")
- end
- function pixel(color,ch)
- term.setBackgroundColor(color)
- write(ch)
- end
- local me = peripheral.wrap("back")
- term.clear()
- term.setCursorPos(1,1)
- --manual
- posY = -1
- filename = "block_colors.txt"
- --auto
- blockID = {}
- colorID = {}
- screenSize = 0
- if fs.exists(filename) then
- print("file exist loading...")
- sleep(1)
- file = fs.open(filename, "r")
- switch = true
- line = file.readLine()
- while line ~= nil do
- if switch then
- table.insert(blockID,line)
- print("wczytano: " ..line .." do blockID")
- switch = false
- else
- table.insert(colorID,line)
- term.setTextColor(charToColor(line))
- print("wczytano: " ..line .." do colorID")
- term.setTextColor(charToColor("0"))
- switch = true
- end
- line = file.readLine()
- end
- file.close()
- print("file loaded setting screen size...")
- sleep(1)
- end
- --ustawia rozmiar ekranu
- for i, block in pairs(me.scan()) do
- if block.x > screenSize then
- screenSize = block.x
- end
- end
- print("screen size: " ..screenSize)
- sleep(1)
- print("starting scanning!")
- sleep(1)
- tempBlockID = ""
- while true do
- term.setBackgroundColor(colors.black)
- term.clear()
- for i, block in pairs(me.scan()) do
- --evenevenlower
- tempBlockID = ""
- if block.name ~= "minecraft:air" and block.y == posY - 2 then
- term.setCursorPos(block.x + screenSize,block.z + screenSize)
- tempBlockID = ""
- for o, line in pairs(blockID) do
- if block.name == blockID[o] then
- tempBlockID = o
- end
- end
- if tempBlockID ~= "" then
- term.setBackgroundColor(colors.black)
- term.setTextColor(charToColor(colorID[tempBlockID]))
- write("\127")
- end
- end
- --evelower
- tempBlockID = ""
- if block.name ~= "minecraft:air" and block.y == posY - 1 then
- term.setCursorPos(block.x + screenSize,block.z + screenSize)
- tempBlockID = ""
- for o, line in pairs(blockID) do
- if block.name == blockID[o] then
- tempBlockID = o
- end
- end
- if tempBlockID ~= "" then
- term.setTextColor(colors.black)
- pixel(charToColor(colorID[tempBlockID]),"\127")
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- write("\191")
- end
- end
- --floor
- tempBlockID = ""
- if block.name ~= "minecraft:air" and block.y == posY then
- term.setCursorPos(block.x + screenSize,block.z + screenSize)
- for o, line in pairs(blockID) do
- if block.name == blockID[o] then
- tempBlockID = o
- end
- end
- if tempBlockID ~= "" then
- term.setTextColor(colors.gray)
- pixel(charToColor(colorID[tempBlockID]),"\127")
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- write("?")
- end
- end
- --walls
- tempBlockID = ""
- if block.name ~= "minecraft:air" and block.y == posY + 1 then
- term.setCursorPos(block.x + screenSize,block.z + screenSize)
- tempBlockID = ""
- for o, line in pairs(blockID) do
- if block.name == blockID[o] then
- tempBlockID = o
- end
- end
- if tempBlockID ~= "" then
- term.setTextColor(colors.white)
- pixel(charToColor(colorID[tempBlockID]),"\127")
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- write("X")
- end
- end
- --walls +1
- tempBlockID = ""
- if block.name ~= "minecraft:air" and block.y == posY + 2 then
- term.setCursorPos(block.x + screenSize,block.z + screenSize)
- tempBlockID = ""
- for o, line in pairs(blockID) do
- if block.name == blockID[o] then
- tempBlockID = o
- end
- end
- if tempBlockID ~= "" then
- term.setTextColor(colors.black)
- pixel(charToColor(colorID[tempBlockID])," ")
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.red)
- write("X")
- end
- end
- end
- --pozycja gracza
- term.setCursorPos(screenSize,screenSize)
- term.setBackgroundColor(term.getBackgroundColor())
- term.setTextColor(colors.red)
- write("\2")
- sleep(0.2)
- end
Add Comment
Please, Sign In to add comment