mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2024-11-22 15:33:52 +01:00
better handling of exiting the color selector form
also prints a warning if the user clicked "Accept" without a color selected
This commit is contained in:
parent
057baacf2d
commit
62806f795e
16
init.lua
16
init.lua
@ -1045,20 +1045,28 @@ minetest.register_craft( {
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
print(dump(fields))
|
||||
if formname == "unifieddyes:dye_select_form" then
|
||||
local player_name = player:get_player_name()
|
||||
local s1 = string.sub(minetest.serialize(fields), 11)
|
||||
local s3 = string.sub(s1,1, string.find(s1, '"')-1)
|
||||
if s3 == "cancel" then
|
||||
if fields.quit then
|
||||
if not fields.accept then
|
||||
unifieddyes.player_selected_dye[player_name] = nil
|
||||
return
|
||||
elseif s3 == "accept" and unifieddyes.player_selected_dye[player_name] then
|
||||
else
|
||||
local dye = unifieddyes.player_selected_dye[player_name]
|
||||
if not dye then
|
||||
minetest.chat_send_player(player_name, "*** Clicked \"Accept\", but no color was selected!")
|
||||
return
|
||||
end
|
||||
unifieddyes.player_current_dye[player_name] = dye
|
||||
unifieddyes.player_selected_dye[player_name] = nil
|
||||
minetest.chat_send_player(player_name, "*** Selected "..string.sub(dye, 5).." for the airbrush.")
|
||||
return
|
||||
end
|
||||
else
|
||||
local s1 = string.sub(minetest.serialize(fields), 11)
|
||||
local s3 = string.sub(s1,1, string.find(s1, '"')-1)
|
||||
|
||||
local inv = player:get_inventory()
|
||||
local creative = creative and creative.is_enabled_for(player_name)
|
||||
local dye = "dye:"..s3
|
||||
|
Loading…
Reference in New Issue
Block a user