I have a config file, inside is this:

[biome_name]
full_biome_name="Surface"
[parallax]
background="generic_background"

I have a script that loads the config file (in the correct path, I verified) and then gets values from the file.
Problem is that, for example, ConfigFile.get_value("biome_name", "full_biome_name") returns Null. Does anyone know the reason why, or is it something to do with the sections?

  • I fixed it by changing the Dictionary line from:
    BlockTypes={main_block=6,sub_block=7,sub_block2=11}
    to:
    BlockTypes={"main_block":6,"sub_block":7,"sub_block2":11}

    After that change, ConfigFile can load the file and get the sections, keys and values without errors. Tested in Godot 3.5.2-rc2 and Godot 4.0-rc2.

Did ConfigFile.load() run correctly (return value = 0)?

There's a space before [biome_name] in your post, but that may be a typo here, or may not matter.

If neither of those is the issue, you could try printing the results of get_sections() and get_section_keys() to help identify the problem.

    DaveTheCoder There's a space before [biome_name] in your post, but that may be a typo here, or may not matter.

    It was just an artifact of the inline code formatting used on the multi-line entry. I've fixed that formatting in OP.

    Did you create the file using ConfigFile, or did you create it manually (with a text editor)? If you created it manually, it could be an issue with stray or unicode characters, or line endings.

    If you're willing to put it in a .zip and upload it, I could take a look at it.

      I fixed it by changing the Dictionary line from:
      BlockTypes={main_block=6,sub_block=7,sub_block2=11}
      to:
      BlockTypes={"main_block":6,"sub_block":7,"sub_block2":11}

      After that change, ConfigFile can load the file and get the sections, keys and values without errors. Tested in Godot 3.5.2-rc2 and Godot 4.0-rc2.