Advertisement
CelticCoder

predictSupport

Jan 11th, 2024 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("findBlocks.lua")
  2. os.loadAPI("userInput.lua")
  3. cost = 0
  4.  
  5. function setCost(newCost)
  6.     cost = newCost
  7. end
  8.  
  9. function getCost()
  10.     return cost
  11. end
  12.  
  13. function predictFloor(newlength, newwidth)
  14.     width = tonumber(newwidth)
  15.     length = tonumber(newlength)
  16.     print(width)
  17.     print(length)
  18.     for i = 1, length do
  19.         for j = 1, width do
  20.             if j < width then
  21.                 cost = cost + 1
  22.             end
  23.         end
  24.         if i < length then
  25.             if i % 2 == 0 then
  26.                 cost = cost + 1
  27.             else
  28.                 cost = cost + 1
  29.             end
  30.         end
  31.     end
  32. end
  33.  
  34. function predictWalls(newlength, newwidth, newHeight)
  35.     width = tonumber(newwidth - 2)
  36.     length = tonumber(newlength - 2)
  37.     height = tonumber(newHeight)
  38.     distance = 0
  39.     for i = 1, 4 do
  40.         if i % 2 == 1 then
  41.             distance = length
  42.         else
  43.             distance = width
  44.         end
  45.  
  46.         for j = 1, distance do
  47.             cost = cost + 1
  48.             for k = 1, height do
  49.                 cost = cost + 1
  50.             end
  51.             predictSupportBeam(height)
  52.         end
  53.         cost = cost + 1
  54.     end
  55. end
  56.  
  57. function predictSupportBeam(newHeight)
  58.         height = tonumber(newHeight)
  59.         cost = cost + 1
  60.         for j = 1, height do
  61.            if j < height then
  62.                 cost = cost + 1
  63.            end
  64.         end
  65. end
  66.  
  67. function predictSupportBeams(height, orientation)
  68.         width = width - 1
  69.         length = length - 1
  70.         for i = 1, 4 do
  71.                 predictSupportBeam(height)
  72.                 distance = 0
  73.                 if i % 2 == 1 and i ~= 4 then
  74.                     distance = length
  75.                 end
  76.                 if i % 2 == 0 and i ~= 4 then
  77.                     distance = width
  78.                 end
  79.  
  80.                 for j = 1, distance do
  81.                     cost = cost + 1
  82.                 end
  83.                 for k = 1, height do
  84.                     cost = cost + 1
  85.                 end
  86.         end
  87.         if orientation == 0 then
  88.             for l = 1, length do
  89.                 cost = cost + 1
  90.             end
  91.         else
  92.             for l = 1, width do
  93.                 cost = cost + 1
  94.             end
  95.  
  96.             for m = 1, length do
  97.                 cost = cost + 1
  98.             end
  99.  
  100.         end
  101. end
  102.  
  103. function setOrientation(newWidth)
  104.     newwidth = tonumber(newWidth)
  105.     orientation = 0
  106.     if newwidth % 2 == 1 then
  107.         orientation = 0
  108.     else
  109.         orientation = 1
  110.     end
  111. end
  112.  
  113. function predictFullBuild(newlength, newwidth, height)
  114.     cost = cost + 1
  115.     predictFloor(newwidth, newlength)
  116.     setOrientation(newwidth)
  117.     predictSupportBeams(height, orientation)
  118.     predictWalls(newlength, newwidth, height)
  119.     turtle.select(1)
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement