carpets/init.lua

52 lines
1.1 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
if def.base_material then
return false
end
2016-11-05 07:17:08 +01:00
-- not supported node types for carpets
if def.drawtype == "liquid" or
def.drawtype == "firelike" or
def.drawtype == "airlike" or
def.drawtype == "plantlike" or
def.drawtype == "nodebox" or
def.drawtype == "raillike" 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