MCPcopy Create free account
hub / github.com/ActiveState/code / moveOnto

Method moveOnto

recipes/Python/361168_Vpython_example/recipe-361168.py:26–42  ·  view source on GitHub ↗

Move a onto b Where a and b are block numbers, puts block a onto block b after returning any blocks that are stacked on top of blocks a and b to their initial positions.

(self, a, b)

Source from the content-addressed store, hash-verified

24 return a, b
25
26 def moveOnto(self, a, b):
27 """
28 Move a onto b
29
30 Where a and b are block numbers, puts block a onto block b
31 after returning any blocks that are stacked on top of blocks
32 a and b to their initial positions.
33 """
34 # Get the actual block objects
35 a, b = self._getBlocks(a, b)
36 if not a: return # Ignore bad indexes
37 # Return blocks ontop of a to original positions (in reverse order of course)
38 a.removeBlocksFromAbove()
39 # Return blocks ontop of b to original positions
40 b.removeBlocksFromAbove()
41 # Move block a on top of block b
42 a.moveTo(b.position)
43
44 def moveOver(self, a, b):
45 """

Callers 1

test1Function · 0.95

Calls 3

_getBlocksMethod · 0.95
removeBlocksFromAboveMethod · 0.80
moveToMethod · 0.45

Tested by

no test coverage detected