Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaring swift types from my GDScript classes #472

Closed
eimfach opened this issue May 19, 2024 · 4 comments
Closed

Declaring swift types from my GDScript classes #472

eimfach opened this issue May 19, 2024 · 4 comments

Comments

@eimfach
Copy link

eimfach commented May 19, 2024

Hello there !

Is it possible to declare types of class members from my own GDScript classes (I use "class_name" there to make it accessible) ?
So, basically calling into GDScript ?
I didn't find anything that covers that topic...

Thanks

Windows 10
Swift 5.10
Godot 4.2

@eimfach
Copy link
Author

eimfach commented May 20, 2024

So for example I have an enemy controller Node written in GDScript that will get generated pawn nodes as childs (from elsewhere ) also written in GDScript. Now I want to port the enemy controller into Swift...

@migueldeicaza
Copy link
Owner

Please use the Discussion group for questions, not issues.

You can call the methods using the call method on a given instance, but these are loosely typed, so you do things like:

someObject.call ("method", Variant (1), Variant ("Hello world"), Variant (myVector))

Does that solve the problem?

One thing that I would like to do is to generate bindings of APIs that users define in GDScript or other languages, and there are some other folks interested, I believe it might have been discussed somewhere in Godot land. There is an alternative somewhere in the bug tracking here along the lines of "Run a GDScript to dump the API, and then write a generator for that"

@eimfach
Copy link
Author

eimfach commented May 21, 2024

Hey there, thanks for the reply. I wanted to join the slack server but it doesn't let me.

As for your stated code:
I am not sure how I get to that point where I can call "someObject"s methods. "someObject" is a GDScript object I suppose ? If yes, how can I create them ?

@migueldeicaza
Copy link
Owner

Oh, I mean the discussions here on GitHub:

https://github.com/migueldeicaza/SwiftGodot/discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants