Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- --Monitor
- --width = 5 Blocks
- --height = 4 Blocks
- --peripherals
- local monSide = "back"
- local senSide = "right"
- --sensor coords
- local senX = -2
- local senY = 0
- local senZ = 0
- --customization Options
- local Bcol = colors.lightGray
- --customized Screen Options (Max: 16)
- Items = {"Glass","UU-Matter","Cobblestone"}
- mon = peripheral.wrap(monSide)
- sen = sensor.wrap(senSide)
- local xMax,yMax = mon.getSize()
- if #Items > 16 then
- print("zu viele Items im customized Screen!")
- end
- Item = {}
- for i = 1,#Items do
- Item[i] = {"_","_",Items[i]}
- end
- function Bg(xP1,yP1,xP2,yP2,col)
- mon.setBackgroundColor(col)
- for xPos = xP1,xP2 do
- for yPos = yP1,yP2 do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- end
- function JoJa(xP,yP)
- mon.setCursorPos(xP,yP)
- mon.setBackgroundColor(colors.gray)
- mon.setTextColor(colors.cyan)
- mon.write("Jo")
- mon.setTextColor(colors.orange)
- mon.write("Ja ")
- mon.setTextColor(colors.lightGray)
- mon.write("Productions")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- function Bstart()
- Bg(1,1,xMax,yMax,colors.lightGray)
- Bg(xMax/2-9,5,xMax/2+8,7,colors.gray)
- JoJa(xMax/2-8,6)
- mon.setCursorPos(xMax/2-7,10)
- mon.setTextColor(colors.white)
- Bg(xMax/2-9,9,xMax/2+8,11,colors.cyan)
- mon.setCursorPos(xMax/2-8,10)
- mon.write("ME-System Reader")
- mon.setBackgroundColor(colors.lightGray)
- mon.setCursorPos(2,yMax-2)
- mon.write("Bildschirmgroesse:")
- mon.setCursorPos(2,yMax-1)
- mon.write("-Breite: 5 Bloecke")
- mon.setCursorPos(2,yMax)
- mon.write("-Hoehe: 4 Bloecke")
- Bg(8,14,xMax-9,17,colors.red)
- mon.setCursorPos(9,15)
- mon.write("Copyright by JoJa Productions")
- mon.setCursorPos(9,16)
- mon.write("Weitergabe nicht gestattet!")
- mon.setBackgroundColor(colors.gray)
- mon.setCursorPos(12,19)
- mon.write("Klicke um fortzufahren...")
- event = os.pullEvent("monitor_touch")
- end
- function drawB(xP1,yP1,xP2,yP2,col,txt)
- mon.setBackgroundColor(col)
- for xPos = xP1,xP2 do
- for yPos = yP1,yP2-1 do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- mon.setCursorPos((xP1+xP2)/2-#txt/2,(yP1+yP2)/2)
- mon.write(txt)
- end
- function getDataMenue()
- ziele = sen.getTargets()
- for k,v in pairs(ziele) do
- if v.Name == "ME Wireless Access Point"
- and v.Position.X == senX
- and v.Position.Y == senY
- and v.Position.Z == senZ
- then
- details = sen.getTargetDetails(k)
- bItemarten = details.UsedTypes
- fItemarten = details.FreeTypes
- fSpeicherplatz = details.FreeCount*(-1)
- end
- end
- end
- function Menue()
- Bg(1,1,xMax,yMax,Bcol)
- Bg(2,3,xMax-1,7,colors.gray)
- JoJa(xMax/2-8,1)
- mon.setBackgroundColor(colors.gray)
- mon.setCursorPos(3,4)
- mon.write("Benutzte Itemarten: "..bItemarten.." Arten")
- mon.setCursorPos(3,5)
- mon.write("Freie Itemarten: "..fItemarten.." Arten")
- mon.setCursorPos(3,6)
- mon.write("Freier Speicherplatz: "..fSpeicherplatz.." Items")
- Bg(2,9,xMax-1,13,colors.gray)
- drawB(3,10,xMax/2-1,13,colors.lime,"ShowAllItems")
- drawB(xMax/2+1,10,xMax-2,13,colors.red,"CustomItems")
- Bg(2,15,xMax-1,17,colors.gray)
- mon.setTextColor(colors.white)
- mon.setCursorPos(3,16)
- mon.write("Klicke auf den Monitor um zu aktualiesieren...")
- end
- function ShowAllItems()
- while true do
- Bg(1,1,xMax,yMax,Bcol)
- Bg(2,2,xMax-1,yMax-7,colors.gray)
- Bg(2,yMax-5,xMax-1,yMax-1,colors.gray)
- drawB(3,yMax-4,17,yMax-1,colors.blue," Seite zurueck")
- drawB(xMax-17,yMax-4,xMax-2,yMax-1,colors.blue," naechste Seite")
- drawB(19,yMax-4,xMax-19,yMax-1,colors.red," Hauptmenue")
- ziele = sen.getTargets()
- for k,v in pairs(ziele) do
- if v.Name == "ME Wireless Access Point"
- and v.Position.X == senX
- and v.Position.Y == senY
- and v.Position.Z == senZ
- then
- details = sen.getTargetDetails(k)
- MaxP= math.ceil(details.UsedTypes/16)
- zP1 = cP*16-15
- zP2 = cP*16
- if zP2 > details.UsedTypes then
- zP2 = details.UsedTypes
- end
- b = 0
- mon.setBackgroundColor(colors.gray)
- for i = zP1,zP2 do
- mon.setCursorPos(3,3+b)
- mon.write(i.." "..details.Items[i].Name)
- mon.setCursorPos(30,3+b)
- mon.write("Anzahl: "..details.Items[i].Size)
- b=b+1
- end
- end
- end
- event,_,xPos,yPos = os.pullEvent("monitor_touch")
- if xPos >= 3 and xPos <= 17 and yPos >= yMax-4 and yPos <= yMax-1 then
- cP = cP-1
- end
- if xPos >= xMax-17 and xPos <= xMax-2 and yPos >= yMax-4 and yPos <= yMax-1 then
- cP = cP+1
- end
- if cP > MaxP then
- cP = 1
- elseif cP < 1 then
- cP = MaxP
- end
- if xPos >= 19 and xPos <= xMax-19 and yPos >= yMax-4 and yPos <= yMax -1 then
- break
- end
- end
- end
- function customItems()
- while true do
- Bg(1,1,xMax,yMax,Bcol)
- Bg(2,2,35,3+#Item,colors.gray)
- Bg(40,2,47,3+#Item,colors.gray)
- Bg(18,yMax-5,xMax-18,yMax-1,colors.gray)
- drawB(19,yMax-4,xMax-19,yMax-1,colors.red," Hauptmenue")
- ziele = sen.getTargets()
- for k,v in pairs(ziele) do
- if v.Name == "ME Wireless Access Point"
- and v.Position.X == senX
- and v.Position.Y == senY
- and v.Position.Z == senZ
- then
- details = sen.getTargetDetails(k)
- for i = 1,details.UsedTypes do
- for b = 1,#Item do
- if details.Items[i].Name == Item[b][3] then
- if Item[b][1] ~= "_" then
- Item[b][2] = Item[b][1]
- end
- Item[b][1] = details.Items[i].Size
- end
- end
- end
- mon.setBackgroundColor(colors.gray)
- for i = 1,#Item do
- mon.setCursorPos(3,2+i)
- mon.write(i.." "..Item[i][3])
- mon.setCursorPos(18,2+i)
- mon.write("Anzahl: "..Item[i][1])
- if Item[i][2] ~= "_" then
- mon.setCursorPos(41,2+i)
- mon.write(Item[i][1]-Item[i][2])
- else
- mon.setCursorPos(46,2+i)
- mon.write("_")
- end
- end
- end
- end
- event,_,xPos,yPos = os.pullEvent("monitor_touch")
- if xPos >= 19 and xPos <= xMax-19 and yPos >= yMax-4 and yPos <= yMax-1 then
- break
- end
- end
- end
- Bstart()
- while true do
- getDataMenue()
- Menue()
- event,_,xPos,yPos = os.pullEvent("monitor_touch")
- if xPos >= 3 and xPos <= xMax/2-1 and yPos >= 10 and yPos <= 13 then
- drawB(3,10,xMax/2-1,13,colors.green,"ShowAllItems")
- sleep(.1)
- cP = 1
- ShowAllItems()
- elseif xPos >= xMax/2+1 and xPos <= xMax-2 and yPos >= 10 and yPos <= 13 then
- drawB(xMax/2+1,10,xMax-2,13,colors.magenta,"CustomItems")
- sleep(.1)
- customItems()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment