scripting: generate object defaults on type change, tidyer code