Advertisement
Dima99

setup

Aug 4th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. --inistaller maked with tabler pastebin: MgqZYDtR
  2. lib = {'function write2file(path, array)', '  f = fs.open(path, "w")', '  for i = 1, #array do', '    f.writeLine(array[i])  ', '  end', '  f.close()', 'end', ' ', 'function readFromFile(path)', '  f = fs.open(path, "r")', '  local array = {}', '  local i = 1', '  local temp', '  while true do', '    temp = f.readLine()', '    if not temp then break end', '    array[i] = temp', '    i = i + 1', '  end', '  f.close()', '  return array', 'end', ' ', 'function array2String(array, d)', '  string = ""', '  for i = 1, #array do', '     string = string .. array[i] .. d', '  end', '  return string', 'end'}
  3. receive = {'os.loadAPI("lib")', 'rednet.open("top")', 'id, msg = rednet.receive()', 'print(msg)', 'array = {}', 'array[1] = msg', 'lib.write2file("test", array)'}
  4. send = {'local args = {...}', 'os.loadAPI("lib")', ' ', 'array = lib.readFromFile(args[1])', 'string = lib.array2String(array, "\n")', 'rednet.open("top")', 'rednet.send(tonumber(args[2]), string)'}
  5. v = "1.0.1"
  6. text = "Welcome to rednet files inistaller!"
  7. xScr, yScr = term.getSize()
  8.  
  9. --
  10.  
  11. function setup(file, name)
  12.  local h = fs.open(name, "w")
  13.  for i = 1, #file do
  14.   h.writeLine(file[i])
  15.  end
  16.  h.close()
  17. end
  18.  
  19. function aans()
  20.  ans = read()
  21.  return ans
  22. end
  23.  
  24. --
  25.  
  26. if #text > xScr - 5 then
  27.  print("Welcome!")
  28.  else print(text)
  29. end
  30. print("Do you really want ")
  31. print("to inistall rednet files?")
  32. print("y/n")
  33. aans()
  34. if ans == "y" then
  35.  setup(lib, "lib")
  36.  sleep(0.5)
  37.  print("lib inistalled")
  38.  setup(send, "send")
  39.  sleep(0.5)
  40.  print("send inistalled")
  41.  setup(receive, "receive")
  42.  sleep(0.5)
  43.  print("receive inistalled")
  44.  elseif ans == "n" then
  45.  term.clear()
  46.  term.setCursorPos(1, 1)
  47.  else print("Unreadable input.")
  48.  aans()
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement