Scene creation through script not agreeing with engine

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DavidMag

I’m using a script that imports maps from LDtk to Godot scenes.
But the problem is that when I’m opening the scene in Godot it shows that it has changes even though nothing is changed. If I save these changes it will show that it changed again when the script runs and this loop will continue.

The script isn’t changing that node BUT it will open the scene and make modifications to other nodes and then resave the scene.

Does anyone has any ideas to why this happens?

:bust_in_silhouette: Reply From: skysphr

Sounds like the script generates files that do not entirely stick to the current file format standard but are usable enough for Godot to understand and fix. It is kind of odd that the player.gd script is being associated with the instance even though the diff shows no indication of such script in the initial variant (unless there’s more to the diff).

Okey, yes that is the only diff.

The player scenes root node is a KinematicBody2D with the player.gd script attached but the correct scene would be like this?

[ext_resource path="res://src/actors/player/player.tscn" type="PackedScene" id=1]
...
...
[node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( -3.10229, 9.93152 )

But as a said the only thing the script does to that node is loading the scene with ResourceLoader.load then packing the scene with

var packed_scene = PackedScene.new()
packed_scene.pack(map)

And then saving it with ResourceSaver.Save again. Is it some other way I could make changes to that scene or options I can check?

The script I’m using is this https://github.com/DavidMag/godot-LDtk-import/blob/master/addons/LDtk-Importer/LDtkImporter.gd

The interesting lines for this issue is 126 - 134 and 189 - 205

DavidMag | 2021-10-26 17:22