Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # CC:Tweaked and Python 3
- # "Go Home" turtle command
- # Version 1.0 08.07.2021 12:24:00
- # (c) 2021, MCAP-2020 (mcap_nikita & mcap_slipers)
- from cc import gps, turtle
- t = turtle
- # Сoordinates of the Home
- x, y, z = 706, 74, -502
- # Item slot 2 - Wireless modem
- if (t.getItemDetail(2) != None):
- t.select(2); t.equipLeft()
- def move(item, direction, distance):
- distance = abs(distance)
- for s in range(distance):
- if (direction == 'forward'):
- while not item.forward():
- item.up()
- elif (direction == 'back'):
- while not item.back():
- item.up()
- elif (direction == 'up'):
- item.up()
- elif (direction == 'down'):
- item.down()
- for i in 1, 2:
- fd = ''
- x1, y1, z1 = gps.locate()
- dx = x - x1; dz = z - z1
- t.forward(); x2, y2, z2 = gps.locate(); t.back()
- if (x2 != x1):
- fd = 'x+' if (x2 > x1) else 'x-'
- elif (z2 != z1):
- fd = 'z+' if (z2 > z1) else 'z-'
- if ((dx > 0) and (fd == 'x+')) or ((dx < 0) and (fd == 'x-')):
- move(t, 'forward', dx)
- elif ((dx < 0) and (fd == 'x+')) or ((dx > 0) and (fd == 'x-')):
- move(t, 'back', dx)
- elif ((dz > 0) and (fd == 'z+')) or ((dz < 0) and (fd == 'z-')):
- move(t, 'forward', dz)
- elif ((dz < 0) and (fd == 'z+')) or ((dz > 0) and (fd == 'z-')):
- move(t, 'back', dz)
- t.turnRight()
- x1, y1, z1 = gps.locate(); dy = y - y1
- move(t, 'up' if (dy > 0) else 'down', dy)
Add Comment
Please, Sign In to add comment