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

Method to_json

scratchattach/editor/sprite.py:345–383  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

343 )
344
345 def to_json(self) -> dict:
346 _json = {
347 "isStage": self.is_stage,
348 "name": self.name,
349 "currentCostume": self.current_costume,
350 "volume": self.volume,
351 "layerOrder": self.layer_order,
352 "variables": {_variable.id: _variable.to_json() for _variable in self.variables},
353 "lists": {_list.id: _list.to_json() for _list in self.lists},
354 "broadcasts": {_broadcast.id: _broadcast.to_json() for _broadcast in self.broadcasts},
355 "blocks": {_block_id: _block.to_json() for _block_id, _block in (self.blocks | self.prims).items()},
356 "comments": {_comment.id: _comment.to_json() for _comment in self.comments},
357 "costumes": [_costume.to_json() for _costume in self.costumes],
358 "sounds": [_sound.to_json() for _sound in self.sounds],
359 }
360
361 if self.is_stage:
362 _json.update(
363 {
364 "tempo": self.tempo,
365 "videoTransparency": self.video_transparency,
366 "videoState": self.video_state,
367 "textToSpeechLanguage": self.text_to_speech_language,
368 }
369 )
370 else:
371 _json.update(
372 {
373 "visible": self.visible,
374 "x": self.x,
375 "y": self.y,
376 "size": self.size,
377 "direction": self.direction,
378 "draggable": self.draggable,
379 "rotationStyle": self.rotation_style,
380 }
381 )
382
383 return _json
384
385 # Finding/getting from list/dict attributes
386 def find_asset(

Callers 1

exportMethod · 0.95

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected