Discuss Scratch

scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

This is for a collab between me and TeenySpoon. It is a math collab about graphing lines, linear equations, parsing, solving, PEMDAS, etc.

Graphing engine - Complete ✅
Graphing and finding solution to system of linear equations (intersection point) - Complete ✅
Equation parser - Complete ✅
PEMDAS sorter - [###################-] 90%
#{op} solver - [——————–] 0%

PEMDAS sorter update 1:

Update 2:

Update 3:

Update 4:

Here's a screenshot of a comment I wrote in the script, showing what #{op} format is:
https://assets.scratch.mit.edu/get_image/.%2E/c2e62405e7674556cd8597110a474ecc.png (I'm not showing the actual picture because it's too big and takes up too much of the page)

Text version:
"
P E M D A S
0 1 2 3 4 5

Each “rank” corresponds to a specific part of PEMDAS, and is assigned to each operation, which is added back into the list as #{op} question depending on their rank. To clarify what this means, here's a basic breakdown of the simple equation y = 3x:

Here's the list at it's starting point, completely parsed:

y
=
3
*
x

Each newline is an item, by the way. After that, the “y =” are deleted since we don't need them. The project is to graph x and y after all, so we already know that we need to set y. Then, it is rewritten into #{op}™ format (invented by me lol) and since there is only one operation, 3 * x, it will fit in only one #{op}. Here is how it would look like in this format:

2{ // the 2 is the rank, in this case M or multiplication since it is multiplication.
3
*
x
}

If this still doesn't clarify what #{op} is, here's a simple, short explanation. The # is the rank, where it is the first thing read by the solver. Then, the { and } brackets are used to signify the start and end of a single operation, stored as a single chunk in the list, not separated. Then, the parsed piece of equation, the operation, goes inside of the curly brackets.

Another extra note: for parentheses, the parentheses themselves are deleted, since we only need the numbers and the operation symbols. The solver itself will take care of it using the # rank. To solve nested parentheses, it has to put the nested ones first in the list, making it get solved first."

Last edited by scratchcode1_2_3 (July 19, 2023 15:47:22)


I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

Is this our math collab?

Link, please. I'll help you.
Also, it could be that they appear to intersect because of the pen size, but don't actually intersect.

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#2)
Is this our math collab?

Link, please. I'll help you.
Also, it could be that they appear to intersect because of the pen size, but don't actually intersect.

lol I didn't expect to see you here

Anyways, it's the same exact already existing script, but with added precision so that every hundredth of a unit would also get stored in the lists, and would greatly improve the script by having a greater chance at detecting equations that normally have decimal points and aren't all whole numbers. Since the added precision slows it down, I just did that on turbowarp, so the only way i can share a link is by downloading the file and posting it on a project, but it wouldn't be able to run in scratch as well. I just have 250 fps on with turbo mode.

As you can see, I've modified it to adjust to a 1920x1080 display, a full HD player size. I made the loop run 192000 times instead of just 480, so that it could run on a bigger player size and increase the precision 100 times more than it already was. Here is a screenshot of the new equation 2 block:



(offtopic) By the way, I'm almost done with the pemdas sorter, just need to use the #{op} format I made XD
Also, could changing precision be the new feature we could add?

Last edited by scratchcode1_2_3 (July 17, 2023 23:09:13)


I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

scratchcode1_2_3 wrote:

lol I didn't expect to see you here
I check the forums every day. unluckily for you… were you trying to hide this from me??

Hmm, could be that x and y positions can't be decimals?
Also could be that Scratch math starts acting funny with big numbers, but that's because of the extra 0s.

Let me think about this a bit more.

scratchcode1_2_3 wrote:

(offtopic) By the way, I'm almost done with the pemdas sorter, just need to use the #{op} format I made XD
Also, could changing precision be the new feature we could add?
Sure, why not?

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#4)
unluckily for you… were you trying to hide this from me??
uh…um definitely not

TeenySpoon wrote:

(#4)
Hmm, could be that x and y positions can't be decimals?
I think they CAN be, it just isn't really displayed. The decimal values still get added to the list either way, meaning it's okay. They just get added to the list wrong.

Last edited by scratchcode1_2_3 (July 17, 2023 23:20:57)


I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

Idk what's causing it because the code looks fine to me.

Maybe you could add something that looks for for extra decimal digits and gets rid of them? And parse it as a string and not a number, maybe that will work.

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#6)
Idk what's causing it because the code looks fine to me.

Maybe you could add something that looks for for extra decimal digits and gets rid of them? And parse it as a string and not a number, maybe that will work.
Yeah, I think that would work.

edit: i found a script that may work:
([floor v] of (((x position) * (100)) / (100)))

Last edited by scratchcode1_2_3 (July 18, 2023 00:11:44)


I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

scratchcode1_2_3 wrote:

TeenySpoon wrote:

(#6)
Idk what's causing it because the code looks fine to me.

Maybe you could add something that looks for for extra decimal digits and gets rid of them? And parse it as a string and not a number, maybe that will work.
Yeah, I think that would work.

edit: i found a script that may work:
([floor v] of (((x position) * (0)) / (100)))

Last edited by scratchcode1_2_3 (Tomorrow 0:00:00)
Wouldn't x * 0 just end up being 0?

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#8)

scratchcode1_2_3 wrote:

TeenySpoon wrote:

(#6)
Idk what's causing it because the code looks fine to me.

Maybe you could add something that looks for for extra decimal digits and gets rid of them? And parse it as a string and not a number, maybe that will work.
Yeah, I think that would work.

edit: i found a script that may work:
([floor v] of (((x position) * (0)) / (100)))

Last edited by scratchcode1_2_3 (Tomorrow 0:00:00)
Wouldn't x * 0 just end up being 0?
oops i meant 100 gotta go fix it

I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

scratchcode1_2_3 wrote:

oops i meant 100 gotta go fix it
Ok, makes sense.
Tell me when it's done!

Also, how are we going to collaborate if it's on TurboWarp and we can't upload it to Scratch?

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#10)

scratchcode1_2_3 wrote:

oops i meant 100 gotta go fix it
Ok, makes sense.
Tell me when it's done!

Also, how are we going to collaborate if it's on TurboWarp and we can't upload it to Scratch?

The final pemdas sorter will not be on turbowarp, it will be in scratch. I was just using turbowarp to make it faster and tweak some things. Here's a tiny essay I wrote on the #{op} format:
P E M D A S
0 1 2 3 4 5

Each “rank” corresponds to a specific part of PEMDAS, and is assigned to each operation, which is added back into the list as #{op} question depending on their rank. To clarify what this means, here's a basic breakdown of the simple equation y = 3x:

Here's the list at it's starting point, completely parsed:

y
=
3
*
x

Each newline is an item, by the way. After that, the “y =” are deleted since we don't need them. The project is to graph x and y after all, so we already know that we need to set y. Then, it is rewritten into #{op}™ format (invented by me lol) and since there is only one operation, 3 * x, it will fit in only one #{op}. Here is how it would look like in this format:

2{ // the 2 is the rank, in this case M or multiplication since it is multiplication.
3
*
x
}

If this still doesn't clarify what #{op} is, here's a simple, short explanation. The # is the rank, where it is the first thing read by the solver. Then, the { and } brackets are used to signify the start and end of a single operation, stored as a single chunk in the list, not separated. Then, the parsed piece of equation, the operation, goes inside of the curly brackets.

Another extra note: for parentheses, the parentheses themselves are deleted, since we only need the numbers and the operation symbols. The solver itself will take care of it using the # rank. To solve nested parentheses, it has to put the nested ones first in the list, making it get solved first.



But this is getting off-topic. I will ask an ST member to close it and we can continue this conversation on the studio I made.


Or…. we can instead just ask for this to be moved to the “collaboration forum” dunno which works best.

Last edited by scratchcode1_2_3 (July 18, 2023 00:20:58)


I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

scratchcode1_2_3 wrote:

Or…. we can instead just ask for this to be moved to the “collaboration forum” dunno which works best
Can we do that instead?

I kinda like the forums better XD

Just rename the title to something like “Linear equation collab (closed!)” and we'll be good to go. Although I don't know if we really need the “closed” because most people will be scared away by “linear equation” lol

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#12)

scratchcode1_2_3 wrote:

Or…. we can instead just ask for this to be moved to the “collaboration forum” dunno which works best
Can we do that instead?

I kinda like the forums better XD

Just rename the title to something like “Linear equation collab (closed!)” and we'll be good to go. Although I don't know if we really need the “closed” because most people will be scared away by “linear equation” lol
Okay lol

I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

hey it actually got moved! yay

I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

PEMDAS sorter update:

I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

Lol you're using the Debugger from forbidden word?
I have bad eyesight so I'm not really going to look at the code right now, but I'll definitely read through it once you port it to Scratch.

MATH!!

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#16)
Lol you're using the Debugger from forbidden word?
Yes I am lol, I was using it to test some things that weren't working but I haven't removed it yet. Should I even remove it? idk

I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

Using custom emojis, huh? Well so can I /j

I don't think you should remove them, they work well as in-line comments.

⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
scratchcode1_2_3
Scratcher
1000+ posts

Linear equations collab

TeenySpoon wrote:

(#18)
Using custom emojis, huh? Well so can I /j

I don't think you should remove them, they work well as in-line comments.

Yeah, you're right. I still need just a bit of progress on it though

I am scratchcode1_2_3 I like making projects based on…………………………cubes?
select + shift + scroll down to see my signature | Also, comment on my Comment animations #2 + Bonus Q+A!
when green flag clicked
set [scratchcode v] to [1_2_3]
add [hello] to [list v]
stop [every single project v]
BLOCK
define BLOCK
click green flag


SIGNATURE

I'm very helpful when it comes to coding projects, not very helpful when it comes to art decently helpful when it comes to art (i wrote that a long time ago when i couldn't draw) XD
So, If you need help, I'll be there! (when I'm active, of course)

picture made with awesome-llama's image editor– go check it out: scratch | turbowarp it saves to BBCode and other formats as well

Order on my shop now! Orders open! Need staff.



(#^-^) // this is a circly that is now good! he defends my signature! that bite mark is from the time josueart tried to eat it... 
Oh no! The circly was bitten by josueart!

TeenySpoon
Scratcher
500+ posts

Linear equations collab

I searched up “linear function grapher” and there were very few results.

Analyzing our competitors! I mean…friends who we learn from?

https://scratch.mit.edu/projects/49414894/
This one also does quadratic equations, which is pretty impressive. However, it doesn't parse the equation, just asks for input values.

https://scratch.mit.edu/projects/426657742/
This pretty good except it mixed up K and b. Again, ours will actually parse the equation.

The others I didn't have time to go through lol

I think we should also add the option to customize colors (after we finish the main code) and draw our own background. Scratch's default one looks too…default.

Last edited by TeenySpoon (July 18, 2023 23:47:26)


⚜ TeenySpoon ⚜ Alt: TeenyTea
An absent-minded programmer/artist

A Random Pen Window Manager
⚜ Me ⚜ TeenyForkTeenyKnife

“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas

Powered by DjangoBB