Discuss Scratch
- Discussion Forums
- » Suggestions
- » instances of () in ()
- trolley_explodes
-
100+ posts
instances of () in ()
Last edited by trolley_explodes (Yesterday 16:10:18)
- trolley_explodes
-
100+ posts
instances of () in ()
If you have 4 e's in a string of letters like adwpigjpnavoitwetnweopajrintoweptkoawe it returns 4. What would this do?
- BendyOl183
-
500+ posts
instances of () in ()
That sounds cool, I supportIf you have 4 e's in a string of letters like adwpigjpnavoitwetnweopajrintoweptkoawe it returns 4. What would this do?
This could be used for stuff like checking how many characters you have typed which would be helpful in TTS projects, as each TTS block doesn't speak more than 100 characters, this would make it easier for people to check how many characters they have written without using a different website.
- Zydrolic
-
1000+ posts
instances of () in ()
Workaround incase you'd want to make it in a custom block:
define instances of (letter) in (string)(If you don't wanna recreate this in the editor for some reason, you can just backpack it here)
set [cycle v] to [0]
set [output v] to [0]
repeat until <(cycle) > (length of (string))>
if <(letter (cycle) of (string)) contains (letter)?> then
change [output v] by [1]
end
change [cycle v] by [1]
end
Last edited by Zydrolic (Yesterday 16:08:31)
- trolley_explodes
-
100+ posts
instances of () in ()
That's pretty big, I think new scratchers would have a real hard time making this so… Workaround incase you'd want to make it in a custom block:define instances of (letter) in (string)
set [cycle v] to [0]
set [output v] to [0]
repeat until <(cycle) > (length of (string))>
if <(letter (cycle) of (string)) contains (letter)?> then
change [output v] by [1]
end
change [cycle v] by [1]
end
Last edited by trolley_explodes (Yesterday 16:08:54)
- Zydrolic
-
1000+ posts
instances of () in ()
(#6)It's not that big, though? It's only 15 blocks - Most code is longer than that. Though I can see your point about a new scratcher having a hard time if they just… Don't think about cycling through the text for the count. (Not sure how I can put that any other way)
That's pretty big, I think new scratchers would have a real hard time making this so…
Last edited by Zydrolic (Yesterday 16:12:36)
- unknown2467
-
100+ posts
instances of () in ()
I think this is a duplicate, but I can't find the original topic.
- trolley_explodes
-
100+ posts
instances of () in ()
Then please don't post it until you're sure. I think this is a duplicate, but I can't find the original topic.
- TheBaton
-
100+ posts
instances of () in ()
Hey, there is a better workaround to this so you can check for multi-character strings.
There is no “it would be too difficult for new users to implement” excuse here, or anywhere. Certainly, this block is a good idea. However, since the workarounds are plentiful and are easy to integrate, there is no reason to add it in. And if new users cannot deal with the fact that they are required to build something as such, that is an issue that does not fall to the Scratch Team to fix.
define instances of (string1) in (string2)
delete [all v] of [paste v]
delete [all v] of [parse v]
set [index v] to [0]
set [instances v] to [0]
set [cycle v] to [0]
repeat (length of (string2))
change [index v] by [1]
change [cycle v] by [1]
add (letter (index) of (string2)) to [paste v]
if < (cycle) > (length of (string1)) > then
delete [1] of [paste v]
set [cycle v] to [0]
end
if < (string1) = (paste) > then
change [instances v] by [1]
end
end
There is no “it would be too difficult for new users to implement” excuse here, or anywhere. Certainly, this block is a good idea. However, since the workarounds are plentiful and are easy to integrate, there is no reason to add it in. And if new users cannot deal with the fact that they are required to build something as such, that is an issue that does not fall to the Scratch Team to fix.
- medians
-
1000+ posts
instances of () in ()
There could also be an equivalent for lists:
(# of [item] in [list v]::list)
- TheBaton
-
100+ posts
instances of () in ()
There could also be an equivalent for lists:(# of [item] in [list v]::list)
This can also be worked around:
repeat until <not <[list v] contains [hello]>
delete (item # of [hello] in [list v]) of [list v]
change [instances v] by [1]
end
There may be a slight error, and an additional “change instances by -1” after the repeat loop, but it should work as you'd want it to.
- trolley_explodes
-
100+ posts
instances of () in ()
Go look at the list of rejected suggestions and find the 3d scratch section. The literal reason that they rejected it is because it was to complicated. -snip-
There is no “it would be too difficult for new users to implement” excuse here, or anywhere. Certainly, this block is a good idea. However, since the workarounds are plentiful and are easy to integrate, there is no reason to add it in. And if new users cannot deal with the fact that they are required to build something as such, that is an issue that does not fall to the Scratch Team to fix.
- TheBaton
-
100+ posts
instances of () in ()
Go look at the list of rejected suggestions and find the 3d scratch section. The literal reason that they rejected it is because it was to complicated. …
There's no sense in argument here, because I do believe this would be a cool block, but it's simply too easy to implement yourself. The reason 3D Scratch isn't a base feature is because what most would see as functional 3D engines, being something like Unity or Godot, have very complicated menus and windows which Scratch does not. 3D Scratch is not even remotely in proportion of complexity to counting the instances of a string in another. 3D Scratch's ambiguity really holds no validity to your suggestion, but I digress. You must think about the workarounds, and this block doesn't necessarily meet nor exceed the threshold of complexity required for the Scratch Team to go out of their way to make it. There is no project delay or congestion as a result of using a workaround as many have already shown. So, there is no reason to implement this block. No coding is beginner friendly. You just have to take baby steps. And once you've reached a certain “Scratch maturity”, you can handle any kind of project-making.
I hope you understand that this is in no way a personal attack or anything like that. I'm simply letting you know that you have to really weigh the importance of the block or extension. The Scratch Team's job is to take care and monitor the app, not add in random blocks to the community's every whim.
Last edited by TheBaton (Today 06:16:39)
- Discussion Forums
- » Suggestions
-
» instances of () in ()