The key is that you can create a variable which is of type 'Player' (on the variable's menu, select 'change value type' and choose 'Player'). E.g., I created a player variable called 'clone1' for my sketch (actually I called it 'clone', but apparently it conflicted with some reserved var, so a '1' was appended). You can then 1) assign something to that var - e.g. 'sketch's copy', and 2) use that var on the left-hand of an assignment - e.g. replace the 'sketch' in 'sketch's x <- <value>' with 'sketch's clone'
Hopefully the attached image will help clarify.
You might also want to get in the habit of doing things in a playfield instead of in the world.
Please copy the list if you still have problems. --Randy
-----Original Message----- From: Blake [mailto:blake@kingdomrpg.com] Sent: Monday, March 06, 2006 5:26 AM To: Randy Heiland Subject: Re: [Squeakland] Copy an object programmatically.
On Fri, 03 Mar 2006 03:56:35 -0800, Randy Heiland heiland@indiana.edu wrote:
Your question gets into the semantics of a 'copy' vs a 'sibling', but...
Well, I think I understand that.
short answer: http://squeakland.org/pipermail/squeakland/2005-August/002707.html
Thanks.
I think what threw me is that it's called "ship's copy", which doesn't seem like an action.
OK, so I make a copy and put it into the world with
word include:ship's copy
so how do I get a variable of ship's copy that I can set the starting location in the world? Or perhaps that's the wrong question. What do I do to get the newly created object to perform whatever actions are needed at set-up?
On Mon, 06 Mar 2006 07:20:10 -0800, Randy Heiland heiland@indiana.edu wrote:
The key is that you can create a variable which is of type 'Player' (on the variable's menu, select 'change value type' and choose 'Player'). E.g., I created a player variable called 'clone1' for my sketch (actually I called it 'clone', but apparently it conflicted with some reserved var, so a '1' was appended). You can then
- assign something to that var - e.g. 'sketch's copy', and
- use that var on the left-hand of an assignment - e.g. replace the
'sketch' in 'sketch's x <- <value>' with 'sketch's clone'
Hopefully the attached image will help clarify.
Yes, thank you. So you have to do everything with the base type first and then replace with the variable?
You might also want to get in the habit of doing things in a playfield instead of in the world.
Yeah, I noticed the problems with using the world pretty quickly.
squeakland@lists.squeakfoundation.org