mirror of
https://github.com/minetest-mods/carpets.git
synced 2024-08-20 12:34:05 +02:00
47 lines
1.1 KiB
Lua
47 lines
1.1 KiB
Lua
carpets = {}
|
|
|
|
local modname = minetest.get_current_modname()
|
|
local modpath = minetest.get_modpath(modname)
|
|
|
|
dofile(modpath .. "/api.lua")
|
|
|
|
local modutils = dofile(modpath .. "/modutils.lua")
|
|
local depmod = modutils.get_depend_checker(modname)
|
|
|
|
local function filter(name, def)
|
|
-- disable carpets from loaded modules but not defined in dependency
|
|
if not depmod:check_depend_by_itemname(name) then
|
|
return false
|
|
end
|
|
|
|
-- disable carpets for blocks without description
|
|
if def.description == nil or def.description == "" then
|
|
return false
|
|
end
|
|
|
|
-- 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
|
|
return false
|
|
end
|
|
|
|
-- no carpet for signs, rail, ladder
|
|
if def.paramtype2 == "wallmounted" then
|
|
return false
|
|
end
|
|
|
|
-- all checks passed
|
|
return true
|
|
end
|
|
|
|
-- main execution
|
|
for name, def in pairs(minetest.registered_nodes) do
|
|
if filter(name, def) then
|
|
carpets.register(name)
|
|
end
|
|
end
|