Skip to content

Vectors #2074

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 41 commits into
base: master
Choose a base branch
from
Open

Vectors #2074

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e437ea9
Create timeutills.js
unknown07724 Jun 22, 2024
f0f99b6
Rename extensions/timeutills.js to extensions/unknown/timeutills.js
unknown07724 Jun 25, 2024
17680ea
Update timeutills.js
unknown07724 Jun 25, 2024
af93815
Update timeutills.js
unknown07724 Jun 25, 2024
5d4882b
Update timeutills.js
unknown07724 Jun 26, 2024
b9ad34e
Update timeutills.js
unknown07724 Jun 26, 2024
8cd2ad5
Create mailutils.js
unknown07724 Aug 19, 2024
c8ba421
Update mailutils.js
unknown07724 Aug 21, 2024
1425e97
Update mailutils.js
unknown07724 Aug 21, 2024
bafa172
Merge branch 'TurboWarp:master' into master
unknown07724 Nov 30, 2024
c83d9f4
Delete extensions/unknown/mailutils.js
unknown07724 Nov 30, 2024
080e790
Delete extensions/unknown/timeutills.js
unknown07724 Nov 30, 2024
957cc7f
Merge branch 'TurboWarp:master' into api-toolbox
unknown07724 Apr 7, 2025
293efd2
Create api-toolbox.js
unknown07724 Apr 7, 2025
84784db
Rename api-toolbox.js to api-toolbox.js
unknown07724 Apr 7, 2025
2bdeb70
Update extensions.json
unknown07724 Apr 7, 2025
fe8abcc
Update api-toolbox.js
unknown07724 Apr 7, 2025
6c6085d
Update api-toolbox.js
unknown07724 Apr 7, 2025
766784d
Update api-toolbox.js
unknown07724 Apr 7, 2025
58b0eca
Create vectors.js
unknown07724 Apr 8, 2025
6587f1b
Delete extensions/unknown/api-toolbox.js
unknown07724 Apr 8, 2025
215bcf8
Update extensions.json
unknown07724 Apr 8, 2025
7f5daee
Update vectors.js
unknown07724 Apr 9, 2025
094a242
[Automated] Format code
DangoCat Apr 9, 2025
7dfa05a
Update vectors.js
unknown07724 Apr 9, 2025
db0edbd
[Automated] Format code
DangoCat Apr 9, 2025
86ddd01
Update vectors.js
unknown07724 Apr 9, 2025
fa0d902
[Automated] Format code
DangoCat Apr 9, 2025
abbdf2f
Update vectors.js
unknown07724 Apr 9, 2025
a481dcb
Update vectors.js
unknown07724 Apr 9, 2025
14cdecc
Update vectors.js
unknown07724 Apr 9, 2025
7e9c6fc
Update vectors.js
unknown07724 Apr 17, 2025
d422aff
Merge branch 'TurboWarp:master' into vectors
unknown07724 Apr 17, 2025
2c7e9da
Update vectors.js
unknown07724 Apr 17, 2025
38f99bf
Update vectors.js
unknown07724 Apr 17, 2025
7fe7b1a
Update vectors.js
unknown07724 Apr 17, 2025
1d505e4
Update vectors.js
unknown07724 Apr 17, 2025
f374566
Update vectors.js
unknown07724 Apr 17, 2025
30b67f0
[Automated] Format code
DangoCat Apr 17, 2025
605495f
Update vectors.js
unknown07724 Apr 20, 2025
84a6583
[Automated] Format code
DangoCat Apr 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extensions/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"Lily/AllMenus",
"Lily/HackedBlocks",
"Lily/Cast",
"Unknown/vectors",
"-SIPC-/time",
"-SIPC-/consoles",
"ZXMushroom63/searchApi",
Expand Down
175 changes: 175 additions & 0 deletions extensions/unknown/vectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
// Name: Vectors
// ID: unknownvectors
// Description: variables with a direction.
// By: Unknown07724 <https://scratch.mit.edu/users/Unknown07724/>
// License: MPL-2.0

