mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2025-06-28 14:26:21 +02:00
Compare commits
4 Commits
2018-08-27
...
2018-08-27
Author | SHA1 | Date | |
---|---|---|---|
d53fb146dd | |||
5b1051f8ae | |||
62806f795e | |||
057baacf2d |
54
init.lua
54
init.lua
@ -829,10 +829,13 @@ end
|
|||||||
function unifieddyes.show_airbrush_form(player)
|
function unifieddyes.show_airbrush_form(player)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
|
local painting_with = unifieddyes.player_selected_dye[player_name] or unifieddyes.player_current_dye[player_name]
|
||||||
local creative = creative and creative.is_enabled_for(player_name)
|
local creative = creative and creative.is_enabled_for(player_name)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
|
||||||
local base_form = "size[15,8.5]label[7,-0.25;Select a color:]"
|
local base_form = "size[15,8.5]label[7,-0.25;Select a color:]"
|
||||||
|
local selindic = "unifieddyes_select_overlay.png^unifieddyes_question.png]"
|
||||||
|
|
||||||
local size="0.75,0.75;"
|
local size="0.75,0.75;"
|
||||||
local hps=0.6
|
local hps=0.6
|
||||||
local vps=1.3
|
local vps=1.3
|
||||||
@ -864,16 +867,20 @@ function unifieddyes.show_airbrush_form(player)
|
|||||||
|
|
||||||
local color = string.format("%02x", r2)..string.format("%02x", g2)..string.format("%02x", b2)
|
local color = string.format("%02x", r2)..string.format("%02x", g2)..string.format("%02x", b2)
|
||||||
local dye = "dye:"..val..hue..sat
|
local dye = "dye:"..val..hue..sat
|
||||||
|
|
||||||
local overlay = ""
|
local overlay = ""
|
||||||
|
local colorize = minetest.formspec_escape("^[colorize:#"..color..":255")
|
||||||
|
|
||||||
if not creative and inv:contains_item("main", dye) then
|
if not creative and inv:contains_item("main", dye) then
|
||||||
overlay = "^unifieddyes_available_overlay.png"
|
overlay = "^unifieddyes_available_overlay.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
if dye == unifieddyes.player_selected_dye[player_name] then
|
if dye == painting_with then
|
||||||
overlay = "^unifieddyes_select_overlay.png"
|
overlay = "^unifieddyes_select_overlay.png"
|
||||||
|
selindic = "unifieddyes_white_square.png"..colorize..overlay.."]"..
|
||||||
|
"tooltip["..val..hue..sat..";"..val..hue..sat.."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local colorize = minetest.formspec_escape("^[colorize:#"..color..":255")
|
|
||||||
base_form = base_form.."image_button["..
|
base_form = base_form.."image_button["..
|
||||||
(hp*hps)..","..(v2*vps+vs)..";"..
|
(hp*hps)..","..(v2*vps+vs)..";"..
|
||||||
size..
|
size..
|
||||||
@ -914,16 +921,18 @@ function unifieddyes.show_airbrush_form(player)
|
|||||||
local dye = "dye:"..val..hue..sat
|
local dye = "dye:"..val..hue..sat
|
||||||
|
|
||||||
local overlay = ""
|
local overlay = ""
|
||||||
|
local colorize = minetest.formspec_escape("^[colorize:#"..color..":255")
|
||||||
|
|
||||||
if not creative and inv:contains_item("main", dye) then
|
if not creative and inv:contains_item("main", dye) then
|
||||||
overlay = "^unifieddyes_available_overlay.png"
|
overlay = "^unifieddyes_available_overlay.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
if dye == unifieddyes.player_selected_dye[player_name] then
|
if dye == painting_with then
|
||||||
overlay = "^unifieddyes_select_overlay.png"
|
overlay = "^unifieddyes_select_overlay.png"
|
||||||
|
selindic = "unifieddyes_white_square.png"..colorize..overlay.."]"..
|
||||||
|
"tooltip["..val..hue..sat..";"..val..hue..sat.."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local colorize = minetest.formspec_escape("^[colorize:#"..color..":255")
|
|
||||||
|
|
||||||
base_form = base_form.."image_button["..
|
base_form = base_form.."image_button["..
|
||||||
(hp*hps)..","..(v2*vps+vs)..";"..
|
(hp*hps)..","..(v2*vps+vs)..";"..
|
||||||
size..
|
size..
|
||||||
@ -952,15 +961,18 @@ function unifieddyes.show_airbrush_form(player)
|
|||||||
local dye = "dye:"..grey2
|
local dye = "dye:"..grey2
|
||||||
|
|
||||||
local overlay = ""
|
local overlay = ""
|
||||||
|
local colorize = minetest.formspec_escape("^[colorize:#"..grey..":255")
|
||||||
|
|
||||||
if not creative and inv:contains_item("main", dye) then
|
if not creative and inv:contains_item("main", dye) then
|
||||||
overlay = "^unifieddyes_available_overlay.png"
|
overlay = "^unifieddyes_available_overlay.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
if dye == unifieddyes.player_selected_dye[player_name] then
|
if dye == painting_with then
|
||||||
overlay = "^unifieddyes_select_overlay.png"
|
overlay = "^unifieddyes_select_overlay.png"
|
||||||
|
slindic = "unifieddyes_white_square.png"..colorize..overlay.."]"..
|
||||||
|
"tooltip["..grey2..";"..grey2.."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local colorize = minetest.formspec_escape("^[colorize:#"..grey..":255")
|
|
||||||
base_form = base_form.."image_button["..
|
base_form = base_form.."image_button["..
|
||||||
(hp*hps)..","..(v2*vps+vs)..";"..
|
(hp*hps)..","..(v2*vps+vs)..";"..
|
||||||
size..
|
size..
|
||||||
@ -973,20 +985,21 @@ function unifieddyes.show_airbrush_form(player)
|
|||||||
base_form = base_form..
|
base_form = base_form..
|
||||||
"image[10.3,"..(vps*5+vs)..";"..size..
|
"image[10.3,"..(vps*5+vs)..";"..size..
|
||||||
"unifieddyes_available_overlay.png]"..
|
"unifieddyes_available_overlay.png]"..
|
||||||
"label[11.0,"..(vps*5.1+vs)..";Dyes on hand]"..
|
"label[11.0,"..(vps*5.1+vs)..";Dyes on hand]"
|
||||||
"image[12.5,"..(vps*5+vs)..";"..size..
|
|
||||||
"unifieddyes_select_overlay.png]"..
|
|
||||||
"label[13.2,"..(vps*5.1+vs)..";Your selection]"
|
|
||||||
end
|
end
|
||||||
|
base_form = base_form..
|
||||||
|
"image[12.5,"..(vps*5+vs)..";"..size..
|
||||||
|
selindic..
|
||||||
|
"label[13.2,"..(vps*5.1+vs)..";Your selection]"
|
||||||
|
|
||||||
base_form = base_form..
|
base_form = base_form..
|
||||||
"button_exit[11,8;2,1;cancel;Cancel]"..
|
"button_exit[11,8;2,1;cancel;Cancel]"..
|
||||||
"button_exit[13,8;2,1;accept;Accept]"
|
"button_exit[13,8;2,1;accept;Accept]"
|
||||||
|
|
||||||
if unifieddyes.player_selected_dye[player_name] then
|
if painting_with then
|
||||||
base_form = base_form..
|
base_form = base_form..
|
||||||
"label[1,"..(7.5+vs)..";Selected dye: "..
|
"label[1,"..(7.5+vs)..";Selected dye: "..
|
||||||
unifieddyes.player_selected_dye[player_name].."]"
|
painting_with.."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.show_formspec(player_name, "unifieddyes:dye_select_form", base_form)
|
minetest.show_formspec(player_name, "unifieddyes:dye_select_form", base_form)
|
||||||
@ -1036,18 +1049,25 @@ minetest.register_craft( {
|
|||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, 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
|
||||||
elseif s3 == "accept" and unifieddyes.player_selected_dye[player_name] then
|
else
|
||||||
local dye = unifieddyes.player_selected_dye[player_name]
|
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_current_dye[player_name] = dye
|
||||||
unifieddyes.player_selected_dye[player_name] = nil
|
unifieddyes.player_selected_dye[player_name] = nil
|
||||||
minetest.chat_send_player(player_name, "*** Selected "..string.sub(dye, 5).." for the airbrush.")
|
minetest.chat_send_player(player_name, "*** Selected "..string.sub(dye, 5).." for the airbrush.")
|
||||||
return
|
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
|
||||||
|
BIN
textures/unifieddyes_question.png
Normal file
BIN
textures/unifieddyes_question.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 917 B |
Reference in New Issue
Block a user