Discuss Scratch

MathlyCat
Scratcher
1000+ posts

Ultimate List of Workarounds And More

Botcho_Otkho wrote:

TheAdriCoolManDude wrote:

when [variable v] = (6) :: events hat
//Workaround

forever
if <(variable) = [6]> then
...
end
end
Meh, this is better:
when green flag clicked
forever
wait until <(foo) = (. . .)>
. . .
end
Your example is fairly ineffective for organizing multiple variables.

TheAdriCoolManDude wrote:

I don't have a lot of workarounds, but I'm willing to help people if I can.
Sweet!

sonicfan12p wrote:

TheMonsterOfTheDeep wrote:

-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) => result
set [i v] to (a)
set [result v] to []
repeat (((b) - (a)) + (1))
set [result v] to (join (result) (letter (i) of (str)))
Note 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.

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.
I’ll look into fixing it

Think before you act.
Actions speek louder than words.

hi there fella
Botcho_Otkho
Scratcher
1000+ posts

Ultimate List of Workarounds And More

MathlyCat wrote:

(snip)
Your example is fairly ineffective for organizing multiple variables.
Indeed, that's the workaround for only one variable.
Yeah it was better if I said that before

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
creeper82
Scratcher
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:

(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
Scratcher
1000+ posts

Ultimate List of Workarounds And More

creeper82 wrote:

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!
Sweet!

Think before you act.
Actions speek louder than words.

hi there fella
Shaymin524
Scratcher
68 posts

Ultimate List of Workarounds And More

Comment block:
if <[1] = [1] > then
forever

end
end
say [This is a comment!]

—————————————————————————

GENERATION 1: When you first see this copy it to the start of your sig and change Generation by 1.

—————

Bring back remix trees, scroll blocks, picoboards and the discuss tab!

—————

Trans girl / Lesbian / 13 / Libra
thelostgames
Scratcher
58 posts

Ultimate List of Workarounds And More

MathlyCat wrote:

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

No form of coding is right or wrong, they are all simply ways of developing your brain to reach new levels.

Find me here: HERE!
space_elephant
Scratcher
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)


red link
[url=redlink.com][color=red][u]red link[/u][/color][/url]
space_elephant
Scratcher
500+ posts

Ultimate List of Workarounds And More

SuperHal989 wrote:

<<<> or <>> and <not <<> and <>>>> // XOR (place the first 2 reporters in the last 2 as well
better way:
<not<<input 1::custom-arg>=<input 2::custom-arg>>>

red link
[url=redlink.com][color=red][u]red link[/u][/color][/url]
creeper82
Scratcher
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:

when [timer v] > (10)

We can make this:

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

Botcho_Otkho
Scratcher
1000+ posts

Ultimate List of Workarounds And More

creeper82 wrote:

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:

when [timer v] > (10)

We can make this:

when [timer v] > ((timer) - <touching [mouse pointer v]?>)
say [you touched me!] for (2) secs
I always recommend to test scripts before suggesting them. This won't absolutely work, and doesn't mean anything in coding.

creeper82 wrote:

You can do more of them in one project but it may become laggy.
Really? I don't think at all few scripts will make the project lag.
I don't want to be rude, but that's how it is.

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
MathlyCat
Scratcher
1000+ posts

Ultimate List of Workarounds And More

Botcho_Otkho wrote:

creeper82 wrote:

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:

when [timer v] > (10)

We can make this:

when [timer v] > ((timer) - <touching [mouse pointer v]?>)
say [you touched me!] for (2) secs
I always recommend to test scripts before suggesting them. This won't absolutely work, and doesn't mean anything in coding.

creeper82 wrote:

You can do more of them in one project but it may become laggy.
Really? I don't think at all few scripts will make the project lag.
I don't want to be rude, but that's how it is.
A lot of hat blocks can cause issues with running in the Scratch Player, but the lag is based on computer specifics.

thelostgames wrote:

