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

feat!: Additional Lua bindings, documentation, attitude decoupled from creature #3990

Closed
wants to merge 18 commits into from

Conversation

AluminumAlman
Copy link
Contributor

@AluminumAlman AluminumAlman commented Dec 27, 2023

Summary

SUMMARY: Infrastructure "More game, mostly creature class-family's, functions/methods exposed to Lua. Additional documentation added for Lua. Decoupled creature attitude from creature header. Incremented internal Lua version constant to 2."

Purpose of change

Building on top of #2216, a whole bunch of functions for creature, character, avatar and NPC are now exposed to Lua, with other bindings in order for the aforementioned bindings to work, and a few other miscellaneous bindings.
Added docs for binding Lua classes/structs by transforming the definition.
As suggested by olanti-p, I've decoupled the creature attitude enum from its class so as not to include the massive creature.h file in catalua files.

Describe the solution

In order to bind most of the creature class family's methods and members to Lua, the types used/returned had to be bound to Lua first, which required additions to them, most of them covered by doc/LUA_SUPPORT.md. By using (mostly) regex, header files of the classes in question were formatted step-by-step so that it wouldn't be as tedious as doing it manually, however looking over the result was necessary sometimes. Preprocessor macros were made to make typing bindings manually less of a hassle when the regex processing didn't work.
Writing Lua bindings by hand can be quite cumbersome and tedious, so through the use of macros and regular expression substitution on a class definition, binding large classes/structs shouldn't be as awful.
The creature attitude enum is now a part of enums.h file. Additionally, a enum_conversions.cpp file was created to have the enum_to_string<Attitude> needed for Lua bindings.

Testing

  • Project builds (on my machine);
  • Ran some bound functions through the Lua console to make sure that they worked;
  • Changed/added a little bit of tests;
  • Current tests may be lacking (e. g. no creature class family tests);

Additional context

  • Remake of feat(lua): additional, mostly creature class family, bindings #3170 as the branch was failing to build after merge conflict fix because of the PR's staleness.
  • Some of the bindings are commented out, whether it be because they are unnecessary, throw errors when building or "I did not want to confuse Lua modders with too many bindings" (I was lazy to uncomment them). If need be, those can (hopefully) be uncommented easily.
  • Additional images:
    image
    image
    image
    image

@github-actions github-actions bot added the src changes related to source code. label Dec 27, 2023
Copy link
Contributor

autofix-ci bot commented Dec 28, 2023

The Autofix app has found code style violation and automatically formatted this Pull Request.

I locally edit my commits (e.g: git, github desktop)

Please choose following options:

I'd like to accept the automated commit
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

This PR is complete and I don't want to edit it anymore

It's safe to ignore this message.

I edit this PR through web UI

You can ignore this message and continue working.

I have no idea what this message is talking about

You can ignore this message and continue working. If you find any problem, please ask for help and ping @scarf005.

@github-actions github-actions bot added the tests changes related to tests label Dec 28, 2023
@AluminumAlman AluminumAlman marked this pull request as ready for review December 28, 2023 13:35
@olanti-p olanti-p changed the title feat(lua): Additional (mostly creature class-family) lua bindings feat: Additional (mostly creature class-family) Lua bindings Jan 1, 2024
tests/lua/global_functions_test.lua Outdated Show resolved Hide resolved
src/catalua_bindings_creature.cpp Outdated Show resolved Hide resolved
src/catalua_bindings_creature.cpp Outdated Show resolved Hide resolved
src/catalua_bindings_creature.cpp Outdated Show resolved Hide resolved
src/catalua_bindings_creature.cpp Outdated Show resolved Hide resolved
src/catalua_bindings.cpp Outdated Show resolved Hide resolved
src/catalua_luna_doc.h Outdated Show resolved Hide resolved
@github-actions github-actions bot added the docs PRs releated to docs page label Jan 1, 2024
src/catalua.cpp Show resolved Hide resolved
doc/src/content/docs/en/mod/lua/reference/lua.md Outdated Show resolved Hide resolved
doc/src/content/docs/en/mod/lua/reference/lua.md Outdated Show resolved Hide resolved
@AluminumAlman AluminumAlman changed the title feat: Additional (mostly creature class-family) Lua bindings feat: Additional Lua bindings, documentation, decoupling attitude from creature Jan 1, 2024
@AluminumAlman AluminumAlman changed the title feat: Additional Lua bindings, documentation, decoupling attitude from creature feat: Additional Lua bindings, documentation, attitude decoupled from creature Jan 1, 2024
@github-actions github-actions bot added JSON related to game datas in JSON format. mods PR changes related to mods. labels Jan 1, 2024
@scarf005 scarf005 changed the title feat: Additional Lua bindings, documentation, attitude decoupled from creature feat!: Additional Lua bindings, documentation, attitude decoupled from creature Jan 5, 2024
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feat!: Additional Lua bindings, documentation, attitude decoupled from creature

Would it be possible to list commits or changes for attitude decoupled from creature? As this is a huge change image, Splitting this PR into two step would make it easier to review, e.g)

  1. refactor: decouple attitude from creature
  2. feat!: additional lua bindings
    huge

@AluminumAlman
Copy link
Contributor Author

Splitting this PR into two per request of scarf005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs releated to docs page JSON related to game datas in JSON format. mods PR changes related to mods. src changes related to source code. tests changes related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants