1
0
mirror of git://repo.or.cz/minetest_schemedit.git synced 2024-11-10 18:30:16 +01:00

Add force place checkbox

This commit is contained in:
Wuzzy 2017-09-02 04:06:17 +02:00
parent 5ea250646b
commit 236cc1cf34

View File

@ -173,9 +173,11 @@ local function set_item_metadata(itemstack, prob, force_place)
"Not Set") "Not Set")
end end
-- Update force place if value is not nil -- Update force place
if force_place then if force_place == true then
smeta:set_string("advschem_force_place", "true") smeta:set_string("advschem_force_place", "true")
elseif force_place == false then
smeta:set_string("advschem_force_place", nil)
end end
-- Update description -- Update description
@ -194,7 +196,7 @@ local function set_item_metadata(itemstack, prob, force_place)
local force_desc = "" local force_desc = ""
if smeta:get_string("advschem_force_place") == "true" then if smeta:get_string("advschem_force_place") == "true" then
force_desc = "\n".."Force Place" force_desc = "\n".."Force placement"
end end
desc = desc..minetest.colorize("#D79E9E", prob_desc..force_desc) desc = desc..minetest.colorize("#D79E9E", prob_desc..force_desc)
@ -379,7 +381,7 @@ advschem.add_form("prob", {
(smeta.advschem_prob or "127").."]" .. (smeta.advschem_prob or "127").."]" ..
[[ [[
field_close_on_enter[probability;false] field_close_on_enter[probability;false]
checkbox[3.1,0.1;force_place;Force Place;]]..(smeta.advschem_force_place or "false")..[[] checkbox[3.1,0.1;force_place;Force placement;]]..(smeta.advschem_force_place or "false")..[[]
button[5,0.1;1.5,1;rst;Reset] button[5,0.1;1.5,1;rst;Reset]
button[6.5,0.1;1.5,1;save;Save] button[6.5,0.1;1.5,1;save;Save]
]] ]]
@ -583,10 +585,12 @@ advschem.add_form("probtool", {
end end
local form = "size[5,4]".. local form = "size[5,4]"..
"label[0,0;Schematic Node Probability Tool]".. "label[0,0;Schematic Node Probability Tool]"..
"field[0.75,1;4,1;prob;Probability;"..prob.."]".. "field[0.75,1;4,1;prob;Probability (0-127);"..prob.."]"..
"checkbox[0.60,1.5;force_place;Force placement;" .. force_place .. "]" ..
"button_exit[0.25,3;2,1;cancel;Cancel]".. "button_exit[0.25,3;2,1;cancel;Cancel]"..
"button_exit[2.75,3;2,1;submit;Okay]".. "button_exit[2.75,3;2,1;submit;Apply]"..
"tooltip[submit;Use the new probability value for this tool]".. "tooltip[prob;Probability that the node will be placed]"..
"tooltip[force_place;If enabled, the node will replace nodes other than air and ignore]"..
"field_close_on_enter[prob;false]" "field_close_on_enter[prob;false]"
return form return form
end, end,
@ -603,13 +607,18 @@ advschem.add_form("probtool", {
return return
end end
set_item_metadata(probtool, prob, false) local force_place = self.force_place == true
set_item_metadata(probtool, prob, force_place)
player:set_wielded_item(probtool) player:set_wielded_item(probtool)
-- TODO: Force place
end end
end end
if fields.force_place == "true" then
self.force_place = true
elseif fields.force_place == "false" then
self.force_place = false
end
end, end,
}) })