#Replacing a corrupted scene?

1 messages · Page 1 of 1 (latest)

unborn hull
#

My player scene became corrupted. It's not difficult to delete the node and recreate it from scratch, but is there a way to do so while putting the new node in place of the old one in all my levels?

fast reef
#

Might be an editor cache issue tho

unborn hull
#

you might be right, it still technically works when I run the game.. I just can't access it in the editor

fast reef
#

Try deleting (or moving) the .godot folder from res:// while the editor is closed

unborn hull
#

that worked!!

#

@fast reef mind helping me figure out how to fix the issue that caused this in the first place?

#

I have an autoload singleton for global variables, which contains a dictionary of tile resources for when I need to instantiate any of them into my level

#

right now it only has the Wire resource which works perfectly fine

#

but when I try to add any more entries to this dictionary, the corresponding scene fails to load when I start the game

fathom plover
#

Are you sure tiles/Plug.tscn actually exists? The errors suggest it's not there at all.

unborn hull
# unborn hull

it exists and works correctly if I remove line 25 🥲

fathom plover
#

Is there a tiles/TileBase that's broken? It's possibly trying to use that for Plug.tscn, failing, and erroring.

fast reef
#

Could be a script error somewhere ye

unborn hull
#

my game is on a grid, so every object I have inherits from TileBase (including Wire.tscn) to handle grid movement/collisions. They all work correctly with no errors UNTIL I try to preload them in this script

#

except Wire, which for some reason works with the preload

fathom plover
#

And is the path for TileBase definitely correct? I'm sure I've had similar errors after reorganising the code.

unborn hull
#

ah

fast reef
#

Cyclic imports perhaps?

unborn hull
#

I don't think it is

fast reef
#

Open the plug scene once, then add it in script

unborn hull
#

alright, let me try

#

should I clear the editor cache again before doing this?

fast reef
#

Nah

unborn hull
#
  • only WIRE in resource dictionary
  • run game
  • works
  • open Plug.tscn in editor
  • add line to script
  • run game
  • nope
fathom plover
#

I don't know how useful this would be, but I'm wondering if it would be worth posting the ext_resource section from the top of both Wire and Plug, just to see if there's any obvious differences. Tscn files can be opened in notepad, and then there's a section right at the top for the various resources.

Something like this

[ext_resource type="Script" path="res://scenes/world.gd" id="1_kpj12"]
[ext_resource type="TileSet" uid="uid://ccskplvx7ylud" path="res://tile_sets/tile_map_sf.tres" id="2_r1b3g"]

The first error it gives is a parse error, so it feels like the issue must be there.

unborn hull
#

wire

[ext_resource type="PackedScene" uid="uid://0kyy5eqd4w0w" path="res://tiles/TileBase.tscn" id="1_wbqma"]
[ext_resource type="Script" path="res://tiles/scripts/Wire.gd" id="2_bw8ks"]
[ext_resource type="Texture2D" uid="uid://c8kjhn6erfajc" path="res://sprites/wire-spritesheet.png" id="3_iemk0"]

plug

[ext_resource type="PackedScene" uid="uid://0kyy5eqd4w0w" path="res://tiles/TileBase.tscn" id="1_b1ncv"]
[ext_resource type="Texture2D" uid="uid://dthyr1b6ju1uk" path="res://sprites/plug-spritesheet.png" id="2_nppwc"]
[ext_resource type="Script" path="res://tiles/scripts/Plug.gd" id="2_ycywt"]
[ext_resource type="PackedScene" uid="uid://cemyt5t615e1w" path="res://tiles/components/MoveComponent.tscn" id="4_3avxy"]
fathom plover
#

Thanks.

unborn hull
#

(plug has a MoveComponent to respond to keyboard input by moving on the grid)

fathom plover
#

Does MoveComponent do any of its own loads or preloads?

unborn hull
#

only its own script

#

is it unusual that the id for TileBase is different between Wire and Plug?

fathom plover
#

I think that's normal, but I'll double check my own code.

#

Yeah, it's random per scene, so they won't match. It's the uid that it uses to work out which one it is, and that matches here.

#

Incidentally, does TileBase refer to MovementComponent at all? That could cause a cyclic dependency, like the one Ste mentioned.

unborn hull
#

it does

#

@onready var move_component: MoveComponent = get_node_or_null("MoveComponent")

fathom plover
#

Any chance of backing up the scene, removing the component, and commenting out the code using the component? Just to confirm whether the component is breaking it.

fast reef
#

.. git commit time

fathom plover
#

Good call.

unborn hull
#

replaced the line with @onready var move_component = null, same errors

#

also let me check whether it works with other tiles that don't have a MoveComponent

fathom plover
#

Replace the preload with a load too, maybe?

unborn hull
#

it works with a load

#

which I guess is not a big deal, since I don't need to load that many resources

fathom plover
#

Huh. So it does sound like there's some sort of cycle somewhere. But as long as it works, I guess that's the main thing.

unborn hull