+1 vote

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 cantset(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 cantset 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.

Godot version 3.5.1
in Engine by (18 points)

Could you post the code for the MyNode class?

class_name MyNode
extends Node

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

(Thanks LordBoots)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.