godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.59k stars 2.96k forks source link

Misunderstanding with get_custom_data #9423

Open Torguen opened 1 month ago

Torguen commented 1 month ago

Your Godot version: 4.3 dev 6 windows Issue description: Error in argument description

The documentation states that it is the name of the layer, This is wrong, really the argument is the name of the data

Captura5

URL to the documentation page: https://docs.godotengine.org/en/latest/classes/class_tiledata.html#class-tiledata-method-get-custom-data

If you know how to fix the issue you are reporting please consider opening a pull request. We provide a tutorial on using git here: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html, writing documentation at https://docs.godotengine.org/en/stable/community/contributing/docs_writing_guidelines.html and contributing to the class reference here: https://docs.godotengine.org/en/stable/community/contributing/updating_the_class_reference.html

AThousandShips commented 1 month ago

The documentation states that it is the name of the layer, This is wrong, really the argument is the name of the data

It doesn't say it returns the name of the layer, it says it returns the data value of the layer named that

This is the code that does it, so the description is correct:

Variant TileData::get_custom_data(String p_layer_name) const {
    ERR_FAIL_NULL_V(tile_set, Variant());
    int p_layer_id = tile_set->get_custom_data_layer_by_name(p_layer_name);
    ERR_FAIL_COND_V_MSG(p_layer_id < 0, Variant(), vformat("TileSet has no layer with name: %s", p_layer_name));
    return get_custom_data_by_layer_id(p_layer_id);
}
Torguen commented 1 month ago

The documentation states that it is the name of the layer, This is wrong, really the argument is the name of the data

It doesn't say it returns the name of the layer, it says it returns the data value of the layer named that

This is the code that does it, so the description is correct:

Variant TileData::get_custom_data(String p_layer_name) const {
  ERR_FAIL_NULL_V(tile_set, Variant());
  int p_layer_id = tile_set->get_custom_data_layer_by_name(p_layer_name);
  ERR_FAIL_COND_V_MSG(p_layer_id < 0, Variant(), vformat("TileSet has no layer with name: %s", p_layer_name));
  return get_custom_data_by_layer_id(p_layer_id);
}

I think I'm not clear. Tell me this, what do you have to put in the argument? the name of the data, however the documentation indicates that the name of the layer must be entered

AThousandShips commented 1 month ago

Tell me this, what do you have to put in the argument?

get_custom_data(HERE)? What do you mean? The name is right there, you enter it as the argument?

Do you mean "where do I set the name of the layer"? Then the answer is set_custom_data_layer_name (helpfully named IMO) or in the editor where it's at the top of the custom layer in the Custom Data Layers area, it says "Name"

If you want the data by the layer ID instead use get_custom_data_by_layer_id

Torguen commented 1 month ago

I am speaking only and expressly of the "get_custom_cata" argument.

The argument must be the name of a data type "custom_data". This name "nombre_tile" can be used as an argument to "get_custom_data":

Captura5

A layer name is not a valid argument to "get_custom_data". The documentation states that the argument for "get_custom_data" is a "layer_name", that is incorrect.

AThousandShips commented 1 month ago

Yes it's that name, the name of the custom layer, not a map layer, is it not working? Or what is the problem, please explain

Torguen commented 1 month ago

This is confusing. That's not the name of the layer, that's the name of a custom data. It is not like this?.

Each individual tile can assign a value to "nombre_tile". Here you can see, and that is not changing the name of the layer, what is changing is the value of the custom data. That tile has been assigned the name "muelle".

Captura4

For example, in the Godot 3 version, the tiles had a "name" field, you could assign a tile name to each tile, now that is gone and it must be done as shown here.

"nombre_tile" is not the name of a layer, it is the name of a custom data of type string. That's what I understand.

Captura5

AThousandShips commented 1 month ago

It's the name of the custom data layer, they are called "custom data layers", so how is it confusing to talk about them that way?

There are multiple custom data layers, each can have a name, that's the name "the custom data layer named"

What's confusing about that?

There are no other layers in a tile set, only in a tile map, that's different

Torguen commented 1 month ago

So I understand that godot is creating a layer for each new "custom_data" that is created. The confusion comes from calling "custom_data_layers", I found it a little confusing but now I understand that godot is creating an additional layer every time a new "custom_data_layer" is created, I understood it differently. I didn't understand it as layers, but as data that it creates for each tile, it could perfectly be called "custom tile data" without using "layer" in the name.

Now I understand it but the nomenclature was confusing to me.

Torguen commented 1 month ago

Still, I think it might be clearer to call the argument "custom_data_layer_name". That's what it seems to me.

AThousandShips commented 1 month ago

Why? There's no other layer name to confuse it with? And the documentation is clear. It's far too cumbersome a name

What other layer can it be confused with?

Torguen commented 1 month ago

In my case it was not clarified enough but I would like to settle this, it is expensive to have to use Google translation to see that everything is clear and a hassle! Thank you for the information.

AThousandShips commented 1 month ago

I suspect you are alone in this confusion and I think it's simply caused by language barrier, as it says "custom data layers"

it is expensive to have to use Google translation to see that everything is clear and a hassle

That's not something we can fix though, we don't control the quality of the translations there, and the best help would be to have translation for the documentation to your language, but that would be made harder by the changes you propose, as the documentation would be reset

But hope things go smoothly in the future using tile maps!