(version 2)
(include "sci.sh")
(exports
    0 rm802
)
(use "Main")
(use "InterFeature")
(use "InterProp")
(use "InterView")
(use "Sync")
(use "CueObj")
(use "Sound")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 802)

(local
    local0
    local1
    local2
    local3
    local4
    local5
    local6
    local7
    local8
    local9[12] = (0 0 69 24 169 120 217 122 278 122 144 152 )
    local21[10] = (0 102 113 128 143 159 174 189 204 216 )
    local31[16] = (102 102 113 128 128 143 143 159 159 174 174 189 189 204 204 216 )
    local47[10] = (0 2 4 6 8 10 12 14 15 15 )
    local57

)
(instance public rm802 of Rm
    (properties
        picture 111
        style $000a
    )

    (method (init)
        (var temp0)
        (send global1:handsOff())
        (super:init())
        (send global80:mapKeyToDir(0))
        (send gMH:addToFront(self))
        (send gKH:addToFront(self))
        = local6 (send global1:masterVolume())
        = local7 local6
        = temp0 global106
        = temp0 (- temp0 1)
        (whichNumber:
            init()
            setCel(temp0)
        )
        (if (<= global106 6)
            = temp0 (+ temp0 1)
            (roomPic:
                view(5)
                setCel(temp0)
                init()
                stopUpd()
            )
        )(else
            = temp0 (- temp0 6)
            (roomPic:
                view(6)
                setCel(temp0)
                init()
                stopUpd()
            )
        )
        (goLeft:init())
        (tFrame:init())
        (nFrame:init())
        (teleLeft:init())
        (teleRight:init())
        (OKButton:init())
        (okFeat:init())
        (creditButton:init())
        (volButton:
            posn(local31[local6] 166)
            init()
        )
        (button1:init())
        (button2:init())
        (button3:init())
        (button4:init())
        (button5:init())
        (button6:init())
        (button7:init())
        (button8:init())
        (volSlider:
            init()
            stopUpd()
        )
        (slater:init())
        (if (not global122)
            = global122 1
            (send global2:setScript(describeButtonScript))
        )(else
            (send global1:handsOn())
        )
    )


    (method (dispose)
        DisposeScript(929)
        (send gMH:delete(self))
        (send gKH:delete(self))
        (send global80:mapKeyToDir(1))
        (mySound:dispose())
        (my2Sound:dispose())
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 1
        )
        return 
            (switch ((send pEvent:type))
                (case evKEYBOARD
                    (send pEvent:claimed(1))
                    (switch ((send pEvent:message))
                        (case KEY_NUMPAD2
                            (if (> ++local8 5)
                                = local8 1
                            )
                            (send global1:setCursor(999 1 local9[(* local8 2)] local9[(+ (* local8 2) 1)]))
                        )
                        (case KEY_TAB
                            (if (> ++local8 5)
                                = local8 1
                            )
                            (send global1:setCursor(999 1 local9[(* local8 2)] local9[(+ (* local8 2) 1)]))
                        )
                        (case KEY_UP
                            (if (< --local8 1)
                                = local8 5
                            )
                            (send global1:setCursor(999 1 local9[(* local8 2)] local9[(+ (* local8 2) 1)]))
                        )
                        (case KEY_SHIFTTAB
                            (if (< --local8 1)
                                = local8 5
                            )
                            (send global1:setCursor(999 1 local9[(* local8 2)] local9[(+ (* local8 2) 1)]))
                        )
                        (case KEY_NUMPAD4
                            (if (== local8 5)
                                (if (< --local7 1)
                                    = local7 1
                                )
                                (send global1:masterVolume(local47[local7]))
                                (volButton:posn(local21[local7] 166))
                                (mySound:
                                    number(992)
                                    setLoop(1)
                                    play()
                                )
                            )(else
                                (if (< --local8 1)
                                    = local8 5
                                )
                                (send global1:setCursor(999 1 local9[(* local8 2)] local9[(+ (* local8 2) 1)]))
                            )
                        )
                        (case KEY_RIGHT
                            (if (== local8 5)
                                (if (> ++local7 9)
                                    = local7 9
                                )
                                (send global1:masterVolume(local47[local7]))
                                (volButton:posn(local21[local7] 166))
                                (mySound:
                                    number(992)
                                    setLoop(1)
                                    play()
                                )
                            )(else
                                (if (> ++local8 5)
                                    = local8 1
                                )
                                (send global1:setCursor(999 1 local9[(* local8 2)] local9[(+ (* local8 2) 1)]))
                            )
                        )
                        (default 
                            (send pEvent:claimed(0))
                            (super:handleEvent(pEvent))
                        )
                    )
                    = local57 0
                )
                (case evMOUSERELEASE
                    = local57 1
                )
                (case evMOUSEBUTTON
                    = local57 2
                )
                (default 
                    (super:handleEvent(pEvent))
                )
            )
    )


    (method (doVerb)
        return 0
    )

)
(instance goToRoom801 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                (goLeft:setCel(1))
                = cycles 2
            )
            (case 1
                (mySound:
                    number(910)
                    setLoop(1)
                    play(self)
                )
            )
            (case 2
                (goLeft:
                    setCel(0)
                    stopUpd()
                )
                = ticks 6
            )
            (case 3
                (send global2:newRoom(801))
            )
        )
    )

)
(instance theScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                = ticks 6
            )
            (case 1
                (if (local1)
                    (teleLeft:setCel(1))
                )(else
                    (teleRight:setCel(1))
                )
                = cycles 2
            )
            (case 2
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                (if (local1)
                    (teleLeft:setCel(0))
                )(else
                    (teleRight:setCel(0))
                )
                = ticks 6
            )
            (case 3
                (if (local1)
                    (if (== global106 1)
                        = global106 global118
                    )(else
                        --global106
                    )
                )(else
                    (if (== global106 global118)
                        = global106 1
                    )(else
                        ++global106
                    )
                )
                = local0 global106
                = local0 (- local0 1)
                (whichNumber:
                    setCel(local0)
                    stopUpd()
                )
                (if (<= global106 6)
                    = local0 (+ local0 1)
                    (roomPic:
                        view(5)
                        setCel(local0)
                        stopUpd()
                    )
                )(else
                    = local0 (- local0 6)
                    (roomPic:
                        view(6)
                        setCel(local0)
                        stopUpd()
                    )
                )
                = ticks 6
            )
            (case 4
                (send global1:handsOn())
                (self:dispose())
            )
        )
    )

)
(instance describeButtonScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                = ticks 24
            )
            (case 1
                (send global1:handsOff())
                (slater:
                    setLoop(3)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 2
                (slater:
                    setLoop(4)
                    setCel(0)
                )
                = ticks 6
            )
            (case 3
                (sHead:
                    setLoop(0)
                    setCel(0)
                    setPri(15)
                    posn(93 74)
                    init()
                    setCycle(MouthSync 802 0 0 0 2)
                )
                DoAudio(2 802 0 0 0 2)
                = ticks 100
            )
            (case 4
                (slater:
                    setCycle(0)
                    setLoop(3)
                    setCel(0)
                    stopUpd()
                )
                (sHead:
                    setCycle(0)
                    setCel(0)
                    hide()
                    posn(96 92)
                    dispose()
                )
                = ticks 25
            )
            (case 5
                (teleRight:setCel(1))
                = cycles 1
            )
            (case 6
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                (whichNumber:setCel((+ (whichNumber:cel) 1)))
                (roomPic:setCel((+ (roomPic:cel) 1)))
                = ticks 25
            )
            (case 7
                (teleRight:setCel(0))
                = ticks 50
            )
            (case 8
                (teleRight:setCel(1))
                = cycles 1
            )
            (case 9
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                (whichNumber:setCel((+ (whichNumber:cel) 1)))
                (roomPic:setCel((+ (roomPic:cel) 1)))
                = ticks 25
            )
            (case 10
                (teleRight:setCel(0))
                = ticks 75
            )
            (case 11
                (teleLeft:setCel(1))
                = cycles 1
            )
            (case 12
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                (whichNumber:setCel((- (whichNumber:cel) 1)))
                (roomPic:setCel((- (roomPic:cel) 1)))
                = ticks 25
            )
            (case 13
                (teleLeft:setCel(0))
                = ticks 50
            )
            (case 14
                (teleLeft:setCel(1))
                = cycles 1
            )
            (case 15
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                (whichNumber:setCel((- (whichNumber:cel) 1)))
                (roomPic:setCel((- (roomPic:cel) 1)))
                = ticks 25
            )
            (case 16
                (teleLeft:setCel(0))
                = ticks 50
            )
            (case 17
                (OKButton:setCel(1))
                = cycles 1
            )
            (case 18
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                = ticks 25
            )
            (case 19
                (OKButton:setCel(0))
                (send global1:handsOn())
                (self:dispose())
            )
        )
    )

)
(instance sayOkScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (cHead:init())
                    (sHead:
                        setLoop(1)
                        setCel(0)
                        posn(96 92)
                        setPri(15)
                        init()
                    )
                )
                (if (local2)
                    (OKButton:setCel(1))
                )
                = cycles 1
            )
            (case 1
                (if (local2)
                    (my2Sound:
                        number(910)
                        setLoop(1)
                        play()
                    )
                    = ticks 15
                )(else
                    (self:cue())
                )
            )
            (case 2
                (if (local2)
                    (OKButton:setCel(0))
                    (if (DoSound(sndGET_AUDIO_CAPABILITY))
                        (sHead:setCycle(CT 1 1))
                        (cHead:setCycle(CT 1 1))
                    )
                )
                = ticks 6
            )
            (case 3
                (if (local2)
                    (mySound:
                        number(1146)
                        loop(1)
                        play(self)
                    )
                    (if (DoSound(sndGET_AUDIO_CAPABILITY))
                        (sHead:setCycle(CT 2 1))
                        (cHead:setCycle(CT 2 1))
                    )
                )(else
                    (self:cue())
                )
            )
            (case 4
                (if (DoSound(sndGET_AUDIO_CAPABILITY) and local2)
                    (sHead:
                        setCycle(0)
                        setCel(0)
                    )
                    (cHead:
                        setCycle(0)
                        setCel(0)
                    )
                )
                = ticks 6
            )
            (case 5
                (if (local2)
                    = local2 0
                    (send global2:newRoom(global106))
                )(else
                    (if (local3)
                        (creditButton:setCel(1))
                        = cycles 1
                    )(else
                        (self:cue())
                    )
                )
            )
            (case 6
                (if (local3)
                    (mySound:
                        number(910)
                        setLoop(1)
                        play()
                    )
                )
                (cHead:dispose())
                (sHead:dispose())
                (creditButton:
                    setCel(0)
                    stopUpd()
                )
                = ticks 25
            )
            (case 7
                (if (local3)
                    = local3 0
                    (send global2:setScript(goTo111))
                )(else
                    (send global1:handsOn())
                    (self:dispose())
                )
            )
        )
    )

)
(instance goTo111 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (cHead:init())
                    (sHead:
                        setLoop(1)
                        setCel(0)
                        posn(96 92)
                        setPri(15)
                        init()
                    )
                )
                = cycles 2
            )
            (case 1
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (sHead:setCycle(CT 1 1))
                    (cHead:setCycle(CT 1 1))
                )
                = ticks 6
            )
            (case 2
                (mySound:
                    number(1146)
                    loop(1)
                    play(self)
                )
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (sHead:setCycle(CT 2 1))
                    (cHead:setCycle(CT 2 1))
                )
            )
            (case 3
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (sHead:
                        setCycle(0)
                        setCel(0)
                    )
                    (cHead:
                        setCycle(0)
                        setCel(0)
                    )
                )
                = ticks 6
            )
            (case 4
                (cHead:dispose())
                (sHead:dispose())
                = ticks 6
            )
            (case 5
                (send global2:newRoom(111))
            )
        )
    )

)
(instance okFeat of InterFeature
    (properties
        x 224
        y 157
        z 100
        nsTop 17
        nsLeft 160
        nsBottom 98
        nsRight 288
    )

    (method (doVerb)
        (send global1:handsOff())
        = local2 1
        (send global2:setScript(sayOkScript))
    )

)
(instance button1 of Feature
    (properties
        nsTop 152
        nsLeft 101
        nsBottom 164
        nsRight 113
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(0))
        )
    )

)
(instance button2 of Feature
    (properties
        nsTop 152
        nsLeft 113
        nsBottom 164
        nsRight 129
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(2))
        )
    )

)
(instance button3 of Feature
    (properties
        nsTop 152
        nsLeft 129
        nsBottom 164
        nsRight 145
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(4))
        )
    )

)
(instance button4 of Feature
    (properties
        nsTop 152
        nsLeft 145
        nsBottom 164
        nsRight 161
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(6))
        )
    )

)
(instance button5 of Feature
    (properties
        nsTop 152
        nsLeft 161
        nsBottom 164
        nsRight 175
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(8))
        )
    )

)
(instance button6 of Feature
    (properties
        nsTop 152
        nsLeft 175
        nsBottom 164
        nsRight 190
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(10))
        )
    )

)
(instance button7 of Feature
    (properties
        nsTop 152
        nsLeft 190
        nsBottom 164
        nsRight 207
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(12))
        )
    )

)
(instance button8 of Feature
    (properties
        nsTop 152
        nsLeft 207
        nsBottom 164
        nsRight 218
    )

    (method (doit)
        (if ((super:onMe(global70 global71)))
            (send global1:masterVolume(15))
        )
    )

)
(instance tFrame of View
    (properties
        x 221
        y 103
        view 2
        priority 2
        signal $0011
    )
)
(instance nFrame of View
    (properties
        x 248
        y 132
        view 2
        loop 1
        priority 2
        signal $0011
    )
)
(instance whichNumber of View
    (properties
        x 248
        y 120
        view 2
        loop 2
        priority 3
        signal $0011
    )
)
(instance teleLeft of InterView
    (properties
        x 219
        y 134
        view 2
        loop 7
        priority 2
        signal $0011
    )

    (method (doVerb)
        = local1 1
        = local5 1
        (send global2:setScript(theScript))
    )

)
(instance teleRight of InterView
    (properties
        x 276
        y 134
        view 2
        loop 8
        priority 2
        signal $0011
    )

    (method (doVerb)
        = local1 0
        = local4 1
        (send global2:setScript(theScript))
    )

)
(instance OKButton of InterView
    (properties
        x 170
        y 133
        view 2
        loop 6
        priority 2
        signal $0011
    )

    (method (doVerb)
        (send global1:handsOff())
        = local2 1
        (send global2:setScript(sayOkScript))
    )

)
(instance creditButton of InterView
    (properties
        x 73
        y 38
        view 2
        loop 5
        priority 2
        signal $0011
    )

    (method (doVerb)
        = local3 1
        (send global2:setScript(sayOkScript))
    )

)
(instance roomPic of View
    (properties
        x 226
        y 97
        view 5
        cel 1
        priority 3
        signal $0011
    )

    (method (doVerb)
        (send global1:handsOff())
        = local2 1
        (send global2:setScript(sayOkScript))
    )

)
(instance goLeft of InterView
    (properties
        x 7
        y 199
        view 1301
        priority 15
        signal $0011
    )

    (method (doVerb)
        (send global2:setScript(goToRoom801))
    )

)
(instance volSlider of InterProp
    (properties
        x 166
        y 185
        view 1301
        loop 1
        priority 12
        signal $4010
    )
)
(instance slater of Prop
    (properties
        x 77
        y 135
        view 2
        loop 3
        priority 2
        signal $0011
    )
)
(instance sHead of Prop
    (properties
        x 96
        y 92
        view 991
        priority 15
        signal $4010
    )
)
(instance cHead of Prop
    (properties
        x 61
        y 103
        view 992
        priority 15
        signal $4010
    )
)
(instance volButton of View
    (properties
        x 144
        y 166
        view 1301
        loop 2
        priority 15
        signal $4810
    )

    (method (doit)
        (var temp0[21], temp21)
        (if ((((((== local57 2) and (send global80:canInput())) and (< 80 global70)) and (< global70 230)) and (< 147 global71)) and (< global71 171))
            (if (< global70 105)
                = temp21 105
            )(else
                (if (> global70 213)
                    = temp21 213
                )(else
                    = temp21 global70
                )
            )
            (volButton:
                x(temp21)
                y(166)
                startUpd()
            )
            Animate((send global5:elements) 0)
            (send global32:eachElementDo(#doit))
            (if (not (mySound:handle))
                (mySound:
                    number(992)
                    setLoop(1)
                    play()
                )
            )
        )(else
            (self:stopUpd())
        )
        (super:doit())
    )

)
(instance mySound of Sound
    (properties)
)
(instance my2Sound of Sound
    (properties)
)
