33from typing import Optional , TYPE_CHECKING
44
55from typing_extensions import deprecated
6+ import warnings
67
78if TYPE_CHECKING :
89 from . import project
910
10- from . import base
11+ from . import base , block
1112
1213
1314class Monitor (base .ProjectSubcomponent ):
@@ -33,6 +34,9 @@ def __init__(self, reporter: Optional[base.NamedIDComponent] = None,
3334 """
3435 assert isinstance (reporter , base .SpriteSubComponent ) or reporter is None
3536
37+ if sprite_name is None and hasattr (reporter , 'sprite' ):
38+ sprite_name = None if reporter .sprite .is_stage else reporter .sprite .name
39+
3640 self .reporter_id = reporter_id
3741 """
3842 ID referencing the VLB being referenced. Replaced with None during project instantiation, where the reporter attribute is updated
@@ -142,14 +146,14 @@ def link_using_project(self):
142146 # todo: consider reimplementing this
143147 @deprecated ("This method does not work correctly (This may be fixed in the future)" )
144148 @staticmethod
145- def from_reporter (reporter : Block , _id : str = None , mode : str = "default" ,
149+ def from_reporter (reporter : block . Block , _id : str = None , mode : str = "default" ,
146150 opcode : str = None , sprite_name : str = None , value = 0 , width : int | float = 0 ,
147151 height : int | float = 0 ,
148152 x : int | float = 5 , y : int | float = 5 , visible : bool = False , slider_min : int | float = 0 ,
149153 slider_max : int | float = 100 , is_discrete : bool = True , params : dict = None ):
150- if "reporter" not in reporter .stack_type :
154+ if not reporter .block_shape . is_reporter :
151155 warnings .warn (f"{ reporter } is not a reporter block; the monitor will return '0'" )
152- elif "(menu)" in reporter .stack_type :
156+ elif reporter .block_shape . is_menu :
153157 warnings .warn (f"{ reporter } is a menu block; the monitor will return '0'" )
154158 # Maybe add note that length of list doesn't work fsr?? idk
155159 if _id is None :
@@ -166,7 +170,7 @@ def from_reporter(reporter: Block, _id: str = None, mode: str = "default",
166170 params [field .id ] = field .value , field .value_id
167171
168172 return Monitor (
169- _id ,
173+ reporter ,
170174 mode ,
171175 opcode ,
172176
0 commit comments