Deleting Nodes, Textures, etc

Here’s something I’m trying to figure out…

I draw out some gui for a simple scene
the gui draws boxes and dynamically loads textures into those boxes

A sample scene is <12 nodes

A routine called SceneToRender(sceneID) handles all of that

SceneID is a pointer to a JSON data structure that says which background, and foreground objects to load and where to position them.

I store a bunch of pointers to nodes and textures in an array to track them
e.g. SceneObjects.node = gui node for object (a box)
SceneObjects.texture = pointer to texture

When done with these elements I run a loop through the array(s) to delete all relevant textures and nodes.

To render a new scene the idea is…

Call DeleteCurrentScene
Call SceneToRender(sceneID) again

Ideally SceneToRender acts like a fresh start because all previous nodes and textures were deleted by DeleteCurrentScene.

Except…

They’re not deleting and all I get is artifacts of textures from the previous scene.

EXCEPT

I decided on the last line of DeleteCurrentScene to see what happens if I do this:

print(gui.get_node(imagery))

One would assume if I deleted imagery that would toss an error.

And I do get an error:

ERROR:SCRIPT: /main/PokeyScroll.gui_script:175: bad argument #1 to ‘get_node’ (hash expected, got userdata)
stack traceback:
[C]: in function ‘get_node’
/main/PokeyScroll.gui_script:175: in function ‘UnloadScrollScene’
/main/PokeyScroll.gui_script:334: in function </main/PokeyScroll.gui_script:228>

AND then the new scene loads properly.

If I delete print(gui.get_node(imagery)) and just do print(“hello world”) I get no updated scene and artifacts of past textures.

Any ideas?

Can you create and share a minimal project?