@name Triple Number Selector
@inputs Num:wirelink Slash Astrix Minus 
@model models/expression 2/cpu_controller_mini.mdl
#enable this to use button activation
#@inputs Enable
@outputs Number1 Number2 Number3 T1 T2 T3 Out:vector State:vector Enable
#@outputs N0 N1 N2 N3 N4 N5 N6 N7 N8 N9 Slash Astrix Minus 
@persist Number1 Number2 Number3 T1 T2 T3 Enable 
@persist Disabled Invert
@trigger all
#disable this if not on my server
#ifdef entity:createWire(entity,string,string,number,vector,string)
    if(first()) {
        Self=entity()
        Color=vec(255,255,255)
        Material="arrowire2"
        Width=0.5
        Numberpad=Self:isConstrainedTo()
        Self:createWire(Numberpad,"Slash","/",Width,Color,Material)
        Self:createWire(Numberpad,"Astrix","*",Width,Color,Material)
        Self:createWire(Numberpad,"Minus","-",Width,Color,Material)
        Self:createWire(Numberpad,"Num","link",Width,Color,Material)
    }
#endif
Time=150
interval(Time)
Inv="Inverting: "
Break="<"
Break2=","
Own=entity():owner()
Chat = Own:lastSaid()
runOnChat(1)
K=chatClk()
#K = (curtime() - entity():owner():lastSaidWhen()) < Time/1000 
Numpad=Chat:find("Num")
On = Chat:find("On")
Off = Chat:find("Off")
Brk=Chat:find(Break)
Brk2=Chat:find(Break2)
#Invert=Chat:find("Inv")
Inverse=Own:isCrouch()&Own:keyUse()
if(K&Numpad){
    COMT="Number Selector: "
    if (On) {Enable = 1 print(COMT+"On")}
    if (Off) {Enable = 0  print(COMT+"Off")}
    if(Brk){
        Dump=Chat:explode(Break)
        Dump1=Dump[2,string]:explode(Break2)
        X=Dump1[1,string]:toNumber()
        Y=Dump1[2,string]:toNumber()
        Z=Dump1[3,string]:toNumber()
        if(X){Number1=X}
        if(Y){Number2=Y}
        if(Z){Number3=Z}
        print("Numbers: "+Out+"|"+State)
    }
#if (Invert){Inverse=1}
}
if (Enable) {
N0 = Num:number("0")
N1 = Num:number("1")
N2 = Num:number("2")
N3 = Num:number("3")
N4 = Num:number("4")
N5 = Num:number("5")
N6 = Num:number("6")
N7 = Num:number("7")
N8 = Num:number("8")
N9 = Num:number("9")
#Slash = Num:number("/")
#Astrix = Num:number("*")
#Minus = Num:number("-")
Plus = Num:number("+")
Enter = Num:number("enter")
Del = Num:number(".")



P1 = (0.1 * (N7 - N1))
P2 = (0.01 * (N8 - N2))
P3 = (0.001 * (N9 - N3))
I1 = (1 * (N6 - N4))
I5 = (N5 - Plus) * 5
I100 = (N0 - Del) * 100
if (Slash & ~Slash) {T1 = !T1 print("Num1="+T1)}
if (Astrix & ~Astrix) {T2 = !T2 print("Num2="+T2)}
if (Minus & ~Minus) {T3 = !T3 print("Num3="+T3)}
if (T1) {Number1+=P1+P2+P3+I1+I5+I100
        if(Inverse){Number1*=-1 print(Inv+"X")}
        if(Enter){Number1=0}
    Red=255}else{Red=0}
if (T2) {Number2+=P1+P2+P3+I1+I5+I100
        if(Inverse){Number2*=-1 print(Inv+"Y")}
        if(Enter){Number2=0}
    Green=255}else{Green=0}
if (T3) {Number3+=P1+P2+P3+I1+I5+I100
        if(Inverse){Number3*=-1 print(Inv+"Z")}
        if(Enter){Number3=0}
    Blue=255}else{Blue=0}
}
entity():setColor(Red,Green,Blue)
Out=vec(Number1,Number2,Number3)
State=vec(T1,T2,T3)
if(changed(Number1)|changed(Number2)|changed(Number3)){
    print("Numbers: "+Out+"|"+State)
}
