@name Plug and Play hub 1
@inputs Rewire E2hub:entity Linked:entity
@outputs Hub:entity Linkup
@persist WiredTo:entity PodControl:entity Linkup Cam:entity
@trigger all

interval(500)
if(first()){PodControl = ranger(-10):entity()
     Hub = entity() Linkup = 1
    findInSphere(entity():pos(),1000)
    findClipToClass("gmod_wire_cameracontroller")
    Cam = findClosest(entity():pos())
    }
if(Rewire & ~Rewire) {
   
    Linked:deleteWire("W")
    Linked:deleteWire("A")
    Linked:deleteWire("S")
    Linked:deleteWire("D")
    Linked:deleteWire("R")
    Linked:deleteWire("Shift")
    Linked:deleteWire("Alt")
    Linked:deleteWire("Mouse1")
    Linked:deleteWire("Mouse2")
    Linked:deleteWire("Space")
    Linked:deleteWire("Active")
    Linked:deleteWire("Linkup")
    Cam:deleteWire("Position")
    Cam:deleteWire("Direction")
    Cam:deleteWire("Activated")
    entity():deleteWire("Linked")
    
    
    findInSphere(entity():pos(),100)
    findClipToClass("gmod_wire_expression2")
    Ranger = findClosest(entity():pos())
    if(Ranger == entity()) {Ranger = findResult(2)}
    if(Ranger == E2hub) {Ranger = findResult(3)}
    
    WiredTo = Ranger
    WiredTo:createWire(PodControl,"W","W")
    WiredTo:createWire(PodControl,"A","A")
    WiredTo:createWire(PodControl,"S","S")
    WiredTo:createWire(PodControl,"D","D")
    WiredTo:createWire(PodControl,"R","R")
    WiredTo:createWire(PodControl,"Shift","Shift")
    WiredTo:createWire(PodControl,"Alt","Alt")
    WiredTo:createWire(PodControl,"Mouse1","Mouse1")
    WiredTo:createWire(PodControl,"Mouse2","Mouse2")
    WiredTo:createWire(PodControl,"Space","Space")
    WiredTo:createWire(PodControl,"Active","Active")
    Cam:createWire(WiredTo,"Position","PosVec")
    Cam:createWire(WiredTo,"Direction","AngVec")
    Cam:createWire(WiredTo,"Activated","CamOn")
    WiredTo:createWire(entity(),"Linkup","Linkup")
    entity():createWire(WiredTo,"Linked","Linked",0.25,vec(255,255,255),"arrowire2")
    }
