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

fix: remove cash property from player class to use cash from Character for Lua #5751

Merged
merged 3 commits into from
Nov 23, 2024

Conversation

AluminumAlman
Copy link
Contributor

@AluminumAlman AluminumAlman commented Nov 22, 2024

Required

Purpose of change

Lua currently only binds the cash property of Character, not player, therefore Lua cannot access the actual cash value of NPCs and avatar. Removing the duplicate cash from player will make C++ use Character's cash and for the Lua to work.

Describe alternatives you've considered

  • None.

Testing

  1. Testing whether existing characters retain their cash:
    1. Made a new character with a version of the game prior to this change;
    2. Placed an ATM terrain and spawned a cash card item;
    3. Deposited some cash into the ATM;
    4. Saved and exited the game;
    5. Loaded the character in a version with the changes;
    6. Checked the ATM;
    7. The cash amount displayed by the ATM didn't change.
  2. Testing whether LUA can change the cash amount now:
    1. Loaded a character;
    2. Placed an ATM terrain;
    3. Checked the current cash amount through the ATM;
    4. Opened the Lua console;
    5. Changed the cash amount through Lua to be different, e.g. gapi.get_avatar().cash = 50;
    6. Checked the current cash amount through the ATM and found it to be the new value.

Additional context

@github-actions github-actions bot added the src changes related to source code. label Nov 22, 2024
@AluminumAlman AluminumAlman changed the title fix(lua): remove cash property from player class to use cash from Character fix: remove cash property from player class to use cash from Character Nov 22, 2024
@AluminumAlman AluminumAlman changed the title fix: remove cash property from player class to use cash from Character fix: remove cash property from player class to use cash from Character for Lua Nov 22, 2024
Copy link
Contributor

autofix-ci bot commented Nov 22, 2024

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  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.

Copy link
Collaborator

@KheirFerrum KheirFerrum left a comment

Choose a reason for hiding this comment

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

Both described tests produced appropriate results when tested on my machine.

This is pretty long overdue, we really need to spend time pruning Player of Character variables.

@KheirFerrum KheirFerrum merged commit fffed7c into cataclysmbnteam:main Nov 23, 2024
12 checks passed
@AluminumAlman AluminumAlman deleted the RemovePlayerCash branch November 24, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants