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

Method find_broadcast

scratchattach/editor/sprite.py:468–496  ·  view source on GitHub ↗
(
        self, value: str, by: str = "name", multiple: bool = False
    )

Source from the content-addressed store, hash-verified

466 return None
467
468 def find_broadcast(
469 self, value: str, by: str = "name", multiple: bool = False
470 ) -> None | vlb.Broadcast | list[vlb.Broadcast]:
471 _ret = []
472 by = by.lower()
473 for _broadcast in self.broadcasts + self._local_globals:
474 if not isinstance(_broadcast, vlb.Broadcast):
475 continue
476 if by == "id":
477 compare = _broadcast.id
478 else:
479 # Defaulting
480 compare = _broadcast.name
481 if compare == value:
482 if multiple:
483 _ret.append(_broadcast)
484 else:
485 return _broadcast
486 # Search in stage for global broadcasts
487 if self.project:
488 if not self.is_stage:
489 if multiple:
490 _ret += self.stage.find_broadcast(value, by, True)
491 else:
492 return self.stage.find_broadcast(value, by)
493
494 if multiple:
495 return _ret
496 return None
497
498 def find_vlb(
499 self, value: str, by: str = "name", multiple: bool = False

Callers 2

find_vlbMethod · 0.95
link_using_spriteMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected