Browse Source

use table.copy instead of own clone node

tags/2019-06-18-1
Vanessa Dannenberg 1 year ago
parent
commit
7e7b2bcabb
2 changed files with 8 additions and 27 deletions
  1. +4
    -13
      homedecor_3d_extras/init.lua
  2. +4
    -14
      homedecor_doors_and_gates/init.lua

+ 4
- 13
homedecor_3d_extras/init.lua View File

@@ -89,28 +89,19 @@ end
-- 3d-ify default mtg wood and steel doors and trap doors

if minetest.get_modpath("doors") then
local function clone_node(name)
local node2 = {}
local node = minetest.registered_nodes[name]
for k,v in pairs(node) do
node2[k]=v
end
return node2
end

local def
for _,mat in ipairs({"wood", "steel"}) do
def = clone_node("doors:door_"..mat.."_a")
def = table.copy(minetest.registered_nodes["doors:door_"..mat.."_a"])
def.mesh = "homedecor_3d_door_"..mat.."_a.obj"
minetest.register_node(":doors:door_"..mat.."_a", def)

def = clone_node("doors:door_"..mat.."_b")
def = table.copy(minetest.registered_nodes["doors:door_"..mat.."_b"])
def.mesh = "homedecor_3d_door_"..mat.."_b.obj"
minetest.register_node(":doors:door_"..mat.."_b", def)
end

for _,mat in ipairs({"", "_steel"}) do
def = clone_node("doors:trapdoor"..mat)
def = table.copy(minetest.registered_nodes["doors:trapdoor"..mat])
def.drawtype = "mesh"
def.mesh = "homedecor_3d_trapdoor"..mat..".obj"
def.tiles = {
@@ -119,7 +110,7 @@ if minetest.get_modpath("doors") then
}
minetest.register_node(":doors:trapdoor"..mat, def)

def = clone_node("doors:trapdoor"..mat.."_open")
def = table.copy(minetest.registered_nodes["doors:trapdoor"..mat.."_open"])
def.mesh = "homedecor_3d_trapdoor"..mat.."_open.obj"
def.drawtype = "mesh"
def.tiles = {


+ 4
- 14
homedecor_doors_and_gates/init.lua View File

@@ -3,17 +3,6 @@
local S = homedecor.gettext
local mesecons_mp = minetest.get_modpath("mesecons")


function hd_doors_clone_node(name)
local node2 = {}
local node = minetest.registered_nodes[name]
for k,v in pairs(node) do
node2[k]=v
end
return node2
end

-- new doors using minetest_game doors API

local door_list = {
@@ -181,22 +170,22 @@ for _, door in ipairs(door_list) do
local nn_b = "doors:homedecor_"..door.name.."_b"

if door.alpha then
local def = hd_doors_clone_node(nn_a)
local def = table.copy(minetest.registered_nodes[nn_a])
def.use_texture_alpha = true
def.mesh = "door_a.obj" -- leaving this out will break the _a model
minetest.register_node(":"..nn_a, def) -- assignment when the override takes place

def = hd_doors_clone_node(nn_b)
def = table.copy(minetest.registered_nodes[nn_b])
def.use_texture_alpha = true
minetest.register_node(":"..nn_b, def)
end

if door.custom_model and hd_3d then
def = hd_doors_clone_node(nn_a)
def = table.copy(minetest.registered_nodes[nn_a])
def.mesh = door.custom_model.."_a.obj"
minetest.register_node(":"..nn_a, def)

def = hd_doors_clone_node(nn_b)
def = table.copy(minetest.registered_nodes[nn_b])
def.mesh = door.custom_model.."_b.obj"
minetest.register_node(":"..nn_b, def)
end


Loading…
Cancel
Save