Regarding adding tooltips to functions inside the editor

Godot Version

v4.3.stable.official [77dcf97d8]

Question

Good late night everyone.

I am trying to be professional and organized while writing my code base.

I recently watched a youtube video from “Indently” titled “How To Write Better Functions In Python” - link (https://youtu.be/mSoEjBpJUJ0?si=hkj6ibGR43G-kNCL)

In that video, he showed that custom comments could be added to the tool tip pop up when hovering over the function.

I got it to write the custom details about my function but I am unsure of how to do it with multiple lines of text.

My function is the following …

##
##Use this function to pick a random Shape and Color combo from the ENUM lists
##
##Example Output:
##res://Assets/Icons/SQUARE_RED.png
##
func pick_random_tile(shape=TILE_SHAPE.keys(), color=TILE_COLOR.keys()) -> Texture:
	#example path = load("res://Assets/Icons/"Diamond_BLUE.png")
	var generated_tile_path = "res://Assets/Icons/" + shape[randi() % TILE_SHAPE.size()] + "_" + color[randi() % TILE_COLOR.size()] + ".png"
	var texture = load(generated_tile_path)
	print(generated_tile_path)
	print(typeof(texture))
	return texture

When I hover over top of the function, i get a single line of Description that looks like this…

You can break doc comment lines with the BBCode tag [br]

## Use this function to...[br]
## get a random value!
## [br]
## Decided by fair dice roll
func random_number() -> int:
    return 4

More about BBCode tags in doc comments:

2 Likes

That definitely solved my issue and my brain from freaking out lol. I appreciate the quick help on that. I knew it would be something simple, but I am pretty weak when it comes to bb code tags like that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.