MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / attach_block

Method attach_block

scratchattach/editor/block.py:530–547  ·  view source on GitHub ↗

Connect another block onto the boottom of this block (not necessarily bottom of chain)

(self, new: Block)

Source from the content-addressed store, hash-verified

528
529 # Adding/removing block
530 def attach_block(self, new: Block) -> Block:
531 """
532 Connect another block onto the boottom of this block (not necessarily bottom of chain)
533 """
534 if not self.can_next:
535 raise exceptions.BadBlockShape(f"{self.block_shape} cannot be stacked onto")
536 elif new.block_shape.is_hat or not new.block_shape.is_stack:
537 raise exceptions.BadBlockShape(f"{new.block_shape} is not stackable")
538
539 new.parent = self
540 new.next = self.next
541
542 self.next = new
543
544 new.check_toplevel()
545 self.sprite.add_block(new)
546
547 return new
548
549 def duplicate_single_block(self) -> Block:
550 return self.attach_block(self.dcopy())

Callers 3

attach_chainMethod · 0.80
add_chainMethod · 0.80

Calls 2

check_toplevelMethod · 0.80
add_blockMethod · 0.45

Tested by

no test coverage detected