@name Swipepad
@inputs S:wirelink User:entity Fade Reset 
@outputs Fade
@persist CircleOne CircleTwo CircleThree CircleFour CircleFive CircleSix CircleSeven CircleEight CircleNine One Two Three Four OneOne TwoTwo ThreeThree FourFour Fail Success 

S:egpClear()
interval(100)
S:egpDrawTopLeft(1)
KUse=User:keyUse()
CSR=S:egpCursor(User)

#Circle One

S:egpCircle(1,vec2(100,125),vec2(50,50))
S:egpColor(1,vec(255,255,255))
S:egpRoundedBox(2,vec2(88,115),vec2(25,25))
S:egpColor(2,vec(0,0,0))

#Circle Two

S:egpCircle(3,vec2(260,125),vec2(50,50))
S:egpColor(3,vec(255,255,255))
S:egpRoundedBox(4,vec2(250,115),vec2(25,25))
S:egpColor(4,vec(0,0,0))

#Circle Three

S:egpCircle(5,vec2(430,125),vec2(50,50))
S:egpColor(5,vec(255,255,255))
S:egpRoundedBox(6,vec2(420,115),vec2(25,25))
S:egpColor(6,vec(0,0,0))

#Circle Four

S:egpCircle(7,vec2(100,275),vec2(50,50))
S:egpColor(7,vec(255,255,255))
S:egpRoundedBox(8,vec2(88,265),vec2(25,25))
S:egpColor(8,vec(0,0,0))

#Circle Five

S:egpCircle(9,vec2(260,275),vec2(50,50))
S:egpColor(9,vec(255,255,255))
S:egpRoundedBox(10,vec2(250,265),vec2(25,25))
S:egpColor(10,vec(0,0,0))

#Circle Six

S:egpCircle(11,vec2(430,275),vec2(50,50))
S:egpColor(11,vec(255,255,255))
S:egpRoundedBox(12,vec2(420,265),vec2(25,25))
S:egpColor(12,vec(0,0,0))

#Circle Seven

S:egpCircle(18,vec2(100,420),vec2(50,50))
S:egpColor(18,vec(255,255,255))
S:egpRoundedBox(19,vec2(88,410),vec2(25,25))
S:egpColor(19,vec(0,0,0))

#Circle Eight

S:egpCircle(20,vec2(260,420),vec2(50,50))
S:egpColor(20,vec(255,255,255))
S:egpRoundedBox(21,vec2(250,410),vec2(25,25))
S:egpColor(21,vec(0,0,0))

#Circle Nine

S:egpCircle(22,vec2(430,420),vec2(50,50))
S:egpColor(22,vec(255,255,255))
S:egpRoundedBox(23,vec2(420,410),vec2(25,25))
S:egpColor(23,vec(0,0,0))


#Success Page 

if
(Success)
{

S:egpClear()

    S:egpRoundedBox(16,vec2(115,50),vec2(350,250))
    S:egpColor(16,vec(33,255,0))
    
     S:egpRoundedBox(25,vec2(250,350),vec2(200,100))
    S:egpColor(25,vec(33,255,0))
    
    S:egpText(52,"Done",vec2(300,375))
    S:egpSize(52,45)
    
    S:egpText(50,"Access Granted",vec2(150,50))
    S:egpSize(50,45)
    S:egpText(51,"Correct Code",vec2(150,150))
    S:egpSize(51,30)

}

if
(Fail)
{
    S:egpClear()
    
    S:egpRoundedBox(16,vec2(115,50),vec2(350,250))
    S:egpColor(16,vec(255,0,0))
    
    S:egpText(50,"Access Denied",vec2(150,50))
    S:egpSize(50,45)
    S:egpText(51,"Incorrect Code Enterted",vec2(150,150))
    S:egpSize(51,30)
    
     soundPlay(0, 0, "ambient/alarms/apc_alarm_loop1.wav")
    
}

if
(Success)
{
    Fade = 1
}
else
{
    Fade = 0
}

if
(Reset)
{
    reset()
}


if(KUse){
    if(inrange(CSR,S:egpPos(25),S:egpPos(25)+S:egpSize(25))){
        reset()
        
    }
}



if(KUse){
    if(inrange(CSR,S:egpPos(2),S:egpPos(2)+S:egpSize(2))){
        CircleOne = 1
        
        soundPlay(0, 0, "buttons/blip1.wav")
    }
}
if
(CircleOne)
{
S:egpColor(1,vec(251,32,32))
}

if(KUse){
    if(inrange(CSR,S:egpPos(4),S:egpPos(4)+S:egpSize(4))){
        CircleTwo = 1
    }
}
if
(CircleTwo)
{
S:egpColor(3,vec(251,32,32))
}

