Discuss Scratch

codeman1044
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

Is this topic an open poll for workarounds for requested features?

I couldn't help it, although it was kind of a stretch…


I'm not even sorry
openPoll
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

codeman1044 wrote:

Is this topic an open poll for workarounds for requested features?

I couldn't help it, although it was kind of a stretch…


I'm not even sorry
Wow. Just wow.

But not really. More like a list instead of a poll
DaEpikDude
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

Workaround for an <if <…> then <…>> boolean block:

Za-Chary wrote:

It's subtle, but there is a relatively simple workaround.

<<not <> > or <> >

When you write this:

<if <boolean A> then <boolean B> ::control>

It is always true unless “boolean A” is true and “boolean B” is false. Similarly:

<<not <boolean A> > or <boolean B> >

If “boolean A” is false, then the entire boolean would be true due to the “or” statement. If “boolean A” is true, then we need “boolean B” to be true in order for the boolean to be true (otherwise, it's false). In other words, this boolean is always true unless “boolean A” is true and “boolean B” is false.

Applying this logic to the example you gave might make more sense.
-Reshiram-
Scratcher
100+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

oof nevermind my post b r o k e

Last edited by -Reshiram- (Aug. 5, 2019 19:26:48)

MrFluffyPenguins
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

DaEpikDude wrote:

Workaround for an <if <…> then <…>> boolean block:

Za-Chary wrote:

-snip-
r.i.p my suggestion
WindOctahedron
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

[] starts with []? :: operators boolean
The workaround:
define check if (string) starts with (letters)
set [i v] to (1)
set [output v] to []
repeat (length of (letters :: custom arg))
if <not <(letter (i) of (string :: custom arg)) = (letter (i) of (letters :: custom arg))>> then
set [output v] to [false]
end
if <not <(output) = [false ]>> then
change [i v] by (1)
if <[i v] > (length of (letters :: custom arg))> then
set [output v] to [true]
end
end
Taken from here. @hedgehog_blue posted another workaround:
define does (word) start with (letters)?
set [number v] to (1)
set [result v] to [unknown]
repeat (length of (letters :: custom arg))
if <not<(letter (number) of (letters :: custom arg))=(letter (number) of (word :: custom arg))>> then
set [result v] to [false]
stop [this script v]
end
change [number v] by (1)
end
set [result v] to [true]

Last edited by WindOctahedron (Aug. 27, 2019 15:50:55)

lunaraemaemae
Scratcher
50 posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

prievios costume is in the set costume block.
DaEpikDude
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

<<A> xor <B>::operators>
can also be workarounded as
<not <<A> = <B>>>
A xor B returns true if one, but not both, of A and B are 1: i.e. A and B are different.
This would also return true only if A and B are both different.

(slightly shorter than “(A or B) and not (A and B)”)
Computer_Fizz
Scratcher
100+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

Better way to make a “when stop sign clicked”
when @greenFlag clicked
forever
set [timer v] to (timer)
end

when [timer v] > (timer :: variables)
. . .
Better way to make a “when <boolean>”
when [timer v] > (timer :: variables)
if <. . .> then
broadcast [WhenBoolean v]
end
set [timer v] to (timer)

I don't understand the “move up 10 steps” one though… that the regular “move 10 steps” moves in the direction the sprite is pointing?

Last edited by Computer_Fizz (Sept. 25, 2019 19:56:09)

46009361
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

My workaround for a suggested block
(which keys pressed? :: sensing)
:
https://scratch.mit.edu/projects/328947478/
46009361
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

DaEpikDude wrote:

<<A> xor <B>::operators>
can also be workarounded as
<not <<A> = <B>>>
A xor B returns true if one, but not both, of A and B are 1: i.e. A and B are different.
This would also return true only if A and B are both different.

(slightly shorter than “(A or B) and not (A and B)”)
I think this is better:
<not <<not <<A> or <B>>> or <<A> and <B>>>>
WindOctahedron
Scratcher
1000+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

kChiaEC19 wrote:

DaEpikDude wrote:

<<A> xor <B>::operators>
can also be workarounded as
<not <<A> = <B>>>
A xor B returns true if one, but not both, of A and B are 1: i.e. A and B are different.
This would also return true only if A and B are both different.

(slightly shorter than “(A or B) and not (A and B)”)
I think this is better:
<not <<not <<A> or <B>>> or <<A> and <B>>>>
I disagree, it's longer (and therefore slower to calculate).
Computer_Fizz
Scratcher
100+ posts

(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪

Note: This thread is now replaced by this one in the stickies. I have also requested this thread to be closed to keep all the discussion in one place.

Powered by DjangoBB