MathlyCat wrote:

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
Replace 365 with 365.25

Think before you act.
Actions speek louder than words.

hi there fella
Shaymin524
Scratcher
68 posts

Ultimate List of Workarounds And More

MathlyCat wrote:

-snip-

thelostgames wrote:

MathlyCat wrote:

-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
Replace 365 with 365.25
Or even 365.26

Botcho_Otkho wrote:

creeper82 wrote:

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:

when [timer v] > (10)

We can make this:

when [timer v] > ((timer) - <touching [mouse pointer v]?>)
say [you touched me!] for (2) secs
I always recommend to test scripts before suggesting them. This won't absolutely work, and doesn't mean anything in coding.
-snip-
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:
if (1) {
alert('True = 1!')
}
would pop up with ‘True = 1!’

—————————————————————————

GENERATION 1: When you first see this copy it to the start of your sig and change Generation by 1.

—————

Bring back remix trees, scroll blocks, picoboards and the discuss tab!

—————

Trans girl / Lesbian / 13 / Libra
andyhanwu
Scratcher
76 posts

Ultimate List of Workarounds And More

Can you make a workaround for this:
point towards x:(0) y:(0)

I am awesome.

Check out my latest project: Turret Wars!

https://scratch.mit.edu/projects/139089251/

Oh, this, you say…
(O_O)
It's Blocky, who loves eating kumquats and defending my signature.
andyhanwu
Scratcher
76 posts

Ultimate List of Workarounds And More

thelostgames wrote:

MathlyCat wrote:

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
That wouldn't work, as leap years are imperfect.
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.

I am awesome.

Check out my latest project: Turret Wars!

https://scratch.mit.edu/projects/139089251/

Oh, this, you say…
(O_O)
It's Blocky, who loves eating kumquats and defending my signature.
BlackWolfee
Scratcher
500+ posts

Ultimate List of Workarounds And More

andyhanwu wrote:

Can you make a workaround for this:
point towards x:(0) y:(0)
Create a hidden sprite that is at that position and use
point towards [ v]

13 | INFP-A | Ravenclaw | Introvert | Violist | Pianist | bookworm | writer | straight-A student | artist | nerd | science lover |
This shop is advertised courtesy of the Scratch Shop Support Union. Join today to get your shop featured!
brendanthescratcher
Scratcher
49 posts

Ultimate List of Workarounds And More

PythonKitten wrote:

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
There is now a block that does that.
TheThirdMario
Scratcher
1 post

Ultimate List of Workarounds And More

Hi! These are great workarounds!
unikyliecorn
Scratcher
72 posts

Ultimate List of Workarounds And More

brendanthescratcher wrote:

PythonKitten wrote:

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
There is now a block that does that.
Shoot, I was just about to answer their question oof xD

Last edited by unikyliecorn (Jan. 14, 2019 20:56:19)


(ɔ)ɔ :* υηιкүιεcσяη *: c(c)
sk7725
Scratcher
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
() + () + () :: operators reporter
will make no sense, because it is easily accomplishable by New Scratchers.
But blocks like
letter () to () of [sk7725] :: operators reporter
will definitely help

About Scratch wrote:

young people learn to think creatively, reason systematically, and work collaboratively.
another example is
if <> then {

}else if <> then {

}else {

}::control cblock
which is great for teachers who are using Scratch as a bridge towards other languages like C.

Please, help the new scratchers!

Creator of *Mochi Run* along with some others, and still Scratching on!

KOI is pretty easy, hope IOI is better…
Now solving all your Scratch 3.0 problems! Comment me here!

달려라 나의 모찌! ><
ihgfedcba
Scratcher
100+ posts

Ultimate List of Workarounds And More

ScratchDiogoh wrote:

ihgfedcba wrote:

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
In aabs should Use in Workaround:
((0) - ([abs v] of (e)))
The thing is, each abs output has 2 inverses. Including 0 of course, because +0 and -0 are stored differently.

Powered by DjangoBB