Greet Player
into Another ProgramPG: We /may/ want to use the CREATE VARIABLE block that now exists.
BH: But fix the text, which now says you're exporting a project when you export blocks.
MF: need to discuss FP plan to remove and replace with 1.2.4 (and then abandonment of plan)
Often you will find a use for code that you've already built in some other project.
On this page, you will copy your greet player
block into your Number Guessing game so you can use it there.
greet player
. When it's working correctly, export it. (Instructions below.)
greet player
), and click "OK." An XML file will download.greet player
block.
greet player
. Can you determine what's wrong?Sometimes when you take a script out of the program where you built it and try to use it somewhere else, something breaks. It could be that the script depends on a custom block that isn't defined in the new program, or it could be (as in this case) that the script depends on a global variable that isn't defined in the new program.
To fix this problem so you can use the imported block, you'll need to define the global variable in your new program. Dependencies are one reason to use script variables rather than global variables whenever you can. Because they are defined in their scripts, you don't lose them when you move the script to a new place.
If player list is initialized every time the game starts again, the game won't be able to remember any names. So, you will need to use a different event to start the game than to initialize player list. For example, you could use the green flag to initialize the list and use the space bar to begin the Number Guessing game.