(include "sci.sh")
(use "Obj")
(script 804)



(class BeltWay of Code
    (properties
        who 0
        xStep 0
        yStep 0
        xOff 0
        yOff 0
        xTweak 0
        yTweak 0
        key 0
        head 0
        xDir 0
        yDir 0
        onCon 0
        cnt 0
    )

    (method (doit)
        (var theXTweak, theYTweak)
        (if (not onCon)
            (send who:
                setMotion(0)
                setHeading(head)
            )
            = onCon 1
            = cnt xOff
        )
        (if ((== (send who:heading) key) and (send who:mover))
            = cnt xOff
            = theXTweak xTweak
            = theYTweak yTweak
        )(else
            (if (not cnt)
                = cnt xOff
                = theXTweak xStep
                = theYTweak yOff
            )(else
                --cnt
                = theXTweak xStep
                = theYTweak yStep
            )
        )
        (send who:
            x(+ (send who:x) (* theXTweak xDir))
            y(+ (send who:y) (* theYTweak yDir))
        )
    )

)
