Horror stories of nodes being active while in editor.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lavaduder
:warning: Old Version Published before Godot 3 was released.

Gather round the campfire, I got a story to tell.

They say there is something wrong with the tool function. Like something is out there, waiting to strike, Whenever it is use. I believe this as I myself have encountered the tool function’s real power. I once had a timer function. a timer would go off and delete the node. But whenever I attached the script, the editor crashed. I decided to edit the script in another text editor. But once I had the node instance with the script. It would delete itself before I could move it. As if the tool node was not bound by the editor.

I didn’t think much of it at first. but then later When I was messing with the move() function. dramatic pause IT HAPPENED! The node moved it’s position on it’s own. It didn’t matter if i reseted the position back to 0,0 it would constantly move away. I hit the stop play button to see if it would stop, it did not, for I was in THE EDITOR! So I tell you this. Never, ever, use, the, tooooool, FUNCTION!

You can roast your marshmallows now.

:bust_in_silhouette: Reply From: Zylann

tool litterally means your script will run in the editor just as if it was in game. Which is why you get these “weird” behaviours, that means it can even get in the way of the editor itself, especially when it’s about deleting nodes (queue_free or free? how would you undo this anyways?).

This keyword is powerful but must be used with great care. I use it in several places in my game to draw helpers and improve editor friendlyness. To prevent things from happening you can use if get_tree().is_editor_hint().

I’ve crashed the editor and cleaned the Project Manager once, but that is not weird coming from me…

eons | 2017-04-27 14:09