Do you have your own tips when working with GDScript? 🔥 SUPPORT THE CHANNEL ►► www.patreon.com/StayAtHomeDev_
@julietmikealpha7 ай бұрын
Use a linter - GDFormat is my preferred choice; it will format the document following the official style guide, including line-breaks
@themghicks7 ай бұрын
I just discovered gdtoolkit a few days ago and I'm loving it!
@Art-n-Chill7 ай бұрын
I was wondering if Godot had a linter of some sort but never looked into because I’m usually pretty diligent in good formatting. This is good to know, thank you
@truc_e7 ай бұрын
this is the real tip lol, I feel like "cleaner code" shouldn't just mean formatting
@davidj30482 ай бұрын
How do I do that in Godot 4.3? is it the plugin gdLinter? they warn about when you save you might lose your code for it runs python script on the file an you might lose data
@smiffsoft7 ай бұрын
Good tips for any language, but the last one specifically for GDScript made this really useful for me, I didn't realise you could do that
@PawelKozlowski777 ай бұрын
0:46 is new for me but soo intuitive. I always struggled to differentiate between "temporary comment", and "comment that is here to stay"
@imogen__7 ай бұрын
You can also have your expression continue over multiple lines by writing a backslash \ at the end of the line. This doesn't look as clean as the brackets mentioned in the video though.
@MauriMahtava5 ай бұрын
A tip from history from old C coder. Do not use any numeric values in the code, except 0 for initialization. When you use numeric values, then after you read the code, you don't know background of the value. It is self documentary to use constants all the time. When you need to edit your code, you just need to change the constant. This is the number one code cleaning tip when going professional.
@marko95g7 ай бұрын
for the last tip, you can use "\" for multiple lines
@pipeliner89697 ай бұрын
your channel is becoming more a more a huge goldmine. Heavily underrated!
@Atropos1487 ай бұрын
Thank you so much for talking about documentation comments :) i always wanted something like that in Godot, now i don´t have to keep going back to my own functions to remember how they work, i can just write documentation
@BigBossRazz7 ай бұрын
Great tips! That last one was new for me!
@Rai2M7 ай бұрын
Basically, this is the video about code style ) Simple but never gets old )
@computersciencestudentriverbat7 ай бұрын
I'm a big fan of using Word Wrap for long lines. It's simple and works well when I resize the window for whatever reason.
@Rai2M7 ай бұрын
Word wrapping isn't your friend, because you often need to use different lines for semantic reasons and readability. a quick example this: var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset)) would look much better: var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset)) Imagine the expression is much longer than that. Word wrapping can completely f it up: var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset))
@computersciencestudentriverbat7 ай бұрын
@@Rai2M - I just put both examples that in my editor, it seems fine.
@Rai2M7 ай бұрын
@@computersciencestudentriverbat Whatever works for you, buddy.
@AndrewGrofff7 ай бұрын
Most of these are things that should be handled by an auto formatter IMO. It would be awesome if Godot adds one but for now there is gdscript toolkit for linting and formatting
@tomppeli77277 ай бұрын
Good tips, I Iearned something new!
@charliegnu7 ай бұрын
I wish godot had an opinionated autoformatter like many other modern languages have out of the box. Spend less time formatting and more time coding.
@asdfasdfasdfasdf-f3p2 ай бұрын
Well, writing clear code is much, much more than just five tips. In this video, you don't even scratch the surface. You blew five tiny specks of dust from it.
@jayroi18147 ай бұрын
Very nice, some of these suggestions are good for any developer, game or otherwise. I'm a professional software engineer and my company uses lint to enforce some of these things for our frontend (built in React). With this your git pipeline will actually fail if you have any lint warnings regarding styling like this that weren't automatically formatted by our pre-commit hooks. Very helpful.
@Thomas-jj1ev7 ай бұрын
there should be something similar to prettier in VSCode within Godot which adds a default code style.
@dexlovesgames_dlg7 ай бұрын
Uhh.. why does keeping a trailing comma help to add items?
@ghostradiodelete7 ай бұрын
It doesn't. I was also baffled by this.
@goldkat947 ай бұрын
1:00 how can you write the hashtags before the marked text?
@MattEatsMochi7 ай бұрын
Is there a place I can learn more about 4? I struggle with naming stuff all the time and would love to see a full writeup.
@jRsqILVOY7 ай бұрын
I wish the GDScript lang server would add a linter to do this like rustfmt in Rust.
@TheRealKaiProton7 ай бұрын
I do number 2 because it looks nicer in the code, I had no idea it was a coding rule
@ThiVasss7 ай бұрын
Any tips for grouping and naming for the filesystem? Like do you seperate scenes from scripts or do you save similar things (like an enemy scene and enemy scripts) in the same place for easier access?
@charliegnu7 ай бұрын
I like keeping scripts together with their scenes and group scenes with folders. I've seen people just put all their scenes in one folder and scripts in another and that looks so messy to me.
@ThiVasss7 ай бұрын
@@charliegnu Yeah right now I do the same but I am always looking for the more efficient way. I wish the scenes with scripts were bundled together in the filesystem. (like next to each other) I also go between name sorting so the scripts that have the same name as the scenes are together but also tried by type which separates the scenes and scripts in 2 but keeps them in the same folder.
@lyghtkruz7 ай бұрын
The comma at the end of elements for an array, dictionary is great for git repos. If you add an item to the array it's a single line change not 2 changes (1 for the comma and another for the new item). Great tips!
@liamkoehler88207 ай бұрын
Actually it's called SCREAMING_SNAKE_CASE
@ulrich-tonmoy7 ай бұрын
godot editor editor need a little some code editor feature that all editor comes with nowadays like format on save
@ince55ant7 ай бұрын
instead of doing if condition_A && condition_B && condition_C: i like to do one of these if condition_A: if !condition_B: return if !condition_C: return
@randomnyyStrannik7 ай бұрын
Thank you
@gryzman7 ай бұрын
write more code to have better lighting ;)
@laughingvampire75555 ай бұрын
every time he says godot I listen "el gato"
@morganp72387 ай бұрын
The thing is that Godot is a game engine. To try to be an IDE too is a lot of work that is never going to come close to VSCode or Visual Studio. Just saying.
@dingdong11127 ай бұрын
hi sir i'm a new sub here hope you don't mind if i have a request i have a problem running my godot engine in forward and mobile renderer every time i try to run it, it just show black editor and i couldn't do any thing i hope you will see this and accept my request in return i will continue supporting your channel till the end of my life
@theTeslaFalcon7 ай бұрын
So u declare that "document comments" exist, but u never explained the difference between the 3 different comments u refer to. Comment where it's confusing. Use proper variable names so it's less confusing. Comments should be minimal.
@scotmcpherson7 ай бұрын
Some expressions won’t work with a trailing comma. Most will, but not all. Just be warned.