Update:
It turns out the problem was actually a child node of the root node of map_editor.tscn, an instance of another scene (gui.tscn). When I remove the node, the load errors stop appearing.
I still have no idea what specifically is causing them though, gui.gd isn’t a @tool
script, so I feel like it shouldn’t do anything at loadtime and it shouldn’t be a problem for the script to reference it’s parent in a variable, right?
Edit:
These are the contents of map_editor.tscn and gui.tscn in text form, in case that helps:
gui.tscn:
[gd_scene load_steps=11 format=3 uid="uid://dpqy3qrl3s30s"]
[ext_resource type="Script" path="res://scripts/gui.gd" id="1_fo7kp"]
[ext_resource type="Texture2D" uid="uid://dpo86qdv148oa" path="res://graphics/ui_sprites/selection_box.png" id="2_u6vnw"]
[ext_resource type="PackedScene" uid="uid://d2mctb42543e7" path="res://scenes/player_cam.tscn" id="3_u5fmy"]
[ext_resource type="PackedScene" uid="uid://r6j8ifsygrhm" path="res://scenes/button.tscn" id="4_388cl"]
[ext_resource type="Theme" uid="uid://dkejeknet1ny0" path="res://graphics/test_theme.tres" id="4_x702p"]
[ext_resource type="Texture2D" uid="uid://ckfecr2e1kvql" path="res://graphics/ui_sprites/UIBackground.png" id="5_4jejm"]
[ext_resource type="Texture2D" uid="uid://cjkwuqilluctg" path="res://graphics/ui_sprites/MenuBorderScaled.png" id="6_3ykaa"]
[ext_resource type="Texture2D" uid="uid://c007m1qndnjdy" path="res://graphics/ui_sprites/HourglassBackground.png" id="7_syn1n"]
[ext_resource type="Texture2D" uid="uid://cfyfdrsyj40mm" path="res://graphics/ui_sprites/turn_timer/0.png" id="8_bel4j"]
[ext_resource type="Script" path="res://scripts/drawing.gd" id="9_j515p"]
[node name="GUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_fo7kp")
[node name="Markers" type="Node3D" parent="."]
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="Overlay" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
[node name="Screen" type="Control" parent="Overlay"]
layout_mode = 2
size_flags_vertical = 3
[node name="CamDisplay" type="SubViewportContainer" parent="Overlay/Screen"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 3
stretch = true
[node name="SubViewport" type="SubViewport" parent="Overlay/Screen/CamDisplay"]
handle_input_locally = false
size = Vector2i(2, 2)
render_target_update_mode = 4
[node name="PlayerCam" parent="Overlay/Screen/CamDisplay/SubViewport" instance=ExtResource("3_u5fmy")]
transform = Transform3D(-1, 6.18173e-08, -6.18173e-08, 0, 0.707107, 0.707107, 8.74228e-08, 0.707107, -0.707107, 0, 2, -2)
[node name="UnitPaths" type="Control" parent="Overlay/Screen/CamDisplay/SubViewport"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="DebugTexts" type="Control" parent="Overlay/Screen/CamDisplay/SubViewport"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="FormationDirPreview" type="Polygon2D" parent="Overlay/Screen/CamDisplay/SubViewport"]
color = Color(1, 0.901961, 0, 1)
[node name="SelectionBox" type="NinePatchRect" parent="Overlay/Screen/CamDisplay/SubViewport"]
visible = false
texture_filter = 1
offset_right = 5.0
offset_bottom = 5.0
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("2_u6vnw")
patch_margin_left = 2
patch_margin_top = 2
patch_margin_right = 2
patch_margin_bottom = 2
axis_stretch_horizontal = 1
axis_stretch_vertical = 1
[node name="EscapeMenu" type="Control" parent="Overlay/Screen"]
visible = false
layout_mode = 2
anchors_preset = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Tint" type="ColorRect" parent="Overlay/Screen/EscapeMenu"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.752941)
[node name="Items" type="CenterContainer" parent="Overlay/Screen/EscapeMenu"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Buttons" type="VBoxContainer" parent="Overlay/Screen/EscapeMenu/Items"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="Resume" parent="Overlay/Screen/EscapeMenu/Items/Buttons" instance=ExtResource("4_388cl")]
layout_mode = 2
text = "Resume"
[node name="Options" parent="Overlay/Screen/EscapeMenu/Items/Buttons" instance=ExtResource("4_388cl")]
layout_mode = 2
text = "Options"
[node name="ToMainMenu" parent="Overlay/Screen/EscapeMenu/Items/Buttons" instance=ExtResource("4_388cl")]
layout_mode = 2
text = "Exit to main menu"
[node name="ToDesktop" parent="Overlay/Screen/EscapeMenu/Items/Buttons" instance=ExtResource("4_388cl")]
layout_mode = 2
text = "Exit to desktop"
[node name="MainInterface" type="TextureRect" parent="Overlay"]
layout_mode = 2
theme = ExtResource("4_x702p")
texture = ExtResource("5_4jejm")
expand_mode = 5
stretch_mode = 4
[node name="Content" type="VBoxContainer" parent="Overlay/MainInterface"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
[node name="MenuBorder" type="TextureRect" parent="Overlay/MainInterface/Content"]
layout_mode = 2
size_flags_vertical = 3
size_flags_stretch_ratio = 0.1
texture = ExtResource("6_3ykaa")
expand_mode = 5
stretch_mode = 4
[node name="Focus" type="HBoxContainer" parent="Overlay/MainInterface/Content"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 0
[node name="TurnTimer" type="TextureRect" parent="Overlay/MainInterface/Content/Focus"]
layout_mode = 2
texture = ExtResource("7_syn1n")
expand_mode = 3
stretch_mode = 4
[node name="Hourglass" type="TextureRect" parent="Overlay/MainInterface/Content/Focus/TurnTimer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 0.089283
offset_right = 0.0892868
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("8_bel4j")
expand_mode = 1
stretch_mode = 4
[node name="EndTurnPending" type="GridContainer" parent="Overlay/MainInterface/Content/Focus"]
layout_mode = 2
columns = 2
[node name="EndScreen" type="ColorRect" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.501961)
[node name="VBoxContainer" type="VBoxContainer" parent="EndScreen"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -138.0
offset_top = -48.0
offset_right = 138.0
offset_bottom = 48.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="RichTextLabel" parent="EndScreen/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/normal_font_size = 50
text = "Game over!"
fit_content = true
autowrap_mode = 0
[node name="Winner" type="RichTextLabel" parent="EndScreen/VBoxContainer"]
layout_mode = 2
bbcode_enabled = true
text = "[center]XXX[/center]"
fit_content = true
autowrap_mode = 0
[node name="MainMenu" type="Button" parent="EndScreen"]
custom_minimum_size = Vector2(512, 64)
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -256.0
offset_top = -64.0
offset_right = 256.0
offset_bottom = -20.0
grow_horizontal = 2
grow_vertical = 0
theme = ExtResource("4_x702p")
theme_override_font_sizes/font_size = 32
action_mode = 0
text = "Main Menu"
[node name="Drawing" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("9_j515p")
[connection signal="button_up" from="Overlay/Screen/EscapeMenu/Items/Buttons/Resume" to="." method="resume"]
[connection signal="button_up" from="Overlay/Screen/EscapeMenu/Items/Buttons/Options" to="." method="options"]
[connection signal="button_up" from="Overlay/Screen/EscapeMenu/Items/Buttons/ToMainMenu" to="." method="to_main_menu"]
[connection signal="button_up" from="Overlay/Screen/EscapeMenu/Items/Buttons/ToDesktop" to="." method="to_desktop"]
[connection signal="button_up" from="EndScreen/MainMenu" to="." method="to_main_menu"]
map_editor.tscn:
[gd_scene load_steps=4 format=3 uid="uid://dm78awv05wt4c"]
[ext_resource type="Script" path="res://scripts/map_editor.gd" id="1_4l750"]
[ext_resource type="PackedScene" uid="uid://dpqy3qrl3s30s" path="res://scenes/gui.tscn" id="2_noyj8"]
[sub_resource type="Environment" id="Environment_t1esx"]
ambient_light_source = 2
ambient_light_color = Color(1, 1, 1, 1)
[node name="MapEditor" type="Node3D"]
script = ExtResource("1_4l750")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_t1esx")
[node name="GUI" parent="." instance=ExtResource("2_noyj8")]