Discuss Scratch
- Discussion Forums
- » Suggestions
- » Ultimate List of Workarounds And More
- MathlyCat
-
1000+ posts
Ultimate List of Workarounds And More
Your example is fairly ineffective for organizing multiple variables.Meh, this is better:when [variable v] = (6) :: events hat
//Workaround
forever
if <(variable) = [6]> then
...
end
endwhen green flag clicked
forever
wait until <(foo) = (. . .)>
. . .
end
Sweet! I don't have a lot of workarounds, but I'm willing to help people if I can.
I’ll look into fixing it-snip-
“But that's too long!” I hear you say. Note that this is the absolute complete workaround, that does everything mentioned in the OP (reverse output on backwards indices) and then some (return the same thing as letter (0) of (str) if indices are out of bounds).
For the majority of cases, something much simpler will work, such as:define letters (a) to (b) of (str) => resultNote that the only things this block does not support are a) reverse strings, b) bounds checking, and c) strings above the join block limit, which is barely even a problem, as most string manipulation will involve the join block anyways.
set [i v] to (a)
set [result v] to []
repeat (((b) - (a)) + (1))
set [result v] to (join (result) (letter (i) of (str)))
Also note that this block will still return a valid value for invalid bounds, simply due to how Scratch bound checks the letter of () block.
-snip-
I would like to point out that this script is broken, it will return letter a of str a total of the number of letters to check + 1. So for the string “Happy Birthday!” trying to get letters 4 - 7 with this script would set result to pppp. To fix it, make it look like this.define letters (a) to (b) of (str) => result
set [i v] to (a)
set [result v] to []
repeat (((b) - (a)) + (1))
set [result v] to (join (result) (letter (i) of (str)))
change [i v] by (1)
end
Or this.define letters (a) to (b) of (str) => result
set [i v] to ((a) - (1))
set [result v] to []
repeat (((b) - (a)) + (1))
change [i v] by (1)
set [result v] to (join (result) (letter (i) of (str)))
end
Now letters 4 - 7 of “Happy Birthday!” will return py B.
- Botcho_Otkho
-
1000+ posts
Ultimate List of Workarounds And More
Indeed, that's the workaround for only one variable. (snip)
Your example is fairly ineffective for organizing multiple variables.
Yeah it was better if I said that before
- creeper82
-
15 posts
Ultimate List of Workarounds And More
I'm not sure if I understand what is this topic about and i understand nothing. i think that's my third post on these forums…
Okay, so… here's my block:
)
See my profile!
My best 3D pen project!
Okay, so… here's my block:
(how much [letter] in [word]?)and the workaround or whatever is it called (sorry if i do something wrong

define how much [letter] in [word]
set [num v] to (0)
set [result v] to (0)
repeat (length of (word))
change [num v] by (1)
if<(letter (num) of (word)) = (letter)> then
change [result v] by (1)
end
i think it works :D
example below!
when flag clicked
ask [hello, i can count how many letters are there in a word. type in any word] and wait
set [word v] to (answer)
ask [now type any letter] and wait
how much (answer) in (word)
^^ block above is moreblock we defined at top
say (join [This word has ] (join (result) [letters])) for (2) secs
See my profile!
My best 3D pen project!
- MathlyCat
-
1000+ posts
Ultimate List of Workarounds And More
Sweet! I'm not sure if I understand what is this topic about and i understand nothing. i think that's my third post on these forums…
Okay, so… here's my block:(how much [letter] in [word]?)and the workaround or whatever is it called (sorry if i do something wrong)
define how much [letter] in [word]
set [num v] to (0)
set [result v] to (0)
repeat (length of (word))
change [num v] by (1)
if<(letter (num) of (word)) = (letter)> then
change [result v] by (1)
end
i think it works :D
example below!when flag clicked
ask [hello, i can count how many letters are there in a word. type in any word] and wait
set [word v] to (answer)
ask [now type any letter] and wait
how much (answer) in (word)
^^ block above is moreblock we defined at top
say (join [This word has ] (join (result) [letters])) for (2) secs
See my profile!
My best 3D pen project!
- Shaymin524
-
68 posts
Ultimate List of Workarounds And More
Comment block:
if <[1] = [1] > then
forever
end
end
say [This is a comment!]
- thelostgames
-
58 posts
Ultimate List of Workarounds And More
Workarounds
Note: If you have trouble finding one already in the list then make a post asking about a workaround to a certain block. I'll reply with the workaround if there is one!
____________________day of year :: sensing reporter((days since 2000) - ((365) * ((current [year v]) - (2000))))____________________
____________________
____________________
____________________
____________________
You would also have to include a multiplication by 1/4 to account for leap years
- space_elephant
-
500+ posts
Ultimate List of Workarounds And More
workaround for
when(value::)changes::events hat
//is
when[timer v]>((timer)-<not<(value::)=(var)>>)
set[var v]to(value::)
Last edited by space_elephant (Oct. 5, 2018 16:51:38)
- space_elephant
-
500+ posts
Ultimate List of Workarounds And More
better way:<<<> or <>> and <not <<> and <>>>> // XOR (place the first 2 reporters in the last 2 as well
<not<<input 1::custom-arg>=<input 2::custom-arg>>>
- creeper82
-
15 posts
Ultimate List of Workarounds And More
When <x> becomes true
Have you ever wanted to do certain action, when you hover over the sprite? Now You can! Thanks to this block:
We can make this:
You can do more of them in one project but it may become laggy.
———————————————————————————————————————————————-
Check My Profile!
Featured Projects in my opinion:


Have you ever wanted to do certain action, when you hover over the sprite? Now You can! Thanks to this block:
when [timer v] > (10)
We can make this:
when [timer v] > ((timer) - <touching [mouse pointer v]?>)sprite will say it, when the mouse will touch it. you can replace touching m.p. block with for example: score > best score
say [you touched me!] for (2) secs
You can do more of them in one project but it may become laggy.
———————————————————————————————————————————————-
Check My Profile!
Featured Projects in my opinion:


- Botcho_Otkho
-
1000+ posts
Ultimate List of Workarounds And More
When <x> becomes trueI always recommend to test scripts before suggesting them. This won't absolutely work, and doesn't mean anything in coding.
Have you ever wanted to do certain action, when you hover over the sprite? Now You can! Thanks to this block:when [timer v] > (10)
We can make this:when [timer v] > ((timer) - <touching [mouse pointer v]?>)
say [you touched me!] for (2) secs
Really? I don't think at all few scripts will make the project lag. You can do more of them in one project but it may become laggy.
I don't want to be rude, but that's how it is.
- MathlyCat
-
1000+ posts
Ultimate List of Workarounds And More
A lot of hat blocks can cause issues with running in the Scratch Player, but the lag is based on computer specifics.When <x> becomes trueI always recommend to test scripts before suggesting them. This won't absolutely work, and doesn't mean anything in coding.
Have you ever wanted to do certain action, when you hover over the sprite? Now You can! Thanks to this block:when [timer v] > (10)
We can make this:when [timer v] > ((timer) - <touching [mouse pointer v]?>)
say [you touched me!] for (2) secsReally? I don't think at all few scripts will make the project lag. You can do more of them in one project but it may become laggy.
I don't want to be rude, but that's how it is.
Replace 365 with 365.25Workarounds
Note: If you have trouble finding one already in the list then make a post asking about a workaround to a certain block. I'll reply with the workaround if there is one!
____________________day of year :: sensing reporter((days since 2000) - ((365) * ((current [year v]) - (2000))))____________________
____________________
____________________
____________________
____________________
You would also have to include a multiplication by 1/4 to account for leap years
- Shaymin524
-
68 posts
Ultimate List of Workarounds And More
Or even 365.2 -snip-6Replace 365 with 365.25-snip-day of year :: sensing reporter((days since 2000) - ((365) * ((current [year v]) - (2000))))
You would also have to include a multiplication by 1/4 to account for leap years
This will work: in programming, a ‘true’ boolean is a value other than zero, and a ‘false’ boolean is equal to zero. In this case, the timer would be larger than the timer only if the second reference had something subtracted from it, i.e. when the boolean is true. In, say, javascript:When <x> becomes trueI always recommend to test scripts before suggesting them. This won't absolutely work, and doesn't mean anything in coding.
Have you ever wanted to do certain action, when you hover over the sprite? Now You can! Thanks to this block:when [timer v] > (10)
We can make this:when [timer v] > ((timer) - <touching [mouse pointer v]?>)
say [you touched me!] for (2) secs
-snip-
if (1) {would pop up with ‘True = 1!’
alert('True = 1!')
}
- andyhanwu
-
76 posts
Ultimate List of Workarounds And More
Can you make a workaround for this:
point towards x:(0) y:(0)
- andyhanwu
-
76 posts
Ultimate List of Workarounds And More
That wouldn't work, as leap years are imperfect.Workarounds
Note: If you have trouble finding one already in the list then make a post asking about a workaround to a certain block. I'll reply with the workaround if there is one!
____________________day of year :: sensing reporter((days since 2000) - ((365) * ((current [year v]) - (2000))))____________________
____________________
____________________
____________________
____________________
You would also have to include a multiplication by 1/4 to account for leap years
As far as I know, every 4 years there is a leap year unless the year is divisible by 100 but not 400, with an exception every 3200 years. Don't worry if you got lost. Almost everyone does.
- BlackWolfee
-
500+ posts
Ultimate List of Workarounds And More
Create a hidden sprite that is at that position and use Can you make a workaround for this:point towards x:(0) y:(0)
point towards [ v]
- brendanthescratcher
-
49 posts
Ultimate List of Workarounds And More
There is now a block that does that. Could someone give me a workaround to if some variable contains another? EG:set [ variable1] to [HELLO!!!!!! ]
set [variable2] to [HELLO]
if (variable2) contains (variable1) then
set [variable1] to (pick random (1) to (10))
end
- TheThirdMario
-
1 post
Ultimate List of Workarounds And More
Hi! These are great workarounds!
- unikyliecorn
-
72 posts
Ultimate List of Workarounds And More
Shoot, I was just about to answer their question oof xDThere is now a block that does that. Could someone give me a workaround to if some variable contains another? EG:set [ variable1] to [HELLO!!!!!! ]
set [variable2] to [HELLO]
if (variable2) contains (variable1) then
set [variable1] to (pick random (1) to (10))
end
Last edited by unikyliecorn (Jan. 14, 2019 20:56:19)
- sk7725
-
35 posts
Ultimate List of Workarounds And More
I would say that rejecting suggestions because of ‘workarounds’ is opposing to the Scratch's intent and Goal, and just not smart in general.
Sure, blocks like
But blocks like
Please, help the new scratchers!
Sure, blocks like
() + () + () :: operators reporterwill make no sense, because it is easily accomplishable by New Scratchers.
But blocks like
letter () to () of [sk7725] :: operators reporterwill definitely help
another example is young people learn to think creatively, reason systematically, and work collaboratively.
if <> then {which is great for teachers who are using Scratch as a bridge towards other languages like C.
}else if <> then {
}else {
}::control cblock
Please, help the new scratchers!
- ihgfedcba
-
100+ posts
Ultimate List of Workarounds And More
The thing is, each abs output has 2 inverses. Including 0 of course, because +0 and -0 are stored differently.In aabs should Use in Workaround: Workaround for inverses of the built in functions of a single number (assuming e is the number)([aabs v] of (e)::operators)
((0) - (e))([asqrt v] of (e)::operators)
([10 ^ v] of (([log v] of (e)) * (2)))
aln=e^
alog=10^
a10^=log
ae^=ln((0) - ([abs v] of (e)))
- Discussion Forums
- » Suggestions
-
» Ultimate List of Workarounds And More