(function (Scratch) {
Copy link
Member

Choose a reason for hiding this comment

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

you're missing the header data

Copy link
Author

@unknown07724 unknown07724 Apr 20, 2025

Choose a reason for hiding this comment

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

< >, Imma re-add that Ig

"use strict";

// Ensuring the extension is unsandboxed
if (!Scratch.extensions.unsandboxed) {
throw new Error("This extension must run unsandboxed");
}

// Vectors storage
const ids = [];
Copy link
Member

Choose a reason for hiding this comment

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

why can't this be a set

const directions = {};
Copy link
Member

Choose a reason for hiding this comment

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

these should be Object.create(null); or a Map

const magnitudes = {};

class UnknownVectors {
getInfo() {
return {
id: "unknownvectors",
name: Scratch.translate("Vectors"),
color1: "#3495eb",
blocks: [
{
opcode: "vectorCreate",
blockType: Scratch.BlockType.COMMAND,
text: Scratch.translate(
"create vector with ID [ID], direction [DIRECTION] and magnitude [MAGNITUDE]"
Copy link
Member

Choose a reason for hiding this comment

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

you have inconsistent capitalization across the blocks, the blocks should be written starting with lowercase. they are NOT sentences.

),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
DIRECTION: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 90,
},
MAGNITUDE: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 10,
},
},
},
{
opcode: "vectorChangeMag",
blockType: Scratch.BlockType.COMMAND,
text: Scratch.translate(
"change vector [ID]'s magnitude to [MAGNITUDE]"
),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
MAGNITUDE: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 10,
},
},
},
{
opcode: "vectorChange",
blockType: Scratch.BlockType.COMMAND,
text: Scratch.translate(
"change vector [ID] to direction [DIRECTION] and magnitude [MAGNITUDE]"
),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
DIRECTION: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 90,
},
MAGNITUDE: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 10,
},
},
},
{
opcode: "vectorDelete",
blockType: Scratch.BlockType.COMMAND,
text: Scratch.translate("delete vector with [ID]"),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
},
},
{
opcode: "vectorChangedir",
blockType: Scratch.BlockType.COMMAND,
text: Scratch.translate(
"change vector [ID]'s direction to [DIRECTION]"
),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
DIRECTION: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: 90,
},
},
},
{
opcode: "vectorMag",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate("magnitude of vector [ID]"),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
},
},
{
opcode: "listofIDs",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate("List of IDs"),
},
{
opcode: "vectorDir",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate("direction of vector [ID]"),
arguments: {
ID: { type: Scratch.ArgumentType.STRING, defaultValue: "vec1" },
},
},
],
};
}

vectorCreate(args) {
const id = args.ID;
Copy link
Member

Choose a reason for hiding this comment

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

you don't cast anything, this is poor practice

Copy link
Author

Choose a reason for hiding this comment

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

aren't they numbers, you can not put strings in there, and if you could, who would?

if (!ids.includes(id)) {
ids.push(id);
}
directions[id] = args.DIRECTION;
magnitudes[id] = args.MAGNITUDE;
}

vectorChange(args) {
const id = args.ID;
directions[id] = args.DIRECTION;
magnitudes[id] = args.MAGNITUDE;
}

vectorChangedir(args) {
const id = args.ID;
directions[id] = args.DIRECTION;
}

vectorChangeMag(args) {
const id = args.ID;
magnitudes[id] = args.MAGNITUDE;
}

vectorMag(args) {
const id = args.ID;
return magnitudes[id] ?? Scratch.translate("vector not found");
Copy link
Member

Choose a reason for hiding this comment

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

you should return an empty string or 0 here

Copy link
Author

Choose a reason for hiding this comment

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

do I want people to wonder why their shit isn't working? if you said yes then you are wrong, the answer is no.

Copy link
Contributor

Choose a reason for hiding this comment

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

do I want people to wonder why their shit isn't working? if you said yes then you are wrong, the answer is no.

@GarboMuffin said to chill the language

}

vectorDelete(args) {
const id = args.ID;
const index = ids.indexOf(id);
if (index !== -1) {
ids.splice(index, 1);
delete directions[id];
delete magnitudes[id];
}
}

vectorDir(args) {
const id = args.ID;
return directions[id] ?? Scratch.translate("vector not found");
Copy link
Member

Choose a reason for hiding this comment

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

same here

}

listofIDs() {
return ids.join(", ");
}
}

Scratch.extensions.register(new UnknownVectors());
})(Scratch);
Loading