-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Inconsistent data types in Itemstack #4947
Comments
This is intended (see http:https://dev.minetest.net/ItemStack). You could also use a string as an itemstack. |
Perhaps we should avoid a crash for this situation? |
I am not sure how that would be possible, calling a method on a string or a table will obviously cause a crash. I think the documentation is fairly clear about this and the reason why |
If the parameter is called itemstack then it should always give an object that conforms to ItemStack. It's misleading otherwise |
Yeah, I have misread the issue, |
bump |
The
awards
mod has aregister_on_craft
which receives anitemstack
object. In general, it appears thattype(itemstack)=="userdata"
, however, in some cases it looks liketype(itemstack)=="table"
. Specifically, if I make a mese pickaxe and add a couple of cavorite handles, as long as the mese pickaxe has never been used, thentype(itemstack)=="userdata"
and when the awards mod callsitemstack:get_name()
, everything is fine. But if the mese pickaxe has been used, thentype(itemstack)=="table"
and trying to callitemstack:get_name()
crashes the server.I can work around this by detecting when
type(itemstack)=="table"
and then calllingitemstack["name"]
to get the name instead ofitemstack:get_name()
, but I feel like this isn't optimalThe text was updated successfully, but these errors were encountered: