forked from minetest-mods/technic
Constructor now digs node drops instead of actual nodes.
This commit is contained in:
parent
60c9d97101
commit
a1da74209b
|
@ -273,26 +273,56 @@ minetest.register_node("technic:constructor_mk3_on", {
|
||||||
|
|
||||||
|
|
||||||
deploy_node =function (inv, slot_name, pos1, node1, node)
|
deploy_node =function (inv, slot_name, pos1, node1, node)
|
||||||
if node1.name == "air" then
|
if node1.name == "air" then
|
||||||
if not inv:is_empty(slot_name) then
|
if not inv:is_empty(slot_name) then
|
||||||
stack1=inv:get_list(slot_name)
|
stack1=inv:get_list(slot_name)
|
||||||
node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
|
local def = stack1[1]:get_definition()
|
||||||
minetest.env:set_node(pos1,node_to_be_placed)
|
if def.type == "node" then
|
||||||
stack1[1]:take_item()
|
node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
|
||||||
inv:set_stack(slot_name, 1, stack1[1])
|
minetest.env:set_node(pos1,node_to_be_placed)
|
||||||
return
|
stack1[1]:take_item()
|
||||||
|
inv:set_stack(slot_name, 1, stack1[1])
|
||||||
|
elseif def.type == "craft" then
|
||||||
|
minetest.item_place_object(stack1[1], nil, {
|
||||||
|
-- Fake pointed_thing
|
||||||
|
type = "node",
|
||||||
|
above = pos1,
|
||||||
|
under = pos1,
|
||||||
|
})
|
||||||
|
inv:set_stack(slot_name, 1, nil)
|
||||||
end
|
end
|
||||||
return
|
|
||||||
end
|
end
|
||||||
if node1.name == "ignore" or
|
return
|
||||||
node1.name == "default:lava_source" or
|
end
|
||||||
node1.name == "default:lava_flowing" or
|
if node1.name == "ignore" or
|
||||||
node1.name == "default:water_source" or
|
node1.name == "default:lava_source" or
|
||||||
node1.name == "default:water_flowing"
|
node1.name == "default:lava_flowing" or
|
||||||
then return end
|
node1.name == "default:water_source" or
|
||||||
if inv:room_for_item(slot_name,node1) then
|
node1.name == "default:water_flowing"
|
||||||
inv:add_item(slot_name,node1)
|
then return end
|
||||||
|
if inv:room_for_item(slot_name,node1) then
|
||||||
|
local def = minetest.registered_nodes[node1.name]
|
||||||
|
if not def then return end
|
||||||
|
local drop = def.drop or node1.name
|
||||||
|
if type(drop) == "table" then
|
||||||
|
local pr = PseudoRandom(math.random())
|
||||||
|
local c = 0
|
||||||
|
local loop = 0 -- Prevent infinite loop
|
||||||
|
while (c < (drop.max_items or 1)) and (loop < 1000) do
|
||||||
|
local i = math.floor(pr:next(1, #drop.items))
|
||||||
|
if pr:next(1, drop.items[i].rarity or 1) == 1 then
|
||||||
|
for _,item in ipairs(drop.items[i].items) do
|
||||||
|
inv:add_item(slot_name,item)
|
||||||
|
end
|
||||||
|
c = c + 1
|
||||||
|
end
|
||||||
|
loop = loop + 1
|
||||||
|
end
|
||||||
|
minetest.env:remove_node(pos1)
|
||||||
|
elseif type(drop) == "string" then
|
||||||
|
inv:add_item(slot_name,drop)
|
||||||
minetest.env:remove_node(pos1)
|
minetest.env:remove_node(pos1)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user