Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local turtleState = {};
- turtleState.haveModem = function(self, right)
- if right == nil then
- right = true;
- end
- local modem = peripheral.find("modem");
- if modem == nil then
- for slot = 1, 16 do
- local itemDetail = turtle.getItemDetail(slot);
- if itemDetail ~= nil and itemDetail.name == "computercraft:peripheral" and itemDetail.damage == 1 then
- local oldSlot = turtle.getSelectedSlot();
- turtle.select(slot);
- if right then
- turtle.equipRight()
- else
- turtle.equipLeft()
- end
- turtle.select(oldSlot);
- modem = peripheral.find("modem");
- break;
- end
- end
- end
- return modem;
- end
- local area = {};
- area.globalPosition = vector.new(0, 0, 0);
- area.globalRotation = { x = vector.new(1, 0, 0), y = vector.new(0, 1, 0), z = vector.new(0, 0, 1) };
- area.getLocalPosition = function(self, state)
- state:haveModem();
- local globalPosition;
- while globalPosition == nil do
- globalPosition = vector.new(gps.locate(10));
- end
- globalPosition = globalPosition - self.globalPosition;
- local localX = globalPosition:dot(self.globalRotation.x);
- local localY = globalPosition:dot(self.globalRotation.y);
- local localZ = globalPosition:dot(self.globalRotation.z);
- return vector.new(localX, localY, localZ);
- end
- print(area:getLocalPosition);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement