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

Expand in-source script definition macros to allow for custom embedded scripts at global scope #89

Open
ImmutableOctet opened this issue Jul 15, 2024 · 1 comment
Assignees
Labels
C++ Script API Feature New feature or request module: engine For features that involve the `engine` module. (optional) On Hold Features that are lower priority

Comments

@ImmutableOctet
Copy link
Owner

ImmutableOctet commented Jul 15, 2024

We currently need scripts to be defined either as individual files (my_script_file.cpp) or as embedded lambdas/script expressions (SCRIPT_BEGIN, SCRIPT_END, on(...), etc.), but this isn't always the most natural way to define a script.

We should extend the macro API (found in engine:script's embedded_script.hpp file) to allow script definitions outside of the body of the current script.

This would look something like:

SCRIPT(my_custom_script)
	while (true)
	{
		const auto& button_event = co_await until<OnButtonPressed>();

		print("Button pressed: {}", button_event.button);
	}
END_SCRIPT()

auto my_script_file()
{
	co_await start_script<my_custom_script>();

	// ...
}

We could also optionally have a SCRIPT_CLASS macro to allow for extensions similar to the header-based approach.

SCRIPT_CLASS(my_custom_script)
	decltype(auto) some_fn(thid auto&& self, auto&& some_arg, auto&&... etc)
	{
		// ...
	}
END_SCRIPT_CLASS()

NOTE: SCRIPT_CLASS may need to be defined above the SCRIPT(my_custom_script) section.

@ImmutableOctet ImmutableOctet added Feature New feature or request Idea Ideas, concepts, etc. (for features without a clear scope yet) module: engine For features that involve the `engine` module. (optional) C++ Script API labels Jul 15, 2024
@ImmutableOctet ImmutableOctet self-assigned this Jul 15, 2024
@ImmutableOctet
Copy link
Owner Author

Implemented the SCRIPT and END_SCRIPT macros. Going to put the SCRIPT_CLASS idea on hold for now.

@ImmutableOctet ImmutableOctet added On Hold Features that are lower priority and removed Idea Ideas, concepts, etc. (for features without a clear scope yet) labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Script API Feature New feature or request module: engine For features that involve the `engine` module. (optional) On Hold Features that are lower priority
Projects
None yet
Development

No branches or pull requests

1 participant