Skip to content

Line Reader extension for TurboWarp #2193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

PearComputer
Copy link

Hello. I made a custom extension for TurboWarp that can count the amount of lines in a piece of text, show a certain line of a certain number in text, and can understand UNIX (~n), Classic Mac OS (~r), and Windows (~z) line types. Its unique feature is its custom ~n, ~r, and ~z tilde delimiters that can be useful for writing certain line types easily without rendering issues, but it, importantly, understands the generic Unicode versions too.

@github-actions github-actions bot added the pr: new extension Pull requests that add a new extension label Jul 19, 2025
@Brackets-Coder
Copy link
Contributor

I'll give a starting review for best practices

Copy link
Contributor

@Brackets-Coder Brackets-Coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking you should create a new branch in your fork instead of making all commits from the master branch. Having one branch per extension helps organize things a bit better so you don't have file overload in one PR. Looks pretty good, but you'll have to talk to moderators about whether it will get merged.

@@ -0,0 +1,140 @@
// Name: Line Reader
// ID: linereader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ID should contain your username

Suggested change
// ID: linereader
// ID: microBoyLineReader

// Name: Line Reader
// ID: linereader
// Description: A simple extension for reading newlines and supports special tilde delimiters. Use ~n for UNIX, ~r for Classic Mac OS, and ~z for Windows.
// By: Pear Computer LLC. <https://scratch.mit.edu/users/-Microboy-/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a LLC?

// ID: linereader
// Description: A simple extension for reading newlines and supports special tilde delimiters. Use ~n for UNIX, ~r for Classic Mac OS, and ~z for Windows.
// By: Pear Computer LLC. <https://scratch.mit.edu/users/-Microboy-/>
// License: BSD-2-Clause
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity wondering why you have special licensing, generally speaking this isn't necessary. Turbowarp recommends Mozilla Public License v2. See CONTRIBUTING.md.

getInfo() {
return {
id: 'linereader', // Unique ID for the extension
name: 'Line Reader', // Name displayed in Scratch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint is falling because you have a lot of translation errors. You should use Scratch.translate() on the extension name and block texts.

Suggested change
name: 'Line Reader', // Name displayed in Scratch
name: Scratch.translate('Line Reader'), // Name displayed in Scratch

{
opcode: 'getLine', // Opcode for getting a specific line
blockType: Scratch.BlockType.REPORTER, // It's a reporter block (returns a value)
text: 'line [LINE_NUM] in [TEXT_INPUT]', // The text displayed on the block
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and for the rest of the blocks. Also, I have to ask why you're using so many comments for things that should be obvious? It just distracts from the code

*/
_processNewlines(text) {
// Ensure the input is treated as a string
let processedText = String(text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't use JavaScript's native casting functions for block arguments as scratch has numerous odd quirks that could lead to issues. Use Scratch.Cast.toString() or Scratch.Cast.toNumber() for all block inputs.

Suggested change
let processedText = String(text);
let processedText = Scratch.Cast.toString(text);

*/
getLine(args) {
// Process custom escape sequences into actual newlines
const processedText = this._processNewlines(args.TEXT_INPUT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also use casting, assuming it's a string it should probably look like this:

Suggested change
const processedText = this._processNewlines(args.TEXT_INPUT);
const processedText = this._processNewlines(Scratch.Cast.toString(args.TEXT_INPUT));

// Process custom escape sequences into actual newlines
const processedText = this._processNewlines(args.TEXT_INPUT);
// Ensure the line number is an integer
const lineNum = parseInt(args.LINE_NUM, 10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument too and same goes for the rest of the args in every block

class LineReaderExtension {
getInfo() {
return {
id: 'linereader', // Unique ID for the extension
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ID should also contain your username and be the same as the one in the header comment

Suggested change
id: 'linereader', // Unique ID for the extension
id: 'microBoyLineReader', // Unique ID for the extension

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is showing the SVG as a code instead of an image, don't really know why, maybe it's the review Github Preview problem

Copy link
Collaborator

@CST1229 CST1229 Jul 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me it works (as long as i have the Preview tab selected).
also the SVG is the wrong size (shouldn't be 480x360 at the very least, probably 600x300). and if you're just embedding a PNG just make the file a PNG itself; that's allowed

@Brackets-Coder
Copy link
Contributor

!format

@Brackets-Coder
Copy link
Contributor

Validate is failing because your image aspect ratio is incorrect, it must be 2:1. Your image is 480x360, the same as the Scratch Stage, but turbowarp should use something like 960x480. Format is failing because you didn't do npm run prettier before making the commit and lint is just because of the translation. All trivial and common errors that can be easily fixed, don't worry about them. The comment above should attempt to fix the formatting issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not delete CNAME, it's what allows the custom domain name (extensions.turbowarp.org) to work

@SharkPool-SP
Copy link
Collaborator

This extension is useless, it can be easily recreated with Utilities and JSON
Screenshot 2025-07-19 at 9 35 11 PM

@SharkPool-SP
Copy link
Collaborator

I also get a lot of AI written vibes from this extension

@Brackets-Coder
Copy link
Contributor

I also get a lot of AI written vibes from this extension

That's kinda what I was thinking....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new extension Pull requests that add a new extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants