Airbrush: Fix dye selection by not relying on internal behaviour of minetest.serialize (#10)

This commit is contained in:
Thomas--S 2022-09-11 11:49:23 +02:00 committed by GitHub
parent 878377301f
commit 96a939c069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -455,14 +455,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return
end
else
local s1 = string.sub(minetest.serialize(fields), 11)
local s3 = string.sub(s1,1, string.find(s1, '"')-1)
local color, _ = next(fields)
local inv = player:get_inventory()
local creative = minetest.is_creative_enabled(player_name)
local dye = "dye:"..s3
local dye = "dye:"..color
if (showall or unifieddyes.palette_has_color[nodepalette.."_"..s3]) and
if (showall or unifieddyes.palette_has_color[nodepalette.."_"..color]) and
(creative or inv:contains_item("main", dye)) then
unifieddyes.player_selected_dye[player_name] = dye
unifieddyes.show_airbrush_form(player)