forked from mtcontrib/unifieddyes
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
30
init.lua
30
init.lua
@ -1045,20 +1045,28 @@ minetest.register_craft( {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
print(dump(fields))
|
||||||
if formname == "unifieddyes:dye_select_form" then
|
if formname == "unifieddyes:dye_select_form" then
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local s1 = string.sub(minetest.serialize(fields), 11)
|
if fields.quit then
|
||||||
local s3 = string.sub(s1,1, string.find(s1, '"')-1)
|
if not fields.accept then
|
||||||
if s3 == "cancel" then
|
unifieddyes.player_selected_dye[player_name] = nil
|
||||||
unifieddyes.player_selected_dye[player_name] = nil
|
return
|
||||||
return
|
else
|
||||||
elseif s3 == "accept" and unifieddyes.player_selected_dye[player_name] then
|
local dye = unifieddyes.player_selected_dye[player_name]
|
||||||
local dye = unifieddyes.player_selected_dye[player_name]
|
if not dye then
|
||||||
unifieddyes.player_current_dye[player_name] = dye
|
minetest.chat_send_player(player_name, "*** Clicked \"Accept\", but no color was selected!")
|
||||||
unifieddyes.player_selected_dye[player_name] = nil
|
return
|
||||||
minetest.chat_send_player(player_name, "*** Selected "..string.sub(dye, 5).." for the airbrush.")
|
end
|
||||||
return
|
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
|
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 inv = player:get_inventory()
|
||||||
local creative = creative and creative.is_enabled_for(player_name)
|
local creative = creative and creative.is_enabled_for(player_name)
|
||||||
local dye = "dye:"..s3
|
local dye = "dye:"..s3
|
||||||
|
Loading…
Reference in New Issue
Block a user