-- Descended from "carpet" by srifqi -- License: CC0 1.0 Universal -- This mod doesn't use much from the original "carpet" mod other than -- the original carpet registration routine. local reg_alias = ocutil.safe_register_alias minicarpet = {} minicarpet.count = 0 local reg_node = ocutil.safe_register_node --[[ def is a table that contains: name : itemstring "carpet:name" description : node description (optional) images : node tiles recipeitem : node crafting recipeitem {recipeitem,recipeitem} groups : node groups sounds : node sounds (optional) --]] minicarpet.register = function (def) local name = def.name local desc = def.description or "" local recipeitem = def.recipeitem local sounds = def.sounds or default.node_sound_defaults() local nodename = "carpet:" .. name minetest.register_node (":" .. nodename, { description = desc , tiles = def.images , paramtype = "light" , node_box = { type = "fixed" , fixed = { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 } , } , drawtype = "nodebox" , groups = def.groups , sounds = sounds , }) if false then ocutil.log ("minicarpet: registered " .. nodename) end minicarpet.count = minicarpet.count + 1 end local sds_color_list = { "black" , "blue" , "brown" , "cyan" , "dark_green" , "dark_grey" , "green" , "grey" , "magenta" , "orange" , "pink" , "red" , "violet" , "white" , "yellow" , } local mix_decor_list = { { "sunflower" , "minicarpet_sunflower.png" } , } for _, sds_color in ipairs (sds_color_list) do local desc = ocutil.all_first_to_upper (sds_color, true) local sds_node = "sds:" .. sds_color local sds_png = "sds_" .. sds_color .. "_carpet.png" reg_node ("relaxed:" .. sds_color, { description = "Relaxed " .. sds_color .. " block" , tiles = { sds_png } , is_ground_content = false , groups = { snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, flammable = 3, wool = 1 } , sounds = default.node_sound_defaults() , }) minicarpet.register ({ name = sds_color , description = desc .. " carpet" , images = { sds_png } , groups = { snappy=2, choppy=2, oddly_breakable_by_hand=3, flammable=3, falling_node=1, carpet=1 } , sounds = default.node_sound_defaults() }) default.convert_node ("carpet3d:" .. sds_color, "carpet:" .. sds_color) default.convert_node ("carpet:wool_" .. sds_color, "carpet:" .. sds_color) for _, decor_row in ipairs (mix_decor_list) do local debase = decor_row [1] local imgfile = decor_row [2] local mix_png = sds_png .. "^" .. imgfile minicarpet.register ({ name = sds_color .. "_" .. debase , description = desc .. ", " .. debase .. " style" , images = { mix_png , mix_png, sds_png } , groups = { snappy=2, choppy=2, oddly_breakable_by_hand=3, flammable=3, falling_node=1, carpet=1 } , }) end end -- =================================================================== for _, sds_color in ipairs (sds_color_list) do nodepart = "relaxed_" .. sds_color neednode = "stairs:slope_" .. nodepart fromnode = "relaxed:" .. sds_color if minetest.registered_nodes [neednode] == nil and minetest.registered_nodes [fromnode] ~= nil then stairs.register_all (nodepart, fromnode, { snappy=2, choppy=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1, flammable=3, } , { "sds_" .. sds_color .. "_carpet.png" } , " Relaxed - " .. sds_color , default.node_sound_defaults()) end end -- =================================================================== local other_nodes = { { "default_bookshelf" , "default_bookshelf.png" } , { "default_coalblock" , "default_coalblock.png" } , { "default_dirt" , "default_dirt.png" } , { "default_ice" , "default_ice.png" } , { "default_nyancat" , "nyancat_front.png" } , { "default_nyancat_rainbow" , "nyancat_rainbow.png" } , { "default_sand" , "default_sand.png" } , { "default_snow" , "default_snow.png" } , } -- =================================================================== for _, info in ipairs (other_nodes) do local desc = info [1] local img = info [2] local is_default = false if ocutil.starts_with (desc, "default_") then desc = desc:gsub ("^default_", "") is_default = true end minicarpet.register ({ name = desc , description = desc .. " carpet" , images = { img } , groups = { snappy=2, choppy=2, oddly_breakable_by_hand=3, falling_node=1, carpet=1 } , sounds = default.node_sound_defaults() }) if is_default then reg_alias ("carpet:default_" .. desc , "carpet:" .. desc ) end end -- =================================================================== -- End of file.