mirror of
https://github.com/minetest-mods/carpets.git
synced 2024-11-19 22:03:43 +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)
|
||||
-- disable carpets from loaded modules but not defined in dependency
|
||||
if depmod.check_depmod(name) == false then
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
||||
-- disable carpets for blocks without description
|
||||
@ -16,19 +16,19 @@ function carpet.enabledfilter(name, def)
|
||||
end
|
||||
|
||||
-- not supported node types for carpets
|
||||
if def.drawtype == "liquid" or
|
||||
if def.drawtype == "liquid" or
|
||||
def.drawtype == "firelike" or
|
||||
def.drawtype == "airlike" or
|
||||
def.drawtype == "plantlike" or
|
||||
def.drawtype == "nodebox" or
|
||||
def.drawtype == "airlike" or
|
||||
def.drawtype == "plantlike" or
|
||||
def.drawtype == "nodebox" or
|
||||
def.drawtype == "raillike" then
|
||||
return false
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- no carpet for signs, rail, ladder
|
||||
if def.paramtype2 == "wallmounted" then
|
||||
return false
|
||||
end
|
||||
if def.paramtype2 == "wallmounted" then
|
||||
return false
|
||||
end
|
||||
|
||||
-- all checks passed
|
||||
return true
|
||||
|
42
modutils.lua
42
modutils.lua
@ -5,41 +5,45 @@ function modutils.get_depmod(modname)
|
||||
|
||||
-- Definition of returning object attributes
|
||||
local depmod = {
|
||||
modname, -- module name from get_depmod
|
||||
modname, -- module name from get_depmod
|
||||
deplist = {}, -- depends.txt parsed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- Definition of returning object methods
|
||||
function depmod.check_depmod(checknode)
|
||||
-- check if the node (checknode) is from dependent module
|
||||
local delimpos = string.find(checknode, ":")
|
||||
if delimpos then
|
||||
local checkmodname = string.sub(checknode, 1, delimpos - 1)
|
||||
for name, ref in pairs(depmod.deplist) do
|
||||
if name == checkmodname then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
function depmod.check_depmod(checknode)
|
||||
-- check if the node (checknode) is from dependent module
|
||||
local delimpos = string.find(checknode, ":")
|
||||
if delimpos then
|
||||
local checkmodname = string.sub(checknode, 1, delimpos - 1)
|
||||
for name, ref in pairs(depmod.deplist) do
|
||||
if name == checkmodname then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Full returning object attributes
|
||||
depmod.modname = modname
|
||||
|
||||
-- local variable definition
|
||||
local depentry = {} -- Entry in deplist
|
||||
local depentry = {} -- Entry in deplist
|
||||
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
|
||||
for dependsline in dependsfile:lines() do
|
||||
if string.sub(dependsline, -1) == "?" then
|
||||
depentry.required = false
|
||||
depmodname = string.sub(dependsline, 1, -2)
|
||||
depmodname = string.sub(dependsline, 1, -2)
|
||||
else
|
||||
depentry.required = true
|
||||
depmodname = dependsline
|
||||
depmodname = dependsline
|
||||
end
|
||||
depmod.deplist[depmodname] = depentry
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user