2016-11-05 07:17:08 +01:00
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
local modpath = minetest.get_modpath(modname)
|
|
|
|
|
|
|
|
local config = Settings(modpath .. "/settings.txt")
|
2016-09-04 17:09:25 +02:00
|
|
|
|
|
|
|
local carpet_proto = {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}
|
2016-11-05 07:17:08 +01:00
|
|
|
}
|
2016-09-04 17:09:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if config:get_bool("WoolFeeling") then
|
2016-11-05 07:17:08 +01:00
|
|
|
carpet_proto.sounds = default.node_sound_defaults()
|
|
|
|
carpet_proto.groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, flammable = 3}
|
2016-09-04 17:09:25 +02:00
|
|
|
end
|
|
|
|
|
2016-11-05 01:48:07 +01:00
|
|
|
function carpets.register(recipe, def)
|
2016-09-04 17:09:25 +02:00
|
|
|
|
2017-01-11 20:13:36 +01:00
|
|
|
local node = table.copy(def or {})
|
2016-09-04 17:09:25 +02:00
|
|
|
|
|
|
|
for k, v in pairs(carpet_proto) do
|
|
|
|
node[k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
local recipe_def = minetest.registered_nodes[recipe]
|
|
|
|
|
2017-01-11 20:13:36 +01:00
|
|
|
node.description = node.description or recipe_def.description.." Carpet"
|
|
|
|
node.tiles = table.copy(node.tiles or recipe_def.tiles or {})
|
|
|
|
node.sounds = table.copy(node.sounds or recipe_def.sounds or {})
|
|
|
|
node.groups = table.copy(node.groups or recipe_def.groups or {})
|
2016-11-05 07:17:08 +01:00
|
|
|
|
2016-12-16 13:27:57 +01:00
|
|
|
if node.tiles[6] then
|
2016-09-04 18:32:27 +02:00
|
|
|
node.tiles = {node.tiles[6]}
|
|
|
|
end
|
2017-01-11 20:13:36 +01:00
|
|
|
node.groups.leafdecay = nil
|
2017-02-24 00:54:13 +01:00
|
|
|
node.material = recipe
|
|
|
|
node.formation = "carpet"
|
2016-09-04 17:09:25 +02:00
|
|
|
|
|
|
|
if config:get_bool("FallingCarpet") and node.groups.falling_node == nil then
|
|
|
|
node.groups.falling_node = 1
|
|
|
|
elseif node.groups.falling_node == 1 then
|
|
|
|
node.groups.falling_node = 0
|
|
|
|
end
|
|
|
|
|
2016-11-05 07:17:08 +01:00
|
|
|
local name = "carpet:" .. (node.name or recipe:gsub(":", "_"))
|
2016-09-04 17:09:25 +02:00
|
|
|
node.name = nil
|
|
|
|
|
|
|
|
if config:get_bool("NoFlyCarpet") then
|
|
|
|
local previous_on_place = node.on_place or minetest.item_place
|
|
|
|
node.on_place = function(itemstack, placer, pointed_thing, ...)
|
2016-11-05 07:17:08 +01:00
|
|
|
if not pointed_thing then
|
|
|
|
return
|
|
|
|
end
|
2016-09-04 17:09:25 +02:00
|
|
|
|
|
|
|
local above = pointed_thing.above
|
|
|
|
local under = pointed_thing.under
|
|
|
|
local under_node = minetest.get_node(under)
|
|
|
|
|
2016-11-05 07:17:08 +01:00
|
|
|
if above.y == (under.y + 1) and under_node.name == name then
|
2016-09-04 17:09:25 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
return previous_on_place(itemstack, placer, pointed_thing, ...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-05 07:17:08 +01:00
|
|
|
minetest.register_node(":" .. name, node)
|
2016-09-04 17:09:25 +02:00
|
|
|
|
|
|
|
minetest.register_craft({
|
2016-11-05 07:17:08 +01:00
|
|
|
output = name .. " 32",
|
|
|
|
recipe = {
|
|
|
|
{"group:wool", "group:wool", "group:wool"},
|
|
|
|
{"group:wool", recipe, "group:wool"}
|
|
|
|
}
|
2016-09-04 17:09:25 +02:00
|
|
|
})
|
|
|
|
end
|