Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- mon = peripheral.wrap("right")
- pipe = peripheral.wrap("back")
- craftings = {}
- function getCrafts()
- pipe.getCraftableItems()
- evt, craftings = os.pullEvent("craftable_items_return")
- end
- items= {}
- function getItems()
- pipe.getAvailableItems()
- evt, items = os.pullEvent("available_items_return")
- end
- resources = {"Lapis Lazuli","UU-Matter","Gold Ingot","Iron Ingot","Refined Iron","Redstone","Glowstone Dust","Cobblestone","Glass","Rubber","Coal Dust","Coal", "Sticky Resin","Oak Wood","Oak Wood Planks","Diamond","Uranium Cell","Uranium Ore", "Refined Uranium"}
- crafts = {"Copper Cable","2xIns. Gold Cable","Furnace","Iron Furnace","Electronic Circuit","RE-Battery","LV-Transformer","MV-Transformer","HV-Transformer"}
- solars = {"Solar Panel","High Voltage Solar Array","Medium Voltage Solar Array", "Low Voltage Solar Array"}
- gx,gy = mon.getSize()
- mon.setTextScale(0.5)
- mon.clear()
- function cbut(cx,cy,text,bcol,tcol)
- if bcol == nil then
- bcol = colors.black
- end
- if tcol == nil then
- tcol = colors.white
- end
- mon.setCursorPos(cx-1,cy)
- for a = 0, string.len(text)+1,1 do
- write(" ")
- end
- mon.setBackgroundColor(bcol)
- mon.setTextColor(tcol)
- mon.setCursorPos(cx,cy)
- mon.write(text)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- config = {}
- while true do
- getItems()
- getCrafts()
- x = 2
- y = 3
- cbut(x,y-1,"Resources")
- for v, k in pairs(items) do
- item = pipe.getItemName(k[1])
- size = k[2]
- s = string.format("%-8dx %15s", size,string.sub(item,0,15))
- for v2,k2 in pairs(resources) do
- if item == k2 then
- cbut(x,y,s)
- y = y+ 1
- if y >= gy/2-2 then
- y = 2
- x = x + 15
- end
- end
- end
- end
- x= 40
- y = 3
- cbut(x,y-1,"Craftings")
- for v, k in pairs(items) do
- item = pipe.getItemName(k[1])
- size = k[2]
- s = string.format("%-8dx %15s", size,string.sub(item,0,15))
- for v2,k2 in pairs(crafts) do
- if item == k2 then
- cbut(x,y,s)
- y = y+ 1
- if y >= gy/2-2 then
- y = 2
- x = x + 15
- end
- end
- end
- end
- x = 80
- y =3
- cbut(x,y-1,"Solars")
- for v, k in pairs(items) do
- item = pipe.getItemName(k[1])
- size = k[2]
- s = string.format("%-8dx %15s", size,string.sub(item,0,15))
- for v2,k2 in pairs(solars) do
- if item == k2 then
- cbut(x,y,s)
- y = y+ 1
- if y >= gy/2-2 then
- y = 2
- x = x + 15
- end
- end
- end
- end
- x = 2
- y = gy/2
- cbut(x,y-1,"Craftable")
- for v, k in pairs(craftings) do
- item = pipe.getItemName(k)
- s = string.format("%-20s",string.sub(item,0,15))
- if #config == 0 then
- table.insert(config,{["Name"]= s, ["X"] = x,["Y"] = y , ["State"] = 0})
- else
- for a,b in pairs(config) do
- if b["Name"]== s then
- if b["State"] == 0 then
- cbut(x,y,s,nil,colors.red)
- else
- cbut(x,y,s,nil,colors.green)
- end
- else
- table.insert(config,{["Name"]= s, ["X"] = x,["Y"] = y , ["State"] = 0})
- end
- end
- y = y+ 1
- if y >= gy-2 then
- y = gy/2
- x = x + 20
- end
- end
- end
- x = 1
- y = 1
- for v, k in pairs(config) do
- term.setCursorPos(x,y)
- term.write(string.format("%d" ,v))
- term.setCursorPos(x+4,y)
- term.write(k["Name"])
- term.setCursorPos(x+20,y)
- term.write(string.format("%d" ,k["X"]))
- term.setCursorPos(x+25,y)
- term.write(string.format("%d" ,k["Y"]))
- term.setCursorPos(x+30,y)
- term.write(string.format("%d" ,k["State"]))
- y = y + 1
- end
- evt, side, x,y = os.pullEvent("monitor_touch")
- for v, k in pairs(config) do
- if x >= k["X"] and x <= k["X"] + 15 and y == k["Y"] then
- if k["State"] == 0 then
- k["State"] = 1
- elseif k["State"] == 1 then
- k["State"] = 0
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement