"The setter function isn't defined." But it is, in the script extended by current. Help?

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

I’ve been working with “Node”-s, writing their script, then I started to set up setters, like one that does nothing, hence protecting the value.
I figured that cant_set(x): method could be useful at any of my nodes, so I made a new class for it (“MyNode”), extending “Node”.
Then changed the old “Node”-s scripts to extend “MyNode”.
I thought it would change the simple “Node” to a “MyNode” with cant_set():, so added setget cant_set and got error in editor that “The setter function isn’t defined.”.
Tried right-click “Change Type” too, but don’t seem to do anything after I select “MyNode”.
Weird thing is, I have two similar node that, on hover over shows “Type: Node” for one and “Type: MyNode” on the other, but neither can find my cant_set.

I guess there might be an already built function that could be used to protect var-s, I’m curious to find out about that.
However not understanding why it happens, is what bugs me more.

Could you post the code for the MyNode class?

Ha-kuro | 2022-12-02 00:02

class_name MyNode
extends Node

func cant_set(x):
(tab) print(x + " is not meant to change")

(Thanks LordBoots)

exslacker | 2022-12-02 07:39

top of the text editor, click the {} and input your code between the operators.

you can use ` this operator before and after like you would a text comment to turn anything in this text space to a code snippet.

LordBoots | 2022-12-03 13:14