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

Use simplesquirrel library for creating Squirrel API binds #2792

Merged
merged 82 commits into from
Jul 6, 2024

Conversation

Vankata453
Copy link
Member

@Vankata453 Vankata453 commented Feb 20, 2024

Incorporates a SuperTux fork of the simplesquirrel library. Most important feature of this library in the context of SuperTux is the ability to easily expose functions, classes (which can include properties) and other entries to Squirrel in one or a few lines.

Every exposed class, variable and function has been migrated to incorporate this change. As a result, the scripting/ directory, which included all scripting functions, classes and variables, as well as the API wrapper, has been removed, since it is no longer needed for the new binds.

Some scripting functions have been deprecated (currently only via a tag in comment, later to be migrated to docmentation) for several reasons:

  • Some get_ and set_ functions have been deprecated, since a class property has been added and should replace their usage.
  • Functions with the names get_pos_x or get_pos_y have been replaced with get_x and get_y for consistency, thus are now deprecated.

This way of creating Squirrel binds would allow for way more flexibility in exposing functions, classes and properties.

Additionally:

  • Removed the camera() function, as it only printed the camera position, which is already accessible through methods from the Camera itself.
  • Granito and GranitoBig are now scriptable.

Documentation

Doxygen scripting documentation is now generated for the entire codebase as well, since scripting classes might be found anywhere.

The @scripting tag for classes, functions, constants and variables indicates the item should be added to the scripting documentation. Otherwise, it should be ignored.

Added support for the following:

  • Enumerators
  • Member variables
  • Listing of base and derived classes

TODO

  • Expand usage of simplesquirrel functions, instead of ones in SquirrelVM, to reduce code duplication.
  • Update the scripting API documentation/reference generator to incorporate all changes.

Closes #2736.

Incorporates a SuperTux fork of the `simplesquirrel` library. Most important feature of this library in the context of SuperTux is the ability to easily expose functions, classes (which can include properties) and other entries to Squirrel in one or a few lines.

Every exposed class, variable and function has been migrated to incorporate this change. As a result, the `scripting/` directory, which included all scripting functions, classes and variables, as well as the API wrapper, has been removed, since it is no longer needed for the new binds.

Some scripting functions have been deprecated (currently only via a tag in comment, later to be migrated to docmentation) for several reasons:
* Some `get_` and `set_` functions have been deprecated, since a class property has been added and should replace their usage.
* Functions with the names `get_pos_x` or `get_pos_y` have been replaced with `get_x` and `get_y` for consistency, thus are now deprecated.

This way of creating Squirrel binds would allow for way more flexibility in exposing functions, classes and properties.

**TODO:**

* Expand usage of simplesquirrel functions, instead of ones in `SquirrelVM`, to reduce code duplication.
* Update the scripting API documentation/reference generator to incorporate all changes.

Closes SuperTux#2736.
@Vankata453 Vankata453 added status:in-progress Progress has been done, but more is intended be done category:code involves:scripting labels Feb 20, 2024
@tobbi
Copy link
Member

tobbi commented Feb 20, 2024

Supersedes #650

@MatusGuy
Copy link
Member

Update this branch to fix the workflows

@MatusGuy
Copy link
Member

Nvm

src/supertux/game_object.hpp Outdated Show resolved Hide resolved
Copy link
Member

@tobbi tobbi left a comment

Choose a reason for hiding this comment

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

Great job, guys! This has been a tremendous effort! Other than the few discussion points I posted, this is ready to merge!

Copy link
Contributor

@tylerandari13 tylerandari13 left a comment

Choose a reason for hiding this comment

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

Ive been playing around with my scripts on this PR and i happened to notice some issues with errors, namely they dont appear to have any stacktrace attached unlike errors before simplesquirrel. This means that there are no line numbers which makes it particularly annoying to debug my scripts.

Less of an issue and more of a suggestion but can we have functions such as print_stacktrace() print to the ingame console and not just to the terminal if you open it from the terminal on Linux? Also if camera() is being removed because it redundant can we also remove whereami()? Its basically the same as camera() but for Tux instead.

Copy link
Contributor

@tylerandari13 tylerandari13 left a comment

Choose a reason for hiding this comment

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

print_stacktrace() works great, but theres still no stacktrace when i get an error, meaning my initial issue still isnt resolved. I cant debug my scripts without a stacktrace.

Copy link
Contributor

@tylerandari13 tylerandari13 left a comment

Choose a reason for hiding this comment

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

Now this is what the people in the discord would refer to as "peakazoidal". Tested it and it works great.

@MatusGuy MatusGuy mentioned this pull request Jul 6, 2024
@MatusGuy MatusGuy merged commit 19e2884 into SuperTux:master Jul 6, 2024
33 checks passed
@Vankata453 Vankata453 deleted the simplesquirrel branch July 6, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:code involves:scripting status:in-progress Progress has been done, but more is intended be done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revamp the scripting API
5 participants