Discuss Scratch
- Discussion Forums
- » Suggestions
- » Universal Procedures (ALL SPRITES)
- likegames
-
11 posts
Universal Procedures (ALL SPRITES)
I think it would be very helpful, and much appreciated to have the ability to make procedures which can be accessed by every sprite. You could make it so that it works like a variable, where you have the option to select if it is global or not as you create it (or edit it as well, in this case). You could also make it so that procedures defined in the stage are global. Thanks for reading. 
tl;dr: Custom blocks that you can run on every sprite.

tl;dr: Custom blocks that you can run on every sprite.
Last edited by likegames (Sept. 13, 2013 18:04:16)
- likegames
-
11 posts
Universal Procedures (ALL SPRITES)
For the use that functions are used in programming. DRY/Don't Repeat Yourself is a key part of simplifying programming, to cut out half the effort. It involves using functions to combine similar chunks of code, e.g.
if a=5 then
say “Yay!”
/
if a=1 then
say “No!”
/
You could just do
define aexamine str num
if a=num then
say num
/
aexamine Yay! 5
aexamine No! 1
However if these two scripts are both in different sprites, you can't use the same block without copying over the definition, which ruins the concept of “DRY”.
if a=5 then
say “Yay!”
/
if a=1 then
say “No!”
/
You could just do
define aexamine str num
if a=num then
say num
/
aexamine Yay! 5
aexamine No! 1
However if these two scripts are both in different sprites, you can't use the same block without copying over the definition, which ruins the concept of “DRY”.
Last edited by likegames (Sept. 13, 2013 21:47:14)
- Discussion Forums
- » Suggestions
-
» Universal Procedures (ALL SPRITES)