minetest_game icon indicating copy to clipboard operation
minetest_game copied to clipboard

give_initial_stuff: cannot add items with metadata containing commas via the setting

Open fluxionary opened this issue 3 years ago • 2 comments

e.g. an item w/ an itemstring like

waypoint_compass:compass 1 0 "\u0001color\u0002#FFFFFF\u0003description\u0002Waypoint compass to \"Public Farm\"\u0003waypoint_compass:label\u0002Public Farm\u0003waypoint_compass:position\u0002(2035,14,1303)\u0003waypoint_compass:color\u000216777215\u0003waypoint_compass:owner\u0002flux\u0003"

this is because item delimiting is done by simply splitting the value of the initial_stuff setting on commas.

there is an API which can be used as a work-around, but having an option that doesn't require coding would be preferable.

one solution would be to escape the commas somehow. another would be to add another setting to configure the delimiter (e.g. being able to set it to a newline would be useful).

fluxionary avatar Nov 11 '22 21:11 fluxionary

Sounds more like a missing feature than a bug. Recommendation: Update documentation instead, that metadata is not allowed.

Wuzzy2 avatar Jan 30 '23 17:01 Wuzzy2

Ugh, this is ugly. I agree that this can be seen as a missing feature. The underlying issue is that the Settings file format is too primitive (basically only a string k/v) to properly represent lists, so the wheel has to be reinvented each time and we're left with a variety of different delimiters across mods. The proper solution would be conf files allowing a proper object notation (might be something like YAML if it's supposed to be user friendly).

there is an API which can be used as a work-around, but having an option that doesn't require coding would be preferable.

I think using the API ("codefiguration") is the cleaner solution here actually. The configuration line in your example is hardly human-readable and -editable (it was probably generated using code), which is the whole point of configuration (which strives to be even more accessible than code). Proper "codefiguration" would be more readable here and wouldn't have to rely on the engine-interal, undocumented ItemString metadata encoding format; you could just use the ItemStack class to construct your initial items there.

appgurueu avatar Jan 30 '23 18:01 appgurueu