Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("top")
- mon = peripheral.wrap("back")
- x,y = mon.getSize()
- akzeptierende = {}
- admins = {}
- function updateAdmins()
- admins = {}
- file = fs.open("admins.tbl","r")
- line = file.readLine()
- while line do
- admins[#admins+1] = line
- line = file.readLine()
- end
- file.close()
- end
- function arrayContains(table,value)
- for i=1,#table do
- if table[i] == value then
- return true
- end
- end
- return false
- end
- function update()
- akzeptierende = {}
- file = fs.open("akzeptierende.tbl","r")
- line = file.readLine()
- while line do
- akzeptierende[#akzeptierende+1] = line
- line = file.readLine()
- end
- file.close()
- end
- function monitor_touch()
- targets = sen.getTargets()
- counter = 0
- player = ""
- for k,v in pairs(targets) do
- if v.Name == "Player"
- and v.Position.X>=-1.5 and v.Position.X<=1.5
- and v.Position.Y>=-4 and v.Position.Y<=1
- and v.Position.Z>=1 and v.Position.Z<=3.5
- then
- counter = counter+1
- player = k
- end
- end
- if counter == 1 then
- if not arrayContains(akzeptierende,player) then
- file = fs.open("akzeptierende.tbl","a")
- file.write(player.."\n")
- file.close()
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.gray)
- txt = player .. ","
- mon.setCursorPos(1,5)
- for i=1,x do
- mon.write(" ")
- end
- mon.setCursorPos(1,6)
- for i=1,x do
- mon.write(" ")
- end
- mon.setCursorPos(math.floor((x-#txt)/2),5)
- mon.write(txt)
- txt = "Du hast nun akzeptiert"
- mon.setCursorPos(math.floor((x-#txt)/2),6)
- mon.write(txt)
- else
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.gray)
- txt = player .. ","
- mon.setCursorPos(1,5)
- for i=1,x do
- mon.write(" ")
- end
- mon.setCursorPos(1,6)
- for i=1,x do
- mon.write(" ")
- end
- mon.setCursorPos(math.floor((x-#txt)/2),5)
- mon.write(txt)
- txt = "Du hast bereits akzeptiert"
- mon.setCursorPos(math.floor((x-#txt)/2),6)
- mon.write(txt)
- end
- else
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.gray)
- mon.setCursorPos(1,5)
- for i=1,x do
- mon.write(" ")
- end
- mon.setCursorPos(1,6)
- for i=1,x do
- mon.write(" ")
- end
- txt = "Es muss genau 1 Spieler"
- mon.setCursorPos(math.floor((x-#txt)/2),5)
- mon.write(txt)
- txt = "auf der Wolle stehen!"
- mon.setCursorPos(math.floor((x-#txt)/2),6)
- mon.write(txt)
- end
- end
- function key(k)
- if k == 30 then
- shell.run("edit akzeptierende.tbl")
- elseif k == 22 then
- shell.run("update")
- elseif k == 19 then
- os.reboot()
- end
- end
- updateAdmins()
- while true do
- term.clear()
- print("Druecke a um die Liste zu sehen, u zum updaten und r zum rebooten")
- if not fs.exists("akzeptierende.tbl") then
- file = fs.open("akzeptierende.tbl","w")
- file.close()
- end
- update()
- mon.setBackgroundColor(colors.white)
- for i=1,y do
- mon.setCursorPos(1,i)
- for j=1,x do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.cyan)
- txt = "Shop-Regeln akzeptieren"
- mon.setCursorPos(math.floor((x-#txt)/2),3)
- mon.write(txt)
- mon.setTextColor(colors.orange)
- txt = "Klicke um zu akzeptieren"
- mon.setCursorPos(1,9)
- mon.setCursorPos(math.floor((x-#txt)/2),9)
- mon.write(txt)
- txt = "und stehe auf der roten Wolle"
- mon.setCursorPos(math.floor((x-#txt)/2),10)
- mon.write(txt)
- if rs.getInput("left") then
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.white)
- for i=5,10 do
- mon.setCursorPos(1,i)
- for j=1,x do
- mon.write(" ")
- end
- end
- txt = "Wartung"
- mon.setCursorPos(math.floor((x-#txt)/2),6)
- mon.write(txt)
- txt = "Ausser Betrieb!"
- mon.setCursorPos(math.floor((x-#txt)/2),9)
- mon.write(txt)
- end
- event, a, b, c = os.pullEvent()
- if event == "monitor_touch" then
- if not rs.getInput("left") then
- monitor_touch()
- end
- elseif event == "key" then
- key(a)
- end
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement