@name - Skee Ball -
@inputs Run
@outputs F E:entity T Score Spawn Undo Clk Str:string
@persist

interval(10)

Clk = 1

# First execution
if (first() | duped()) {
        timer("Text1",1000)
        gSetStr(0,"weapons/teleporter_ready.wav")
        E = entity()
        T = 60
}

# On or Off
if (Run) {
    if (T > 0) {
        timer("Tick",1000)
        if (clk("Tick")) {
            T--
            soundPlay(0,1,"buttons/lightswitch2.wav")
            }
        if (gGetNum(1)) {Score += 1000}
        elseif (gGetNum(2) | gGetNum(3) | gGetNum(4)) {Score += 20}
        elseif (gGetNum(5) |gGetNum(6)) {Score += 200}
        elseif (gGetNum(7) | gGetNum(8)) {Score += 500}
    }
    else {
        T = 0
    }
}
else {
    T = 60
    Score = 0
}

# Defaults
Undo = gGetNum(1)|gGetNum(2)|gGetNum(3)|gGetNum(4)|T<=0|
        gGetNum(5)|gGetNum(6)|gGetNum(7)|gGetNum(8)|!Run
F = 10000
Spawn = 0

# Spawn the prop / play sounds
if ($Undo & Undo & T & Run | ~Run & Run) {
    Spawn = 1
    soundStop(1)
    soundPlay(1,2,"items/suitchargeok1.wav")
}
if ($T & !T | ~Run & !Run) {
    soundStop(2)
    soundPlay(2,2,"buttons/button2.wav")
}

if (E:getAlpha() != 0) {E:setAlpha(0)}

if (clk("Text1")) {
    Str = "Skee Ball"
    timer("Text2",2000)
}
elseif (clk("Text2")) {
    Str = "Made by Drunkie"
    timer("Text1",2000)
}
