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

Squirrel: Fix inaccessible class member variables, improvements #3031

Merged
merged 5 commits into from
Aug 12, 2024

Conversation

Vankata453
Copy link
Member

Fixes a bug in simplesquirrel, which caused exposed class member variables to be inaccessible from Squirrel.

Additionally:

  • Simplesquirrel now supports custom getters and setters for class member variables. Because of this, more get_ and set_ functions of objects now have an alternative variable, which can also be used.
  • All get_ and set_ functions which were made obsolete by member variables are now un-deprecated, because of a noticeable preference amongst scripters to keep both options available for convenience.

Fixes a bug in simplesquirrel, which caused exposed class member variables to be inaccessible from Squirrel.

Additionally, simplesquirrel now supports custom getters and setters for class member variables. Because of this, more `get_` and `set_` functions of objects now have an alternative variable, which can also be used.

All `get_` and `set_` functions which were made obsolete by member variables are now un-deprecated, because of a noticeable preference amongst scripters to keep both options available for convenience.
@Vankata453 Vankata453 added type:feature category:code involves:scripting status:needs-review Work needs to be reviewed by other people type:bugfix Pull Requests that fix bugs. labels Jul 31, 2024
@Vankata453 Vankata453 requested a review from MatusGuy July 31, 2024 19:18
@tylerandari13
Copy link
Contributor

I happen to notice that candle.burning returns 0 and 1, not true and false. However you can pass true and false into it to turn it on and off, but not 0 and 1. Im not sure if any other variables do this yet. Id need to test.

@Vankata453
Copy link
Member Author

Vankata453 commented Jul 31, 2024

display(false): Displays 0.
display(true): Displays 1.

It just does that.
Perhaps because SQTrue and SQFalse behind the hood are just 0 and 1.

@tylerandari13
Copy link
Contributor

ohhhhhhhhhhhhhhhhhhh

wait huh
image

Odd quirk, but at least nothings wrong. You can disregard what I said.

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.

Tested this. It works. This is actually pretty cool.

Copy link
Member

@MatusGuy MatusGuy left a comment

Choose a reason for hiding this comment

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

Code looks fine, but how would I test this PR?

@Vankata453
Copy link
Member Author

Try using some variables that use getters and setters. Make sure variables as a whole work properly.

@Vankata453 Vankata453 merged commit 7aad14c into SuperTux:master Aug 12, 2024
@Vankata453 Vankata453 deleted the squirrel-variable-improvements branch August 12, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:code involves:scripting status:needs-review Work needs to be reviewed by other people type:bugfix Pull Requests that fix bugs. type:feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants