Painting system with using the node palettes
This commit is contained in:
parent
8497912719
commit
c345a8a90d
@ -2,18 +2,46 @@ multidecor.helpers = {}
|
||||
|
||||
hlpfuncs = multidecor.helpers
|
||||
|
||||
-- Returns a direction of the node with 'pos' position
|
||||
function multidecor.helpers.get_dir(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local dir = def.paramtype2 == "facedir" and vector.copy(minetest.facedir_to_dir(node.param2)) or
|
||||
def.paramtype2 == "wallmounted" and vector.copy(minetest.wallmounted_to_dir(node.param2)) or
|
||||
vector.new(0, 0, 0)
|
||||
function multidecor.helpers.get_dir_from_param2(name, param2)
|
||||
local def = minetest.registered_nodes[name]
|
||||
|
||||
local dir = vector.new(0, 0, 0)
|
||||
|
||||
if def.paramtype2 == "facedir" then
|
||||
dir = minetest.facedir_to_dir(param2)
|
||||
elseif def.paramtype2 == "wallmounted" then
|
||||
dir = minetest.wallmounted_to_dir(param2)
|
||||
elseif def.paramtype2 == "colorfacedir" then
|
||||
dir = minetest.facedir_to_dir(param2 % 32)
|
||||
elseif def.paramtype2 == "colorwallmounted" then
|
||||
dir = minetest.wallmounted_to_dir(param2 % 8)
|
||||
end
|
||||
|
||||
dir = dir*-1
|
||||
|
||||
return dir
|
||||
end
|
||||
|
||||
-- Returns a direction of the node with 'pos' position
|
||||
function multidecor.helpers.get_dir(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
return multidecor.helpers.get_dir_from_param2(node.name, node.param2)
|
||||
end
|
||||
|
||||
function multidecor.helpers.from_dir_get_param2(name, old_param2, dir)
|
||||
local param2 = minetest.dir_to_facedir(dir)
|
||||
|
||||
local def = minetest.registered_nodes[name]
|
||||
|
||||
if def.paramtype2 == "colorfacedir" then
|
||||
local palette_index = math.floor(old_param2 / 32)
|
||||
param2 = param2 + palette_index * 32
|
||||
end
|
||||
|
||||
return param2
|
||||
end
|
||||
|
||||
-- Returns a node def of the node at 'pos'
|
||||
function multidecor.helpers.ndef(pos)
|
||||
return minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
|
@ -11,21 +11,23 @@ end
|
||||
|
||||
function multidecor.connecting.has_same_cmn_name(pos, cmn_name)
|
||||
local add_props = minetest.registered_nodes[minetest.get_node(pos).name].add_properties
|
||||
minetest.debug("pos_cmn_name: " .. (add_props and add_props.common_name or ""))
|
||||
minetest.debug("cmn_name: " .. cmn_name)
|
||||
|
||||
return add_props and add_props.common_name == cmn_name
|
||||
end
|
||||
|
||||
function multidecor.connecting.are_nodes_codirectional(pos1, pos2)
|
||||
local dir1 = minetest.facedir_to_dir(minetest.get_node(pos1).param2)
|
||||
local dir2 = minetest.facedir_to_dir(minetest.get_node(pos2).param2)
|
||||
local node1 = minetest.get_node(pos1)
|
||||
local node2 = minetest.get_node(pos2)
|
||||
|
||||
local dir1 = hlpfuncs.get_dir_from_param2(node1.name, node1.param2)
|
||||
local dir2 = hlpfuncs.get_dir_from_param2(node2.name, node2.param2)
|
||||
|
||||
return vector.equals(dir1, dir2)
|
||||
end
|
||||
|
||||
function multidecor.connecting.has_same_dir(pos, dir)
|
||||
local dir2 = minetest.facedir_to_dir(minetest.get_node(pos).param2)
|
||||
local node = minetest.get_node(pos)
|
||||
local dir2 = hlpfuncs.get_dir_from_param2(node.name, node.param2)*-1
|
||||
|
||||
return vector.equals(dir, dir2)
|
||||
end
|
||||
@ -92,8 +94,10 @@ function multidecor.connecting.replace_node_to(pos, disconnect, cmn_name)
|
||||
return
|
||||
end
|
||||
|
||||
local param2 = minetest.dir_to_facedir(vector.rotate_around_axis({x=0, y=0, z=1}, {x=0, y=1, z=0}, math.rad(rel_rot))*-1)
|
||||
minetest.set_node(pos, {name="multidecor:" .. cmn_name .. target_node, param2=param2})
|
||||
local name = "multidecor:" .. cmn_name .. target_node
|
||||
local old_param2 = minetest.get_node(pos).param2
|
||||
local param2 = hlpfuncs.from_dir_get_param2(name, old_param2, vector.rotate_around_axis({x=0, y=0, z=1}, {x=0, y=1, z=0}, math.rad(rel_rot))*-1)
|
||||
minetest.set_node(pos, {name=name, param2=param2})
|
||||
end
|
||||
|
||||
-- Shift 'cur_val' in the range [0-3] by 'shift_val' taking into account the range limits.
|
||||
@ -122,8 +126,8 @@ local function shift_val_in_range(cur_val, shift_val)
|
||||
return res
|
||||
end
|
||||
|
||||
function multidecor.connecting.replace_node_vertically(pos, disconnect, cmn_name, param2)
|
||||
local dir = minetest.facedir_to_dir(param2)
|
||||
function multidecor.connecting.replace_node_vertically(pos, disconnect, cmn_name, node)
|
||||
local dir = hlpfuncs.get_dir_from_param2(node.name, node.param2)
|
||||
local ord_shifts = {
|
||||
pos + vector.rotate_around_axis(dir, vector.new(0, 1, 0), math.pi/2),
|
||||
pos + vector.new(0, 1, 0),
|
||||
@ -210,6 +214,9 @@ function multidecor.connecting.replace_node_vertically(pos, disconnect, cmn_name
|
||||
|
||||
local axis_rot = math.floor(axis_rot/90)
|
||||
local param2 = axis_dirs[axis]*4 + shift_val_in_range(axis_rot, axis_rot_shift[axis])
|
||||
|
||||
local name = "multidecor:" .. cmn_name .. target_node
|
||||
|
||||
minetest.set_node(pos, {name="multidecor:" .. cmn_name .. target_node, param2=param2})
|
||||
end
|
||||
|
||||
@ -331,9 +338,11 @@ function multidecor.connecting.directional_replace_node_to(pos, dir, side, disco
|
||||
return
|
||||
end
|
||||
|
||||
local name = "multidecor:" .. add_props.common_name .. target_part
|
||||
local rot_dir = vector.rotate_around_axis(t_dir, vector.new(0, 1, 0), rel_rot)
|
||||
local param2 = minetest.dir_to_facedir(rot_dir*-1)
|
||||
minetest.set_node(pos, {name="multidecor:" .. add_props.common_name .. target_part, param2=param2})
|
||||
local param2 = hlpfuncs.from_dir_get_param2(name, node.param2, rot_dir*-1)
|
||||
|
||||
minetest.set_node(pos, {name=name, param2=param2})
|
||||
end
|
||||
|
||||
-- Connects or disconnects adjacent nodes around 'pos' position.
|
||||
@ -342,8 +351,9 @@ end
|
||||
function multidecor.connecting.update_adjacent_nodes_connection(pos, type, disconnect, old_node)
|
||||
local node = disconnect and old_node or minetest.get_node(pos)
|
||||
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not disconnect then
|
||||
local add_props = minetest.registered_nodes[node.name].add_properties
|
||||
local add_props = def.add_properties
|
||||
local modname = node.name:find("multidecor:")
|
||||
local cmn_name = add_props and add_props.common_name
|
||||
|
||||
@ -352,8 +362,8 @@ function multidecor.connecting.update_adjacent_nodes_connection(pos, type, disco
|
||||
end
|
||||
end
|
||||
|
||||
if type == "horizontal" or type == "vertical" then
|
||||
local dir = disconnect and minetest.facedir_to_dir(old_node.param2) or multidecor.helpers.get_dir(pos)
|
||||
if type == "horizontal" then
|
||||
local dir = disconnect and multidecor.helpers.get_dir_from_param2(old_node.name, old_node.param2)*-1 or multidecor.helpers.get_dir(pos)
|
||||
|
||||
local left_dir = type == "horizontal" and vector.new(-1, 0, 0) or vector.rotate_around_axis(dir, vector.new(0, 1, 0), math.pi/2)
|
||||
local right_dir = type == "horizontal" and vector.new(1, 0, 0) or vector.rotate_around_axis(dir, vector.new(0, 1, 0), -math.pi/2)
|
||||
@ -367,12 +377,12 @@ function multidecor.connecting.update_adjacent_nodes_connection(pos, type, disco
|
||||
pos + down_dir
|
||||
}
|
||||
|
||||
local cmn_name = minetest.registered_nodes[node.name].add_properties.common_name
|
||||
local cmn_name = def.add_properties.common_name
|
||||
for _, s in ipairs(shifts) do
|
||||
if type == "horizontal" then
|
||||
multidecor.connecting.replace_node_to(s, disconnect, cmn_name)
|
||||
else
|
||||
multidecor.connecting.replace_node_vertically(s, disconnect, cmn_name, node.param2)
|
||||
multidecor.connecting.replace_node_vertically(s, disconnect, cmn_name, node)
|
||||
end
|
||||
end
|
||||
|
||||
@ -380,7 +390,7 @@ function multidecor.connecting.update_adjacent_nodes_connection(pos, type, disco
|
||||
if type == "horizontal" then
|
||||
multidecor.connecting.replace_node_to(pos, nil, cmn_name)
|
||||
else
|
||||
multidecor.connecting.replace_node_vertically(pos, nil, cmn_name, node.param2)
|
||||
multidecor.connecting.replace_node_vertically(pos, nil, cmn_name, node)
|
||||
end
|
||||
end
|
||||
elseif type == "pair" then
|
||||
@ -392,7 +402,7 @@ function multidecor.connecting.update_adjacent_nodes_connection(pos, type, disco
|
||||
local lnode = minetest.get_node(left)
|
||||
local rnode = minetest.get_node(right)
|
||||
|
||||
local add_props = minetest.registered_nodes[node.name].add_properties
|
||||
local add_props = def.add_properties
|
||||
local is_left_identical = lnode.name == "multidecor:" .. add_props.common_name and multidecor.connecting.are_nodes_codirectional(left, pos)
|
||||
local is_right_identical = rnode.name == "multidecor:" .. add_props.common_name and multidecor.connecting.are_nodes_codirectional(right, pos)
|
||||
|
||||
@ -405,20 +415,19 @@ function multidecor.connecting.update_adjacent_nodes_connection(pos, type, disco
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_node(place_pos, {name="multidecor:" .. add_props.common_name .. "_double", param2=minetest.dir_to_facedir(dir*-1)})
|
||||
minetest.set_node(place_pos, {name="multidecor:" .. add_props.common_name .. "_double", param2=hlpfuncs.from_dir_get_param2(node.name, node.param2, dir*-1)})
|
||||
minetest.remove_node(place_pos+vector.rotate_around_axis(dir, {x=0, y=1, z=0}, math.pi/2))
|
||||
else
|
||||
local dir = minetest.facedir_to_dir(old_node.param2)
|
||||
local dir = hlpfuncs.get_dir_from_param2(old_node.name, old_node.param2)
|
||||
local right = pos+vector.rotate_around_axis(dir, {x=0, y=1, z=0}, -math.pi/2)
|
||||
local add_props = minetest.registered_nodes[old_node.name].add_properties
|
||||
minetest.set_node(right, {name="multidecor:" .. add_props.common_name, param2=minetest.dir_to_facedir(dir)})
|
||||
minetest.set_node(right, {name="multidecor:" .. add_props.common_name, param2=hlpfuncs.from_dir_get_param2(old_node.name, old_node.param2, dir)})
|
||||
end
|
||||
elseif type == "directional" then
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local dir
|
||||
|
||||
if disconnect then
|
||||
dir = minetest.facedir_to_dir(old_node.param2)*-1
|
||||
dir = hlpfuncs.get_dir_from_param2(old_node.name, old_node.param2)
|
||||
else
|
||||
dir = multidecor.helpers.get_dir(pos)
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ end
|
||||
|
||||
-- Defines at which direction (unit vector) depending on the 'mover's look dir the curtains at the position 'pos' should be moved
|
||||
function multidecor.curtains.define_move_dir(pos, mover)
|
||||
local node_dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
|
||||
local node_dir = hlpfuncs.get_dir(pos)*-1
|
||||
node_dir.y = 0
|
||||
|
||||
local mover_dir = mover:get_look_dir()
|
||||
|
@ -2,6 +2,17 @@ multidecor = {}
|
||||
|
||||
multidecor.S = minetest.get_translator("decor_api")
|
||||
|
||||
multidecor.colors = {
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"yellow",
|
||||
"green",
|
||||
"cyan",
|
||||
"magenta",
|
||||
"grey"
|
||||
}
|
||||
|
||||
local modpath = minetest.get_modpath("decor_api")
|
||||
|
||||
dofile(modpath .. "/common_helpers.lua")
|
||||
|
@ -18,7 +18,7 @@ function multidecor.register.register_light(name, base_def, add_def, craft_def)
|
||||
local def = table.copy(base_def)
|
||||
|
||||
def.type = "light"
|
||||
def.paramtype2 = "facedir"
|
||||
def.paramtype2 = def.paramtype2 or "facedir"
|
||||
|
||||
if add_def then
|
||||
if add_def.recipe then
|
||||
|
@ -102,6 +102,44 @@ function multidecor.register.after_place_node(pos, placer, itemstack)
|
||||
return leftover
|
||||
end
|
||||
|
||||
function multidecor.register.on_punch(pos, node, puncher)
|
||||
local wielded_item = puncher:get_wielded_item()
|
||||
|
||||
if wielded_item:get_name() ~= "multidecor:scraper" then
|
||||
return
|
||||
end
|
||||
|
||||
local def = hlpfuncs.ndef(pos)
|
||||
|
||||
if not def.is_colorable then return end
|
||||
|
||||
local mul = def.paramtype2 == "colorwallmounted" and 8 or 32
|
||||
local palette_index = math.floor(node.param2 / mul)
|
||||
|
||||
if palette_index == 0 then return end
|
||||
|
||||
local color = multidecor.colors[palette_index+1]
|
||||
local rot = node.param2 % mul
|
||||
|
||||
minetest.swap_node(pos, {name=node.name, param2=rot})
|
||||
|
||||
minetest.item_drop(ItemStack("dye:" .. color), puncher, pos)
|
||||
|
||||
wielded_item:set_wear(wielded_item:get_wear()+math.modf(65535/50))
|
||||
puncher:set_wielded_item(wielded_item)
|
||||
|
||||
local playername = puncher:get_player_name()
|
||||
if not multidecor.players_actions_sounds[playername] then
|
||||
multidecor.players_actions_sounds[playername] = {
|
||||
name = "multidecor_scraping",
|
||||
cur_time = 0.0,
|
||||
durability = 4.0
|
||||
}
|
||||
|
||||
minetest.sound_play("multidecor_scraping", {to_player=playername})
|
||||
end
|
||||
end
|
||||
|
||||
--[[def:
|
||||
{
|
||||
type = <seat, shelf, bed, table, >
|
||||
@ -161,6 +199,10 @@ function multidecor.register.register_furniture_unit(name, def, craft_def)
|
||||
f_def.mesh = def.mesh
|
||||
end
|
||||
|
||||
if f_def.paramtype2 == "colorfacedir" or f_def.paramtype2 == "colorwallmounted" then
|
||||
f_def.palette = "multidecor_palette.png"
|
||||
end
|
||||
|
||||
f_def.tiles = def.tiles
|
||||
f_def.overlay_tiles = def.overlay_tiles
|
||||
f_def.inventory_image = def.inventory_image
|
||||
@ -222,6 +264,7 @@ function multidecor.register.register_furniture_unit(name, def, craft_def)
|
||||
end
|
||||
|
||||
f_def.prevent_placement_check = def.prevent_placement_check
|
||||
f_def.is_colorable = def.is_colorable
|
||||
|
||||
f_def.callbacks = def.callbacks or {}
|
||||
for cb_name, f in pairs(f_def.callbacks) do
|
||||
@ -241,6 +284,17 @@ function multidecor.register.register_furniture_unit(name, def, craft_def)
|
||||
f_def.after_place_node = multidecor.register.after_place_node
|
||||
end
|
||||
|
||||
if f_def.on_punch then
|
||||
local prev_on_punch = f_def.on_punch
|
||||
f_def.on_punch = function(pos, node, puncher)
|
||||
prev_on_punch(pos, node, puncher)
|
||||
|
||||
multidecor.register.on_punch(pos, node, puncher)
|
||||
end
|
||||
else
|
||||
f_def.on_punch = multidecor.register.on_punch
|
||||
end
|
||||
|
||||
f_def.add_properties = def.add_properties or {}
|
||||
|
||||
local f_name = "multidecor:" .. name
|
||||
|
@ -17,7 +17,7 @@ function multidecor.register.register_seat(name, base_def, add_def, craft_def)
|
||||
local def = table.copy(base_def)
|
||||
|
||||
def.type = "seat"
|
||||
def.paramtype2 = "facedir"
|
||||
def.paramtype2 = def.paramtype2 or "facedir"
|
||||
|
||||
-- additional properties
|
||||
if add_def then
|
||||
|
@ -88,7 +88,7 @@ function multidecor.sitting.sit_player(player, node_pos)
|
||||
if seat_data.model then
|
||||
prev_pdata.model = player_api.get_animation(player)
|
||||
|
||||
local node_dir = vector.multiply(minetest.facedir_to_dir(minetest.get_node(node_pos).param2), -1)
|
||||
local node_dir = multidecor.helpers.get_dir(node_pos)
|
||||
local near_node = minetest.get_node(vector.add(node_pos, node_dir))
|
||||
|
||||
if minetest.get_item_group(near_node.name, "table") ~= 1 then
|
||||
|
BIN
decor_api/textures/multidecor_palette.png
Normal file
BIN
decor_api/textures/multidecor_palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
@ -494,10 +494,11 @@ multidecor.register.register_seat("toilet", {
|
||||
multidecor.register.register_curtain("bathroom_curtain", {
|
||||
style = "modern",
|
||||
material = "plastic",
|
||||
drawtype = "colorfacedir",
|
||||
paramtype2 = "colorfacedir",
|
||||
bounding_boxes = {
|
||||
{-0.5, -0.5, -0.1, 0.5, 0.5, 0.1}
|
||||
}
|
||||
},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
common_name = "bathroom_curtain",
|
||||
@ -507,7 +508,7 @@ multidecor.register.register_curtain("bathroom_curtain", {
|
||||
name = "bathroom_curtain_with_rings",
|
||||
description = "Bathroom Curtain With Rings",
|
||||
mesh = "multidecor_curtain_with_rings.b3d",
|
||||
tiles = {"multidecor_cloth.png", "multidecor_metal_material.png"},
|
||||
tiles = {"multidecor_cloth.png", {name="multidecor_metal_material.png",color=0xffffffff}},
|
||||
craft = {
|
||||
recipe = {
|
||||
{"multidecor:wool_cloth", "multidecor:metal_bar", "multidecor:steel_scissors"},
|
||||
|
@ -30,14 +30,16 @@ multidecor.register.register_seat("soft_kitchen_modern_wooden_chair", {
|
||||
style = "modern",
|
||||
material = "wood",
|
||||
description = "Soft Kitchen Modern Wooden Chair",
|
||||
paramtype2 = "colorfacedir",
|
||||
visual_scale = 0.4,
|
||||
mesh = "multidecor_soft_kitchen_modern_wooden_chair.b3d",
|
||||
tiles = {"multidecor_wood.png", "multidecor_wool_material.png"},
|
||||
tiles = {{name="multidecor_wood.png", color=0xffffffff}, "multidecor_wool_material.png"},
|
||||
bounding_boxes = {
|
||||
{-0.29, -0.5, -0.29, 0.29, 0.145, 0.21},
|
||||
{-0.29, -0.5, 0.21, 0.29, 0.9375, 0.285},
|
||||
{-0.32, 0.145, -0.32, 0.32, 0.23, 0.21}
|
||||
}
|
||||
},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
seat_data = {
|
||||
@ -59,13 +61,15 @@ multidecor.register.register_seat("soft_modern_jungle_chair", {
|
||||
style = "modern",
|
||||
material = "wood",
|
||||
description = "Soft Modern Jungle Chair",
|
||||
paramtype2 = "colorfacedir",
|
||||
visual_scale = 0.4,
|
||||
mesh = "multidecor_soft_modern_jungle_chair.b3d",
|
||||
tiles = {"multidecor_jungle_wood.png", "multidecor_wool_material.png"},
|
||||
tiles = {{name="multidecor_jungle_wood.png", color=0xffffffff}, "multidecor_wool_material.png"},
|
||||
bounding_boxes = {
|
||||
{-0.27, -0.5, -0.27, 0.27, 0.13, 0.225},
|
||||
{-0.27, -0.5, 0.225, 0.27, 0.825, 0.3}
|
||||
}
|
||||
},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
seat_data = {
|
||||
@ -87,13 +91,15 @@ multidecor.register.register_seat("soft_round_modern_metallic_chair", {
|
||||
style = "modern",
|
||||
material = "metal",
|
||||
description = "Soft Round Modern Metallic Chair",
|
||||
paramtype2 = "colorfacedir",
|
||||
visual_scale = 0.4,
|
||||
mesh = "multidecor_round_soft_metallic_chair.b3d",
|
||||
tiles = {"multidecor_wool_material.png", "multidecor_metal_material.png"},
|
||||
tiles = {"multidecor_wool_material.png", {name="multidecor_metal_material.png", color=0xffffffff}},
|
||||
bounding_boxes = {
|
||||
{-0.5, -0.5, -0.4, 0.5, 0.25, 0.2},
|
||||
{-0.5, -0.5, 0.2, 0.5, 0.8, 0.325}
|
||||
}
|
||||
},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
seat_data = {
|
||||
@ -114,13 +120,15 @@ multidecor.register.register_seat("soft_round_modern_metallic_chair", {
|
||||
multidecor.register.register_seat("round_modern_metallic_stool", {
|
||||
style = "modern",
|
||||
material = "metal",
|
||||
description = "Round Modern Jungle Stool",
|
||||
description = "Round Modern Metallic Stool",
|
||||
paramtype2 = "colorfacedir",
|
||||
visual_scale = 0.4,
|
||||
mesh = "multidecor_modern_round_metallic_stool.b3d",
|
||||
tiles = {"multidecor_wool_material.png", "multidecor_metal_material.png"},
|
||||
tiles = {"multidecor_wool_material.png", {name="multidecor_metal_material.png", color=0xffffffff}},
|
||||
bounding_boxes = {
|
||||
{-0.3, -0.5, -0.3, 0.3, 0.175, 0.3}
|
||||
}
|
||||
},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
seat_data = {
|
||||
@ -143,14 +151,20 @@ multidecor.register.register_seat("armchair_with_wooden_legs", {
|
||||
material = "wood",
|
||||
description = "Armchair with wooden legs",
|
||||
inventory_image = "multidecor_armchair_with_wooden_legs_inv.png",
|
||||
paramtype2 = "colorfacedir",
|
||||
mesh = "multidecor_armchair_with_wooden_legs.b3d",
|
||||
tiles = {"multidecor_pine_wood2.png", "multidecor_wool_material.png", "multidecor_wool_material.png"},
|
||||
tiles = {
|
||||
{name="multidecor_pine_wood2.png", color=0xffffffff},
|
||||
"multidecor_wool_material.png",
|
||||
"multidecor_wool_material.png"
|
||||
},
|
||||
bounding_boxes = {
|
||||
{-0.3, -0.5, -0.45, 0.3, 0.15, 0.3},
|
||||
{-0.5, -0.5, -0.45, -0.3, 0.375, 0.3},
|
||||
{0.3, -0.5, -0.45, 0.5, 0.375, 0.3},
|
||||
{-0.5, -0.5, 0.3, 0.5, 0.85, 0.5}
|
||||
}
|
||||
},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
seat_data = {
|
||||
@ -172,14 +186,16 @@ multidecor.register.register_seat("sofa", {
|
||||
style = "modern",
|
||||
material = "plastic",
|
||||
description = "Sofa",
|
||||
paramtype2 = "colorfacedir",
|
||||
mesh = "multidecor_modern_sofa.b3d",
|
||||
tiles = {"multidecor_modern_sofa.png", "multidecor_cloth.png"},
|
||||
tiles = {{name="multidecor_modern_sofa.png", color=0xffffffff}, "multidecor_cloth.png"},
|
||||
bounding_boxes = {
|
||||
{-0.4, -0.5, -0.325, 0.4, 0, 0.225},
|
||||
{-0.5, -0.5, -0.325, -0.4, 0.2, 0.225},
|
||||
{0.4, -0.5, -0.325, 0.5, 0.2, 0.225},
|
||||
{-0.5, -0.5, 0.225, 0.5, 0.6, 0.5}
|
||||
},
|
||||
is_colorable = true,
|
||||
callbacks = {
|
||||
on_construct = function(pos)
|
||||
multidecor.connecting.update_adjacent_nodes_connection(pos, "directional")
|
||||
|
@ -100,9 +100,56 @@ minetest.register_craftitem(":multidecor:plaster_lump", {
|
||||
inventory_image = "multidecor_plaster_lump.png"
|
||||
})
|
||||
|
||||
|
||||
minetest.register_tool(":multidecor:paint_brush", {
|
||||
description = "Paint Brush (for painting armchairs, curtains, beds, chairs and etc)",
|
||||
inventory_image = "multidecor_paint_brush.png"
|
||||
inventory_image = "multidecor_paint_brush.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = vector.add(pointed_thing.above, pointed_thing.under) / 2
|
||||
local def = hlpfuncs.ndef(pos)
|
||||
|
||||
if not def.is_colorable then -- not colorable
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
local mul = def.paramtype2 == "colorwallmounted" and 8 or 32
|
||||
local palette_index = math.floor(node.param2 / mul)
|
||||
|
||||
if palette_index ~= 0 then -- already colored
|
||||
return
|
||||
end
|
||||
|
||||
local inv = placer:get_inventory()
|
||||
local dye_index = placer:get_wield_index()
|
||||
local next_itemstack = inv:get_stack("main", dye_index+1)
|
||||
local next_itemname = next_itemstack:get_name()
|
||||
|
||||
if not next_itemstack or next_itemstack:is_empty() or
|
||||
minetest.get_item_group(next_itemname, "dye") ~= 1 then -- no any dye next to the brush or the slot is empty
|
||||
return
|
||||
end
|
||||
|
||||
local index, dye_color
|
||||
|
||||
for colorindex, colorname in ipairs(multidecor.colors) do
|
||||
if minetest.get_item_group(next_itemname, "color_" .. colorname) == 1 then
|
||||
index = colorindex - 1
|
||||
dye_color = colorname
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not dye_color then return end -- not supported color
|
||||
|
||||
local rot = node.param2 % mul
|
||||
minetest.swap_node(pos, {name=node.name, param2=index*mul+rot})
|
||||
|
||||
next_itemstack:take_item()
|
||||
inv:set_stack("main", dye_index+1, next_itemstack)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_tool(":multidecor:spatula", {
|
||||
|
@ -76,11 +76,13 @@ multidecor.register.register_light("silvered_desk_lamp_off", {
|
||||
style = "modern",
|
||||
material = "metal",
|
||||
description = "Silvered Desk Lamp",
|
||||
paramtype2 = "colorfacedir",
|
||||
visual_scale = 0.4,
|
||||
use_texture_alpha = "blend",
|
||||
mesh = "multidecor_silvered_desk_lamp.b3d",
|
||||
tiles = {"multidecor_silver_material.png", "multidecor_silvered_lampshade.png"},
|
||||
tiles = {{name="multidecor_silver_material.png", color=0xffffffff}, "multidecor_silvered_lampshade.png"},
|
||||
bounding_boxes = {{-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}},
|
||||
is_colorable = true
|
||||
},
|
||||
{
|
||||
swap_light = {
|
||||
@ -116,10 +118,16 @@ multidecor.register.register_light("plastic_desk_lamp_off", {
|
||||
style = "modern",
|
||||
material = "plastic",
|
||||
description = "Plastic Desk Lamp",
|
||||
paramtype2 = "colorfacedir",
|
||||
visual_scale = 0.4,
|
||||
use_texture_alpha = "blend",
|
||||
mesh = "multidecor_plastic_desk_lamp.b3d",
|
||||
tiles = {"multidecor_plastic_material.png", "multidecor_plastic_desk_lampshade.png", "multidecor_bulb_surf.png"},
|
||||
tiles = {
|
||||
{name="multidecor_plastic_material.png", color=0xffffffff},
|
||||
"multidecor_plastic_desk_lampshade.png",
|
||||
{name="multidecor_bulb_surf.png", color=0xffffffff}
|
||||
},
|
||||
is_colorable = true,
|
||||
bounding_boxes = {{-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}},
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user