Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angle = math.asin(3.0 / 5.0);
- sin = math.sin(angle);
- cos = math.cos(angle);
- local function rotateBack(vec)
- local vx = vec.x * (cos - sin);
- local vy = vec.y * (cos + sin);
- return vector.new(vx, vy);
- end
- local function getJitterDirY(position, inv1, inv2)
- local p = rotateBack(position);
- if p.y > inv2.y then
- return 1;
- elseif p.y < 0 then
- return -1;
- else
- return 0;
- end
- end
- args = {...};
- width = tonumber(args[1]);
- -- Initial position is (0,0)
- position = vector.new(0, 0, 0);
- inverted1 = rotateBack(vector.new(4, -3, 0)).mul(width);
- inverted2 = rotateBack(vector.new(3, 4, 0)).mul(width);
- lastX = inverted1.add(inverted2).x;
- for xi = 0, lastX do
- local downDone = false;
- local upDone = false;
- while getJitterDirY(position, inverted1, inverted2) <= 0 do
- turtle.place();
- turtle.up();
- position.y += 1;
- end
- while getJitterY(position, inverted1, inverted2) >= 0 do
- if not turtle.detect() then
- turtle.place();
- end
- turtle.down();
- position.y -= 1;
- end
- turtle.turnRight();
- turtle.forward();
- turtle.turnLeft();
- position.x += 1;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement