Skip to content

New extension: Complexity!#2091

Closed
Kenay555 wants to merge 2 commits into
TurboWarp:masterfrom
Kenay555:patch-1
Closed

New extension: Complexity!#2091
Kenay555 wants to merge 2 commits into
TurboWarp:masterfrom
Kenay555:patch-1

Conversation

@Kenay555

Copy link
Copy Markdown

A new way to play with Complex Numbers in TurboWarp! Must be loaded Unsandboxed for the [Go To ( )] to run.

A new way to play with Complex Numbers in TurboWarp! Must be loaded Unsandboxed for the [Go To ( )] to run.
@github-actions github-actions Bot added the pr: new extension Pull requests that add a new extension label Apr 23, 2025
Comment thread extensions/Complexity!.js
Comment thread extensions/Complexity!.js
throw new Error("We don't like sand :(");
}

const OGcomplexCode = `

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Must you put the library in a constant? Everyone else just includes the minified library straight in the JS code with the license and // prettier-ignore above it. Also must go inside the extension's function

@Kenay555 Kenay555 Apr 24, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Tried to put the library inside the class thing, but it Unexpected token or smth like that. Me and ClickerTale had tried our best, Can you help?
Oh, and that's the minified version, see source.

Comment thread extensions/Complexity!.js Outdated
Comment on lines +10 to +12
if (!Scratch.extensions.unsandboxed) {
throw new Error("We don't like sand :(");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this must go in the extension IIFE

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't know what IIFE means but I'll try to put it in the main function.

This comment was marked as abuse.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thx @yuri-kiss !

Comment thread extensions/Complexity!.js Outdated
Comment thread extensions/Complexity!.js Outdated
this.trig = ['sin', 'cos', 'tan', 'cot', 'sec', 'csc', 'asin', 'acos', 'atan', 'acot', 'asec', 'acsc', 'sinh', 'cosh', 'tanh', 'coth', 'sech', 'csch', 'asinh', 'acosh', 'atanh', 'acoth', 'asech', 'acsch'];

try {
eval(OGcomplexCode);

@Brackets-Coder Brackets-Coder Apr 24, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this is used to execute the library code, but no. Eval is a banned function because it can be used to execute malicious JS code, so if you're possibly going to have errors with loading the library then do it inside this try block and not outside the extension's function. See Banned APIs under CONTRUBUTING.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank for the tip! I'll try to see what can I do.

This comment was marked as abuse.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I also don't know what a global scope or wrapper for values are, but i'll se what i can do @yuri-kiss!

Comment thread extensions/Complexity!.js Outdated
Comment on lines +461 to +479
imComplex({ COMPLEX })
{
try {
const cInstance = new this.Complex(COMPLEX);
return cInstance.im;
} catch (e) {
return NaN
}
}

polarComplex({ RADIUS, ANGLE })
{
try {
const cInstance = coolCis(Complex(ANGLE)).mul(Complex(RADIUS));
return cInstance.toString().replace(/\s+/g, '');
} catch (e) {
return NaN
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This inconsistent formatting with the try blocks are painful to look at. Prettier

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

When ClickerTale build half the extension and I checked for errors, I had to delete the try{}catch(e){} thingies. It'll take time to move EVERY single one, but it's not like someone's gonna review my extension looking each and every line and tell me to take a workaround for eval() [i know you will].

Comment thread extensions/Complexity!.js Outdated
Comment thread extensions/Complexity!.js Outdated
Comment thread extensions/Complexity!.js Outdated
Comment thread extensions/Complexity!.js Outdated
@Brackets-Coder

Brackets-Coder commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

Also, a similar extension already has a PR, so this is a duplicate: #1861, so I don't even know if this can be merged

@yuri-kiss

This comment was marked as abuse.

@Brackets-Coder

Copy link
Copy Markdown
Contributor

Also, a similar extension already has a PR, so this is a duplicate: #1861, so I don't even know if this can be merged

theres like 5 complex number extensions atp, and almost none of them are different with the only thing ever changing being the library they steal use

are we going to fix that problem and close the dupes?

@Kenay555

Kenay555 commented Apr 24, 2025

Copy link
Copy Markdown
Author

Also, a similar extension already has a PR, so this is a duplicate: #1861, so I don't even know if this can be merged

theres like 5 complex number extensions atp, and almost none of them are different with the only thing ever changing being the library they steal use

Well, @yuri-kiss , mine has polar and can play with position easier :) And yes, I stole used a library, but Rawify's credited too. Plus, got more trig tools and a cool deg->rad thing, so it's different :3

@CubesterYT

Copy link
Copy Markdown
Member

Ok let's see what pettier does here
!format

@Kenay555 Kenay555 marked this pull request as draft April 25, 2025 18:30
@Brackets-Coder

Copy link
Copy Markdown
Contributor

@yuri-kiss or @CubesterYT can this be closed now that #2113 is a thing?

@Kenay555

Kenay555 commented Jun 9, 2025

Copy link
Copy Markdown
Author

@yuri-kiss or @CubesterYT can this be closed now that #2113 is a thing?

Let me do the honors ;)

@Kenay555 Kenay555 closed this Jun 9, 2025
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.

6 participants