SHARE
TWEET

Untitled

a guest Nov 20th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- TODO: Requires that its on the left side. Should add auto detection later
  2. rednet.open("left")
  3.  
  4. while true do
  5.   -- Create /disk
  6.   fs.makeDir('/disk')
  7.  
  8.   -- Sync directory structure
  9.   local _id, rawDirs, _distance = rednet.receive('fs-dirs', 5)
  10.   local dirs = textutils.unserialize(rawDirs)
  11.   for i = 1, #dirs
  12.   do
  13.     fs.makeDir('/disk/' .. dirs[i])
  14.   end
  15.  
  16.   -- Sync files
  17.   local _id, rawFiles, _distance = rednet.receive('fs-files', 5)
  18.   local files = textutils.unserialize(rawFiles)
  19.   for name, value in pairs(files) do
  20.     local fp = fs.open('/disk/' .. name, 'w')
  21.     fp.write(value)
  22.     fp.close()
  23.   end
  24.  
  25.   -- For non-disk-attacehd computers, move the startup file to root
  26.   fs.move('/disk/startup.lua', '/startup.lua')
  27.  
  28.   if arg[1] == 'init' then
  29.     -- Reboot for the first run
  30.     os.reboot()
  31.   else
  32.     -- Print
  33.     print('Synced.')
  34.  
  35.     -- Sleep to reduce load on the minecraft server
  36.     os.sleep(10)
  37.   end
  38. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top