How do I load a preset curve resource .res or .tres from code

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

I’m visually editing a simple curve like this

export(Curve) var bezier

I have no problem saving them as presets .tres files, problem arises because I don’t know how to load them, I want to store many and then dynamically interchange them at will

doc’s dont say nothing about loading presets

storing them in variables indeed works

var stored = load("res//path/file.tres")

but then how do i apply it?

just in case the node path2d also manage curves if somebody does know how to load curves there by code maybe the same could apply to Curves class

:bust_in_silhouette: Reply From: lofi

Nevermind I figured out,

visually editing them like this makes easier to achieve desired shapes

export(Curve) var bezier

when you have some shape you want, you save it as a .tres file

then to load them you either use load or preload

var stored = load("res//path/file.tres")


var stored = preload("res//path/file.tres")

and finally call it by its name, in this case I used it to interpolate some values from linear to exponential

var get_new_value = stored.interpolate(range_lerp(some_value, value_origin, value_ending, 0.0, 1.0))

I like how u choose your own answer as best . Anyway I was also trying to figure that out in vain. Thanks.

magicalogic | 2021-05-04 17:44