From 440d966b939059dfa51604eb68d61eecb12baeb4 Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Sun, 9 Oct 2022 05:06:09 -0700 Subject: add an 'equals' method to ItemStack and compatibility w/ lua '==' (#12771) Co-authored-by: rubenwardy Co-authored-by: sfan5 --- doc/lua_api.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'doc') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 202f66262..46b4ed642 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -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` ------------------ -- cgit v1.2.3