EDITOR: small change in script template? => init()

Just a small idea, perhaps not worth considering. However, the script template currently looks like this:

function init(self)
	-- Add initialization code here
	-- Learn more: https://defold.com/manuals/script/
	-- Remove this function if not needed
end

As a beginner, I can see that in almost every example code looks like this:

function init(self)
    -- make sure the script will receive user input
    msg.post(‘.’, ‘acquire_input_focus’)
end

One might want to change the template to look like this?:

function init(self)
	-- Add initialization code here, ex.
    -- msg.post(‘.’, ‘acquire_input_focus’) -- <= ADDITION HERE
	-- Learn more: https://defold.com/manuals/script/
	-- Remove this function if not needed
end

I don’t know, I just wonder… :thinking:

The question is whether using auto-complete when writing this specific line of code will be faster than uncommenting it since it is such a common code?

btw it is possible to change templates for your project:

5 Likes

Thank you for the information.

After thinking about it and getting more information, I discovered that there is a limit on capturing ‘events’ aka input_focuses.

So I guess my suggestion could lead the wrong way for novice users who might feel tempted to use this everywhere, as I did just a few moments ago.

2 Likes