Chapter 3: Scripting Props and Acts

In addition to a room having a script associated with it, props and actors can also have scripts.  If you have a lot of actors and props in a room, all doing different things, it is much easier to associated the scripting logic for a particular actor with that actor instead of in the room’s script.

Adding a shadow of the ego

For this exercise, we’ll make a Prop that acts as the shadow of the ego.  The Prop’s script’s doit method will check the ego’s position, and adjust its own position accordingly.


(instance aShadow of Prop


        x 0

        y 0

        view 800


    (method (init)


        (self:ignoreActors() z(-90))





(instance shadowScript of Script


    (method (doit)


            posn((+ 20 (send gEgo:x)) (- (send gEgo:y) 90))





And then, in the init method of the room, you do

For example:



It’s that easy.  Of course, the prop or actor’s script can contain any of the standard script methods: changeState, handleEvent or doit.

<< Prev

Next >>