Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "Attach Node Script" dialog should suggest snake_case file names, consistent with the documentation #1211

Closed
homchom opened this issue Jul 17, 2020 · 15 comments · Fixed by godotengine/godot#78119

Comments

@homchom
Copy link

homchom commented Jul 17, 2020

Describe the project you are working on: A 2D rhythm platformer

Describe the problem or limitation you are having in your project: The GDScript Style Guide page on the documentation says that per the style guide, GDScript file names should be in snake case. However, the 'Attach Node Script' dialog suggests the same name as the node, in pascal case by default.

image

Describe the feature / enhancement and how it helps to overcome the problem or limitation: To achieve consistency with the documentation, the autocompleted file name should be converted to snake case.

image

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: From what I have heard, Godot already has case conversion methods, so it should be easy to just convert pascal to snake case.

If this enhancement will not be used often, can it be worked around with a few lines of script?: N/A

Is there a reason why this should be core and not an add-on in the asset library?: It is more consistent with the (core) documentation.

@Xrayez
Copy link
Contributor

Xrayez commented Jul 17, 2020

From what I have heard, Godot already has case conversion methods, so it should be easy to just convert pascal to snake case.

Those methods exist, but they are not part of core currently, see my proposal #719.

@KoBeWi
Copy link
Member

KoBeWi commented Jul 17, 2020

I think scene names should be snake_case too, otherwise it doesn't make much sense. And the script name already uses scene name, so they are consistent.

@Calinou
Copy link
Member

Calinou commented Jul 17, 2020

To anyone implementing this: The convention should be changed automatically depending on the target language. It should not apply when using C#, which uses PascalCase for file names (the file name should be the same as the class name).

@Shadowblitz16
Copy link

pls no this should be a option not a requirement

@homchom
Copy link
Author

homchom commented Aug 23, 2020

pls no this should be a option not a requirement

@Shadowblitz16 Both would still be an option. This is just suggesting that the default option should be consistent with the documentation.

@homchom
Copy link
Author

homchom commented Aug 23, 2020

I think scene names should be snake_case too, otherwise it doesn't make much sense. And the script name already uses scene name, so they are consistent.

@KoBeWi I might be wrong, but doesn't it use the name of the node you attach it to? (which should be PascalCase)

Also, I previously had been using PascalCase for scene names, but I think you're right. If Godot as an engine wants to start formally autosuggesting snake case for script names, it should do it for scene names too. The snake case next to the node icons in the editor itself will take some getting used to, but I guess it's consistent.
image

EDIT: Apparently the script does suggest the scene name, but only if it is the root node. Otherwise, it suggests the name of the node. This means that if you use snake case for scene files, the root node will have a script name suggested in snake case, but all other nodes will have a script name suggested in pascal case.

@KoBeWi
Copy link
Member

KoBeWi commented Aug 23, 2020

I might be wrong, but doesn't it use the name of the node you attach it to? (which should be PascalCase)

Actually it's both. It uses scene name when script is attached to root and node name for other nodes.

@homchom
Copy link
Author

homchom commented Aug 23, 2020

That's funny. I just realized that and edited my comment, but before I saw your reply just now.

@Calinou Calinou changed the title 'Attach Node Script' Dialog should suggest snake case file names, consistent with the documentation The "Attach Node Script" dialog should suggest snake_case file names, consistent with the documentation Mar 30, 2021
@MickL
Copy link

MickL commented Nov 18, 2021

I wonder if the docs are wrong or the save dialog:

The docs say it should be snake_case but the dialog proposes PascalCase. Further, all tutorials I've seen so far, even the ones within the Godot docs, use PascalCase.

In each case consistency should be applied everywhere: In the dialogs and in the docs (not just on the styleguide page).

@Calinou
Copy link
Member

Calinou commented Nov 18, 2021

I wonder if the docs are wrong or the save dialog:

For saving scenes, we've established that the save dialog is wrong. Documentation that still uses PascalCase scene file names should be updated to use snake_case instead.

@passivestar
Copy link

I asked people and it seems like everybody is kinda doing their own thing when it comes to naming conventions:
https://twitter.com/passivestar_/status/1708115945799995542

There probably should be an additional dropdown on this screen for script names, with the default being whatever the documentation is recommending:

image

@GuyUnger
Copy link

GuyUnger commented Oct 1, 2023

i think many people (like me) started using pascal case for scripts because it’s what this box suggests. working with people and online resources that use different conventions is annoying, you can retype it if you really want to be different but i don’t think the engine should promote this with having a pascal case option

@ScriptSlinger
Copy link

ScriptSlinger commented Nov 22, 2023

After constantly renaming script file names to snake case, I support this as a potential feature, it would be nice to have a more consistent naming of script names according to the official convention stated by docs. It should be an option as well for people who want it to continue to default to PascalCase

@RedMser
Copy link

RedMser commented Feb 29, 2024

From the closed as duplicate #9199 there was a new suggestion which should be considered as well:

A warning could be also added to the script creation windows to warn when a user's file name might cause issues dependent on the case specified in the project setting

Could be done as a follow-up PR, in which case this should likely be moved to a new dedicated design task.

@Dev-Marco
Copy link

Dev-Marco commented Apr 16, 2024

The thing with this setting is that it only applies to scripts on nodes that are saved as a scene. So if I save my BaseTower node as a scene and attach the script then it suggests the name base_tower.gd.
If the node is not saved as a scene it's BaseTower.gd.
I found that annoying so I created a plugin for anyone who's interested. It's my first plugin so far and I am working on the comments :D
https://github.com/Dev-Marco/CCN---Correct-Conventional-Naming-for-Godot-Scripts.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
13 participants