5 Tricks For Better GDScript in Godot

  Рет қаралды 16,946

StayAtHomeDev

StayAtHomeDev

Күн бұрын

Пікірлер: 47
@stayathomedev
@stayathomedev 7 ай бұрын
Do you have your own tips when working with GDScript? 🔥 SUPPORT THE CHANNEL ►► www.patreon.com/StayAtHomeDev_
@julietmikealpha
@julietmikealpha 7 ай бұрын
Use a linter - GDFormat is my preferred choice; it will format the document following the official style guide, including line-breaks
@themghicks
@themghicks 7 ай бұрын
I just discovered gdtoolkit a few days ago and I'm loving it!
@Art-n-Chill
@Art-n-Chill 7 ай бұрын
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_e
@truc_e 7 ай бұрын
this is the real tip lol, I feel like "cleaner code" shouldn't just mean formatting
@davidj3048
@davidj3048 2 ай бұрын
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
@smiffsoft
@smiffsoft 7 ай бұрын
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
@PawelKozlowski77
@PawelKozlowski77 7 ай бұрын
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__
@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.
@MauriMahtava
@MauriMahtava 5 ай бұрын
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.
@marko95g
@marko95g 7 ай бұрын
for the last tip, you can use "\" for multiple lines
@pipeliner8969
@pipeliner8969 7 ай бұрын
your channel is becoming more a more a huge goldmine. Heavily underrated!
@Atropos148
@Atropos148 7 ай бұрын
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
@BigBossRazz
@BigBossRazz 7 ай бұрын
Great tips! That last one was new for me!
@Rai2M
@Rai2M 7 ай бұрын
Basically, this is the video about code style ) Simple but never gets old )
@computersciencestudentriverbat
@computersciencestudentriverbat 7 ай бұрын
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.
@Rai2M
@Rai2M 7 ай бұрын
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))
@computersciencestudentriverbat
@computersciencestudentriverbat 7 ай бұрын
@@Rai2M - I just put both examples that in my editor, it seems fine.
@Rai2M
@Rai2M 7 ай бұрын
@@computersciencestudentriverbat Whatever works for you, buddy.
@AndrewGrofff
@AndrewGrofff 7 ай бұрын
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
@tomppeli7727
@tomppeli7727 7 ай бұрын
Good tips, I Iearned something new!
@charliegnu
@charliegnu 7 ай бұрын
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-f3p
@asdfasdfasdfasdf-f3p 2 ай бұрын
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.
@jayroi1814
@jayroi1814 7 ай бұрын
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-jj1ev
@Thomas-jj1ev 7 ай бұрын
there should be something similar to prettier in VSCode within Godot which adds a default code style.
@dexlovesgames_dlg
@dexlovesgames_dlg 7 ай бұрын
Uhh.. why does keeping a trailing comma help to add items?
@ghostradiodelete
@ghostradiodelete 7 ай бұрын
It doesn't. I was also baffled by this.
@goldkat94
@goldkat94 7 ай бұрын
1:00 how can you write the hashtags before the marked text?
@MattEatsMochi
@MattEatsMochi 7 ай бұрын
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.
@jRsqILVOY
@jRsqILVOY 7 ай бұрын
I wish the GDScript lang server would add a linter to do this like rustfmt in Rust.
@TheRealKaiProton
@TheRealKaiProton 7 ай бұрын
I do number 2 because it looks nicer in the code, I had no idea it was a coding rule
@ThiVasss
@ThiVasss 7 ай бұрын
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?
@charliegnu
@charliegnu 7 ай бұрын
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.
@ThiVasss
@ThiVasss 7 ай бұрын
@@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.
@lyghtkruz
@lyghtkruz 7 ай бұрын
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!
@liamkoehler8820
@liamkoehler8820 7 ай бұрын
Actually it's called SCREAMING_SNAKE_CASE
@ulrich-tonmoy
@ulrich-tonmoy 7 ай бұрын
godot editor editor need a little some code editor feature that all editor comes with nowadays like format on save
@ince55ant
@ince55ant 7 ай бұрын
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
@randomnyyStrannik
@randomnyyStrannik 7 ай бұрын
Thank you
@gryzman
@gryzman 7 ай бұрын
write more code to have better lighting ;)
@laughingvampire7555
@laughingvampire7555 5 ай бұрын
every time he says godot I listen "el gato"
@morganp7238
@morganp7238 7 ай бұрын
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.
@dingdong1112
@dingdong1112 7 ай бұрын
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
@theTeslaFalcon
@theTeslaFalcon 7 ай бұрын
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.
@scotmcpherson
@scotmcpherson 7 ай бұрын
Some expressions won’t work with a trailing comma. Most will, but not all. Just be warned.
Add Motion Blur To Your Godot Game in 2 Minutes
1:26
StayAtHomeDev
Рет қаралды 9 М.
13 Godot HACKS You Don't Know, But Should
5:31
StayAtHomeDev
Рет қаралды 26 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
Understanding The Basics of GDScript - Godot Fundamentals
19:12
Game Dev Artisan
Рет қаралды 35 М.
Save Files in Godot! (Custom Resource Tutorial)
15:32
Queble
Рет қаралды 25 М.
Abstraction Can Make Your Code Worse
5:13
CodeAesthetic
Рет қаралды 680 М.
How I Mastered GODOT In Only a WEEK!
7:08
Simplicity
Рет қаралды 17 М.
We made Vampire Survivors BUT in 10 Lines of Code
7:08
PlayWithFurcifer
Рет қаралды 1 МЛН
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,8 МЛН
Godot Game Awards 2024
13:49
StayAtHomeDev
Рет қаралды 21 М.
How to program in Godot - GDScript Tutorial
58:10
Brackeys
Рет қаралды 870 М.
The 7 Greatest TIPS for Any Game Developer
5:19
DevWorm
Рет қаралды 59 М.