if(KUse){
    if(inrange(CSR,S:egpPos(6),S:egpPos(6)+S:egpSize(6))){
        CircleThree = 1
        
        soundPlay(0, 0, "buttons/blip1.wav")
    }
}
if
(CircleThree)
{
S:egpColor(5,vec(251,32,32))

}

if(KUse){
    if(inrange(CSR,S:egpPos(8),S:egpPos(8)+S:egpSize(8))){
        CircleFour = 1
    }
}
if
(CircleFour)
{
S:egpColor(7,vec(251,32,32))
}


if(KUse){
    if(inrange(CSR,S:egpPos(10),S:egpPos(10)+S:egpSize(10))){
        CircleFive = 1
        
        soundPlay(0, 0, "buttons/blip1.wav")
    }
}
if
(CircleFive)
{
S:egpColor(9,vec(251,32,32))
}

if(KUse){
    if(inrange(CSR,S:egpPos(12),S:egpPos(12)+S:egpSize(12))){
        CircleSix = 1
    }
}
if
(CircleSix)
{
S:egpColor(11,vec(251,32,32))
}

if(KUse){
    if(inrange(CSR,S:egpPos(19),S:egpPos(19)+S:egpSize(19))){
        CircleSeven = 1
    }
}
if
(CircleSeven)
{
S:egpColor(18,vec(251,32,32))
}

if(KUse){
    if(inrange(CSR,S:egpPos(21),S:egpPos(21)+S:egpSize(21))){
        CircleEight = 1
    }
}
if
(CircleEight)
{
S:egpColor(20,vec(251,32,32))
}

if(KUse){
    if(inrange(CSR,S:egpPos(23),S:egpPos(23)+S:egpSize(23))){
        CircleNine = 1
    }
}
if
(CircleNine)
{
S:egpColor(22,vec(251,32,32))
}


#################################


if
(CircleTwo & CircleOne == 0)
{
    Fail = 1
}

if
(CircleThree & CircleOne == 0)
{
    Fail = 1
}

if
(CircleFour & CircleOne == 0)
{
    Fail = 1
}

if
(CircleFive & CircleOne == 0)
{
    Fail = 1
}

if
(CircleSix & CircleOne == 0)
{
    Fail = 1
}

if
(CircleSeven & CircleOne == 0)
{
    Fail = 1
}

if
(CircleEight & CircleOne == 0)
{
    Fail = 1
}

if
(CircleNine & CircleOne == 0)
{
    Fail = 1
}

#Button One Activated

if
(CircleThree == 0 & CircleTwo)
{
    Fail = 1
}

if
(CircleThree == 0 & CircleFour)
{
    Fail = 1
}

if
(CircleThree == 0 & CircleFive)
{
    Fail = 1
}

if
(CircleThree == 0 & CircleSix)
{
    Fail = 1
}

if
(CircleThree == 0 & CircleSeven)
{
    Fail = 1
}

if
(CircleThree == 0 & CircleEight)
{
    Fail = 1
}

if
(CircleThree == 0 & CircleNine)
{
    Fail = 1
}

#Button Two Activated

if
(CircleFive == 0  & CircleTwo)
{
    Fail = 1
}

if
(CircleFive == 0 & CircleFour)
{
    Fail = 1
}

if
(CircleFive == 0 & CircleSix)
{
    Fail = 1
}

if
(CircleFive == 0 & CircleSeven)
{
    Fail = 1
}

if
(CircleFive == 0 & CircleEight)
{
    Fail = 1
}

if
(CircleFive == 0 & CircleNine)
{
    Fail = 1
}

#Button Number 3 Activated

if
(CircleSix == 0 & CircleTwo)
{
    Fail = 1
}

if
(CircleSix == 0 & CircleFour)
{
    Fail = 1
}

if
(CircleSix == 0 & CircleSeven)
{
    Fail = 1
}

if
(CircleSix == 0 & CircleEight)
{
    Fail = 1
}

if
(CircleSix == 0 & CircleNine)
{
    Fail = 1
}

#Button Number Four

if
(CircleEight == 0 & CircleTwo)
{
    Fail = 1
}

if
(CircleEight == 0 & CircleFour)
{
    Fail = 1
}

if
(CircleEight == 0 & CircleSeven)
{
    Fail = 1
}

if
(CircleEight == 0 & CircleNine)
{
    Fail = 1
}

if
(CircleOne & CircleThree)
{
    Three = 1
}

if
(Three & CircleFive & CircleSix & CircleEight)
{
    Success = 1
}
