Page 1 of 1

Ideas regarding item metadata, and knockback

PostPosted: Mon Nov 23, 2015 11:50
by orwell
The item metadata string is useful for some mods, but it is not used by the engine itself.
There should be a way to override some properties of the item definition with item metadata.

For example, the item name should be changeable, to allow for named swords used in story maps or such things, same goes for damage groups of tools.
Edit: I forgot item enchantments! (or similar stuff)

To do this, it is necessary to transform the metadata string into a table. For the save format, nothing has to be changed, since that table can be serialized. It is some work to keep compatibility to the string metadata, but it should be possible.

Another suggestion: add another special damage/armor group to provide knockback functionality. Knockback in damage group tells how far entities are knocked back, armor group is knockback resistance. This would provide smoother knockback effects on client, since this can be implemented client-side.
(entities not having knockback armor group just don't get knocked back)

Re: Ideas regarding item metadata, and knockback

PostPosted: Mon Nov 23, 2015 12:29
by everamzah
Having to remove a book from a chest and then wield and use it in order to read its contents is a surprisingly large amount of work. It'd be nice to hover over the item and read its contents in a tooltip.

Re: Ideas regarding item metadata, and knockback

PostPosted: Mon Nov 23, 2015 13:26
by yyt16384
So we already have item metadata support? I think I missed it when reading lua_api.txt last time.

It's a great feature. I can start to write a nice mod with this. :)

Re: Ideas regarding item metadata, and knockback

PostPosted: Mon Nov 23, 2015 14:45
by orwell
yyt16384 wrote:So we already have item metadata support? I think I missed it when reading lua_api.txt last time.

It's a great feature. I can start to write a nice mod with this. :)

Yes we have, but remember, ATM it has to be a string.

Re: Ideas regarding item metadata, and knockback

PostPosted: Mon Nov 23, 2015 15:14
by rubenwardy
Meta data for stacks guide:

http://rubenwardy.com/minetest_modding_ ... l#metadata

Strings are a list of bytes, so you could represent anything in them. Doesn't mean it's always a good idea. Use Minetest.serialize to turn tables into strings.

Also, there is an old pr which adds node def based on node metadata.

Re: Ideas regarding item metadata, and knockback

PostPosted: Sat Jan 02, 2016 15:39
by BrunoMine
I wish there was the knockback function.
Is there a mod that allows this?

Re: Ideas regarding item metadata, and knockback

PostPosted: Sat Jan 02, 2016 15:58
by orwell
Tenplus1's mobs redo has this, but it's server side and therefore laggy.

Re: Ideas regarding item metadata, and knockback

PostPosted: Sat Jan 02, 2016 16:01
by orwell
rubenwardy wrote:Strings are a list of bytes, so you could represent anything in them. Doesn't mean it's always a good idea. Use Minetest.serialize to turn tables into strings.

Yes, that was my idea for saving the metadata. But in order for the engine to actually do something with it, it has to be deserialized into a table.

Wait, are item stack metadata transferred to the client yet?

Re: Ideas regarding item metadata, and knockback

PostPosted: Sat Jan 02, 2016 16:06
by rubenwardy
Yes, I think they are.

Re: Ideas regarding item metadata, and knockback

PostPosted: Sun Jan 03, 2016 03:48
by kaeza
There's more discussion about itemstack metadata on issue #3449 for those interested.