Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.find("modem")
- m.open(51)
- ---------------------- CONFIG ------------------------------------------------
- ID = "BEDDR" --Door ID for "rOpen"
- ------------------------------------------------------------------------------
- -- redstone pulse
- local function pulse(side)
- rs.setOutput(side, true)
- sleep(3)
- rs.setOutput(side,false)
- end
- Tr = true
- function os.pullEvent()
- local event, p1,p2,p3,p4,p5 = os.pullEventRaw()
- if event == "terminate" then write("For terminate need password:")
- p = read()
- if p == "ex" then
- Tr = false
- print("exiting")
- end
- end
- return event,p1,p2,p3,p4,p5
- end
- --add function from command "add"
- function Add(Name)
- Fold = "Assets/"
- RC = Fold .. Name
- fs.makeDir("Assets")
- Name = tostring(RC)
- if fs.exists(RC) then
- return false
- else
- f = fs.open(RC,"w")
- f.close()
- return true
- end
- end
- --remove function from command "rm"
- function Rm(Name)
- inp = "Assets/" .. Name
- if fs.exists(inp) then
- fs.delete(inp)
- return true
- else
- return false
- end
- end
- while Tr do
- Recive = {"","",""}
- Recive[1],Recive[2],Recive[3],Recive[4],Recive[5] = os.pullEvent()
- pL = fs.list("Assets")
- --check events
- if Recive[1] == "player" or "modem_message" then
- if Recive[1] == "modem_message" then
- for k,v in string.gmatch(Recive[5], "(%w+)=(%w+)") do
- --command exicute
- if (k == "rOpen" and v == ID) then
- pulse("right")
- elseif k == "add" then
- Add(v)
- elseif k == "rm" then
- Rm(v)
- end
- end
- -- check player and open door
- elseif Recive[1] == "player" then
- for i =1 , 10 ,1 do
- if Recive[3] == pL[i] then
- pulse("right")
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement