Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if fs.exists("events")==false then
- shell.run("pastebin get bmKBU4Rv events")
- end
- os.loadAPI("events")
- if fs.exists("button")==false then
- shell.run("pastebin get hbeLn1ni button")
- end
- os.loadAPI("button")
- local chest=peripheral.wrap("iron_2")
- local portal=peripheral.wrap("right")
- local monitor=peripheral.wrap("top")
- local sensor=peripheral.wrap("bottom")
- local screenx,screeny=monitor.getSize()
- button.setMonitorSide("top")
- local whiteLists={
- ["NanoBob"]={
- ["NanoBob_"]=true,
- ["Joeneter10"]=true,
- ["Ardron"]=true,
- },
- }
- function buttonClicked(buttonID,text)
- local allowed=false
- local players=sensor.getPlayers()
- for i,d in pairs(players) do
- local playerFunctions=sensor.getPlayerByName(d.name)
- local playerData=playerFunctions.select(1)
- local pos=playerData.position
- if whiteLists[text]==nil or whiteLists[text][d.name]==true and pos.x<10 and pos.x>-10 and pos.y<10 and pos.y>-10 and pos.z<10 and pos.z>-10 or whiteLists["*"]==true then
- allowed=true
- break
- end
- end
- if allowed==false then drawWhitelistDeny() sleep(3) return end
- for i=1,chest.getInventorySize() do
- local info=chest.getStackInSlot(i)
- if info~=nil then
- if info.myst_book.destination==text then
- chest.pushItem("up",i,1,1)
- sleep(5)
- portal.pushItem("down",1,1,i)
- break
- end
- end
- end
- drawDisplay()
- end
- function emptyPortal()
- for i=1,chest.getInventorySize() do
- local info=chest.getStackInSlot(i)
- if info==nil then
- portal.pushItem("down",1,1,i)
- break
- end
- end
- end
- emptyPortal()
- function drawDisplay()
- button.removeAllButtons()
- local buttonID=0
- for i=1,chest.getInventorySize() do
- local info=chest.getStackInSlot(i)
- if info~=nil then
- if buttonID>=screeny/3-1 then
- print(info.myst_book.destination.." - Volume 2 ")
- button.addButton(math.floor(screenx*0.5),(buttonID-screeny/3)*3+2,math.floor(screenx*0.5+1),3,info.myst_book.destination,buttonClicked,false,false,128,256)
- else
- print(info.myst_book.destination.." - Volume 1 ")
- button.addButton(1,buttonID*3+1,math.floor(screenx*0.5),3,info.myst_book.destination,buttonClicked,false,false,128,256)
- end
- buttonID=buttonID+1
- end
- end
- end
- drawDisplay()
- function drawWhitelistDeny()
- monitor.setBackgroundColor(1)
- monitor.setTextColor(16384)
- for i=1,5 do
- monitor.setCursorPos(screenx*0.5-10,screeny*0.5-4+i)
- monitor.write(" ")
- end
- monitor.setCursorPos(screenx*0.5-4,screeny*0.5-2)
- monitor.write("Error : ")
- monitor.setCursorPos(screenx*0.5-6,screeny*0.5-1)
- monitor.write("Insufficient")
- monitor.setCursorPos(screenx*0.5-6,screeny*0.5)
- monitor.write("Permission")
- end
- while true do
- events.handleCCEvents()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement