Open Montandalar opened 2 years ago
I think I've just followed documentation here:
An
ItemStack
is a stack of items.It can be created via
ItemStack(x)
, where x is anItemStack
, an itemstring, a table ornil
.
Empty string however is valid with actual engine, for some reason I did leave explicit note "do not fix" there but I do not really anymore remember reasoning for that. Not too long ago I was going to change that to allow empty string but in the end for some reason did not change it...
Reasoning could have been strict rules: "be explicit" which would mean that empty stack should be created with
stack = ItemStack(nil)
instead of
stack = ItemStack("")
Now I'm pretty sure this is a bug in Mineunit and now again I'm leaning towards fixing it, would be nice to remember exact reason why I originally decided to do that...
Also now that I tested engine behavior:
ItemStack()
ItemStack(nil)
ItemStack("")
ItemStack()
ItemStack(nil)
ItemStack("")
So even if it was for "strict" rules it would still be bad option as ItemStack()
is allowed and crashes older engine while ItemStack("")
succeeds with old engine.
For your test you can simply use ItemStack()
instead of ItemStack("")
, I'll leave this issue hanging here for a moment attempting to recall why I've stated "do not fix" for apparent bug.
That explicit "do not fix" note tells me that there might be some actual reason behind it, when I wrote note I already knew that I'm going to spot bug some day there so there has to be some reason why I wrote that note...
So far I've not found any real reason for what I've written there... this should be fixed, preferably with behavior depending on engine version and warnings for usage that is not universally compatible: call without args throws warning or error.
Hi,
So I am implementing a privileged-protected recipe system using
register_craft_predict
andregister_on_craft
. In these callbacks you get a table with 9 ItemStacks, and in my test for the empty slots in the grid I thought I would insertItemStack("")
, but the source of Mineunit says it's meant to cause an error with an empty string. I don't think my function will work without "" as the argument though. Do you know how I should proceed?Code is here: