carpets/init.lua

69 lines
1.3 KiB
Lua
Raw Normal View History

carpets = {}
2016-11-05 07:17:08 +01:00
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
2016-09-04 17:09:25 +02:00
2016-11-05 07:17:08 +01:00
dofile(modpath .. "/api.lua")
2016-09-04 17:09:25 +02:00
2016-11-05 11:29:06 +01:00
local modutils = dofile(modpath .. "/modutils.lua")
local depmod = modutils.get_depend_checker(modname)
2016-11-05 07:17:08 +01:00
local function filter(name, def)
-- disable carpets from loaded modules but not defined in dependency
2016-11-05 17:23:52 +01:00
if not depmod:check_depend_by_itemname(name) then
2016-10-19 09:38:04 +02:00
return false
2016-09-04 17:09:25 +02:00
end
2016-11-05 07:17:08 +01:00
-- disable carpets for blocks without description
2016-09-04 17:09:25 +02:00
if def.description == nil or def.description == "" then
return false
end
-- no 3rd hand carpets
local ignore_groups = {
not_in_creative_inventory = true,
carpet = true,
door = true,
fence = true,
stair = true,
slab = true,
wall = true,
micro = true,
panel = true,
slope = true,
}
for k,v in pairs(def.groups) do
if ignore_groups[k] then
return false
end
end
2016-11-05 07:17:08 +01:00
-- not supported node types for carpets
local ignore_drawtype = {
liquid = true,
firelike = true,
airlike = true,
plantlike = true,
nodebox = true,
raillike = true,
}
if ignore_drawtype[def.drawtype] then
2016-10-19 09:38:04 +02:00
return false
end
2016-09-04 17:09:25 +02:00
2016-11-05 07:17:08 +01:00
-- no carpet for signs, rail, ladder
2016-10-19 09:38:04 +02:00
if def.paramtype2 == "wallmounted" then
return false
end
2016-09-04 17:09:25 +02:00
2016-11-05 07:17:08 +01:00
-- all checks passed
2016-09-04 17:09:25 +02:00
return true
end
-- main execution
for name, def in pairs(minetest.registered_nodes) do
2016-11-05 07:17:08 +01:00
if filter(name, def) then
carpets.register(name)
2016-09-04 17:09:25 +02:00
end
end