Call deferred - can I reference a singleton function ?

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

Hello,

I have a singleton script DataImport.gd and there is an importdata() function within the script. I am trying to get the timing of importing data right with call_deferred on this function within GameRoot node(and game options).

Can I do this and what is the syntax ? Tried with funcref but unable to make it work.

Not ok;

call_deferred("DataImport.importdata")

Also not ok:

var load_data_ref = funcref(DataImport,"importdata")
	call_deferred("load_data_ref.call_func()")

Any help appreciated.

:bust_in_silhouette: Reply From: avencherus
DataImport.call_deferred("importdata")

Hello, thank you for a reply. Still errors out:
E 0:00:06.791 _call_function: Error calling deferred method: ‘Node(DataImport.gd)::load_data_ref’: Method not found…
<C++ Source> core/message_queue.cpp:253 @ _call_function()

AltoWaltz | 2020-12-22 08:43

Typo, the function name is importdata, try that.

avencherus | 2020-12-22 16:17

Great, thank you.

AltoWaltz | 2020-12-23 09:24