minetest_docs icon indicating copy to clipboard operation
minetest_docs copied to clipboard

Document ItemStack returning functions

Open appgurueu opened this issue 3 years ago • 1 comments

on_use etc. Include a note that prevents people from making the common mistake of trying to modify the inventory before/instead of returning the itemstack they want to be set.

appgurueu avatar Jan 04 '22 21:01 appgurueu

The confusion here is likely to stem from the fact that ItemStack is a mutable reference type, yet all functions & callbacks using ItemStacks pass them "by value", copying them (constrast this with e.g. vectors which are mutable but only provide methods that return copies, thus making it apparent that you have to feed the vector back in using some setter). I wonder whether such a note would suit the ItemStack doc well?

appgurueu avatar Sep 14 '22 12:09 appgurueu