godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.73k stars 570 forks source link

function new() and _init() #740

Open lph993 opened 2 years ago

lph993 commented 2 years ago

There are two questions I would like to ask:

  1. When the gdnative script function parameters have default values, the functions that gdscript calls it must all be assigned values, otherwise the game will exit after running the godot game timeout, and there will be no error message.

  2. In gdscript, such as: 'var class=preload("res://**").new()', if the 'new()' function has a value such as 'new(self)', it will prompt an error, The '_init()' parameter is zero.

How should I solve the above two problems. --This article comes from network translation

lph993 commented 2 years ago

The function '_init()' in question 2 belongs to the gdnative script.

Zylann commented 2 years ago

It seems to me both things are unsupported in Godot 3.x's GDNative, at least in C++ bindings. I think there were existing issues about declaring default values and passing arguments to constructors.