How to change default script template?

4.6

Godot/script_templates is empty, so my assumption is - it’s for custom scripts, but i need to change the default one.

UPD:
The meta-default: true is broken in 4.6

Here’s the Godot Documentation on Creating Script Templates. If you want more help than that you’re going to have to explain in more detail what you want. We are not mind readers.

You need to have a top level file folder named script_templates
In that folder you will add a folder named after the node/script type you want a template for.
Inside that folder you will place the template code you want.
I have one to create default code for a State type that I use. So the folder structure is

script_templates/State/state_template.gd   

And this is what the code in state_template.gd looks like:

#-------------------------------------------------------------------------------
# State
#-------------------------------------------------------------------------------
#class_name State extends State

#signal transitioned(from_state:State, to_state_name:String)
#var game:Game 
const NEXT_STATE:String = ""
func enter(_game:Game)->void: 
	print(".enter()")
	game = _game
	transitioned.emit(self, NEXT_STATE)
	pass

func exit()->void: 
	print(".exit()")
	pass	
	
func update()->void: 
	pass
2 Likes

I cant make # meta-default: true , it still adds it as a separate template at project/editor level. Did you make it work? Is this a bug?

Yes, I see the same thing.
If you have meta-default: true it should come up as the default template but it still shows the original Godot default.
However your custom template is under the list of templates for that node and if you select it once it seems to become the default selection for that node type when you create new scripts.
This is likely a bug and it has already been reported here.

1 Like

Thanks for testing. Yeah it’s not a big issue, editor remembers last used even across sessions so it’s fine.