Is it a good practice to use @tool in a script that is mostly written for runtime?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zephram

I’m using a custom resource to create various “sites” in my game.
Theres a “Mine” site and a “Town” site, each with their own image and text.

extends Resource
class_name ResSiteData

@export var siteName = "New Location"
@export var siteImage: Texture2D


func printLocation():
	print("I'm a location and my name is: ", siteName)

These resources are used in a script called “SiteLogic” which will hold the functionality of a “Site” in game.

@tool
extends Node2D

@onready var siteImage = $Control/TextureRect
@onready var siteName = $Control/Label

@export var siteData : ResSiteData

# Called when the node enters the scene tree for the first time.
func _ready():
	siteImage.texture = siteData.siteImage
	siteName.text = siteData.siteName


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass

I want to see the images (siteImage) and names (siteName) while editing the map in which these sites live. So I’m using “@tool”.

Is that the correct use? Should I be doing anything differently?

:bust_in_silhouette: Reply From: zhyrin

There is no right or wrong way. You can use the tools given to you in whatever way you see fit.
Tool scripts are used to make the developer’s time easier while developing the game in the editor. If this makes your development process more convenient then yes, this is a perfectly valid use.
Make sure you distinguis in your code what is allowed to run in the editor and what is not, also make sure you initialize values of variables property when in the editor. I recally that being a bit more tricky than in a regular, non-tool script.