Advertisement
Muzze77

NuclearElmos_Reactor_Touch

Oct 27th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. pcid = os.getComputerID()
  2. mon = peripheral.wrap("back")
  3. gx,gy = mon.getSize()
  4. dbcol = colors.black
  5. dtcol = colors.lime
  6.  
  7. machines = peripheral.getNames()
  8. com = ""
  9. for v, k in pairs(machines) do
  10.     if string.find(k,"drive") ~= nil then
  11.         drive = peripheral.wrap(k)
  12.         driveAPI = k
  13.         methods = peripheral.getMethods(k)
  14.         break
  15.     end
  16.    
  17. end
  18. function readDisk()
  19. diskR = fs.open("disk/akw.lua","r")
  20. reading = diskR.readAll()
  21. print(reading)
  22. diskR.close()
  23. return reading
  24. end
  25.  
  26. function saveDisk(text)
  27. disk = fs.open("disk/akw.lua","w")
  28. disk.write(text)
  29. disk.close()
  30. end
  31.  
  32.  
  33. function mbut(cx,cy,text,bcol,tcol)
  34.     if bcol == nil then
  35.         bcol = dbcol
  36.     end
  37.     if tcol == nil then
  38.         tcol = dtcol
  39.     end
  40.     mon.setCursorPos(cx,cy)
  41.     mon.setBackgroundColor(bcol)
  42.     mon.setTextColor(tcol)
  43.     mon.write(text)
  44.     mon.setBackgroundColor(dbcol)
  45.     mon.setTextColor(dtcol)
  46. end
  47.  
  48. while true do
  49. evt = {os.pullEvent("monitor_touch")}
  50.  
  51. x = evt[3]
  52. y = evt[4]
  53.  
  54. mbut(4,gy,"                        ")
  55. mbut(4,gy,"X: " .. x .. " Y: " .. y)
  56.     if x == 13 and y == 2 then
  57.         state = readDisk()
  58.         print(state)
  59.         if state == "false" or state == nil then
  60.             state = true
  61.             saveDisk(state)
  62.         else
  63.             state = false
  64.             saveDisk(state)
  65.         end
  66.        
  67.     end
  68.         mbut(gx-8,gy,"             ")
  69.         mbut(gx-8,gy,tostring(state))
  70.         sleep(1)
  71. end
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement