See: http://tracker.squeakland.org/browse/SQ-903
If you change the name of an object, the name used to reference it in a script (via show code textually) does not change. So how do I reference the name of the player (as displayed on the screen) in a script?
script4 | t1 t2 p1 selector | p1 := Text3. t1 := Command1 getCharacters. t2 := 5. selector := (t1 , ':') asSymbol. p1 perform: selector with: t2
In this above example I had a Text object where the screen showed its name (on page 2) as Text3, but when I used its characters tile in another Text object's script, it used the name Text4 in the text version of that script?
Stephen
Hi Steve,
I don't think this is a bug. If I understood correctly, the name used to reference an object in a script is not supposed to be the same as the one displayed on the screen but a unique name that identifies only this object in the World. An object's external name can change at any time but the references to this object must remain consistent in all scripts.
I'm not sure what you're trying to do, but you can get an object's displayed name by sending #externalName to the object. See the attached project for an example.
Cheers, Richo
On Tue, Mar 1, 2011 at 2:51 AM, Steve Thomas sthomas1@gosargon.com wrote:
See: http://tracker.squeakland.org/browse/SQ-903
If you change the name of an object, the name used to reference it in a script (via show code textually) does not change. So how do I reference the name of the player (as displayed on the screen) in a script?
script4 | t1 t2 p1 selector | p1 := Text3. t1 := Command1 getCharacters. t2 := 5. selector := (t1 , ':') asSymbol. p1 perform: selector with: t2
In this above example I had a Text object where the screen showed its name (on page 2) as Text3, but when I used its characters tile in another Text object's script, it used the name Text4 in the text version of that script?
Stephen
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
Ricardo,
Thanks, actually what I need is to get the reference to the object from the External Name.
What I am trying to do is something similar to Learn Programming with Robots by Stephane Ducasse http://rmod.lille.inria.fr/botsinc. One of my goals is to find a way to provide a transition for kids from Etoys to Squeak and for me to play around and have fun ;) In looking a at Ducasse's book, I am not really sure what value it adds to kids learning other than showing them the textual syntax of squeak as opposed to the tile version (except the some of the later chapters which introduce the browser, some debugging with halt, etc). Also some of the textual descriptions do not seem as effective or likely to be used by kids as some things that might be done in Etoys.
I really need to think about what for ?Computational Thinking? habits/experiences I want kids to have and how to create an Etoys that can facilitate learning them.
I think, this will take me quite a while (but I'm having fun ;).
In any case
Stephen
On Tue, Mar 1, 2011 at 9:34 AM, Ricardo Moran richi.moran@gmail.com wrote:
Hi Steve,
I don't think this is a bug. If I understood correctly, the name used to reference an object in a script is not supposed to be the same as the one displayed on the screen but a unique name that identifies only this object in the World. An object's external name can change at any time but the references to this object must remain consistent in all scripts.
I'm not sure what you're trying to do, but you can get an object's displayed name by sending #externalName to the object. See the attached project for an example.
Cheers, Richo
On Tue, Mar 1, 2011 at 2:51 AM, Steve Thomas sthomas1@gosargon.comwrote:
See: http://tracker.squeakland.org/browse/SQ-903
If you change the name of an object, the name used to reference it in a script (via show code textually) does not change. So how do I reference the name of the player (as displayed on the screen) in a script?
script4 | t1 t2 p1 selector | p1 := Text3. t1 := Command1 getCharacters. t2 := 5. selector := (t1 , ':') asSymbol. p1 perform: selector with: t2
In this above example I had a Text object where the screen showed its name (on page 2) as Text3, but when I used its characters tile in another Text object's script, it used the name Text4 in the text version of that script?
Stephen
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
On Tue, Mar 1, 2011 at 3:05 PM, Steve Thomas sthomas1@gosargon.com wrote:
Ricardo,
Thanks, actually what I need is to get the reference to the object from the External Name.
The problem is that two or more objects could have the same external name. However, if you're sure only one object has a given external name you can get its reference by implementing the following method in the class side of Player:
withExternalName: aString ^ (World findDeepSubmorphThat: [:each | each player externalName = aString] ifAbsent: []) player
And then you can get the reference from a script by sending:
(Player withExternalName: 'Texto')
I really don't know if there is a better way of doing this, but keep in mind that my "solution" is just a hack that goes through all the morphs in the world looking for the player with the given external name.
I hope this helps :) Richo
What I am trying to do is something similar to Learn Programming with Robots by Stephane Ducasse http://rmod.lille.inria.fr/botsinc. One of my goals is to find a way to provide a transition for kids from Etoys to Squeak and for me to play around and have fun ;) In looking a at Ducasse's book, I am not really sure what value it adds to kids learning other than showing them the textual syntax of squeak as opposed to the tile version (except the some of the later chapters which introduce the browser, some debugging with halt, etc). Also some of the textual descriptions do not seem as effective or likely to be used by kids as some things that might be done in Etoys.
I really need to think about what for ?Computational Thinking? habits/experiences I want kids to have and how to create an Etoys that can facilitate learning them.
I think, this will take me quite a while (but I'm having fun ;).
In any case
Stephen
On Tue, Mar 1, 2011 at 9:34 AM, Ricardo Moran richi.moran@gmail.comwrote:
Hi Steve,
I don't think this is a bug. If I understood correctly, the name used to reference an object in a script is not supposed to be the same as the one displayed on the screen but a unique name that identifies only this object in the World. An object's external name can change at any time but the references to this object must remain consistent in all scripts.
I'm not sure what you're trying to do, but you can get an object's displayed name by sending #externalName to the object. See the attached project for an example.
Cheers, Richo
On Tue, Mar 1, 2011 at 2:51 AM, Steve Thomas sthomas1@gosargon.comwrote:
See: http://tracker.squeakland.org/browse/SQ-903
If you change the name of an object, the name used to reference it in a script (via show code textually) does not change. So how do I reference the name of the player (as displayed on the screen) in a script?
script4 | t1 t2 p1 selector | p1 := Text3. t1 := Command1 getCharacters. t2 := 5. selector := (t1 , ':') asSymbol. p1 perform: selector with: t2
In this above example I had a Text object where the screen showed its name (on page 2) as Text3, but when I used its characters tile in another Text object's script, it used the name Text4 in the text version of that script?
Stephen
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
I hope Scott will chime in here, but I would guess that the world's presenter should be consulted:
World presenter allExtantPlayers collect: [:each | each uniqueNameForReference -> each externalName]
- Bert -
On 01.03.2011, at 11:28, Ricardo Moran wrote:
On Tue, Mar 1, 2011 at 3:05 PM, Steve Thomas sthomas1@gosargon.com wrote: Ricardo,
Thanks, actually what I need is to get the reference to the object from the External Name.
The problem is that two or more objects could have the same external name. However, if you're sure only one object has a given external name you can get its reference by implementing the following method in the class side of Player:
withExternalName: aString ^ (World findDeepSubmorphThat: [:each | each player externalName = aString] ifAbsent: []) player
And then you can get the reference from a script by sending:
(Player withExternalName: 'Texto')
I really don't know if there is a better way of doing this, but keep in mind that my "solution" is just a hack that goes through all the morphs in the world looking for the player with the given external name.
I hope this helps :) Richo
What I am trying to do is something similar to Learn Programming with Robots by Stephane Ducasse. One of my goals is to find a way to provide a transition for kids from Etoys to Squeak and for me to play around and have fun ;) In looking a at Ducasse's book, I am not really sure what value it adds to kids learning other than showing them the textual syntax of squeak as opposed to the tile version (except the some of the later chapters which introduce the browser, some debugging with halt, etc). Also some of the textual descriptions do not seem as effective or likely to be used by kids as some things that might be done in Etoys.
I really need to think about what for ?Computational Thinking? habits/experiences I want kids to have and how to create an Etoys that can facilitate learning them.
I think, this will take me quite a while (but I'm having fun ;).
In any case
Stephen
On Tue, Mar 1, 2011 at 9:34 AM, Ricardo Moran richi.moran@gmail.com wrote: Hi Steve,
I don't think this is a bug. If I understood correctly, the name used to reference an object in a script is not supposed to be the same as the one displayed on the screen but a unique name that identifies only this object in the World. An object's external name can change at any time but the references to this object must remain consistent in all scripts.
I'm not sure what you're trying to do, but you can get an object's displayed name by sending #externalName to the object. See the attached project for an example.
Cheers, Richo
On Tue, Mar 1, 2011 at 2:51 AM, Steve Thomas sthomas1@gosargon.com wrote: See: http://tracker.squeakland.org/browse/SQ-903
If you change the name of an object, the name used to reference it in a script (via show code textually) does not change. So how do I reference the name of the player (as displayed on the screen) in a script?
script4 | t1 t2 p1 selector | p1 := Text3. t1 := Command1 getCharacters. t2 := 5. selector := (t1 , ':') asSymbol. p1 perform: selector with: t2
In this above example I had a Text object where the screen showed its name (on page 2) as Text3, but when I used its characters tile in another Text object's script, it used the name Text4 in the text version of that script?
Stephen
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
On Mar 1, 2011, at 11:36 AM, Bert Freudenberg wrote:
I hope Scott will chime in here, but I would guess that the world's presenter should be consulted:
World presenter allExtantPlayers collect: [:each | each uniqueNameForReference -> each externalName]
- Bert -
*CHIME*
As Bert says, it's the "presenter" object who can produce the lists of players known to a project. The broadest list -- and presumably the right one to use in the case under discussion -- includes not only players whose morphs are in the submorph tree but also players referenced by scripts of any players whose morphs are in the tree; get such a list by sending the tongue-twisting message #reallyAllExtantPlayersNoSort to the presenter.
So if you know that a project has a player named 'Cat', in a textual script you can obtain a reference to that player using the code along the lines of:
catPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p | p costume externalName = 'Cat'] ifNone: [nil]. catPlayer ifNotNil: [ <proceed to do something to or with catPlayer...> ]
-- Scott
On 01.03.2011, at 11:28, Ricardo Moran wrote:
On Tue, Mar 1, 2011 at 3:05 PM, Steve Thomas sthomas1@gosargon.com wrote: Ricardo,
Thanks, actually what I need is to get the reference to the object from the External Name.
The problem is that two or more objects could have the same external name. However, if you're sure only one object has a given external name you can get its reference by implementing the following method in the class side of Player:
withExternalName: aString ^ (World findDeepSubmorphThat: [:each | each player externalName = aString] ifAbsent: []) player
And then you can get the reference from a script by sending:
(Player withExternalName: 'Texto')
I really don't know if there is a better way of doing this, but keep in mind that my "solution" is just a hack that goes through all the morphs in the world looking for the player with the given external name.
I hope this helps :) Richo
What I am trying to do is something similar to Learn Programming with Robots by Stephane Ducasse. One of my goals is to find a way to provide a transition for kids from Etoys to Squeak and for me to play around and have fun ;) In looking a at Ducasse's book, I am not really sure what value it adds to kids learning other than showing them the textual syntax of squeak as opposed to the tile version (except the some of the later chapters which introduce the browser, some debugging with halt, etc). Also some of the textual descriptions do not seem as effective or likely to be used by kids as some things that might be done in Etoys.
I really need to think about what for ?Computational Thinking? habits/experiences I want kids to have and how to create an Etoys that can facilitate learning them.
I think, this will take me quite a while (but I'm having fun ;).
In any case
Stephen
On Tue, Mar 1, 2011 at 9:34 AM, Ricardo Moran richi.moran@gmail.com wrote: Hi Steve,
I don't think this is a bug. If I understood correctly, the name used to reference an object in a script is not supposed to be the same as the one displayed on the screen but a unique name that identifies only this object in the World. An object's external name can change at any time but the references to this object must remain consistent in all scripts.
I'm not sure what you're trying to do, but you can get an object's displayed name by sending #externalName to the object. See the attached project for an example.
Cheers, Richo
On Tue, Mar 1, 2011 at 2:51 AM, Steve Thomas sthomas1@gosargon.com wrote: See: http://tracker.squeakland.org/browse/SQ-903
If you change the name of an object, the name used to reference it in a script (via show code textually) does not change. So how do I reference the name of the player (as displayed on the screen) in a script?
script4 | t1 t2 p1 selector | p1 := Text3. t1 := Command1 getCharacters. t2 := 5. selector := (t1 , ':') asSymbol. p1 perform: selector with: t2
In this above example I had a Text object where the screen showed its name (on page 2) as Text3, but when I used its characters tile in another Text object's script, it used the name Text4 in the text version of that script?
Stephen
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
Scott,
Thanks, using this works fine (mostly),
On Wed, Mar 2, 2011 at 5:28 AM, Scott Wallace scott.wallace@squeakland.orgwrote:
catPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort
detect: [:p | p costume externalName = 'Cat'] ifNone: [nil]. catPlayer ifNotNil: [ catPlayer forward: 5 ]
Except when I have multiple Players with the same name in the project. For example if I have a Player with the ExternalName 'Cat' on page 1 and another Player with the ExternalName 'Cat' on page 2. Then execute the script on Page 2 the 'Cat' on Page 1 moves forward. (Note: in playing around with this at one point the 'Cat' on page 2 did move, but when I renamed the 'Cat' and made a new one it went back to the behavior where the 'Cat' on page 1 moved again.
I changed the script to refer to 'Page' instead of 'ActiveWorld' and that seemed to solve the problem, until I duplicated the page (which causes 'Cat' to become 'Cat1') and then renamed 'Cat1' to 'Cat' then the 'Cat' on the previous page moved.
So is there anyway to specify the 'search order' for players where it looks in its current ?World/Playfield? first? Of course the simplest answer may be for me to avoid the problem and not use books ;)
Stephen
On Mar 25, 2011, at 12:34 AM, Steve Thomas wrote:
Scott,
Thanks, using this works fine (mostly),
On Wed, Mar 2, 2011 at 5:28 AM, Scott Wallace scott.wallace@squeakland.org wrote: catPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p | p costume externalName = 'Cat'] ifNone: [nil]. catPlayer ifNotNil: [ catPlayer forward: 5 ]
Except when I have multiple Players with the same name in the project. For example if I have a Player with the ExternalName 'Cat' on page 1 and another Player with the ExternalName 'Cat' on page 2. Then execute the script on Page 2 the 'Cat' on Page 1 moves forward. (Note: in playing around with this at one point the 'Cat' on page 2 did move, but when I renamed the 'Cat' and made a new one it went back to the behavior where the 'Cat' on page 1 moved again.
I changed the script to refer to 'Page' instead of 'ActiveWorld' and that seemed to solve the problem, until I duplicated the page (which causes 'Cat' to become 'Cat1') and then renamed 'Cat1' to 'Cat' then the 'Cat' on the previous page moved.
So is there anyway to specify the 'search order' for players where it looks in its current ?World/Playfield? first? Of course the simplest answer may be for me to avoid the problem and not use books ;)
Stephen
Hi, Stephen,
Yes, the technique we've spoken of will find *some* player of a given name -- not necessarily the one you're hoping for. The "reallyAllExtantPlayersNoSort" method makes an extreme effort (as its extreme name suggests) to include players that may not currently be "in the world," so name collisions of the sort you mention will arise when "books" involving multiple pages holding players of the same name are used.
If you expect that one and only one player of a given name is actually going to be "in the world" at the moment a particular script is running, and you only want something in the script to happen if such a player *is* found, the following approach should work:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p costume isInWorld])] ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
Cheers,
-- Scott
On Mar 26, 2011, at 3:10 AM, Scott Wallace wrote:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p costume isInWorld])] ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
Oops, left an extra right-paren in there by mistake. The correct code would be:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p costume isInWorld]] ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
On Sat, Mar 26, 2011 at 7:16 AM, Scott Wallace <scott.wallace@squeakland.org
wrote:
On Mar 26, 2011, at 3:10 AM, Scott Wallace wrote:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p
costume isInWorld])]
ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
Oops, left an extra right-paren in there by mistake. The correct code would be:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p
costume isInWorld]] ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
Wouldn't that be equivalent to my script?
(World findDeepSubmorphThat: [:each | each player externalName = aString] ifAbsent: []) player
Cheers, Richo
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
On Mar 26, 2011, at 11:01 AM, Ricardo Moran wrote:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p costume isInWorld]] ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
Wouldn't that be equivalent to my script?
(World findDeepSubmorphThat: [:each | each player externalName = aString] ifAbsent: []) player
Hi, Ricardo,
Yes, you're right. Sorry that I'd lost sight of the earlier history of this thread...
However, the "player" of most morphs is nil, so "each player externalName" will often generate an error. Instead, since it's really the morph and not the player that bears the "externalName" anyway, a bulletproofed improvement might be:
foundMorph := World findDeepSubmorphThat: [:each | (each externalName = aString) and: [each player notNil]] ifAbsent: [nil]. foundMorph ifNotNil: [foundPlayer := foundMorph player. < proceed to do something to or with foundPlayer...> ]
Cheers,
-- Scott
On Sat, Mar 26, 2011 at 5:34 PM, Scott Wallace <scott.wallace@squeakland.org
wrote:
On Mar 26, 2011, at 11:01 AM, Ricardo Moran wrote:
foundPlayer := ActiveWorld presenter reallyAllExtantPlayersNoSort detect: [:p |(p costume externalName = 'Cat') and: [p
costume isInWorld]]
ifNone: [nil]. foundPlayer ifNotNil: [ <proceed to do something to or with foundPlayer...> ]
Wouldn't that be equivalent to my script?
(World findDeepSubmorphThat: [:each | each player externalName = aString]
ifAbsent: []) player
Hi, Ricardo,
Yes, you're right. Sorry that I'd lost sight of the earlier history of this thread...
However, the "player" of most morphs is nil, so "each player externalName" will often generate an error. Instead, since it's really the morph and not the player that bears the "externalName" anyway, a bulletproofed improvement might be:
foundMorph := World findDeepSubmorphThat: [:each | (each
externalName = aString) and: [each player notNil]] ifAbsent: [nil]. foundMorph ifNotNil: [foundPlayer := foundMorph player. < proceed to do something to or with foundPlayer...> ]
That's much better. IMHO, for what Steve is trying to do, it might be good to add this snippet to the Player class, maybe in the form of:
withExternalName: aString do: aBlock | foundMorph | foundMorph := World findDeepSubmorphThat: [:each | each externalName = aString and: [each player notNil]] ifAbsent: [nil]. foundMorph ifNotNil: [aBlock value: foundMorph player]
So that he could write, from a script:
Player withExternalName: 'Cat' do: [:cat | cat forward: 5].
And this way we can hide the ugly code away... Of course, I'm not in favor of polluting the Player class but if Steve finds it useful I guess one more method wouldn't hurt :)
Cheers, Richo
Cheers,
-- Scott
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
etoys-dev@lists.squeakfoundation.org