Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local PCol = colors.lightGray
- local SCol = colors.black
- local DCol = colors.gray
- local senSide = "top"
- local monSide = "front"
- local filename = "databank"
- local delaytime = 5
- local MaxRadius = 28
- local maxPlayer = 5
- local PosX = 2284
- local PosY = 68
- local PosZ = -767
- local z = 7
- local C = 0
- local Button = {}
- Button[1] = {81,37,95,42,"Change Color",colors.cyan,false}
- Button[2] = {81,44,95,49,"Reset List" ,colors.red ,false}
- mon = peripheral.wrap(monSide)
- sen = sensor.wrap(senSide)
- mon.setTextScale(.5)
- xMax,yMax = mon.getSize()
- function ocFile()
- if fs.exists(filename) then
- data = fs.open(filename,"a")
- --Open File
- else
- data = fs.open(filename,"w")
- --Create new File
- 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")
- end
- function Background(col)
- mon.setBackgroundColor(col)
- for yPos = 1,yMax do
- for xPos = 1,xMax do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- end
- function Square(xP1,yP1,xP2,yP2,col)
- mon.setBackgroundColor(col)
- for yPos = yP1,yP2 do
- for xPos = xP1,xP2 do
- mon.setCursorPos(xPos,yPos)
- mon.write(" ")
- end
- end
- end
- function printButton()
- for i = 1,#Button do
- Square(Button[i][1],Button[i][2],Button[i][3],Button[i][4],Button[i][6])
- mon.setCursorPos((Button[i][1]+Button[i][3])/2-#Button[i][5]/2,(Button[i][2]+Button[i][4])/2)
- mon.write(Button[i][5])
- end
- end
- function checkButton(xP,yP)
- for i = 1,#Button do
- if xP >= Button[i][1] and xP <= Button[i][3] and
- yP >= Button[i][2] and yP <= Button[i][4] then
- Button[i][7] = true
- end
- end
- end
- function graph(Wert1,Wert2,xPos,yPos,xMax,col1,col2)
- mon.setBackgroundColor(colors.lightGray)
- for xP = xPos,xMax do
- mon.setCursorPos(xP,yPos)
- mon.write(" ")
- end
- i = Wert1/Wert2
- s = xMax-xPos
- mon.setBackgroundColor(colors.cyan)
- for xP = xPos,xPos+math.floor(s*i) do
- mon.setCursorPos(xP,yPos)
- mon.write(" ")
- end
- end
- while true do
- Background(PCol)
- JoJa(xMax/2-7,1)
- Square(2,3,xMax-1,yMax-1,DCol)
- Square(3,4,xMax-2,yMax-2,SCol)
- mon.setCursorPos(4,5)
- mon.setTextColor(colors.white)
- mon.write("Spieler in Reichweite:")
- printButton()
- mon.setBackgroundColor(SCol)
- Pos = 0
- ziele = sen.getTargets()
- for k,v in pairs(ziele) do
- if v.Name == "Player" then
- if Pos <= z*maxPlayer-1 then
- mon.setCursorPos(4,7+Pos)
- mon.write("Name: "..k)
- mon.setCursorPos(5,8+Pos)
- mon.write("X: "..PosX + v.Position.X)
- mon.setCursorPos(5,9+Pos)
- mon.write("Y: "..PosY + v.Position.Y)
- mon.setCursorPos(5,10+Pos)
- mon.write("Z: "..PosZ + v.Position.Z)
- mon.setCursorPos(5,11+Pos)
- Entfernung = math.sqrt(v.Position.X^2+v.Position.Y^2+v.Position.Z^2)
- mon.write("Entfernung: "..Entfernung)
- graph(Entfernung,MaxRadius,5,12+Pos,15)
- mon.setBackgroundColor(SCol)
- end
- Pos = Pos+z
- end
- end
- --sleep(delaytime)
- event,_,xP,yP = os.pullEvent("monitor_touch")
- checkButton(xP,yP)
- if Button[1][7] then
- C = C+1
- if C > 15 then
- C = 0
- end
- PCol = 2^C
- Button[1][7] = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment