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

Method add_chain

scratchattach/editor/sprite.py:196–211  ·  view source on GitHub ↗

Adds a list of blocks to the sprite **AND RETURNS THE FIRST BLOCK** :param chain: :return:

(self, *chain: block.Block | prim.Prim)

Source from the content-addressed store, hash-verified

194 return _block
195
196 def add_chain(self, *chain: block.Block | prim.Prim) -> block.Block | prim.Prim:
197 """
198 Adds a list of blocks to the sprite **AND RETURNS THE FIRST BLOCK**
199 :param chain:
200 :return:
201 """
202 chain = tuple(chain)
203
204 _prev = self.add_block(chain[0])
205
206 for _block in chain[1:]:
207 if not isinstance(_prev, block.Block) or not isinstance(_block, block.Block):
208 continue
209 _prev = _prev.attach_block(_block)
210
211 return chain[0]
212
213 def add_comment(self, _comment: comment.Comment) -> comment.Comment:
214 _comment.sprite = self

Callers 1

add_chainFunction · 0.80

Calls 2

add_blockMethod · 0.95
attach_blockMethod · 0.80

Tested by

no test coverage detected