I’m creating a button in the code, and I want to assign it a custom variable to use later. What ways can I do this?
I know about “expands”, but I don’t have a separate node for this button to declare variables in .gdscript of this node, because I create it in the code itself.
I want something like:
var a = TextureButton.new()
a.set("value",123)
print("My value is: ",a.value)
‘set’ doesn’t return an error, but it doesn’t set my custom attribute to the button.
Error pops up in print: Invalid get index ‘value’ (on base: ‘TextureButton’).
Oh, I’ve been trying to find other ways to do this. Earlier, when I was creating a separate scene, I had a problem that I couldn’t press this button. However, now I have tried and I can.
But I still want to know if it is possible to assign custom variables to standard nodes such as Button
Thank you very much! It really helped.
I will try to study about meta, because I would like simpler ways to access these meta, but in this case this is the ideal way. Thanks again!