Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variable initialization
- local srcId
- local cmd
- local tgtId
- local index
- local fnc
- local ids
- local access
- local result
- --Check if srcId is valid
- local function checkAccess()
- access = false
- tools.clear()
- print("Awaiting Broadcast...")
- srcId, cmd = rednet.receive()
- srcId, tgtId = rednet.receive()
- if cmd == "open" or cmd == "close" then index = "door" end
- fnc = (index..tgtId)
- ids = getfenv()["idList"][fnc]() --Set Environment within APIs
- for i = 1, ids[0], 1 do
- if srcId == ids[i] then access = true end
- end
- end
- --NO DESCRIPTION
- local function sendResult()
- if access == true then
- rednet.send(tonumber(tgtId), cmd)
- tgtId, result = rednet.receive()
- else
- result = "Access denied"
- end
- rednet.send(tonumber(srcId), result)
- end
- rednet.open("left")
- --Run loop
- while true do
- checkAccess()
- sendResult()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement