0 votes

Hello guys,

My question on GdScript that title has sum of it. I can not learn it and not use it how I want. I just look at demos, tutorials, examples, demos but can not use myself for my needs.

Ahghh... I know you will Ctrl+C and Ctrl+V the docs of GdScript here as a link. However the big trouble is already that docs. My brain really confused to script my game with Class Reference and Gdscript together when read docs. Especially for Reference and it's elements make my mind blurred.

Okay Let me explain my stuck more clearly.

  • If I used a Node2D, Node or Are2D etc. node and then write any script
    for it. Should my script's all element, inheritance come from that used node type?

I ask it because can not decide which of method, func or other element is for my need and where come from. Not only for that condition and that syntax but generally. Look below!

Godot

if not appear >> http://imgur.com/qwltj1r

  • And other trouble side of me on docs is explanation, what makes me confused. Whenever I search any class element just see some little expressions side by side!.. And don't know what these terms corresponds to what. So can not write accurately script for my game project. Look at the below image again please.

Godot Reference descriptive
if not appear >> http://imgur.com/6i5hqKe

Someone help me how to read and use that docs to script. I click an element and that grab me to another link place and there makes me more confused, like endless curve :/

As a proposal from me to developers. Please you may make these docs more readable and comprehensible.

Note:

Sorry for my English :D

Godot terms

if not appear >> http://imgur.com/LeroEvp

in Engine by (14 points)

2 Answers

+2 votes

First of all, if you are completely new to programming in general, I can understand that some aspects of scripting in Godot can be confusing. The documentation is not a programming tutorial, it implicitely requires some basic notions like variables, functions, a bit of inheritance and math.

Your question as been asked already, you can find some links here by doing a quick search: https://godotengine.org/qa/7981/any-good-tutorials?show=7981#q7981
more here: https://godotengine.org/qa/4335/where-find-godot-engine-tutorials-lets-collect-links-together?show=4335#q4335

If you need to chat with devs, you can ask on IRC: http://webchat.freenode.net/?channels=#godotengine
or on this Godot Discord server: https://discord.gg/FtUEgHf

About the images you posted:

  • When you see something.instance(), it almost always means that something is a PackedScene. In fact, you will not find any other function having that name. You can see the word "instance" mixed in a lot of other places because "instance" is a programming concept, meaning that you create an object according to a model. In Godot, a PackedScene contains information to build a scene. Using instance() will create that scene, as many times as you want.

  • The second screenshot is an example of missing documentation, I agree it's frustrating :s
    Contributors are slowly improving it, it's a huge game engine and it takes time to write all these help files (and even more to translate it in many languages).

  • In the third screenshot... well again, these are programming basics, however some of it is specific to the documentation:

  • void: means the function returns vo value. For example, writing var result = the_function() will not put anything into result.
  • const: this means the function will not modify the object it is used on. For example, on a Node2D, the function will not change anything in the node, just give you some information.
  • float: in computers, this is how we commonly call a number that can have decimals (like 3.14 or 0.5). In the screenshot, it means the function returns that kind of number.
  • Vector2: this is a math vector with an X and Y component. Unlike single numbers, you can use it to represent a position in two dimensions, or a direction. You can click on it and see its description.
  • pivot: this is a parameter, the name usually depends on the function (it could be any name, as long as it's relevant). The choice of "pivot" usually means it's the center of something. In your case, that would be "where is the center of the node".
by (27,172 points)

A small addition to the answer:
If you are zero on programming, start with some python basics, that will help you to understand some of the tools.

If you are too young or your algebra is not your strong part, read a bit and be prepared to learn vector math while you do your games or prototypes.

When in Godot, go slowly with things, work on a basic game like a fixed shooter, one element at time, and start on paper, not on screen.

Game developing, as any programing related stuff, requires patience and to study (a lot sometimes).

Umm... Thanks for your answers and giving time to my question.

Sorry not to mention about my programming experince. Yeah I have coding knowlodge for years especially on Pyhton and Lua. However have no any C++ but some C# and Java. I think some part of or most part of Reference manual is based on C++

I had searched community of Godot from reddit to Facebook plus here but have never seen any related question with my statement. Then I asked it, off course don't want to make here like topic garbage for other users.

You misunderstood me or I could not make a fine self expression for my condition (English is not my language if can not explain it, sorry). I just give these image as only examples of my general problem faced off scripting on Godot until now.

I may not connection Nodes and its elements or classes how to direct my game assets/player/events/conditions etc.

In images:

  • first image one - how i decide on an element/func/method to use in any class? It's related with Node that I used or related with my purpose and independent with used Node type.

nope

if not appear >> http://imgur.com/htlWXga

  • second one - Related/familiar with first one.

  • third one- made me shame :/ I did not mean brief of the float, vector2 etc. sorry for word explain "aggh English" :D. I already know them from Python-Lua and Panda3D-Löve2d. I asked it for the arrange of the elements. Why this arrangement is there. Please correct me If I'm right.

void, Vector2, float shows type of element/method/func ?

get_node(), etc. shows method or func ?

And when I see the parentheses-argument of any func there I really stuck :( An example:

Node get_node( NodePath path ) const

If it's type is Node why we have to point out again another type NodePath into as an argument?

After Nodepath comes a parameter path that you greatly explained and I think it's very Pythonish manner that I can write it how I want. Thanks a lot you.

What I believe that discussion will generally solve my stuck points how to read docs an how to use them as I need :) .

**Godot is really great and I don't want to go anywhere ;)*

Nice ^_^

I have made that comment because Godot is attracting a lot of diverse people lately, old, young, programmers, designers, and many others, also people that comes from engines that require zero knowledge and leaves them with zero knowledge too...


Godot scripting and design is object oriented and you can see the SceneTree as a container of Node instances.
All derive from Object, so, some methods you can use can go up to Object (but you may use Node methods more).

  1. If you check the script on Image 1, may see that enemy is probably a PackedScene (loaded with load or preload), a PackedScene is like a composite class made of many nodes and scripts (that you normally save as scn or tscn file).
    Once get an instance, these can be used like a any Node instance.

  2. That get_node method is inherited from the script class, it may extend a subclass of Node (first line of the script) and get the get_node from that.

  3. Here Node get_node( NodePath path ) const, as Zylann said is the form <return type> <method_name>(<parameter type> <parameter name>) says you get a Node (return type) with the method get_node and a parameter "path" of type NodePath.

If you search about the class NodePath, it will give you a long explanation but basically you can use a String as NodePath too.

If you do:

var my_node = get_node( "string_path_to_my_node" )

Then, mynode will store a reference to the Node instance at "stringpathtomy_node"

+1 vote

I decided that I would choose Godot as my engine and I have very little programming experience.

I knew from previous attempts at making a game (where I did a lot of Copy/Paste) that I would never make a game properly unless I learned to program properly (or as well as I can).

So, I researched and read that GDScript is similar to Python.
I then went to Codecademy Python course ( https://www.codecademy.com/learn/python ) and did the whole course.

It took me a couple of weeks, maybe more, as I have to do it part time.
I had to do parts of it a few times.
I even had to skip some parts that just were too much for me (XOR operators etc).

When I came back to GDScript, it all made sense and worked. That's how it was for me.
I'm still a very beginner programmer, but I am about to finish my first game, and I did it myself, with help and guidance of course from people here.

TLDR: Learn Python first. I hope that helps.

by (810 points)

Thanks for your answer.

I'm already a Python programmer for years. My problem is on Gdscript how to use of its' parts/elements/functions/methods etc those together to make a game. Can not combine them because no enough details/description/example about them in official docs. So we have to assume/predict how those works.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories