1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-26 18:21:04 +00:00

add an 'equals' method to ItemStack and compatibility w/ lua '==' (#12771)

Co-authored-by: rubenwardy <rw@rubenwardy.com>
Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
fluxionary 2022-10-09 05:06:09 -07:00 committed by GitHub
parent b2a3f53b29
commit 440d966b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 130 additions and 1 deletions

View file

@ -6811,6 +6811,23 @@ an itemstring, a table or `nil`.
* `peek_item(n)`: returns taken `ItemStack`
* Copy (don't remove) up to `n` items from this stack
* `n`: number, default: `1`
* `equals(other)`:
* returns `true` if this stack is identical to `other`.
* Note: `stack1:to_string() == stack2:to_string()` is not reliable,
as stack metadata can be serialized in arbitrary order.
* Note: if `other` is an itemstring or table representation of an
ItemStack, this will always return false, even if it is
"equivalent".
### Operators
* `stack1 == stack2`:
* Returns whether `stack1` and `stack2` are identical.
* Note: `stack1:to_string() == stack2:to_string()` is not reliable,
as stack metadata can be serialized in arbitrary order.
* Note: if `stack2` is an itemstring or table representation of an
ItemStack, this will always return false, even if it is
"equivalent".
`ItemStackMetaRef`
------------------