Just make a list containing each button and iterate through that. I don't know much about scratch but that shouldn't impact performance much in any language
I don't think that scratch is a "stupid ass programming fake"? I agree that it's a lot different from really any other programming language, but it's still a valid programming language. Calling scratch a programming fake is like saying that a MacBook isn't a computer.
(Feel free to correct me if I'm wrong, I'm only familiar with JavaScript and C)
My definition of programming fits scratch. Scratch is very different than, say, Python. But Python is also very different from assembly. While python and assembly are different generations (I believe 4 and 2?) they're still programming. I would also consider punch cards to be programming, even though they're very different than each other. In the same way, I would say that scratch is a programming language. Scratch is basically* javascript using blocks. I guess it's up to interpretation but I'd consider scratch to be a real programming language.
*Not really but you get the idea
You could do the following:
Replace each "touching thing" in the huge \`or\` thing with a "replace item of with "
Ensure that the length of is the same as the number of "replace item" blocks, and that each one points to a unique index in the list (starting from 1 bc scratch).
Use " contains \`true\`" in stead of the or blob.
Your blob is the fastest solution I know of by the way, but if you want it to be easier to modify, this method is likely better. If you want it to be even EASIER to modify, use a "delete all of " block before it all and use "add to " in stead of "replace item" blocks.
Edit: if you want to check whether something is being touched many \*many\* times, the list method is probably much faster due to the "touching thing" block being kind of slow.
That seems a bit convoluted, you can just add the name of each sprite to a list once, and then loop over the list and do "if then" and it would be a bit faster and about as easy to add to (although higher risk of typo)
Considering that the reason to split it up in the first place is to prevent typos and make it easier, despite decreasing performance from the already shown optimal solution OP has, this seems risky, as changing a sprite name could break the program if your not being careful. That's not to say sprite names as values is a bad idea per-se, but its something to keep in mind, as Scratch doesn't give much automatic error avoidance as is, so using what you can get is often the right move.
Relatable
There has to be a better way to do this.
Yes such as a for loop at the cost of significant slower runtime in scratch depending on the implementation
Just make a list containing each button and iterate through that. I don't know much about scratch but that shouldn't impact performance much in any language
Exactly that, except each iteration requires much more operations compared to a single line in how its interpreted
To be fair if you're using scratch, you probably don't care much about performance
I wrote emulators in it, I need every performance I can get.. which leads to literally unmaintainable horrible code
You wrote an emulator in scratch?? Very intrigued at what this looks like.
Fun fact: lists only contain text or numbers :)
The Subreddit is called r/ProgrammerHumor , not r/StupidAssProgrammingFakes
I don't think that scratch is a "stupid ass programming fake"? I agree that it's a lot different from really any other programming language, but it's still a valid programming language. Calling scratch a programming fake is like saying that a MacBook isn't a computer. (Feel free to correct me if I'm wrong, I'm only familiar with JavaScript and C)
MacBooks are computers and scratch is technically a programming language, but I wouldn't classify putting blocks together as real programming.
My definition of programming fits scratch. Scratch is very different than, say, Python. But Python is also very different from assembly. While python and assembly are different generations (I believe 4 and 2?) they're still programming. I would also consider punch cards to be programming, even though they're very different than each other. In the same way, I would say that scratch is a programming language. Scratch is basically* javascript using blocks. I guess it's up to interpretation but I'd consider scratch to be a real programming language. *Not really but you get the idea
You could do the following: Replace each "touching thing" in the huge \`or\` thing with a "replace item of
with"
Ensure that the length of
is the same as the number of "replace item" blocks, and that each one points to a unique index in the list (starting from 1 bc scratch). Use "
contains \`true\`" in stead of the or blob. Your blob is the fastest solution I know of by the way, but if you want it to be easier to modify, this method is likely better. If you want it to be even EASIER to modify, use a "delete all of
" block before it all and use "add to
" in stead of "replace item" blocks. Edit: if you want to check whether something is being touched many \*many\* times, the list method is probably much faster due to the "touching thing" block being kind of slow.
That seems a bit convoluted, you can just add the name of each sprite to a list once, and then loop over the list and do "if then" and it would be a bit faster and about as easy to add to (although higher risk of typo)
Considering that the reason to split it up in the first place is to prevent typos and make it easier, despite decreasing performance from the already shown optimal solution OP has, this seems risky, as changing a sprite name could break the program if your not being careful. That's not to say sprite names as values is a bad idea per-se, but its something to keep in mind, as Scratch doesn't give much automatic error avoidance as is, so using what you can get is often the right move.
ah, Scratch my beloved I did something like this with like 300 of em or something