imposiblaa

warehouseManager

Mar 5th, 2021 (edited)
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. local warehouseID = "templol"
  2.  
  3. function stringSplit (inputstr, sep)
  4.     if sep == nil then
  5.             sep = "%s"
  6.     end
  7.     local t={}
  8.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  9.             table.insert(t, str)
  10.     end
  11.     return t
  12. end
  13.  
  14. function setup()
  15.     local warehouseData = { }
  16.     term.clear()
  17.     term.setCursorPos(1, 1)
  18.     print("How many rows are there?> ")
  19.     term.setCursorPos(27, 1)
  20.     rowNum = read()
  21.     term.setCursorPos(1,  2)
  22.     print("How long are the rows?> ")
  23.     term.setCursorPos(25, 2)
  24.     rowLen = read()
  25.     term.setCursorPos(1, 3)
  26.     print("How high are the rows?> ")
  27.     term.setCursorPos(25, 3)
  28.     rowHeight = read()
  29.     term.setCursorPos(1, 4)
  30.     print("coords just inside the left, front-most aisle")
  31.     term.setCursorPos(1, 5)
  32.     index = read()
  33.     for i = 1, rowNum, 1 do
  34.         rowID = "row".. i
  35.         warehouseData[rowID] = {}
  36.         for i = 1, rowLen, 1 do
  37.             columnID = "column" .. i
  38.             warehouseData[rowID][columnID] = {}
  39.             for i = 1, rowHeight, 1 do
  40.                 chestID = "chest"..i
  41.                 warehouseData[rowID][columnID][chestID] = {"this is a long table"}
  42.             end
  43.         end
  44.     end
  45.     warehouseDataSplit = stringSplit(textutils.serialize(warehouseData), "\n")
  46.     fs.delete(warehouseID .. "Data")
  47.     warehouseDataFile = fs.open(warehouseID .. "Data", "a")
  48.     for lineNum, line in pairs(warehouseDataSplit) do
  49.         warehouseDataFile.writeLine(line)
  50.         print(line)
  51.     end
  52. end
  53.  
  54.  
  55. if(fs.exists(warehouseID .. "Data"))then
  56.     terminal()
  57. else
  58.     setup()
  59. end
Add Comment
Please, Sign In to add comment