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?

Examples.

void    _ready ( ) virtual
Node    get_child ( int idx ) const
Variant rpc ( String method ) vararg
asked Sep 20, 2018 in Engine by wyattb (161 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.
Example:

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
Example:

func foobar(args):
    for i in args:
        print(i);

foobar(1, 2, 3, 4); # prints 1, 2, 3, 4
answered Sep 20, 2018 by Oen44 (370 points)
edited Sep 20, 2018 by Oen44

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.

https://github.com/godotengine/godot-docs/issues/1753

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.