mirror of
https://github.com/minetest-mods/carpets.git
synced 2025-01-02 02:07:31 +01:00
modutils.lua updated, whitespace-fixes
This commit is contained in:
parent
a579c1b6b9
commit
c058a4589e
20
init.lua
20
init.lua
@ -7,7 +7,7 @@ depmod = modutils.get_depmod("carpets")
|
|||||||
function carpet.enabledfilter(name, def)
|
function carpet.enabledfilter(name, def)
|
||||||
-- disable carpets from loaded modules but not defined in dependency
|
-- disable carpets from loaded modules but not defined in dependency
|
||||||
if depmod.check_depmod(name) == false then
|
if depmod.check_depmod(name) == false then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- disable carpets for blocks without description
|
-- disable carpets for blocks without description
|
||||||
@ -16,19 +16,19 @@ function carpet.enabledfilter(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- not supported node types for carpets
|
-- not supported node types for carpets
|
||||||
if def.drawtype == "liquid" or
|
if def.drawtype == "liquid" or
|
||||||
def.drawtype == "firelike" or
|
def.drawtype == "firelike" or
|
||||||
def.drawtype == "airlike" or
|
def.drawtype == "airlike" or
|
||||||
def.drawtype == "plantlike" or
|
def.drawtype == "plantlike" or
|
||||||
def.drawtype == "nodebox" or
|
def.drawtype == "nodebox" or
|
||||||
def.drawtype == "raillike" then
|
def.drawtype == "raillike" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- no carpet for signs, rail, ladder
|
-- no carpet for signs, rail, ladder
|
||||||
if def.paramtype2 == "wallmounted" then
|
if def.paramtype2 == "wallmounted" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- all checks passed
|
-- all checks passed
|
||||||
return true
|
return true
|
||||||
|
42
modutils.lua
42
modutils.lua
@ -5,41 +5,45 @@ function modutils.get_depmod(modname)
|
|||||||
|
|
||||||
-- Definition of returning object attributes
|
-- Definition of returning object attributes
|
||||||
local depmod = {
|
local depmod = {
|
||||||
modname, -- module name from get_depmod
|
modname, -- module name from get_depmod
|
||||||
deplist = {}, -- depends.txt parsed
|
deplist = {}, -- depends.txt parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Definition of returning object methods
|
-- Definition of returning object methods
|
||||||
function depmod.check_depmod(checknode)
|
function depmod.check_depmod(checknode)
|
||||||
-- check if the node (checknode) is from dependent module
|
-- check if the node (checknode) is from dependent module
|
||||||
local delimpos = string.find(checknode, ":")
|
local delimpos = string.find(checknode, ":")
|
||||||
if delimpos then
|
if delimpos then
|
||||||
local checkmodname = string.sub(checknode, 1, delimpos - 1)
|
local checkmodname = string.sub(checknode, 1, delimpos - 1)
|
||||||
for name, ref in pairs(depmod.deplist) do
|
for name, ref in pairs(depmod.deplist) do
|
||||||
if name == checkmodname then
|
if name == checkmodname then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Full returning object attributes
|
-- Full returning object attributes
|
||||||
depmod.modname = modname
|
depmod.modname = modname
|
||||||
|
|
||||||
-- local variable definition
|
-- local variable definition
|
||||||
local depentry = {} -- Entry in deplist
|
local depentry = {} -- Entry in deplist
|
||||||
local depmodname -- temp value
|
local depmodname -- temp value
|
||||||
local dependsfile = io.open(minetest.get_modpath(modname).."/depends.txt")
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
if not modpath then
|
||||||
|
return nil -- module not found
|
||||||
|
end
|
||||||
|
local dependsfile = io.open(modpath.."/depends.txt")
|
||||||
if dependsfile then
|
if dependsfile then
|
||||||
for dependsline in dependsfile:lines() do
|
for dependsline in dependsfile:lines() do
|
||||||
if string.sub(dependsline, -1) == "?" then
|
if string.sub(dependsline, -1) == "?" then
|
||||||
depentry.required = false
|
depentry.required = false
|
||||||
depmodname = string.sub(dependsline, 1, -2)
|
depmodname = string.sub(dependsline, 1, -2)
|
||||||
else
|
else
|
||||||
depentry.required = true
|
depentry.required = true
|
||||||
depmodname = dependsline
|
depmodname = dependsline
|
||||||
end
|
end
|
||||||
depmod.deplist[depmodname] = depentry
|
depmod.deplist[depmodname] = depentry
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user