Advertisement
Guest User

startup

a guest
Oct 31st, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. --numbers [must be (sn=totn) when pass typed to unlock rs signal]
  2. sn=0
  3. totn=15
  4. --code for door
  5. local pasp=peripheral.wrap("monitor_0")
  6. local pasd=peripheral.wrap("monitor_2")
  7.  
  8. pasp.clear()
  9. pasd.clear()
  10.  
  11. local widthp, heightp=pasp.getSize()
  12. local widthd, heightd=pasd.getSize()
  13. print("password input mon: "..widthp.." "..heightp)
  14. print("password display mon: "..widthd.." "..heightd)
  15. pasp.setCursorPos(1,1)
  16. pasp.write("1 2 3")
  17. pasp.setCursorPos(1,2)
  18. pasp.write("4 5 6")
  19. pasp.setCursorPos(1,3)
  20. pasp.write("7 8 9")
  21. pasp.setCursorPos(3,4)
  22. pasp.write("r")
  23. pasd.setCursorPos(1,5)
  24. function draw(x,y)
  25.   --what will happen after click
  26.   if(x==1 and y==1) then
  27.   --1 number code (will activate when clicked on 1)
  28.   sn=sn+1
  29.   elseif(x==3 and y==1) then
  30.   --2 number code
  31.   sn=sn+2
  32.   elseif(x==5 and y==1) then
  33.   --3 number code
  34.   sn=sn+3
  35.   elseif(x==1 and y==2) then
  36.   --4 number code
  37.   sn=sn+4
  38.   elseif(x==3 and y==2) then
  39.   --5 number code
  40.   sn=sn+5
  41.   elseif(x==5 and y==2) then
  42.   --6 number code
  43.   sn=sn+6
  44.   elseif(x==1 and y==3) then
  45.   --7 number code
  46.   sn=sn+7
  47.   elseif(x==3 and y==3) then
  48.   --8 number code
  49.   sn=sn+8
  50.   elseif(x==5 and y==3) then
  51.   --9 number code
  52.   sn=sn+9
  53.   end
  54.   print("player now has "..sn.." out of "..totn)
  55.   if(sn==totn) then
  56.   pasd.clear()
  57.   print("player typed pass with + of "..sn.."/"..totn)
  58.   sn=0
  59.   print("reseting variable sn to "..sn.."/"..totn)
  60.   end
  61.   if(x==3 and y==4) then
  62.   sn=0
  63.   pasp.setCursorPos(1,5)
  64.   pasp.write("reseting..")
  65.   sleep(1)
  66.   pasp.setCursorPos(1,5)
  67.   pasp.write("          ")
  68.   end
  69.   pasd.setCursorPos(1,1)
  70.   pasd.write("player sum "..sn.."        ")
  71. end
  72.  
  73. while true do
  74.   local event, side, x, y=os.pullEvent("monitor_touch")
  75.   draw(x,y)
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement