Discuss Scratch

Alberknyis
Scratcher
1000+ posts

Work-arounds

AonymousGuy wrote:

Alberknyis wrote:

if <> then ::cstart

elif <> then ::celse

else ::celse

end
Um, actually - that block is not very simple to workaround:
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then

else
end
end
end
end
end
end
end
end
end
end
end
end
end
end
#editorlag


Ummm… You mean this?

if <> then

else
if <> then

else
end

end

Because, y'know… I don't understand what you need 14 if-else blocks for.

Were you talking about having to work around this sort of thing?

if <> then

elif <>::celse

elif <>::celse

elif <>::celse

elif <>::celse

elif <>::celse

else
end

Because honestly I'm fine without an elif block. I do if-else-ception all the time.

stop [all v] ::stack
ev3commander
Scratcher
500+ posts

Work-arounds

Workaround for forever:

define Forever move (number) steps
move (number) steps
Forever move (number) steps :: more blocks

You won't be unknown anymore
My browser / operating system: Windows 7, Chrome 32.XX.XXXX.XX, Flash 12.0 (release 0)
My alternative browser / operating system: OS X 10.9.5, Safari 7, Flash 15.0 (release 0)
Reached 500+ on April 8, 2015
ChocolatePi
Scratcher
1000+ posts

Work-arounds

guys it's called else if not elif.
lalala3
Scratcher
100+ posts

Work-arounds

ChocolatePi wrote:

guys it's called else if not elif.
“elif” is an abbreviation used in Python, I believe.

Alberknyis
Scratcher
1000+ posts

Work-arounds

ChocolatePi wrote:

guys it's called else if not elif.

Welcome to Python. Here we have our own names for things.

Last edited by Alberknyis (Jan. 20, 2015 10:05:52)


stop [all v] ::stack
zorket
Scratcher
500+ posts

Work-arounds

These blocks are included in scratch because they are the BASE of what makes up everything else. The fact that in some block definitions you included other blocks in your workaround that are defined elsewhere proves it. With these blocks, more workarounds are possible, and as Iditaroid said, it is intuitive.

By the way, what's the suggestion here?

Try out my new strategy/luck game: Battleship!
ChocolatePi
Scratcher
1000+ posts

Work-arounds

Alberknyis wrote:

ChocolatePi wrote:

guys it's called else if not elif.

Welcome to Python. Here we have our own names for things.
in better programming languages, else if is treated like

if ...

else
if ...

else
if...
Alberknyis
Scratcher
1000+ posts

Work-arounds

ChocolatePi wrote:

Alberknyis wrote:

ChocolatePi wrote:

guys it's called else if not elif.

Welcome to Python. Here we have our own names for things.
in better programming languages, else if is treated like

if ...

else
if ...

else
if...

In Python, we still call it elif.

stop [all v] ::stack
peppermintpatty5
Scratcher
1000+ posts

Work-arounds

Alberknyis wrote:

ChocolatePi wrote:

Alberknyis wrote:

ChocolatePi wrote:

guys it's called else if not elif.

Welcome to Python. Here we have our own names for things.
in better programming languages, else if is treated like

if ...

else
if ...

else
if...

In Python, we still call it elif.
How wierd. :/ (And it seems Python is an older language than Java.)
Scratch that. Python is soooo inferior

Last edited by peppermintpatty5 (July 29, 2015 12:44:42)



#BringBackDiscuss
CodeLegend
Scratcher
500+ posts

Work-arounds

Wes64 wrote:

the number of blocks is not what determines the computing speed. it is actually the behind-the-scenes operations. just because you have abstracted a function as a single block does not mean it is magically going to be faster than its workaround.

a large number of blocks can take down FPS, but only if you have failed to use “run without screen refresh”.

But it often will be faster, not because of magic, but because there are actually less behind-the-scenes operations when a function is written in native actionscript rather than scratch blocks.

A workaround has to be interpreted block-by-block by the scratch editor, while pure actionscript code can just be interpreted by the flash player.

Example:

polygon x:[list of x points v] y:[list of y points v]::pen

//would be much much faster than

define I didn't make this but it is a real script that has been used in many projects.
set [minHeight v] to (item (1 v) of [polyY v])
set [maxHeight v] to (item (1 v) of [polyY v])
pen up
set [i v] to [0]
repeat (vertices)
change [i v] by (1)
set [j v] to (item (i) of [polyY v])
if <(j) < (minHeight)> then
set [minHeight v] to (j)
end
if <(j) > (maxHeight)> then
set [maxHeight v] to (j)
end
end
set [pixelY v] to (minHeight)
repeat ((maxHeight) - (pixelY))
delete (all v) of [nodeX v]
set [i v] to [1]
set [j v] to (vertices)
repeat (vertices)
if <<<(item (i) of [polyY v]) < (pixelY)> and <not <(item (j) of [polyY v]) < (pixelY)>>> or <<(item (j) of [polyY v]) < (pixelY)> and <not <(item (i) of [polyY v]) < (pixelY)>>>> then
add (round ((item (i) of [polyX v]) + ((((pixelY) - (item (i) of [polyY v])) / ((item (j) of [polyY v]) - (item (i) of [polyY v]))) * ((item (j) of [polyX v]) - (item (i) of [polyX v]))))) to [nodeX v]
end
set [j v] to (i)
change [i v] by (1)
end
set [i v] to [1]
repeat until <not <(i) < (length of [nodeX v])>>
if <(item (i) of [nodeX v]) > (item ((i) + (1)) of [nodeX v])> then
set [swap v] to (item (i) of [nodeX v])
replace item (i) of [nodeX v] with (item ((i) + (1)) of [nodeX v])
replace item ((i) + (1)) of [nodeX v] with (swap)
if <(i) > [1]> then
change [i v] by (-1)
end
else
change [i v] by (1)
end
end
set [i v] to [1]
set pen size to (pen size)
repeat ((length of [nodeX v]) / (2))
go to x:(item (i) of [nodeX v]) y:(pixelY)
pen down
go to x:(item ((i) + (1)) of [nodeX v]) y:(pixelY)
pen up
change [i v] by (2)
end
change [pixelY v] by (pen size)
end
set pen color to [#000008]
repeat ((vertices) + (1))
change [i v] by (1)
go to x:(item (((i) mod (vertices)) + (1)) of [polyX v]) y:(item (((i) mod (vertices)) + (1)) of [polyY v])
pen down
end
peppermintpatty5
Scratcher
1000+ posts

Work-arounds

CodeLegend wrote:

-snip-
Interesting point. One Scatchblock-to-Flash interpretation would be faster than dozens of them. It would probably be an immeasurable difference though

necropost


#BringBackDiscuss
Blank1234
Scratcher
500+ posts

Work-arounds

ChocolatePi wrote:

Alberknyis wrote:

ChocolatePi wrote:

guys it's called else if not elif.

Welcome to Python. Here we have our own names for things.
in better programming languages, else if is treated like

if ...

else
if ...

else
if...
better progrqmming languages have no loops

Did you know that “kaj” means “and” in Esperanto?


















Totally not for SEO:
https://scratch.mit.edu/projects/85467306/
https://scratch.mit.edu/projects/83099266/
https://scratch.mit.edu/projects/81628056/
https://scratch.mit.edu/projects/81562288/
https://scratch.mit.edu/projects/81462110/
https://scratch.mit.edu/projects/81436112/
https://scratch.mit.edu/projects/78896920/
https://scratch.mit.edu/projects/78863998/
https://scratch.mit.edu/projects/76577776/
https://scratch.mit.edu/projects/76459270/
https://scratch.mit.edu/projects/74797364/
https://scratch.mit.edu/projects/74085188/
https://scratch.mit.edu/projects/73150274/
https://scratch.mit.edu/projects/73112658/
https://scratch.mit.edu/projects/72484040/
https://scratch.mit.edu/projects/72737486/
https://scratch.mit.edu/projects/72410420/
https://scratch.mit.edu/projects/72378152/
https://scratch.mit.edu/projects/71910314/
https://scratch.mit.edu/projects/67826618/
https://scratch.mit.edu/projects/67882676/
https://scratch.mit.edu/projects/66909070/
https://scratch.mit.edu/projects/66925858/
https://scratch.mit.edu/projects/66420350/
https://scratch.mit.edu/projects/66062314/
https://scratch.mit.edu/projects/65564542/
https://scratch.mit.edu/projects/64828196/
https://scratch.mit.edu/projects/64286296/
https://scratch.mit.edu/projects/64283600/
https://scratch.mit.edu/projects/62386850/
https://scratch.mit.edu/projects/63907584/
https://scratch.mit.edu/projects/62785306/
https://scratch.mit.edu/projects/63767660/
https://scratch.mit.edu/projects/62676562/
https://scratch.mit.edu/projects/61948978/
https://scratch.mit.edu/projects/62521426/
https://scratch.mit.edu/projects/61074988/
https://scratch.mit.edu/projects/11658256/
https://scratch.mit.edu/projects/60640274/
peppermintpatty5
Scratcher
1000+ posts

Work-arounds

Blank1234 wrote:

ChocolatePi wrote:

Alberknyis wrote:

ChocolatePi wrote:

guys it's called else if not elif.

Welcome to Python. Here we have our own names for things.
in better programming languages, else if is treated like

if ...

else
if ...

else
if...
better progrqmming languages have no loops
wut? WUT?

Last edited by peppermintpatty5 (July 29, 2015 21:51:20)



#BringBackDiscuss
DaBombPop1
Scratcher
4 posts

Work-arounds

too bad you cannot move variables

Last edited by DaBombPop1 (July 6, 2016 20:20:17)

Sheep_maker
Scratcher
1000+ posts

Work-arounds

The ST is busy, so they want to do as less as possible to still benefit Scratch. Removing all the workaroundable blocks would waste the ST's time and won't benefit anyone. Adding blocks take time and effort, and many times if there's a workaround, the ST won't do it because it's already possible. Blocks without workarounds, however, extend what's possible with Scratch.

I think that's why

- Sheep_maker This is a kumquat-free signature. :P
What's happening? This is my signature; it appears below all my posts. Discuss it on my profile, not the forums.
To make your own, click “Change your signature” at the bottom of the discussion home page.

<key (join [enter] []) pressed?> // This works now
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }

Powered by DjangoBB

Standard | Mobile