2016-10-27 09:15:05 +02:00
|
|
|
carpets = {}
|
2016-10-19 23:28:55 +02:00
|
|
|
|
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 07:17:08 +01:00
|
|
|
local depends = (function()
|
|
|
|
local file = io.open(modpath .. "/depends.txt")
|
|
|
|
if not file then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local depends = {}
|
|
|
|
for line in file:lines() do
|
|
|
|
if line:sub(-1) == "?" then
|
|
|
|
line = line:sub(1, -2)
|
|
|
|
end
|
|
|
|
depends[line] = true
|
|
|
|
end
|
2016-09-04 17:09:25 +02:00
|
|
|
|
2016-11-05 07:17:08 +01:00
|
|
|
file:close()
|
|
|
|
|
|
|
|
return depends
|
|
|
|
end)()
|
|
|
|
|
|
|
|
local function filter(name, def)
|
|
|
|
-- disable carpets from loaded modules but not defined in dependency
|
|
|
|
if not depends[def.mod_origin] 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
|
|
|
|
|
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
|
2016-11-05 01:48:07 +01:00
|
|
|
carpets.register(name)
|
2016-09-04 17:09:25 +02:00
|
|
|
end
|
|
|
|
end
|