tutorials/scripting/gdscript/gdscript_exports #143
Replies: 8 comments 8 replies
-
What about |
Beta Was this translation helpful? Give feedback.
-
There's no mention that a description text can be added to exported vars starting the preceding line with ##. ## This is my description text
@export var a: int |
Beta Was this translation helpful? Give feedback.
-
What if you want to listen to a value being changed for exported properties, for instance a bool value changing from true to false. And preferably outside of |
Beta Was this translation helpful? Give feedback.
-
What about if you only want to specify a min or a max to a value instead of a range? For example, if I am exporting a variable called max_health, I want to set the min to 1 (as 0 for max health makes no sense), but I don't want to provide an upper limit. How would I do that? It seems like an @export_min and @export_max might be nice or a keyword you can use in the @export_range (note that INF won't work for ints I believe). |
Beta Was this translation helpful? Give feedback.
-
Hello people, I get some script from 2022 version of Godot. There is a code write in this format: '''export (int, 0, 256) var max_polyphony:int = 96 setget set_max_polyphony''' Can you help me to parse it to actual 4.3 GDScript? Thanks. |
Beta Was this translation helpful? Give feedback.
-
How do I export min-max-values like the ones in the particle system? |
Beta Was this translation helpful? Give feedback.
-
I had the Problem that when I changed an exported property from a tool script the scene was not marked as "modified". The solution was to use undo_redo. Maybe this can be mentioned here |
Beta Was this translation helpful? Give feedback.
-
@export requires a type so Variant can't be exported. Here is a partial, simple work-around. class_name ExportableVariant
extends Resource
enum Type {
BOOL = TYPE_BOOL,
INT = TYPE_INT,
FLOAT = TYPE_FLOAT,
VECTOR2 = TYPE_VECTOR2,
VECTOR3 = TYPE_VECTOR3,
}
@export var type: Type = Type.BOOL
@export var value_bool: bool = false
@export var value_int: int = 0
@export var value_float: float = 0.0
@export var value_vector_2 := Vector2()
@export var value_vector_3 := Vector3()
static func from_float(value: float) -> ExportableVariant:
var result := ExportableVariant.new()
result.type = Type.FLOAT
result.value_float = value
return result
func get_value():
match type:
Type.BOOL:
return value_bool
Type.INT:
return value_int
Type.FLOAT:
return value_float
Type.VECTOR2:
return value_vector_2
Type.VECTOR3:
return value_vector_3 This can be useful when you want to tweak easily tweak animations between instances with property tweeners. For example, an openable container class (some containers you might want to use a hinge joint, others you might want to change color). extends Openable
@export_group("Required Nodes")
@export var hinge: Node3D = null
@export_group("Animation Properties", "animation")
@export var animation_property_path: String = "rotation:x"
@export var animation_final_value := ExportableVariant.from_float(-150)
@export var animation_time: float = 2.5
@export var animation_ease_type: Tween.EaseType = Tween.EaseType.EASE_IN
@export var animation_transition_type: Tween.TransitionType = Tween.TransitionType.TRANS_CIRC
func _open() -> void:
_is_tweening = true
var tween: Tween = create_tween()
tween.tween_property(hinge, animation_property_path, deg_to_rad(animation_final_value.get_value()), animation_time).set_ease(animation_ease_type).set_trans(animation_transition_type) |
Beta Was this translation helpful? Give feedback.
-
tutorials/scripting/gdscript/gdscript_exports
In Godot, class members can be exported. This means their value gets saved along with the resource (such as the scene) they're attached to. They will also be available for editing in the property e...
https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_exports.html
Beta Was this translation helpful? Give feedback.
All reactions