[squeakland] Tools to Export Images from Etoys (eventually directly to a Blog Post)

Steve Thomas sthomas1 at gosargon.com
Mon Apr 4 13:36:25 EDT 2011


So, I have the following script:

script5
(myPlayer costume renderedMorph isKindOf: BookMorph)
ifTrue: [self beep: 'croak']
ifFalse: [(myPlayer costume renderedMorph ownerThatIsA: BookMorph)
ifNil: [self beep: 'chomp']
ifNotNil: [self beep: 'croak']]


It will "croak" if I click on a BookMorph or any object contained inside the
BookMorph. So far so good.

Now how go I set my *myPlayer* variable to the BookMorph in its "owner
chain" (if that's the common terminology)?

Stephen

On Mon, Apr 4, 2011 at 1:09 PM, Scott Wallace
<scott.wallace at squeakland.org>wrote:

> On Apr 4, 2011, at 7:09 AM, Bert Freudenberg wrote:
>
> > On 04.04.2011, at 15:20, Steve Thomas wrote:
> >
> >> How can I detect if a player variable is a book object? (sometimes it is
> hard to click on the book and if you get another object and try to run the
> script an exception is thrown).
> >
> >       (var costume class isKindOf: BookMorph) ifTrue: [...]
>
> This should be simply
>
>        (var costume isKindOf: BookMorph) ifTrue: [...]
>
> i.e. the "class" shouldn't be there.
>
>
> Also, for completeness, perhaps the "best" version would be:
>
>        (var costume renderedMorph isKindOf: BookMorph) ifTrue: [...]
>
> ... because this will work even if the BookMorph has been rotated ;-)
>
>
> Cheers,
>
>  -- Scott
> _______________________________________________
> squeakland mailing list
> squeakland at squeakland.org
> http://lists.squeakland.org/mailman/listinfo/squeakland
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakland.org/pipermail/squeakland/attachments/20110404/735003dc/attachment.html>


More information about the squeakland mailing list