Cleaning of xwall
This commit is contained in:
parent
7edbaa3af4
commit
dc49a06701
2
init.lua
2
init.lua
@ -1,3 +1,4 @@
|
|||||||
|
--local t = os.clock()
|
||||||
xdecor = {}
|
xdecor = {}
|
||||||
local modpath = minetest.get_modpath("xdecor")
|
local modpath = minetest.get_modpath("xdecor")
|
||||||
|
|
||||||
@ -15,4 +16,5 @@ dofile(modpath.."/nodes.lua")
|
|||||||
dofile(modpath.."/sitting.lua")
|
dofile(modpath.."/sitting.lua")
|
||||||
dofile(modpath.."/worktable.lua")
|
dofile(modpath.."/worktable.lua")
|
||||||
dofile(modpath.."/xwall.lua")
|
dofile(modpath.."/xwall.lua")
|
||||||
|
--print(string.format("xdecor loaded in %.2f ms", (os.clock()-t)*1000))
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ xdecor.register("painting_1", {
|
|||||||
wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
|
wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
|
||||||
wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
|
wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}
|
||||||
},
|
},
|
||||||
after_place_node = function(pos, _, _, _)
|
on_construct = function(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
minetest.set_node(pos, {name="xdecor:painting_"..math.random(1,4), param2=node.param2})
|
minetest.set_node(pos, {name="xdecor:painting_"..math.random(1,4), param2=node.param2})
|
||||||
end
|
end
|
||||||
|
@ -46,7 +46,7 @@ xdecor.register("chair", {
|
|||||||
{-0.3125, -0.125, -0.3125, 0.3125, 0, 0.1875}}
|
{-0.3125, -0.125, -0.3125, 0.3125, 0, 0.1875}}
|
||||||
},
|
},
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.1)
|
||||||
for _, p in pairs(objs) do
|
for _, p in pairs(objs) do
|
||||||
if p:get_player_name() ~= clicker:get_player_name() then return end
|
if p:get_player_name() ~= clicker:get_player_name() then return end
|
||||||
end
|
end
|
||||||
@ -56,7 +56,7 @@ xdecor.register("chair", {
|
|||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.1)
|
||||||
|
|
||||||
for _, p in pairs(objs) do
|
for _, p in pairs(objs) do
|
||||||
if not player or not player:is_player() or
|
if not player or not player:is_player() or
|
||||||
@ -77,7 +77,7 @@ xdecor.register("cushion", {
|
|||||||
on_place = minetest.rotate_node,
|
on_place = minetest.rotate_node,
|
||||||
node_box = xdecor.nodebox.slab_y(-0.5, 0.5),
|
node_box = xdecor.nodebox.slab_y(-0.5, 0.5),
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.1)
|
||||||
for _, p in pairs(objs) do
|
for _, p in pairs(objs) do
|
||||||
if p:get_player_name() ~= clicker:get_player_name() then return end
|
if p:get_player_name() ~= clicker:get_player_name() then return end
|
||||||
end
|
end
|
||||||
@ -87,7 +87,7 @@ xdecor.register("cushion", {
|
|||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.1)
|
||||||
|
|
||||||
for _, p in pairs(objs) do
|
for _, p in pairs(objs) do
|
||||||
if not player or not player:is_player() or
|
if not player or not player:is_player() or
|
||||||
|
70
xwall.lua
70
xwall.lua
@ -72,34 +72,6 @@ function xwall.update(pos, name, active, has_been_digged)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function xwall.register(name, def, node_box_data)
|
|
||||||
for k, v in pairs(node_box_data) do
|
|
||||||
def.drawtype = "nodebox"
|
|
||||||
def.paramtype = "light"
|
|
||||||
def.paramtype2 = "facedir"
|
|
||||||
def.drop = name.."_ln"
|
|
||||||
def.node_box = {type = "fixed", fixed = node_box_data[k]}
|
|
||||||
|
|
||||||
if not def.tiles then def.tiles = def.textures end
|
|
||||||
if not def.groups then
|
|
||||||
def.groups = {xwall=1, cracky=3}
|
|
||||||
else def.groups.xwall = 1 end
|
|
||||||
|
|
||||||
local newdef = table.copy(def)
|
|
||||||
if k == "ln" then
|
|
||||||
newdef.on_construct = function(pos)
|
|
||||||
return xwall.update(pos, name.."_ln", true, nil)
|
|
||||||
end
|
|
||||||
else newdef.groups.not_in_creative_inventory = 1 end
|
|
||||||
|
|
||||||
newdef.after_dig_node = function(pos, _, _, _)
|
|
||||||
return xwall.update(pos, name.."_ln", true, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node(name.."_"..k, newdef)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function xwall.construct_node_box_data(node_box_list, center_node_box_list, node_box_line)
|
function xwall.construct_node_box_data(node_box_list, center_node_box_list, node_box_line)
|
||||||
local res = {}
|
local res = {}
|
||||||
res.c0, res.c1, res.c2, res.c3, res.c4 = {}, {}, {}, {}, {}
|
res.c0, res.c1, res.c2, res.c3, res.c4 = {}, {}, {}, {}, {}
|
||||||
@ -134,32 +106,56 @@ function xwall.construct_node_box_data(node_box_list, center_node_box_list, node
|
|||||||
res.c4[#res.c4+1] = v
|
res.c4[#res.c4+1] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
if #res.c0 < 1 then res.c0 = nil end
|
if #res.c0 < 1 then
|
||||||
|
res.c0 = nil
|
||||||
|
end
|
||||||
|
|
||||||
res.ln = node_box_line
|
res.ln = node_box_line
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
function xwall.register_wall(name, tiles, def)
|
function xwall.register_wall(name, tiles)
|
||||||
|
local groups, def = {}, {}
|
||||||
local node_box_data = xwall.construct_node_box_data(
|
local node_box_data = xwall.construct_node_box_data(
|
||||||
{{-.1875,-.6875,0,.1875,.3125,.5}},{{-.25,-.6875,-.25,.25,.5,.25}},
|
{{-.1875,-.6875,0,.1875,.3125,.5}},
|
||||||
|
{{-.25,-.6875,-.25,.25,.5,.25}},
|
||||||
{{-.1875,-.6875,-.5,.1875,.3125,.5}}
|
{{-.1875,-.6875,-.5,.1875,.3125,.5}}
|
||||||
)
|
)
|
||||||
|
|
||||||
if def then return end
|
local function group(k)
|
||||||
|
groups = {xwall=1, cracky=3}
|
||||||
|
if k ~= "ln" then
|
||||||
|
groups.not_in_creative_inventory=1
|
||||||
|
end
|
||||||
|
return groups
|
||||||
|
end
|
||||||
|
|
||||||
|
for k, v in pairs(node_box_data) do
|
||||||
def = {
|
def = {
|
||||||
description = string.sub(name:gsub("%l", string.upper, 7), 8, -6).." Wall",
|
description = name:match("[%w_]+:(%a+)"):gsub("^%l", string.upper).." Wall",
|
||||||
textures = {tiles, tiles, tiles, tiles},
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
tiles = {tiles},
|
||||||
|
drop = name.."_ln",
|
||||||
|
node_box = {type = "fixed", fixed = node_box_data[k]},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
groups = {cracky=3, stone=1, pane=1},
|
groups = group(k),
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
collision_box = {
|
collision_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-.5, -.5, -.25, .5, 1, .25}
|
fixed = {-.5, -.5, -.25, .5, 1, .25}
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
return xwall.update(pos, name.."_ln", true, nil)
|
||||||
|
end,
|
||||||
|
after_dig_node = function(pos, _, _, _)
|
||||||
|
return xwall.update(pos, name.."_ln", true, true)
|
||||||
|
end
|
||||||
}
|
}
|
||||||
}
|
minetest.register_node(name.."_"..k, def)
|
||||||
xwall.register(name, def, node_box_data)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
xwall.register_wall("xdecor:cobble_wall", "default_cobble.png")
|
xwall.register_wall("xdecor:cobble_wall", "default_cobble.png")
|
||||||
|
Loading…
Reference in New Issue
Block a user