(include "sci.sh")
(use "Main")
(use "sPushButtons")
(use "eureka")
(use "Osc")
(use "Cycle")
(use "View")
(use "Obj")
(script 204)


(local
    local0
    local1[16] = (234 80 238 77 243 82 242 82 235 82 227 83 227 83 228 83 )
    local17[2] = (219 235 )

)
(procedure public (proc204_1)
    (waddle:init())
    (lid:init())
    (chickenHead:init())
    (theButton:
        init()
        hide()
    )
    (eggTimer:init())
)


(procedure public (proc204_2)
    (theButton:dispose())
    (eggTimer:dispose())
    (chickenHead:dispose())
    (waddle:dispose())
    (lid:dispose())
    (sStartEggTimer:dispose())
    (if ((send gCast:contains(d0)))
        (d0:dispose())
        (d1:dispose())
        (d2:dispose())
        (d3:dispose())
    )
    (send gCast:eachElementDo(301))
)


(procedure (localproc_00fa)
    (d3:startUpd())
    (d2:startUpd())
    (d1:startUpd())
    (d0:startUpd())
    (if ((< 0 (d0:cel)) and (< (d0:cel) 10))
        (d0:cel((- (d0:cel) 1)))
    )(else
        (if (== (d1:cel) 10)
            (d0:
                cel(10)
                stopUpd()
            )
        )(else
            (d0:cel(9))
        )
        (if ((< 0 (d1:cel)) and (< (d1:cel) 6))
            (d1:cel((- (d1:cel) 1)))
        )(else
            (if (== (d2:cel) 10)
                (d1:
                    cel(10)
                    stopUpd()
                )
            )(else
                (d1:cel(5))
            )
            (if ((< 1 (d2:cel)) and (< (d2:cel) 10))
                (d2:cel((- (d2:cel) 1)))
            )(else
                (if (== (d3:cel) 10)
                    (d2:
                        cel(10)
                        stopUpd()
                    )
                )(else
                    (if (== (d2:cel) 1)
                        (d2:cel(0))
                    )(else
                        (d2:cel(9))
                    )
                )
                (if ((< 0 (d3:cel)) and (< (d3:cel) 10))
                    (d3:cel((- (d3:cel) 1)))
                )(else
                    (d3:
                        cel(10)
                        stopUpd()
                    )
                )
            )
        )
    )
)


(procedure (localproc_0265 param1)
    (var temp0, temp1)
    (d0:cel(10))
    (d1:cel(10))
    (d2:cel(10))
    (d3:cel(10))
    = temp0 (/ param1 60)
    = temp1 (% param1 60)
    (if (temp0)
        (d2:cel((% temp0 10)))
        (if (= temp0 (/ temp0 10))
            (d3:cel((% (= temp0 (/ temp0 10)) 10)))
        )
        (d0:cel(0))
        (d1:cel(0))
    )
    (if (temp1)
        (d0:cel((% temp1 10)))
        (if (= temp1 (/ temp1 10))
            (d1:cel((% (= temp1 (/ temp1 10)) 10)))
        )
    )
)


(instance public sStopEggTimer of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((lid:setMotion(MoveTo 209 56 self)) (d0:dispose()) (d1:dispose()) (d2:dispose()) (d3:dispose()) (waddle:setCycle(0))  )
            )
            (case 1
                (proc204_2() = seconds 1  )
            )
            (case 2
                (proc202_1() = seconds 2  )
            )
            (case 3
                ((self:dispose()) )
            )
        )
    )

)
(instance public sStartEggTimer of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (
                (if (proc0_1(84))
                    = cycles 1
                )(else
                    (eureka:setScript(ScriptID(210 9)))
                    (lid:setMotion(MoveTo 209 27 self))
                    (send gSq5Music2:
                        number(219)
                        loop(1)
                        play()
                    )
                    (if (>= (eureka:puke) 4)
                        proc0_10(201 100)
                    )
                )
 )
            )
            (case 1
                (= next sShowEggTimer (send (ScriptID(202 13)):init()) (send (ScriptID(202 15)):init()) 
                (if ((send gCast:contains(ScriptID(202 14))))
                    (send (ScriptID(202 14)):dispose())
                )
 (send gSq5Music2:
                    number(105)
                    loop(-1)
                    play()
                )
 proc0_2(84) (send gSq5Music1:
                    number(42)
                    loop(-1)
                    play()
                )
 (self:dispose()) )
            )
        )
    )

)
(instance public sShowEggTimer of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((d0:init()) (d1:init()) (d2:init()) (d3:init()) localproc_0265(global136) (theButton:dispose()) = cycles 1  )
            )
            (case 1
                (
                (if (not proc0_1(61))
                    (eggTimer:addToPic())
                    (lid:addToPic())
                )
 (waddle:setCycle(Osc)) = ticks 50  )
            )
            (case 2
                ((chickenHead:setCel((= temp0 (% (+ (chickenHead:cel) 1) 8)))) (waddle:
                    x(local1[* temp0 2])
                    y(local1[+ (* temp0 2) 1])
                    setLoop(+ temp0 1)
                )
 localproc_00fa() (send gSq5Music2:
                    number(220)
                    loop(1)
                    play()
                )
 = ticks 50  )
            )
            (case 3
                (
                (if (--global136)
                    = state (- state 2)
                )
 = cycles 1  )
            )
            (case 4
                ((waddle:setCycle(0)) (self:dispose()) )
            )
        )
    )

)
(instance sShowKey of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds 2  )
            )
            (case 1
                ((theButton:hide()) (self:dispose()) )
            )
        )
    )

)
(instance d0 of Prop
    (properties
        x 245
        y 98
        view 351
        loop 12
        cel 10
        priority 15
        signal 16401
    )

    (method (init param1)
        (self:
            cel(10)
            signal(16401)
        )
        (super:init(rest param1))
    )

)
(instance d1 of Prop
    (properties
        x 237
        y 99
        view 351
        loop 12
        cel 10
        priority 15
        signal 16401
    )

    (method (init param1)
        (self:
            cel(10)
            signal(16401)
        )
        (super:init(rest param1))
    )

)
(instance d2 of Prop
    (properties
        x 227
        y 99
        view 351
        loop 12
        cel 10
        priority 15
        signal 16401
    )

    (method (init param1)
        (self:
            cel(10)
            signal(16401)
        )
        (super:init(rest param1))
    )

)
(instance d3 of Prop
    (properties
        x 219
        y 98
        view 351
        loop 12
        cel 10
        priority 15
        signal 16401
    )

    (method (init param1)
        (self:
            cel(10)
            signal(16401)
        )
        (super:init(rest param1))
    )

)
(instance chickenHead of Prop
    (properties
        x 235
        y 82
        noun 44
        view 351
        priority 11
        signal 16400
    )

    (method (init param1)
        (self:
            ignoreActors(1)
            setLoop(0)
            setCel(0)
        )
        (super:init(rest param1))
    )

)
(instance waddle of Prop
    (properties
        x 234
        y 80
        noun 44
        view 351
        loop 1
        cel 1
        priority 12
        signal 16400
    )

    (method (init param1)
        (self:
            cel(0)
            posn(234 80)
            cycleSpeed(2)
            setLoop(1)
        )
        (super:init(rest param1))
    )

)
(instance public eggTimer of Prop
    (properties
        x 188
        y 185
        z 160
        noun 44
        view 351
        loop 10
        priority 10
        signal 16400
    )

    (method (init param1)
        (if (proc0_1(84))
            (waddle:setScript(sShowEggTimer))
        )
        (self:
            ignoreActors(1)
            stopUpd()
        )
        (super:init(rest param1))
    )


    (method (doVerb param1)
        (switch (param1)
            (case 4
                (
                (if (proc999_4(220 121 235 135 gPEventX gPEventY))
                    (if (not proc0_1(84))
                        (theButton:show(0))
                        (waddle:setScript(sStartEggTimer))
                    )
                )(else
                    (if (proc999_4(235 121 248 135 gPEventX gPEventY))
                        (if (not proc0_1(84))
                            (theButton:show(1))
                            (send gRoom:setScript(sStopEggTimer))
                        )(else
                            (send gTestMessager:say(8 4 0 1 self 202))
                        )
                    )(else
                        (super:doVerb(param1))
                    )
                )
 )
            )
            (default 
                ((super:doVerb(param1)) )
            )
        )
    )

)
(instance lid of Actor
    (properties
        x 209
        y 56
        noun 44
        view 351
        loop 9
        priority 13
        signal 16400
    )

    (method (init param1)
        (if (proc0_1(84))
            (lid:
                setLoop(9)
                x(209)
                y(27)
                stopUpd()
            )
        )(else
            (lid:
                setLoop(9)
                x(209)
                y(56)
                moveSpeed(0)
                stopUpd()
            )
        )
        (super:init(rest param1))
    )

)
(instance theButton of Prop
    (properties
        x 219
        y 111
        noun 44
        view 351
        loop 11
        priority 15
        signal 16400
    )

    (method (show param1 param2)
        (self:
            cel(param1)
            x(local17[param1])
            setScript(sShowKey)
        )
        (super:show(rest param2))
    )

)
