Gdquest Learn gdscript from zero course site [incomplete example]

Godot Version

Godot v4.6.1.stable.mono

Disclaimer

First time posting, pardon me if i did any mistakes. In case i did something wrong or posted wrong or skipped any guidelines, please point me to the correct direction and i will edit or delete the post no problem.

Question

So i decided to give this interactive site a try but I’m getting confused, I’m no expert but something feels off or something is slipping me perhaps? I don’t understand how the health of the robot is increasing from 50 to 100.
I understand the declared member variable at the top, i understand the function definition of heal with the parameter “amount”. I understand we increment 50 to health by the “amount” inside the function. But from where is this extra value of 50 is coming from? It is then added to health from “amount”. I mean yes but “amount” is not 50 so…?

I’m sorry if I’m not making sense and thanks in advance. I also understand this might be a training example but still, i think 50 is missing here.

var health = 50
func heal(amount):
	health += amount

The 50 is passed as an argument of the heal() function when it’s being called.

In this practice, when you hit “Run”, the program itself calls heal(50) and then checks if the robot’s health was increased by 50.

Hey thanks, i think I’m starting to grasp it. I did some manual researching to check other people code here and there and tried to compare it how it was written in other languages. I tried to run it in a separate custom function ( func heal50(): ) and it wasn’t working without godot build in ready(): in order to initialize it first perhaps? i guess! (i also just read about _init and _process as alternatives)

Had to call func heal(amount): inside func ready(): with the keyword “heal”, could not wrap my head around the difference between a parameter and an argument exactly or where structurally should be typed in the main body. Like should be below heal or over heal. It looks like it doesn’t matter but for my brain sanity it made sense to be at the top.

Nice application but the whole time i felt it was hiding key details. I had to test it in the engine to actually see it because it was driving me nuts. Hours went by reading to make it click haha.

Thanks again, sorry if the reply took long enough, i don’t know if there are notifications i can use, i was reading.

That’s exactly what you should be doing. Do the tutorial class and then open the engine and play around with your new found knowledge to understand it better.