@name AutoWire
@inputs Socket:wirelink
@outputs 
@persist [SOCKET INPUTS]:entity Select:string [Inputs Outputs]:array
@trigger 
interval(1000)
E=entity()
runOnChat(1)
O=owner()
Chat=O:lastSaid()
Aim=O:aimEntity()

#SO here's how this works, You say 
Com="AW" #Auto Wire
Brk="<"   #break character
Out="out" #outputs
In="in"   #intputs
GetLink="get" #list all inputs and outputs
Delete="del" #delete an input

COM=Chat:find(Com)
OUT=Chat:find(Out)
IN=Chat:find(In)
BRK=Chat:find(Brk)
GETLINK=Chat:find(GetLink)
DELETE=Chat:find(Delete)


#Get numbers during parsing. 
if(chatClk()&COM){
    if(BRK){
        if(IN){
            Select=Inputs[Chat:explode(Brk)[2,string]:toNumber(),string]
            INPUTS=SOCKET
            print(Select+" Input Selected!")
            print("<"+Select+">")
        }
        if(Select&OUT){
            SOCKET=Aim
            Output=Outputs[Chat:explode(Brk)[2,string]:toNumber(),string]
            print("<"+Output+">")
            
            Test=INPUTS:createWire(SOCKET,Select,Output)
            
            if(Test){
                print(Select+" was wired to "+Output)
            }else{
                print("Could not wire input: "+Select+" to output: "+Output)
            }
            
        }
    }
    if(GETLINK){
        SOCKET=Aim
        
        E:createWire(SOCKET,"Socket","wirelink") #Briefly wirelink in to get info
        Inputs=array()
        Inputs=SOCKET:getWireInputs()
        print("Inputs:") #Display input table
        printTable(Inputs)
        
        Outputs=array() 
        Outputs=SOCKET:getWireOutputs()
        #Outputs:pushString("wirelink")
        print("Outputs:") #Display output table
        printTable(Outputs)
        E:deleteWire("Socket") #Disconnect
    }
}



#[
    Scopes have been added. If you find any bugs,
    please report them on the forums.

    An option to copy with bbcode color syntax
    highlighting has been added (for use on forums).
    Right click anywhere in the editor to use it.

    Documentation and examples are available at:
    http://wiki.wiremod.com/wiki/Expression_2
    The community is available at http://www.wiremod.com
]#
