Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exported array gets emptied when saving scene script #78208

Closed
lazaromenezes opened this issue Jun 14, 2023 · 9 comments · Fixed by #77735
Closed

Exported array gets emptied when saving scene script #78208

lazaromenezes opened this issue Jun 14, 2023 · 9 comments · Fixed by #77735

Comments

@lazaromenezes
Copy link

Godot version

v4.1.beta1.official [828ec2c]

System information

Godot v4.1.beta1 - Windows 10.0.23475 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3550) - AMD Ryzen 5 5500 (12 Threads)

Issue description

I have an exported array for a given type I created with class_name

extends Node3D
class_name Enemy

It is exported as follow

@export var rollable_hazards: Array[Enemy]

I populate it using the editor and it works fine, but sometimes it gets emptied after saving the exporting scene. Not sure if it relates with #62916 and/or #77735.

Here's a screen recording I did showing the issue

Recording.2023-06-13.222554.mp4

Please let me know if you need any additional information.

Steps to reproduce

  1. Export an array from a scene script
  2. Populate it with other nodes
  3. Edit the exporting script and save it

Minimal reproduction project

If you check this branch out, commit 327d03d was the base for the changes I had into the screen recording.

@AThousandShips
Copy link
Member

Can you test if #77735 fixes this? It sounds like the bug I ran into indeed. See here

@lazaromenezes
Copy link
Author

I did a test with v4.1.beta.custom_build [30d247257] from the given pull request, and it still persists. The only change I did on my script was adding a blank space, and it caused the scene to be saved removing the array members.

image

$ git diff
diff --git a/scenes/dungeon/dungeon.gd b/scenes/dungeon/dungeon.gd
index ead4590..3a171aa 100644
--- a/scenes/dungeon/dungeon.gd
+++ b/scenes/dungeon/dungeon.gd
@@ -71,7 +71,7 @@ func _roll_hazards():
        for enemy in rolled:
                var count = rolled.count(enemy)
                if count > 0:
-                       rolled_group[enemy] = count
+                       rolled_group[enemy] = count

        get_tree().call_group("enemies_group", "define_health", rolled_group)

diff --git a/scenes/dungeon/dungeon.tscn b/scenes/dungeon/dungeon.tscn
index 9d06160..19bb1af 100644
--- a/scenes/dungeon/dungeon.tscn
+++ b/scenes/dungeon/dungeon.tscn
@@ -19,9 +19,8 @@ size = Vector3(5, 0.2, 5)
 [sub_resource type="BoxMesh" id="BoxMesh_4whfm"]
 size = Vector3(5, 0.2, 5)

-[node name="Dungeon" type="Node3D" node_paths=PackedStringArray("rollable_hazards")]
+[node name="Dungeon" type="Node3D"]
 script = ExtResource("1_djhe0")
-rollable_hazards = [NodePath("Dragon"), NodePath("Enemies/Slime"), NodePath("Enemies/Goblin"), NodePath("Enemies/Skeleton")]

 [node name="Scenario" type="Node" parent="."]

Not sure if it would make a difference or not, but before testing it I also cleaned the .godot directory to have it clean from anything

@AThousandShips
Copy link
Member

Then this is a separate issue, thank you for testing!

@lazaromenezes
Copy link
Author

No problem, please let me know if I can give any additional information

@AThousandShips
Copy link
Member

Will try and dig into it when I have time/energy, as I've already dug around in related things, will see if I can find anything

@AThousandShips
Copy link
Member

It appears now that my PR when updated further fixes this, can you confirm?

@lazaromenezes
Copy link
Author

Sure, I'll git it a try later today :)

@lazaromenezes
Copy link
Author

Hello again! I did a quick test with the same steps into the initial post and it looks it's fixed with v4.1.beta.custom_build [29903df9a]

Here's a quick video:

Recording.2023-06-19.174154.mp4

Thank you!!

Not sure about your workflow, so I'll leave it open for now.

@AThousandShips
Copy link
Member

It'll be closed automatically when the PR is closed so keep it open, thank you for confirming

@akien-mga akien-mga added this to the 4.1 milestone Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants