Advertisement
Guest User

Untitled

a guest
May 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. local turtleState = {};
  2. turtleState.haveModem = function(self, right)
  3. if right == nil then
  4. right = true;
  5. end
  6. local modem = peripheral.find("modem");
  7. if modem == nil then
  8. for slot = 1, 16 do
  9. local itemDetail = turtle.getItemDetail(slot);
  10. if itemDetail ~= nil and itemDetail.name == "computercraft:peripheral" and itemDetail.damage == 1 then
  11. local oldSlot = turtle.getSelectedSlot();
  12. turtle.select(slot);
  13. if right then
  14. turtle.equipRight()
  15. else
  16. turtle.equipLeft()
  17. end
  18. turtle.select(oldSlot);
  19. modem = peripheral.find("modem");
  20. break;
  21. end
  22. end
  23. end
  24. return modem;
  25. end
  26.  
  27. local area = {};
  28. area.globalPosition = vector.new(0, 0, 0);
  29. area.globalRotation = { x = vector.new(1, 0, 0), y = vector.new(0, 1, 0), z = vector.new(0, 0, 1) };
  30. area.getLocalPosition = function(self, state)
  31. state:haveModem();
  32. local globalPosition;
  33. while globalPosition == nil do
  34. globalPosition = vector.new(gps.locate(10));
  35. end
  36. globalPosition = globalPosition - self.globalPosition;
  37. local localX = globalPosition:dot(self.globalRotation.x);
  38. local localY = globalPosition:dot(self.globalRotation.y);
  39. local localZ = globalPosition:dot(self.globalRotation.z);
  40. return vector.new(localX, localY, localZ);
  41. end
  42.  
  43. print(area:getLocalPosition);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement