mt-mods / pipeworks

Pipeworks is a mod for Minetest allowing the crafting and usage of pipes and tubes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiple tags as string

SwissalpS opened this issue · comments

I'm a bit fuzzy on the discussion going into the tag support. Reading the code at:

item_tags = pipeworks.sanitize_tags({msg.tag})

I would have expected the string to be passed as is to sanitize function so user can send a string with multiple tags.

I probably missed the part of the discussion where this was voted against for whatever reason. Just checking here.

It wasn't really discussed, but since it's msg.tag (singular), then it makes sense to only accept one tag. However, by that logic you should be able to send a string with multiple tags using msg.tags.

I would actually drop the singular msg.tag. Now a user can set a singular tag containing commas but when meta is read, they will multiple tags.
This isn't going to crash anything, it can only lead to unexpected behaviour.
Passing "tag1,tag2, tag3, tag4" as msg.tagcould lead to tag3 and tag4 having leading space and not matching.

Each tag gets commas and whitespace removed here:

tag = tag:gsub("[%s,]", "") -- Remove whitespace and commas

So passing "tag1,tag2, tag3, tag4" as msg.tag will result in one tag "tag1tag2tag3tag4", and passing it as msg.tags will result it each tag being separated.

unexpected behaviour

Just need to update the documentation :)