Advertisement
Archchancellor64

Toolkit API

Apr 21st, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. function isInTable(tab, obj)
  2.     for k, v in pairs(tab) do
  3.         if (k == obj or v == obj) then
  4.             return true
  5.         end
  6.     end
  7.     return false
  8. end
  9.  
  10. function isInSmeltery(TC, liquid)
  11.     for _, liq in pairs(TC) do
  12.         if liq.rawName == liquid then
  13.             return true
  14.         end
  15.     end
  16.     return false
  17. end
  18.  
  19. function findPeripheral(peri)
  20.     for _, side in pairs(rs.getSides()) do
  21.         if peripheral.isPresent(side) and
  22.             peripheral.getType(side) == peri then
  23.                 print(peri.." found at "..side)
  24.                 return side
  25.         end
  26.     end
  27.     error(peri.." not found", 0)
  28. end
  29.  
  30. function distanceTo(pos1, pos2)
  31.     xDis = pos1.x - pos2.x
  32.     yDis = pos1.y - pos2.y
  33.     zDis = pos1.z - pos2.z
  34.     return math.sqrt(xDis * xDis + yDis * yDis + zDis * zDis)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement