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

Add ability to create tool scripts #21

Closed
aclave1 opened this issue Nov 16, 2022 · 3 comments · Fixed by #22
Closed

Add ability to create tool scripts #21

aclave1 opened this issue Nov 16, 2022 · 3 comments · Fixed by #22

Comments

@aclave1
Copy link

aclave1 commented Nov 16, 2022

Currently, FTW supports creating regular classes and singletons using the class and singleton commands. I propose adding another command tool.

Currently, ftw overwrites the lib.rs file and the init function. This means that custom handle.add_class<> calls are removed from the file. In order to register a tool script with godot-rust, you have to do something like

fn init(handle: InitHandle) {
  handle.add_tool_class::<MyClass>();
}

but this will be overwritten if you ever run a command like ftw class again.

I tried implementing this command, but I got stuck because the current implementation reads the source-dir and looks for [NativeClass] using a regex. I couldn't think of a good approach for tool scripts so I decided to post an issue here and get some feedback from you before I proceed. For example, I thought of adding some custom attribute, but this would require users to import a crate into their project which feels messy and against the current approach. I also thought of making the user add a comment but this approach is not always popular.

Another option, instead of implementing this tool command, is some workaround that allows you to call some custom code from the lib.rs file.

@macalimlim
Copy link
Owner

Hi @aclave1

Please check this PR #22. If you have any comments and/or suggestions, please let me know.

Mike

@macalimlim
Copy link
Owner

Also, please check the updated README for creating the tool class.

@aclave1
Copy link
Author

aclave1 commented Nov 19, 2022

@macalimlim thanks for implementing that!

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

Successfully merging a pull request may close this issue.

2 participants