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

A new way to manage player storages #3956

Merged
merged 2 commits into from
Feb 19, 2022
Merged

A new way to manage player storages #3956

merged 2 commits into from
Feb 19, 2022

Conversation

MillhioreBT
Copy link
Contributor

@MillhioreBT MillhioreBT commented Feb 18, 2022

Pull Request Prelude

  • I have followed [proper The Forgotten Server code styling][code].
  • I have read and understood the [contribution guidelines][cont] before making this PR.
  • I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.

Changes Proposed

With this change we add a new way to handle player storages via the __index metamethod of the Player metatable
Here a example:

player.storage[1250] = 100
print(player.storage[1250]) -- output: 100
player.storage[1250] = -1
print(player.storage[1250]) -- output: -1

print(player.storage[1251]) -- output: -1

Account storage:

player.accountStorage[1250] = 100
print(player.accountStorage[1250]) -- output: 100
player.accountStorage[1250] = -1
print(player.accountStorage[1250]) -- output: -1

print(player.accountStorage[1251]) -- output: -1

Issues addressed: Nothing!

@EPuncker EPuncker added the feature New feature or functionality label Feb 18, 2022
@ranisalt
Copy link
Member

I don't like the syntax because it looks like you are indexing a player. player[1250] reads like the 1250th element of a player.

However, you can add a proxy table to index with player.storage[1250] and that would be neat 👌

@MillhioreBT
Copy link
Contributor Author

I don't like the syntax because it looks like you are indexing a player. player[1250] reads like the 1250th element of a player.

However, you can add a proxy table to index with player.storage[1250] and that would be neat 👌

I really like the idea, since we can also add an index to the account's storages player.accountStorage[1250]

Copy link
Member

@nekiro nekiro left a comment

Choose a reason for hiding this comment

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

proxy? 🤔

@DSpeichert DSpeichert merged commit 50f1b46 into otland:master Feb 19, 2022
@MillhioreBT MillhioreBT deleted the storage_with___newindex branch February 22, 2022 18:57
Codinablack pushed a commit to Codinablack/forgottenserver that referenced this pull request Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants