Discuss Scratch

DaEpikDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

MathlyCat wrote:

I'm not going to add the workaround simply because if the person who needs to use it understands the logic, they can use the base methods to ultimately achieve what they need.

Again, I want to have a separation of learning and workarounds
It occurs to me that actually the xor workaround is understandable by people who know what xor is.
Xor is normally said to be “one is true, but not both”, but really, what it says is “the two results are not the same”: i.e. not equal.
I.e. the workaround.
Of course, you could add the other workaround:
<<<bool 1::sensing> or <bool 2::sensing>> and <not <<bool1::sensing> and <bool2::sensing>>>
but I think the other workaround is perfectly valid, just as understandable and is much shorter.

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
Simple_guy
Scratcher
52 posts

Ultimate List of Workarounds And More

Is there a workaround for script/local variables

I`m working on simple games, arts , animations, Requests
and much more !

I`m happy to help you :-)

if <project gets clicked> then
think [OMG] for (ever) secs

end

Hey check this out: https://scratch.mit.edu/discuss/topic/288903/?page=1
sonicfan12p
Scratcher
1000+ posts

Ultimate List of Workarounds And More

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.

Comeback time? Maybe?
ihgfedcba
Scratcher
100+ posts

Ultimate List of Workarounds And More

(round to the nearest number, but when a half is encountered, round down instead of up ()::operators)
can be workarounded as
((0) - (round ((0) - ())))
or
([ceiling v] of (() + (-0.5)))
TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

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


TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

Simple_guy wrote:

Is there a workaround for script/local variables
What do you exactly mean by this?


TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

turn video [on v] for (2) secs :: sensing
//Workaround
turn video [on v]
wait (2) secs
turn video [off v]

days since (2018) :: sensing
//Workaround
((days since 2000) - (((18) * (365)) + (4))) // This is only near-accurate. Not completely

Last edited by TheAdriCoolManDude (June 21, 2018 19:33:49)



Garamol56
Scratcher
100+ posts

Ultimate List of Workarounds And More

TheAdriCoolManDude wrote:

-snip-
//Workaround
((days since 2000) - ((18) * (365))) // This is only near-accurate. Not completely0

What if I wanted to do
days since (1996) :: sensing
?


Current Posts: 266
Code to find my posts: Z2FyYW1vbDU2
Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein
TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

Garamol56 wrote:

TheAdriCoolManDude wrote:

-snip-
//Workaround
((days since 2000) - ((18) * (365))) // This is only near-accurate. Not completely0

What if I wanted to do
days since (1996) :: sensing
?

((days since 2000) + ((4) * (365))) // Again, only near-accurate, not accurate.
// For better accuracy
(((days since 2000) + ((4) * (365))) + (1)) // The one is for the leap year 1996, again.

Last edited by TheAdriCoolManDude (June 21, 2018 19:29:41)



TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

go forward (1) layers :: looks 
//Workaround
go back (-1) layers

glide (10) steps in (5) seconds :: motion
//Workaround
glide (5) secs to x: ((x position) + (([sin v] of (direction)) * (10))) y: ((y position) + (([cos v] of (direction)) * (10)))

number of clones :: control reporter
//Workaround
create clone of [myself v]
change [number of clones v] by (1) // Repeat for every clone made.


Sheep_maker
Scratcher
1000+ posts

Ultimate List of Workarounds And More

TheAdriCoolManDude wrote:

go forward (1) layers :: looks 
//Workaround
go back (-1) layers
That block will come in 3.0 as
go [forward v] (1) layers::looks // forward, backward

- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
ScratchDiogoh
Scratcher
1000+ posts

Ultimate List of Workarounds And More

Sheep_maker wrote:

TheAdriCoolManDude wrote:

go forward (1) layers :: looks 
//Workaround
go back (-1) layers
That block will come in 3.0 as
go [forward v] (1) layers::looks // forward, backward
Yes, but for Scratch 2 you use your
Workaround

Last edited by ScratchDiogoh (June 23, 2018 13:43:36)


+1700 Bad Posts
TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

<[5] = [2] and [3] :: operators> 

//Workaround

<[5] = ((2) + (3))>
can (7) = (6) = [true v] :: operators

//Workaround

<<[7] = [6]> = [true]>
<<[7] = [6]> = [false]>// You have to detect them both.
stop [Every Other Script In Project v]

//Workaround

//In the Sprite
broadcast [stop other scripts in sprite v]
when I receive [stop other scripts in sprite v]
stop [other scripts in sprite v]

//In Everything Else
when I receive [stop other scripts in sprite v]
stop [all scripts in sprite v]


TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

(clicked :: control)

//Workaround

forever
if <mouse down?> then
set [clicked? v] to [1]
else
set [clicked? v] to [0]
end
end

Last edited by TheAdriCoolManDude (June 29, 2018 12:59:21)



ihgfedcba
Scratcher
100+ posts

Ultimate List of Workarounds And More

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

Ultimate List of Workarounds And More

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)))

+1700 Bad Posts
TheAdriCoolManDude
Scratcher
1000+ posts

Ultimate List of Workarounds And More

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

forever
if <(variable) = [6]> then
...
end
end

Last edited by TheAdriCoolManDude (July 11, 2018 23:07:13)



Botcho_Otkho
Scratcher
1000+ posts

Ultimate List of Workarounds And More

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

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
TheAdriCoolManDude
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
I like if <> then C-block better, because it is easier to get used to.


chinatownboy456
Scratcher
19 posts

Ultimate List of Workarounds And More

can you make the limit of clones 500?

Powered by DjangoBB