0 votes

In the API docs, e.g. http://docs.godotengine.org/en/3.0/classes/class_node.html you see functions classified as virtual, const and Variant rpc ( String method ) vararg. I am trying to understand what that means in terms maybe of other languages

So I am guessing virtual classification is similar to abstract, and must be defined in your code (E.g. callbacks). But const or vararg classification I am not so sure. Any ideas?


void    _ready ( ) virtual
Node    get_child ( int idx ) const
Variant rpc ( String method ) vararg
in Engine by (716 points)

1 Answer

0 votes

virtual - used mostly to override class methods like _ready, _process or _input_event.

const - constant variable, set value that can't be changed.

const GAME_NAME = "My Game"; # define constant string GAME_NAME
GAME_NAME = "My New Game"; # error, can't change constant value

vararg - multiple arguments passed to function

func foobar(args):
    for i in args:

foobar(1, 2, 3, 4); # prints 1, 2, 3, 4
by (378 points)
edited by

That still doesn't explain why the methods below are documented as follows.

Node    get_child ( int idx ) const
Variant rpc ( String method ) vararg

How is that? It explains a lot.
You can't modify Node per se, that's why it's const.
rpc(“function_name”, <optional_args>) - that's why it's vararg. Unlimited arguments, first must be function, and then every other is arguments to that function.

Thanks for the clarification. I submitted it as an issue requiring clarification.


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 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 webmaster@godotengine.org with your username.