This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-20 11:20:38

mogwai
Scratcher
Registered: 2009-11-30
Posts: 2

Global Variables and Import/Export Sprites

Hi there-

This is my first post, and I've tried to be diligent about searching the forums for existing threads.  If I've missed one, please link it!

I'm trying to build a AI vs AI TicTacToe program for my 5th grade class.  My goal was to make a complete project, with two AI players and a Board sprite.  The Board would handle all the rules and enforcement, while the AI sprites would wait for their turn and write a Global Variable (XPlayerTurn or OPlayerTurn) with the move of their choice.

Once the students have written their AI scripts, I would like them to Export the Sprite.  Then I can pull two Sprites from two different students, and set them against each other.

However, when I import the student created sprites into my copy of the Project, none of the "SET VARIABLE TO" blocks work.  They execute, but they don't modify the Variables.  This occurs even when I start class with everyone downloading a copy of the same Project.

If I remove all instances of "SET VARIABLE TO" form their script and replace it with new, seemingly identical, blocks from the sidebar it will work.

My question is wether there's some deeper identification of variables that's being hidden by the Scratch interface.  Do Global Variables carry some tag with the filename of the project? 

I've reworked the scripts to use a minimum number of the SET GLOBAL VARIABLE blocks, but I'd love to have the Sprites simply import and work.

If you have any technical or design ideas, I'd love to hear them!

--mogwai

Offline

 

#2 2010-05-20 15:57:26

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Global Variables and Import/Export Sprites

Hm... As far as I'm concerned, it should work just fine. The only issue that I can think of would be if you were using different versions of Scratch - can you check with the students that you're all using the same version?

Offline

 

#3 2010-05-20 16:04:52

TheSaint
Scratcher
Registered: 2008-11-04
Posts: 1000+

Re: Global Variables and Import/Export Sprites

mogwai wrote:

Hi there-

This is my first post, and I've tried to be diligent about searching the forums for existing threads.  If I've missed one, please link it!

I'm trying to build a AI vs AI TicTacToe program for my 5th grade class.  My goal was to make a complete project, with two AI players and a Board sprite.  The Board would handle all the rules and enforcement, while the AI sprites would wait for their turn and write a Global Variable (XPlayerTurn or OPlayerTurn) with the move of their choice.

Once the students have written their AI scripts, I would like them to Export the Sprite.  Then I can pull two Sprites from two different students, and set them against each other.

However, when I import the student created sprites into my copy of the Project, none of the "SET VARIABLE TO" blocks work.  They execute, but they don't modify the Variables.  This occurs even when I start class with everyone downloading a copy of the same Project.

If I remove all instances of "SET VARIABLE TO" form their script and replace it with new, seemingly identical, blocks from the sidebar it will work.

My question is wether there's some deeper identification of variables that's being hidden by the Scratch interface.  Do Global Variables carry some tag with the filename of the project? 

I've reworked the scripts to use a minimum number of the SET GLOBAL VARIABLE blocks, but I'd love to have the Sprites simply import and work.

If you have any technical or design ideas, I'd love to hear them!

--mogwai

This has happened to me before. Unfortunatly, I can think of no other option to fix it. You can either have variables set to sprites only, and then use the ( [Blank] of [ Sprite 1] ) block, or you have to just fix it each time you have something imported. Either way, you will have to change some blocks.

The problem is that it senses the varibles on the existing project, and then creates another global variable of the exact same name. (At least, I think that is what causes it.) Then, they don't connect.

I hope I was able to help a little bit.

Offline

 

#4 2010-05-20 16:21:08

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Global Variables and Import/Export Sprites

TheSaint is right...Scratch scopes each SET block to a specific variable without regard to the variable's name. This is done to minimize the amount of thought that has to be given to the names of the variables so new users can focus on the concept of variables themselves. This is why there's really no way to type a variable name in and each var has its own reporter block. One nasty side effect of this is what you described. If this is becoming a headache for you, you may want to try using BYOB, a more advanced offshoot of Scratch being developed now. I would post a link to the forum topic but I am using my phone. Try byob.berkley.edu!


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5 2010-05-20 16:24:12

TheSaint
Scratcher
Registered: 2008-11-04
Posts: 1000+

Re: Global Variables and Import/Export Sprites

http://scratch.mit.edu/forums/viewtopic.php?id=10887&p=1

Since Fullmoon can't post the link, I thought I could just help there. I bleive this is the topic he was reffering to.

Offline

 

#6 2010-05-24 15:20:10

mogwai
Scratcher
Registered: 2009-11-30
Posts: 2

Re: Global Variables and Import/Export Sprites

Thanks for those replies!  Since this is a project I'm trying to apply with the 5th grade, I was avoiding BYOB or other Scratch-variants.  Getting vanilla Scratch installed across the Macbooks was problematic enough!  If there's a way for the kids to write the Sprites/Scripts in Scratch and then import them into a BYOB "arena," then I'd jump at it!

TheSaint  wrote:

. You can either have variables set to sprites only, and then use the ( [Blank] of [ Sprite 1] ) block, or you have to just fix it each time you have something imported.

Do you mean that Sprite_A can read values from the local variables of Sprite_B?  I've tried to set this up, but haven't figured out how to specify that in the blocks. 


Thanks again for the help!

--mogwai

Offline

 

Board footer