SpitefulJames

SpiteDEDialer.lua

Apr 23rd, 2021
538
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Dialer, by Spite
  2. -- Using original code by Roy Curtis + KJ4IPS @
  3. -- files.haun.guru/ComputerCraft/
  4.  
  5. dofile('SpiteDEDialer.lib.lua')    --Open dialer.lib.lua
  6. dofile('SpiteDEDialer.events.lua')    --Open dailer.events.lua
  7. dofile('SpiteDEDialer.paintutils.lua')    --open dailer.paintutils.lua
  8.  
  9. exiting   = false
  10. debugging = false
  11.  
  12. state = {
  13.   width  = 0,  -- Screen width
  14.   height = 0,  -- Screen height
  15.   scale  = 1.0,
  16.   entryX = 0,  -- Entry columns X
  17.   entryY = 0,  -- Entry columns Y
  18.   entryW = 18, -- Entry column width
  19.  
  20.   buttons  = {},
  21.   selected = nil -- Selected book
  22. }
  23.  
  24. pMonitor = nil
  25. pChest   = nil
  26. pMusic   = nil
  27.  
  28. function Init() --Set up programs
  29.   print('Dialer Server 0.3')
  30.  
  31.   redstone.setOutput('bottom', true) --If activator present, turn off
  32.   discoverPeripherals() --find the monitor, chest and noteblock (dialer.lib)
  33.   prepareUI()
  34.   setPortal()
  35.  
  36.   Loop()
  37. end
  38.  
  39. function Loop()
  40.   print 'Running. Press HOME for help.'
  41.   repeat
  42.     -- Draw UI
  43.     clearUI()
  44.     updateButtons()
  45.     drawBanner()
  46.     drawButtons()
  47.  
  48.     -- Handle events
  49.     event, p1, p2, p3, p4 = os.pullEvent()
  50.  
  51.     debug('Event: ', event)
  52.  
  53.     -- Events handled in dialer.events.lua
  54.     if     event == 'key'
  55.       then onKey(p1)
  56.     elseif event == 'monitor_touch'
  57.       then onTouch(p1, p2, p3)
  58.     elseif event == 'monitor_resize'
  59.       then onResize(p1)
  60.     elseif event == 'peripheral'
  61.       then onPeripheral(p1)
  62.     elseif event == 'peripheral_detach'
  63.       then onPeripheral(p1)
  64.     end
  65.  
  66.   until exiting
  67.   Exit()
  68. end
  69.  
  70. function Exit()
  71.   setPortal()
  72.   clearUI()
  73.   redstone.setOutput('bottom', false)
  74.   os.reboot()
  75. end
  76.  
  77. function Panic(err)
  78.   print("*** PANIC: ", err)
  79.   print("*** Auto-reboot in 5 seconds...")
  80.   sleep(5)
  81.   os.reboot()
  82. end
  83.  
  84. success, err = pcall(Init)
  85. if not success then Panic(err) end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×