Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Components Definition
- component = require("component")
- computer = require("computer")
- event = require("event")
- term = require("term")
- sides = require("sides")
- RScolors = require("colors")
- keyboard = require("keyboard")
- gpu = component.gpu
- trans = component.proxy(component.get("87c2"))
- -- Variables Definition
- Sleep_Loop = 2
- colors = { black = 0x000000, white = 0xf8f8ff, blue = 0x0000ff, lightGray = 0xd9d9d9, red = 0xff0000,
- purple = 0x9b30ff, carrot = 0xffa500, magenta = 0xcd00cd, lightBlue = 0x87cefa, yellow = 0xffff00,
- lime = 0x32cd32, pink = 0xffc0cb, gray = 0x696969, brown = 0x8b4500, green = 0x006400, cyan = 0x008b8b,
- olive = 0x6b8e23, gold = 0x8b6914, orangered = 0xdb4e02, diamond = 0x0fa7c7,crimson = 0xaf002a,fuchsia = 0xfd3f92,
- folly = 0xff004f, frenchBlue = 0x0072bb, lilac = 0x86608e, flax = 0xeedc82, darkGray = 0x563c5c,
- englishGreen = 0x1b4d3e, eggplant = 0x614051, deepPink = 0xff1493, ruby = 0x843f5b, orange = 0xf5c71a,
- lemon = 0xffd300, darkBlue = 0x002e63, bitterLime = 0xbfff00 }
- button = {}
- hammer = sides.north
- chest = sides.top
- siev = sides.south
- borderColor = colors.orange
- TitleBorder = colors.lightBlue
- buttonColor = colors.white
- -- Functions
- function draw_text(x, y, text, text_color, bg_color)
- if text_color == nil then text_color = colors.white end
- if bg_color == nil then bg_color = colors.black end
- gpu.setBackground(bg_color)
- gpu.setForeground(text_color)
- gpu.set(x,y,text)
- gpu.setBackground(colors.black)
- gpu.setForeground(colors.white)
- end
- function draw_line(x, y, length, height, bg_color)
- gpu.setBackground(bg_color)
- gpu.fill(x,y,length,height," ")
- gpu.setBackground(colors.black)
- end
- function draw_button(x, y, length, height, name, func, txt_color, bg_color, Active_bg_color, Active_name)
- if Active_bg_color == nil then
- Active_bg_color = bg_color
- end
- if Active_name == nil then
- Active_name = name
- end
- if button[name] == nil then
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = false
- button[name]["xmin"] = x
- button[name]["ymin"] = y
- button[name]["xmax"] = (x + length)-1
- button[name]["ymax"] = (y + height)-1
- end
- if height > 1 then
- yt = (y + tonumber(string.format("%.f",height/2))-1)
- end
- if button[name]["active"] == false then
- if string.len(name) < length then
- xt = x + ((length - string.len(name)) / 2)
- end
- draw_line(x, y, length, height, bg_color)
- draw_text(xt, yt, name, txt_color, bg_color)
- else
- if string.len(Active_name) < length then
- xt = x + ((length - string.len(Active_name)) / 2)
- end
- draw_line(x, y, length, height, Active_bg_color)
- draw_text(xt, yt, Active_name, txt_color, Active_bg_color)
- end
- end
- function Progress_Bar(x, y , length, height , bg_empty_color, bg_full_color, progress)
- end
- function checkxy(x, y)
- for name, data in pairs(button) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["func"]()
- return true
- end
- end
- end
- return false
- end
- function getClick()
- local _, _, x, y = event.pull(Sleep_Loop,touch)
- if x == nil or y == nil then
- local h, w = gpu.getResolution()
- gpu.set(h, w, ".")
- gpu.set(h, w, " ")
- else
- checkxy(x,y)
- end
- end
- function checkCobble()
- top = trans.getInventorySize(chest)
- for i = 1,top do
- inventory = trans.getStackInSlot(chest, i)
- if inventory ~= nil then
- for k,v in pairs(inventory) do
- if k == "name" then
- if v == "minecraft:cobblestone" then
- trans.transferItem(chest, hammer, 1,i,1)
- os.sleep(.5)
- trans.transferItem(hammer, chest)
- end
- end
- end
- end
- end
- end
- function checkGravel()
- checkCobble()
- top = trans.getInventorySize(chest)
- for i = 1,top do
- inventory = trans.getStackInSlot(chest, i)
- if inventory ~= nil then
- for k,v in pairs(inventory) do
- if k == "name" then
- if v == "minecraft:gravel" then
- trans.transferItem(chest, siev, 1, i, 1)
- os.sleep(.5)
- end
- end
- end
- end
- end
- end
- function checkSand()
- top = trans.getInventorySize(chest)
- for i = 1,top do
- inventory = trans.getStackInSlot(chest, i)
- if inventory ~= nil then
- for k,v in pairs(inventory) do
- if k == "name" then
- if v == "minecraft:cobblestone" then
- trans.transferItem(chest, hammer, 1,i, 1)
- os.sleep(.5)
- trans.transferItem(hammer, chest)
- elseif v == "minecraft:gravel" then
- trans.transferItem(chest,hammer, 1,i,1)
- os.sleep(.5)
- trans.transferItem(hammer, chest)
- end
- if v == "minecraft:sand" then
- trans.transferItem(chest, siev, 1,i, 1)
- os.sleep(.5)
- end
- end
- end
- end
- end
- end
- function Status()
- if args[1] == "sand" then
- checkSand()
- elseif args[1] == "gravel" then
- checkGrav()
- end
- end
- function border_Lines()
- -- title borders
- draw_line(10,3,41,1,TitleBorder)
- draw_line(50,3,1,4,TitleBorder)
- draw_line(10,7,41,1,TitleBorder)
- draw_line(10,3,1,4,TitleBorder)
- -- monitoring borders
- -- ext borders
- draw_line(1,1,61,1,borderColor)
- draw_line(1,1,1,30,borderColor)
- draw_line(1,30,61,1,borderColor)
- draw_line(60,1,1,60,borderColor)
- end
- function toggle_Sand()
- if button["Sand"]["active"] == false then
- button["Sand"]["active"] = true
- else
- button["Sand"]["active"] = false
- end
- end
- function toggle_Gravel()
- if button["Gravel"]["active"] == false then
- button["Gravel"]["active"] = true
- else
- button["Gravel"]["active"] = false
- end
- end
- function toggle_Cobble()
- if button["Cobblestone"]["active"] == false then
- button["Cobblestone"]["active"] = true
- else
- button["Cobblestone"]["active"] = false
- end
- end
- function reboot()
- computer.shutdown(true)
- end
- function init()
- term.clear()
- gpu.setResolution(60,30)
- draw_text(21,5, "Selector for sieves")
- end
- -- Main Code
- init()
- while true do
- draw_button(10,10,16,3,"Cobblestone",toggle_Cobble,colors.black,buttonColor,colors.green,"Cobble")
- button["Cobblestone"]["displayed"] = true
- draw_button(36,10,16,3,"Sand",toggle_Sand,colors.black,buttonColor,colors.green,"Sand")
- button["Sand"]["displayed"] = true
- draw_button(21,15,20,3,"Gravel",toggle_Gravel,colors.black,buttonColor,colors.green,"Gravel")
- button["Gravel"]["displayed"] = true
- border_Lines()
- if button["Sand"]["active"] == true then checkSand() end
- if button["Cobblestone"]["active"] == true then checkCobble() end
- if button["Gravel"]["active"] == true then checkGravel() end
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement