That sounds like you create/joined an alliance. When you add turrets and upgrades via this script they're placed in your personal inventory. If you're part of an alliance, flying an alliance ship, you need to move these upgrades to the alliance inventory first for them to become available for slotting.