s_federici wrote:
registeel wrote:
How do you use it???
Do you mean the clone hack? Download and unzip the whole hack folder from http://www.sitibs.com/files/stefano/Scratch1.2.1plusClone.zip. Then run the Scratch.exe you will find in the folder you unzipped. This hack has two new blocks in the "Control" category, namely "clone this sprite" and "delete this sprite". You can try the simple script I have shown before. Unfortunately, till now, it only works when in design mode. And, needless to say, it wont't work when uploaded to the site.
I can't open the zip...
Offline
I guess you can't download it. I don't know why, but the last period is interpreted as being part of the URL. Ok, try this
http://www.sitibs.com/files/stefano/Scratch1.2.1plusClone.zip
Offline
thanks for the folder s_federici!
Offline
Woah Thats Cool!
Offline
registeel wrote:
Woah Thats Cool!
Let us know how you are going to use it.
Offline
s_federici wrote:
when I write a very simple script, for example
when Sprite1 Clicked
clone this sprite
it only works when in design mode. If I click on the sprite when in presentation mode the sprite won't be duplicated.
Okay, now I got it.
[caution: geek squeak speak ahead]
If you take a look at the 'duplicate' method of class ScriptableScratchMorph you´ll notice that it looks up the current instance of class ScratchFrameMorph by asking itself something like 'self ownerThatIsA: ScratchFrameMorph'. It then only executes the relevant code snippet if that 'frame' is not nil.
Problem is: in presentation mode the morphic tree looks different, the owner not being a ScratchFrameMorph, but a ScratchPresenterMorph, which in turn has an instance variable (called "frame") keeping the reference to the ScratchFrameMorph. That's why in presentation mode asking for the owner frame gets nil and results in the duplication code not being run. You need to access the frame differently, therefore, by accessing the "ownerThatIsA: ScratchPresenterMorph" and by letting that one answer its frame (which it currently doesn't, so you'll have to implement it).
So what you need to do is this:
1. add another accessor method to class ScratchPresenterMorph answering its frame
2. add another condition to the duplicate/delete method to request the frame from the owner that is a ScratchPresenterMorph if that frame has been previously answered as nil.
I have run into the same problem in my lists prototype and solved it in the same way. If you're not sure how to code this you might want to have a look at the relevant methods in that source code.
Hope this helps...
Offline
Jens wrote:
s_federici wrote:
when I write a very simple script, for example
when Sprite1 Clicked
clone this sprite
it only works when in design mode. If I click on the sprite when in presentation mode the sprite won't be duplicated.Okay, now I got it.
[caution: geek squeak speak ahead]
If you take a look at the 'duplicate' method of class ScriptableScratchMorph you´ll notice that it looks up the current instance of class ScratchFrameMorph by asking itself something like 'self ownerThatIsA: ScratchFrameMorph'. It then only executes the relevant code snippet if that 'frame' is not nil.
Problem is: in presentation mode the morphic tree looks different, the owner not being a ScratchFrameMorph, but a ScratchPresenterMorph, which in turn has an instance variable (called "frame") keeping the reference to the ScratchFrameMorph. That's why in presentation mode asking for the owner frame gets nil and results in the duplication code not being run. You need to access the frame differently, therefore, by accessing the "ownerThatIsA: ScratchPresenterMorph" and by letting that one answer its frame (which it currently doesn't, so you'll have to implement it).
So what you need to do is this:
1. add another accessor method to class ScratchPresenterMorph answering its frame
2. add another condition to the duplicate/delete method to request the frame from the owner that is a ScratchPresenterMorph if that frame has been previously answered as nil.
I have run into the same problem in my lists prototype and solved it in the same way. If you're not sure how to code this you might want to have a look at the relevant methods in that source code.
Hope this helps...
I know almost nothing about Squeak, but I am kinda surprised to say that I actually understood that............I have a feeling I learned something. Which in this case is strange, since all I have ever done with Squeak is pen it up and play with the demos I never found the place you are actually supposed to code......
Offline
Cool! I'm glad I didn't scare you off with this...
Cyclone103 wrote:
I never found the place you are actually supposed to code......[in Squeak]
In Squeak you can litterally code anywhere and everywhere, i.e. in every browser, workspace, transcript, walkback, debugger, inspector etc. etc. but usually you want to use one or several instances of the SystemBrowser to both view and modify the "code". There are many other programming tools even in the stripped-down Squeak environment that hosts Scratch (browsers for senders/receivers/implementors of a method, users/defs of instance and class variables, change sorters) but the place to start is definitely the SystemBrowser. Also, try right- (and middle-) clicking a lot on all kinds of objects to explore Squeak...
Offline
Jens wrote:
If you're not sure how to code this you might want to have a look at the relevant methods in that source code.
I'm really not sure So I'll have a look at those methods and ask for help if needed. Thanks!
Offline
Ingoguy15 wrote:
So, does this create instances of the same sprite? Or can you copy and delete sprites on the fly?
With this hack, each sprite can create instances identical to itself (clones) by running the "clone this sprite" block. Then, each sprite (both original sprites and clones) can delete itself by running the "delete this sprite" block.
Last edited by s_federici (2008-07-12 13:05:56)
Offline
I made the hack! That is the first time I have ever done anything at all with Squeak where I don't have like 10000000000 walkbacks. I am pretty bad at using Squeak! I am glad that this worked though, and I fully intend on fooling around with the clone hack and doing stuff.
Offline
Cyclone103 wrote:
I made the hack!
Congratulations!
Offline
s_federici wrote:
Cyclone103 wrote:
I made the hack!
Congratulations!
Thanks! Now all I have to do is to remember not to delete my sprite accidentally!
Offline
wordMan wrote:
didn't work! it sayedbefore the (clone... it says NOTHING MORE EXPECTED but i dont get it. i put it in perfecly though! please tell me how 2 fix it!
To fix what? Sorry, I don't understand your message.
Offline
s_federici wrote:
wordMan wrote:
didn't work! it sayed before the (clone... it says NOTHING MORE EXPECTED but i dont get it. i put it in perfecly though! please tell me how to fix it!
To fix what? Sorry, I don't understand your message.
uh i fixed it my self i put the code before the begining
Offline
Any ideas on how to port this to 1.3? I've tried and it doesn't work (although I don't get a Red Error Box of Doom when I try to use the blocks; they just stay highlighted and don't do anything). In the 1.3 source code, I did find a hiddden, built-in method that lets you clone a sprite and send the clone a message, but as usual, I couldn't get it into a block. Any suggestions?
Offline
This is really awesome! I want it!!
I think the "clone this sprite" behavior is very intuitive and very powerful. However, it seems there still needs to be an easy, more obvious way to initialize the just-created clone. How about having a "when Sprite1 cloned" control block?
Implementation-wise, doing a full copy of the sprite seems quite expensive and may make creating large numbers of instances impractical. It also makes it very easy to mess up a project. Because all the scripts are copied, you can't just add a script to delete all sprites after the fact. If you create more than a couple dozen clones or so and don't know how to delete them, you will very likely have to throw away your project and start over. It also seems too easy to accidentally delete the master. Well I suppose that's what Save is for ;-)
Don't get me wrong, I'd love to have the current clone=duplicate feature ASAP. But in the long term, I'd rather see a scheme where clones share everything with the master except their state, and where a "delete a clones" block would do exactly that (delete the clones but not the master).
Also, a little nit about consistency: The current sprite is already referred to by name, "when Sprite1 clicked", and by the first-person pronoun I, "when I receive ...". These are two different points of reference, and this proposal adds a third, "clone this sprite". I don't have a strong preference except that they should be consistent.
Offline
s_federici wrote:
It turned out that in the end I didn't need the wonderful listhack by Jens. I finished my first clonehack project (you can download the hack from http://www.sitibs.com/files/stefano/Scratch1.2.1plusClone.zip). Well, I guess this is not the most efficient way of implementing arrays. But it works, and it was fun to work on it!
http://scratch.mit.edu/projects/s_federici/198523
Comments, improvements and critisisms are welcome.
How do you make image files?
Offline
cool. now can you figure out how to make somthing reset all variables? or make it so more then one person can play a game online at once and see others?
Offline
Scratchguy12125 wrote:
cool. now can you figure out how to make somthing reset all variables? or make it so more then one person can play a game online at once and see others?
That is IMPOSSIBLE.
Offline
and thats why u joined
Offline