Allow to register custom walls in mcl_walls

This commit is contained in:
Wuzzy 2017-02-17 20:34:08 +01:00
parent 5ccb2ddadf
commit fb5d6f454e
1 changed files with 8 additions and 5 deletions

View File

@ -1,3 +1,5 @@
mcl_walls = {}
local function rshift(x, by) local function rshift(x, by)
return math.floor(x / 2 ^ by) return math.floor(x / 2 ^ by)
end end
@ -20,15 +22,16 @@ local function update_wall(pos)
-- Get the node's base name, including the underscore since we will need it -- Get the node's base name, including the underscore since we will need it
local colonpos = thisnode.name:find(":") local colonpos = thisnode.name:find(":")
local underscorepos local underscorepos
local itemname, basename local itemname, basename, modname
if colonpos ~= nil then if colonpos ~= nil then
itemname = thisnode.name:sub(colonpos+1) itemname = thisnode.name:sub(colonpos+1)
modname = thisnode.name:sub(1, colonpos-1)
end end
underscorepos = itemname:find("_") underscorepos = itemname:find("_")
if underscorepos == nil then -- New wall if underscorepos == nil then -- New wall
basename = thisnode.name .. "_" basename = thisnode.name .. "_"
else -- Already placed wall else -- Already placed wall
basename = "mcl_walls:" .. itemname:sub(1, underscorepos) basename = modname .. ":" .. itemname:sub(1, underscorepos)
end end
local sum = 0 local sum = 0
@ -83,7 +86,7 @@ local full_blocks = {
* name: Item name, visible to user * name: Item name, visible to user
* texture: Wall texture * texture: Wall texture
* invtex: Inventory image ]] * invtex: Inventory image ]]
local function register_wall(nodename, name, texture, invtex) function mcl_walls.register_wall(nodename, name, texture, invtex)
for i = 0, 15 do for i = 0, 15 do
local need = {} local need = {}
local need_pillar = false local need_pillar = false
@ -192,7 +195,7 @@ end
-- Cobblestone wall -- Cobblestone wall
register_wall("mcl_walls:cobble", "Cobblestone Wall", "default_cobble.png", "mcl_walls_cobble.png") mcl_walls.register_wall("mcl_walls:cobble", "Cobblestone Wall", "default_cobble.png", "mcl_walls_cobble.png")
minetest.register_craft({ minetest.register_craft({
output = 'mcl_walls:cobble 6', output = 'mcl_walls:cobble 6',
recipe = { recipe = {
@ -203,7 +206,7 @@ minetest.register_craft({
-- Mossy wall -- Mossy wall
register_wall("mcl_walls:mossycobble", "Mossy Cobblestone Wall", "default_mossycobble.png", "mcl_walls_mossycobble.png") mcl_walls.register_wall("mcl_walls:mossycobble", "Mossy Cobblestone Wall", "default_mossycobble.png", "mcl_walls_mossycobble.png")
minetest.register_craft({ minetest.register_craft({
output = 'mcl_walls:mossycobble 6', output = 'mcl_walls:mossycobble 6',
recipe = { recipe = {