Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- --peripherals
- local senSide = "bottom"
- local monSide = "back"
- --door opener
- local t1 = 4
- local Rside = "left"
- --alert
- local t2 = 5
- local alert = "top"
- --loop
- local t3 = 1
- Player = {"Nike622000","jamawie"}
- mon = peripheral.wrap(monSide)
- sen = sensor.wrap(senSide)
- mon.setTextScale(.5)
- local xMax,yMax = mon.getSize()
- function Txt()
- mon.setCursorPos(1,1)
- mon.write("Bitte vor den")
- mon.setCursorPos(1,2)
- mon.write("Monitor stellen.")
- end
- function Animation()
- xPos = {}
- yPos = {}
- for i = 1,100 do
- xPos[i] = math.random(1,xMax)
- yPos[i] = math.random(4,yMax)
- color = math.random(1,3)
- x = math.random(1,3)
- if color == 1 then
- col = colors.white
- elseif color == 2 then
- col = colors.lime
- elseif color == 3 then
- col = colors.green
- end
- mon.setTextColor(col)
- mon.setCursorPos(xPos[i],yPos[i])
- if x == 1 then
- v = "0"
- elseif x == 2 then
- v = "1"
- elseif x == 3 then
- v = "2"
- end
- mon.write(v)
- end
- end
- function check()
- ziele = sen.getTargets()
- for k,v in pairs(ziele) do
- if v.Name == "Player"
- and v.Position.X <= 0.5 and v.Position.X >= -0.5
- and v.Position.Y <= 2 and v.Position.Y >= -0.5
- and v.Position.Z <= 2 and v.Position.Z >= 1
- then
- if sen.getTargetDetails(k).IsSneaking == true then
- local found = false
- for i = 1,#Player do
- if k == Player[i] then
- found = true
- end
- end
- if found then
- rs.setOutput(Rside,true)
- sleep(t1)
- rs.setOutput(Rside,false)
- else
- rs.setOutput(alert,true)
- sleep(t2)
- rs.setOutput(alert,false)
- end
- end
- elseif v.Position.X <= 4.5 and v.Position.X >= 2.5
- and v.Position.Y <= 2.0 and v.Position.Y >= -1.0
- and v.Position.Z <= 3.5 and v.Position.Z >= 1.0
- then
- rs.setOutput(Rside,true)
- sleep(t1)
- rs.setOutput(Rside,false)
- end
- end
- end
- while true do
- Txt()
- Animation()
- check()
- sleep(t3)
- end
Advertisement
Add Comment
Please, Sign In to add comment