@name Gunshop
@inputs Pos:entity 
@outputs 
@persist [CornerPos1 CornerPos2]:vector Gun:entity 
@trigger 
interval(100)

if (first()) {
    Scale = entity():isWeldedTo():boxSize()
    
    holoCreate(1)    
    holoScaleUnits(1,Scale+vec(0,0,20))
    holoPos(1,entity():isWeldedTo():pos()+vec(0,0,20))
    holoAng(1,entity():isWeldedTo():angles())
    holoColor(1,vec(255,255,255),50)
    holoParent(1,entity():isWeldedTo())
    
    CornerPos1 = Scale / 2
    CornerPos2 = -CornerPos1
    
    CornerPos1 = holoEntity(1):toWorld(CornerPos1)
    CornerPos2 = holoEntity(1):toWorld(CornerPos2)
    
    CornerScale = vec() + 1
    
    holoCreate(2)
    holoPos(2,CornerPos1+vec(0,0,-15))
    holoScaleUnits(2,CornerScale)
    holoParent(2,entity():isWeldedTo())
    
    holoCreate(3)
    holoPos(3,CornerPos2+vec(0,0,15))
    holoScaleUnits(3,CornerScale)
    holoParent(3,entity():isWeldedTo())
    
    for (I = 1,3) {holoColor(I,vec(),0)}
}

findInBox(CornerPos1,CornerPos2)
findIncludeClass("spawned_weapon")
Gun = findClosest(holoEntity(1):pos())

if (Gun) {
    luaCheat("
        local gun = Entity(" + Gun:id() + ")
        gun:SetPos( Entity(" + Pos:id() + "):GetPos() + Vector(0,0,10) )
        gun:SetAngles( Angle(0,0,0) )
    ")
    print(Gun:name())
}

