Topic was automatically imported from the old Question2Answer platform.
Asked By
Mystile1369
Hi again. sorry if I’m a bother.
Here I’m working on an instance script that can load a background based on a global script variable, changing the variable will have one of two images load.
I keep getting a string to object error… what am I doing wrong?
you are setting texture to string and ofcourse it doesn’t work:
get_node("Win2").set_texture("loader")
you should use actual Texture, which can be loaded using load method documentation
Thanks Bartosz!
Please bear with me. I am new. Haven’t been working with this all that long to be honest. I love this site because almost all of the time I can find the answers to whatever questions I have by just looking. Sometimes I have to ask, and nice people like you remind me that sometimes… the answer is the simplest. Here’s what I ended up doing.
In my preloading script I added the following:
Prebattle.Win1 = load(“res://Core/Battle/Resources/Winner/Ferail.png”)
Prebattle.Win2 = load(“res://Core/Battle/Resources/Winner/HFerail.png”)
then I rewrote my call like this:
loadA = Prebattle.Win1
loadB = Prebattle.Win2
if Global.HLevel < 2:
get_node(“Win2”).set_texture(loadA)
else:
get_node(“Win2”).set_texture(loadB)