ZNZNCOOP

build

Jul 14th, 2014
235
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3.     print( "Usage: build <router_name>" )
  4.     return
  5. end
  6. local name=tArgs[1]
  7. local filename='routers'
  8. local file=fs.open(shell.dir()..'/'..filename,'r')
  9. if not file then
  10.   print('File '..filename..' not found')
  11.   return
  12. end
  13. local line=file.readLine()
  14. while line do
  15.   n,x,z=line:match('(%S+)%s+([%+%-%d]%d*)%s+([%+%-%d]%d*)')
  16.   if n==name then break end
  17.   n=nil
  18.   line=file.readLine()
  19. end
  20. file.close()
  21. if n then
  22.   x=tonumber(x)
  23.   z=tonumber(z)
  24.   print(name,' ',x,' ',z)
  25. else
  26.   print(name..' not registered')
  27.   return
  28. end
  29. p=peripheral.wrap('bottom')
  30. w = p.getWorld(p.getPeripheralWorldID())
  31. y=253
  32. if w.getBlockID(x, y, z)~=0 then
  33.   print('Place is not empty. Continue? (y/n)')
  34.   if read()~='y' then
  35.     return
  36.   end
  37. end
  38. blocks={{id=7,md=0},{id=451,md=4},{id=1226,md=1},{id=1225,md=0},{id=7,md=0}}
  39. for i=5,1,-1 do
  40.   for k=-1,1 do
  41.     for l=-1,1 do
  42.       if k==0 and l==0 then
  43.         w.setBlock(x,y+i-4,z,blocks[i].id,blocks[i].md)
  44.       else
  45.         w.setBlock(x+k,y+i-4,z+l,7,0)
  46.       end
  47.     end
  48.   end
  49. end
RAW Paste Data