Easier way to give nodes the same code but with automatic "Replace All"?
I have a 3D chess board of sorts, and each tile is called "A1", "B2", "G4", etc. Here is the code I have for the A1 node (in a script called A1.gd). When a mouse hovers over the tile, the game shows an object hovering above the tile.
extends StaticBody func _ready(): connect("mouse_entered", self, "_on_A1_mouse_entered") connect("mouse_exited", self, "_on_A1_mouse_exited") func _on_A1_mouse_entered(): .get_node("/root/Main/Board/Hover").visible = 1 .get_node("/root/Main/Board/Hover").translation = get_translation() func _on_A1_mouse_exited(): .get_node("/root/Main/Board/Hover").visible = 0
I want the same code for all the other tiles, but with "A1" in this code replaced with the respective name for each tile. Right now the only way I can think to do this is to create a separate script for every single tile and paste into each script the above code and do a Replace All (e.g., "A1" -> "B1") every time.
Is there a better way to do this? I am a beginner in using Godot so I appreciate any help/advice. Thanks.