mirror of
git://repo.or.cz/minetest_schemedit.git
synced 2024-11-10 18:30:16 +01:00
Add schematic void for ignored nodes
This commit is contained in:
parent
425274ae38
commit
d7c8bedfa1
81
init.lua
81
init.lua
|
@ -298,7 +298,7 @@ advschem.add_form("prob", {
|
||||||
]]
|
]]
|
||||||
else
|
else
|
||||||
form = form .. [[
|
form = form .. [[
|
||||||
label[1,0.2;Insert item in slot.]
|
label[1,0.2;Insert node in slot.]
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -668,33 +668,40 @@ minetest.register_on_shutdown(advschem.save)
|
||||||
minetest.register_on_placenode(function(pos, newnode, player, oldnode, itemstack)
|
minetest.register_on_placenode(function(pos, newnode, player, oldnode, itemstack)
|
||||||
local smeta = itemstack:get_meta():to_table().fields
|
local smeta = itemstack:get_meta():to_table().fields
|
||||||
|
|
||||||
|
local prob
|
||||||
if smeta.advschem_prob and tonumber(smeta.advschem_prob) then
|
if smeta.advschem_prob and tonumber(smeta.advschem_prob) then
|
||||||
local px, py, pz = pos.x, pos.y, pos.z
|
prob = tonumber(smeta.advschem_prob)
|
||||||
for strpos, r in pairs(marked) do
|
elseif newnode.name == "advschem:void" then
|
||||||
local ap1, ap2 = r.pos1, r.pos2
|
prob = 0
|
||||||
if (px >= ap1.x and px <= ap2.x) and
|
else
|
||||||
(py >= ap1.y and py <= ap2.y) and
|
return
|
||||||
(pz >= ap1.z and pz <= ap2.z) then
|
end
|
||||||
local realpos = minetest.string_to_pos(strpos)
|
|
||||||
local node = minetest.get_node_or_nil(realpos)
|
|
||||||
|
|
||||||
if node and node.name == "advschem:creator" then
|
local px, py, pz = pos.x, pos.y, pos.z
|
||||||
local meta = minetest.get_meta(realpos)
|
for strpos, r in pairs(marked) do
|
||||||
local prob_list = minetest.deserialize(meta:get_string("prob_list"))
|
local ap1, ap2 = r.pos1, r.pos2
|
||||||
|
if (px >= ap1.x and px <= ap2.x) and
|
||||||
|
(py >= ap1.y and py <= ap2.y) and
|
||||||
|
(pz >= ap1.z and pz <= ap2.z) then
|
||||||
|
local realpos = minetest.string_to_pos(strpos)
|
||||||
|
local node = minetest.get_node_or_nil(realpos)
|
||||||
|
|
||||||
local force_place = false
|
if node and node.name == "advschem:creator" then
|
||||||
if smeta.advschem_force_place == "true" then
|
local meta = minetest.get_meta(realpos)
|
||||||
force_place = true
|
local prob_list = minetest.deserialize(meta:get_string("prob_list"))
|
||||||
end
|
|
||||||
|
|
||||||
local ostrpos = minetest.pos_to_string(pos)
|
local force_place = false
|
||||||
prob_list[ostrpos] = {
|
if newnode.name ~= "advschem:void" and smeta.advschem_force_place == "true" then
|
||||||
pos = pos,
|
force_place = true
|
||||||
prob = tonumber(smeta.advschem_prob),
|
|
||||||
force_place = force_place,
|
|
||||||
}
|
|
||||||
meta:set_string("prob_list", minetest.serialize(prob_list))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ostrpos = minetest.pos_to_string(pos)
|
||||||
|
prob_list[ostrpos] = {
|
||||||
|
pos = pos,
|
||||||
|
prob = prob,
|
||||||
|
force_place = force_place,
|
||||||
|
}
|
||||||
|
meta:set_string("prob_list", minetest.serialize(prob_list))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -802,6 +809,17 @@ minetest.register_node("advschem:creator", {
|
||||||
advschem.show_formspec(pos, player, "prob", true)
|
advschem.show_formspec(pos, player, "prob", true)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
if listname == "probability" then
|
||||||
|
local itemstring = stack:get_name()
|
||||||
|
if itemstring == "advschem:void" then
|
||||||
|
return 0
|
||||||
|
elseif minetest.registered_items[itemstring].type ~= "node" then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
if listname == "probability" then
|
if listname == "probability" then
|
||||||
advschem.show_formspec(pos, player, "prob", true)
|
advschem.show_formspec(pos, player, "prob", true)
|
||||||
|
@ -809,6 +827,23 @@ minetest.register_node("advschem:creator", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("advschem:void", {
|
||||||
|
description = "Schematic Void",
|
||||||
|
tiles = { "advschem_void.png" },
|
||||||
|
drawtype = "nodebox",
|
||||||
|
is_ground_content = false,
|
||||||
|
paramtype = "light",
|
||||||
|
walkable = false,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{ -4/16, -4/16, -4/16, 4/16, 4/16, 4/16 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = { dig_immediate = 3},
|
||||||
|
})
|
||||||
|
|
||||||
-- [entity] Display
|
-- [entity] Display
|
||||||
minetest.register_entity("advschem:display", {
|
minetest.register_entity("advschem:display", {
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
|
BIN
textures/advschem_void.png
Normal file
BIN
textures/advschem_void.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 B |
Loading…
Reference in New Issue
Block a user