Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monSide = "back"
- local Bcolor = colors.blue
- local senSide = "top"
- os.loadAPI("ocs/apis/sensor")
- mon = peripheral.wrap(monSide)
- sen = sensor.wrap(senSide)
- local xMax,yMax = mon.getSize()
- function bdraw(xp1,yp1,xp2,yp2,txt,col)
- if col==nil then
- mon.setBackgroundColor(colors.lime)
- else
- mon.setBackgroundColor(col)
- end
- mon.setCursorPos(xp1,yp1)
- for i=1,(xp2-xp1) do
- mon.write("-")
- end
- mon.setCursorPos(xp1,yp2)
- for i=1,(xp2-xp1) do
- mon.write("-")
- end
- for i=yp1,yp2 do
- mon.setCursorPos(xp1,i)
- mon.write("|")
- mon.setCursorPos(xp2,i)
- mon.write("|")
- end
- for i=(yp1+1),(yp2-1) do
- mon.setCursorPos((xp1+1),i)
- for j=(xp1+1),(xp2-1) do
- mon.write(" ")
- j = j+1
- end
- i = i+1
- end
- if math.floor(((xp2-xp1)-#txt)/2)==0 then
- xp1 = xp1+1
- end
- mon.setCursorPos(math.floor(((xp2-xp1)-#txt)/2)+xp1,math.floor((yp2-yp1)/2)+yp1)
- --print(math.floor(((xp2-xp1)-#txt)/2))
- mon.write(txt)
- end
- function Background()
- mon.setBackgroundColor(Bcolor)
- for yPos=1,yMax do
- for xPos=1,xMax do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- end
- Background()
- mon.clear()
- Itemname = {}
- Itemmenge = {}
- while true do
- mon.setCursorPos(xMax/2-14,1)
- mon.setBackgroundColor(colors.black)
- mon.write("ME-Uebersicht made by ")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.cyan)
- mon.write("Nike622000")
- mon.setBackgroundColor(Bcolor)
- mon.setTextColor(colors.white)
- bdraw(xMax-14,yMax-2,xMax,yMax,"Aktualisieren",colors.cyan)
- event,_,xPos,yPos = os.pullEvent()
- mon.setBackgroundColor(colors.white)
- if event=="monitor_touch" then
- if xPos>=xMax-14 and xPos<=xMax and yPos>=yMax-2 and yPos<=yMax then
- Background()
- for yPos = 2,yMax do
- mon.setBackgroundColor(Bcolor)
- mon.setTextColor(colors.white)
- mon.setCursorPos(xMax/2+5,yPos)
- mon.write("|")
- end
- ziele = sen.getTargets()
- for k,v in pairs(ziele) do
- if v.Name == "ME Wireless Access Point"
- and v.Position.X==-3
- and v.Position.Y==-1
- and v.Position.Z==0
- then
- details = sen.getTargetDetails(k)
- for i = 1,#Itemname do
- mon.setBackgroundColor(Bcolor)
- mon.setTextColor(colors.white)
- mon.setCursorPos(27,2+i)
- --mon.write(Itemname[i])
- mon.setCursorPos(48,2+i)
- --mon.write(Itemmenge[i])
- end
- if #Itemmenge <= 0 then
- print("1")
- d = false
- end
- for i = 1,#details.Items do
- mon.setCursorPos(50,2+i)
- if d then
- bilanz = details.Items[i].Size-Itemmenge[i]
- if bilanz > 0 then
- mon.setTextColor(colors.lime)
- end
- if bilanz < 0 then
- mon.setTextColor(colors.red)
- end
- if bilanz == 0 then
- mon.setTextColor(colors.yellow)
- end
- mon.write(bilanz)
- end
- Itemname[i] = details.Items[i].Name
- Itemmenge[i] = details.Items[i].Size
- print("2")
- mon.setTextColor(colors.white)
- mon.setCursorPos(2,2+i)
- mon.write(details.Items[i].Name)
- mon.setCursorPos(27,2+i)
- mon.write(details.Items[i].Size)
- end
- d = true
- end
- end
- d = true
- end
- end
- end
Add Comment
Please, Sign In to add comment