How to get RichTextEffect variable from RichTextLabel

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By I reject all deals

For example we have a RichTextEffect and its like that:

extend RichTextEffect
class_name a
var bbcode := "a"
func _procces_custom_fx(char_fx) :
        var color= char_fx.env.get("color", #fff) 
        return true

How can I get the color variable out of RichTextEffect?

:bust_in_silhouette: Reply From: jgodfrey

According to this example in the docs, that should look like:

var color = Color(char_fx.env.get("color", Color(1, 1, 1, 0.2)))

(that said, I haven’t tried the above).

Sorry I mean to say how to get the color from out?

I reject all deals | 2023-06-06 10:22

Assuming you provided a color argument in the opening BBcode tag, it’ll be returned in the Dictionary referenced by the env property. Since that’s just a dictionary, the above syntax is attempting to access the color key in that dictionary. If it exists, the value is returned. If it does not exist, the supplied default value is returned instead.

See docs on the env Dict here:

CharFXTransform — Godot Engine (stable) documentation in English

jgodfrey | 2023-06-06 22:21

Yes I know it but I want to get this argument from another gdscript file. How to do it?

I reject all deals | 2023-06-07 09:57