Skip to content

Conversation

FAReTek1
Copy link
Collaborator

@FAReTek1 FAReTek1 commented Dec 8, 2024

scratchattach.editor (sbeditor v2)

This is my response after seeing project_json_capabilites.py. Due to various code style issues mentioned in #291, this is an objectively cleaner version (with type hinting and a modular structure inspired by scratchattach.site).
I also call it sbeditor v2 because it is a revamp of my old, flawed sbeditor project.

This pr will remain a draft until the project has reached the same level of capability as project_json_capabilites.py (it's getting close, and has other features as well).

Advantages to project_json_capabilites.py

  • PyCharm doesn't kill you for the number of warnings
  • Modular code (not so much in 1 single file)
  • Doesn't do horrific one-liners such as [sound for sprite in self.sprites for sound in sprite.sounds] + [costume for sprite in self.sprites for costume in sprite.costumes]
  • Doesn't override builtin names
  • Type hinting
  • Understands the 'weird list at the end of the blocks list' as a prim
  • Defines attributes in __init__
  • Uses @staticmethod and @property
  • Has line breaks for readability
  • Doesn't use mutable default arguments (that will save some people a lot of pain)
  • Can read scripts from the backpack
  • Can directly export and run projects
  • Supports TurboWarp's 'platform' metadata attribute
  • Checks vm value in metadata (thanks to TurboWarp for the regex)
  • Cleaner class-based system
  • Uses enums e.g. for extensions
  • TWConfig parser
  • proccode parsing
  • A todo list
  • And more

@FAReTek1 FAReTek1 changed the title Sbeditor (Rival to project_json_capabilites) sbeditor (Rival to project_json_capabilites) Dec 8, 2024
@FAReTek1
Copy link
Collaborator Author

i might be able to say that this is more powerful that the original proejct_json_capabilites module except that it doesn't have much integration with scratchattach

…obably want to make a function run when a sprite is assigned, instead of just calling the link function when necessary
@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Dec 16, 2024

What is Singleton in this context?

@FAReTek1
Copy link
Collaborator Author

its for a value that says that a block shape is not possible to determine with just opcode (control_stop) (maybe this should be changed) as well as a value that represents the abscence of a sprite so one is automatically assigned (if you are using a with statement with sprite)

its a singleton so there is only 1 instance of these classes, so im using the 'is' keyword. i think there is a bit more tesing to do with it since the two singleton instances i mentioned at the start might be the same instance

@FAReTek1
Copy link
Collaborator Author

i should probably add a documentation so other people can understand the stuff because its not a perfectly intuitive system i guess

@FAReTek1
Copy link
Collaborator Author

just checked

from scratchattach.editor.build_defaulting import SPRITE_DEFAULT
from scratchattach.editor.blockshape import YESNT

print(SPRITE_DEFAULT is YESNT)

returns False: the singletons work as intended

@FAReTek1
Copy link
Collaborator Author

i think 'yesnt' should potentially be renamed

@TimMcCool TimMcCool added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Dec 20, 2024
FAReTek1 and others added 5 commits December 20, 2024 15:27
Signed-off-by: faretek <107722825+FAReTek1@users.noreply.github.com>
# Conflicts:
#	scratchattach/other/other_apis.py
Signed-off-by: faretek <107722825+FAReTek1@users.noreply.github.com>
@FAReTek1
Copy link
Collaborator Author

i keep merging incoming new commits into this branch which makes me worried that i might mess things up
Non sbeditor files should be checked before this is merged

@FAReTek1
Copy link
Collaborator Author

i'll rename yesnt and merge this maybe
i think yesnt should be renamed to 'mutation_dependent' or something

@FAReTek1 FAReTek1 marked this pull request as ready for review December 24, 2024 17:33
@FAReTek1
Copy link
Collaborator Author

there are still more features to be added

@FAReTek1 FAReTek1 merged commit bcae33b into TimMcCool:main Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants