Susceptance

tunnelbot

Apr 27th, 2022 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. os.loadAPI('signToDir.lua')
  2.  
  3. tileTable = {['31'] = 1, ['13'] = 1, ['24'] = 2, ['42'] = 2, ['23'] = 3, ['32'] = 3, ['34'] = 4, ['43'] = 4, ['12'] = 5, ['21'] = 5, ['14'] = 6, ['41'] = 6}
  4.  
  5. openTurtles = {}
  6. activeTurtles = {}
  7.  
  8. jobs = {}
  9. activeJobs = {}
  10.  
  11. tiles = {}
  12.  
  13. homeX = 27
  14. homeY = 48
  15.  
  16. local function printUsage()
  17.     print( "Usages:" )
  18.     print( "tunnelbot <startX> <startZ> <endX> <endZ>" )
  19. end
  20.  
  21. local tArgs = { ... }
  22. if #tArgs < 1 then
  23.     printUsage()
  24.     return
  25. end
  26.  
  27. function tunnelChunk(sx, sy, tx, ty)
  28.     -- Generate jobs
  29.     -- Get next position
  30.     x = sx
  31.     y = sy
  32.  
  33.     prevX = x
  34.     prevY = y
  35.  
  36.     prevDirX = 1
  37.     prevDirY = 1
  38.     prevDir = 3
  39.  
  40.     while (x ~= tx or y ~= ty) do
  41.         if x ~= tx then
  42.             dirX = (tx - x) / math.abs(tx - x)
  43.         end
  44.         if y ~= ty then
  45.             dirY = (ty - y) / math.abs(ty - y)
  46.         end
  47.         dir = 1
  48.         prevX = x
  49.         prevY = y
  50.  
  51.         if tiles[x..','..y + dirY] ~= null or x == tx then
  52.             y = y + dirY
  53.             dir = signToDir.toDirY(dirY)
  54.         else
  55.             x = x + dirX
  56.             dir = signToDir.toDirX(dirY)
  57.         end
  58.         -- Choose tile
  59.         print('')
  60.         print("dirX: "..dirX)
  61.         print("dirY: "..dirY)
  62.         print("dir: "..dir)
  63.         print("prevDir: "..prevDir)
  64.  
  65.         print("X: "..x)
  66.         print("Y: "..y)
  67.         print("Tile: "..tileTable[prevDir..dir])
  68.  
  69.         prevDir = dir
  70.     end
  71.  
  72.     -- Use last and next position to choose tile
  73.  
  74.     -- If tile is same as existing dont create job
  75.  
  76.     print(jobs)
  77.     -- Assign jobs
  78.  
  79. end
  80.  
  81. tunnelChunk(0, 0, 1, 1)
  82. --tunnelChunk(tArgs[1], tArgs[2], tArgs[3], tArgs[4])
Add Comment
Please, Sign In to add comment