Rewritten sitting system, added sofas of different sizes and added glass vase
parent
4c9f8daeee
commit
e306621767
215
chairs.lua
215
chairs.lua
|
@ -1,21 +1,71 @@
|
|||
local is_chair_busy_by = {}
|
||||
local chairs = {}
|
||||
function chairs.sit_player(player, node, pos, player_anim)
|
||||
local meta = player:get_meta()
|
||||
|
||||
function chairs.attach_player_to_node (attacher, node, pos)
|
||||
attacher:set_pos(pos)
|
||||
attacher:set_physics_override({speed=0, jump=0})
|
||||
attacher:get_meta():set_string("is_attached", minetest.serialize({node, pos, old_phys_over = attacher:get_physics_override()}))
|
||||
end
|
||||
|
||||
function chairs.disattach_player_from_node(disattacher)
|
||||
local meta = disattacher.get_meta():get_string("is_attached")
|
||||
local phys_over = meta.old_phys_over
|
||||
attacher:set_physics_override({phys_over.speed, phys_over.jump})
|
||||
meta:set_string("is_attached", "")
|
||||
end
|
||||
|
||||
-- "seats" table should contain: {[1]={is_busy={bool, player_obj}, pos=table}, [2]={is_busy={bool, player_obj}, pos=table}, ... [n]}
|
||||
function chairs.sit_player(sitter, node, sitter_anim)
|
||||
--[[local player_meta = minetest.deserialize(sitter:get_meta():get_string("is_attached"))
|
||||
if player_meta == "" or player_meta == nil then
|
||||
return
|
||||
end]]
|
||||
local meta = minetest.get_meta(pos)
|
||||
local seats = minetest.deserialize(meta:get_string("seats_range"))
|
||||
|
||||
meta:set_string("attached_to", minetest.serialize({node, pos, player:get_player_name(), player:get_physics_override(), player:get_animation(), player_anim}))
|
||||
player:set_pos(pos)
|
||||
|
||||
if player_anim ~= nil then
|
||||
--minetest.debug("TRUE")
|
||||
player:set_animation(player_anim)
|
||||
for seat_num, seat_data in pairs(seats) do
|
||||
if seat_data.is_busy.bool == false then
|
||||
seat_data.is_busy.bool = true
|
||||
seat_data.is_busy.player_obj = sitter
|
||||
chairs.attach_player_to_node(sitter, node, seat_data.pos)
|
||||
if #sitter_anim > 1 then
|
||||
local random_anim = math.random(1, #sitter_anim)
|
||||
sitter:set_animation(sitter_anim[random_anim])
|
||||
else
|
||||
sitter:set_animation(sitter_anim[1])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if seat_num == #seats and seat_data.is_busy.bool == true then
|
||||
minetest.chat_send_player(sitter:get_player_name(), "All seats are busy!")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
player:set_physics_override({speed=0, jump=0})
|
||||
end
|
||||
|
||||
function chairs.standup_player(player)
|
||||
local player_meta = minetest.deserialize(player:get_meta():get_string("is_attached"))
|
||||
if player_meta ~= "" or player_meta ~= nil then
|
||||
local seats = minetest.deserialize(minetest.get_meta():get_string("seats_range"))
|
||||
|
||||
for seat_num, seat_data in pairs(seats) do
|
||||
if seat_data.is_busy.player_obj == player then
|
||||
seat_data.is_busy.bool = false
|
||||
seat_data.is_busy.player_obj = nil
|
||||
|
||||
chairs.disattach_player_from_node(player)
|
||||
player:set_animation({x=1,y=1}, frame_speed=15, frame_blend=0))
|
||||
end
|
||||
end
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--[[function chairs.standup_player(player)
|
||||
local meta = player:get_meta()
|
||||
local is_attached_to = minetest.deserialize(meta:get_string("attached_to"))
|
||||
--minetest.debug(dump(is_attached_to[4]))
|
||||
|
@ -23,7 +73,7 @@ function chairs.standup_player(player)
|
|||
player:set_physics_override(is_attached_to[4])
|
||||
|
||||
meta:set_string("attached_to", "")
|
||||
end
|
||||
end]]
|
||||
|
||||
|
||||
|
||||
|
@ -53,19 +103,29 @@ minetest.register_node("luxury_decor:kitchen_wooden_chair", {
|
|||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("seats_range", minetest.serialize({[1] = {is_busy={bool=false, player_obj=nil}, pos = {x = pos.x, y = pos.y, z = pos.z}}}))
|
||||
end,
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
local meta = clicker:get_meta()
|
||||
local is_attached_to = minetest.deserialize(meta:get_string("attached_to"))
|
||||
local is_attached = minetest.deserialize(meta:get_string("is_attached"))
|
||||
--minetest.debug(dump(is_attached_to))
|
||||
if is_attached_to == nil or is_attached_to == "" then
|
||||
chairs.sit_player(clicker, {pos, node.name, node.param1, node.param2}, {x=pos.x, y=pos.y+0.4, z=pos.z}, {x=81, y=81})
|
||||
if is_attached == nil or is_attached == "" then
|
||||
chairs.sit_player(clicker, node, {{{x=81, y=81}, frame_speed=15, frame_blend=0}})
|
||||
|
||||
elseif clicker:get_player_name() ~= is_attached_to[3] and is_attached_to ~= nil then
|
||||
elseif is_attached ~= nil or is_attached ~= "" then
|
||||
chairs.standup_player(clicker)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
--[[elseif clicker:get_player_name() ~= is_attached_to[3] and is_attached_to ~= nil then
|
||||
minetest.chat_send_player(clicker:get_player_name(), "This bed is already busy!")
|
||||
elseif clicker:get_player_name() == is_attached_to[3] and pos == is_attached_to[1][1] and minetest.get_node(pos).name == is_attached_to[1][2] then
|
||||
minetest.debug("AAAAAAAAAAAAAAAAAAAAAAA")
|
||||
chairs.standup_player(clicker)
|
||||
end
|
||||
end]]
|
||||
--[[if is_attached_to ~= nil then
|
||||
minetest.debug(clicker:get_player_name())
|
||||
minetest.debug(is_attached_to[3])
|
||||
|
@ -82,8 +142,7 @@ minetest.register_node("luxury_decor:kitchen_wooden_chair", {
|
|||
clicker:set_physics_override({speed=1.0})
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
end]]
|
||||
|
||||
end
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
@ -114,24 +173,21 @@ minetest.register_node("luxury_decor:luxury_wooden_chair_with_cushion", {
|
|||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("seats_range", minetest.serialize({[1] = {is_busy={bool=false, player_obj=nil}, pos = {x = pos.x, y = pos.y+0.2, z = pos.z}}}))
|
||||
end,
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
local meta = clicker:get_meta()
|
||||
local is_attached_to = minetest.deserialize(meta:get_string("attached_to"))
|
||||
if is_attached_to == nil or is_attached_to == "" then
|
||||
chairs.sit_player(clicker, {pos, node.name, node.param1, node.param2}, {x=pos.x, y=pos.y+0.45, z=pos.z}, {x=81, y=81})
|
||||
local is_attached = minetest.deserialize(meta:get_string("is_attached"))
|
||||
--minetest.debug(dump(is_attached_to))
|
||||
if is_attached == nil or is_attached == "" then
|
||||
chairs.sit_player(clicker, node, {{{x=81, y=81}, frame_speed=15, frame_blend=0}})
|
||||
|
||||
elseif clicker:get_player_name() ~= is_attached_to[3] and is_attached_to ~= nil then
|
||||
minetest.chat_send_player(clicker:get_player_name(), "This bed is already busy!")
|
||||
elseif clicker:get_player_name() == is_attached_to[3] and pos == is_attached_to[1][1] and minetest.get_node(pos).name == is_attached_to[1][2] then
|
||||
elseif is_attached ~= nil or is_attached ~= "" then
|
||||
chairs.standup_player(clicker)
|
||||
end
|
||||
|
||||
--[[if minetest.get_node(pos).name ~= node.name then
|
||||
is_chair_busy_by = nil
|
||||
clicker:set_physics_override({speed=1.0})
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
end]]
|
||||
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -164,36 +220,21 @@ minetest.register_node("luxury_decor:decorative_wooden_chair", {
|
|||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("seats_range", minetest.serialize({[1] = {is_busy={bool=false, player_obj=nil}, pos = {x = pos.x, y = pos.y+0.2, z = pos.z}}}))
|
||||
end,
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
local meta = clicker:get_meta()
|
||||
local is_attached_to = minetest.deserialize(meta:get_string("attached_to"))
|
||||
local is_attached = minetest.deserialize(meta:get_string("is_attached"))
|
||||
--minetest.debug(dump(is_attached_to))
|
||||
if is_attached_to == nil or is_attached_to == "" then
|
||||
chairs.sit_player(clicker, {pos, node.name, node.param1, node.param2}, {x=pos.x, y=pos.y+0.5, z=pos.z}, {x=81, y=81})
|
||||
if is_attached == nil or is_attached == "" then
|
||||
chairs.sit_player(clicker, node, {{{x=81, y=81}, frame_speed=15, frame_blend=0}})
|
||||
|
||||
elseif clicker:get_player_name() ~= is_attached_to[3] and is_attached_to ~= nil then
|
||||
minetest.chat_send_player(clicker:get_player_name(), "This bed is already busy!")
|
||||
elseif clicker:get_player_name() == is_attached_to[3] and pos == is_attached_to[1][1] and minetest.get_node(pos).name == is_attached_to[1][2] then
|
||||
minetest.debug("AAAAAAAAAAAAAAAAAAAAAAA")
|
||||
elseif is_attached ~= nil or is_attached ~= "" then
|
||||
chairs.standup_player(clicker)
|
||||
|
||||
end
|
||||
--[[if is_attached_to ~= nil then
|
||||
minetest.debug(clicker:get_player_name())
|
||||
minetest.debug(is_attached_to[3])
|
||||
minetest.debug(dump(pos))
|
||||
minetest.debug(dump(is_attached_to[1][1]))
|
||||
minetest.debug(minetest.get_node(pos).name)
|
||||
minetest.debug(is_attached_to[1][2])
|
||||
|
||||
end]]
|
||||
|
||||
|
||||
--[[if minetest.get_node(pos).name ~= node.name then
|
||||
is_chair_busy_by = nil
|
||||
clicker:set_physics_override({speed=1.0})
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
end]]
|
||||
|
||||
end
|
||||
})
|
||||
minetest.register_node("luxury_decor:round_wooden_chair", {
|
||||
|
@ -223,40 +264,45 @@ minetest.register_node("luxury_decor:round_wooden_chair", {
|
|||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("seats_range", minetest.serialize({[1] = {is_busy={bool=false, player_obj=nil}, pos = {x = pos.x, y = pos.y+0.2, z = pos.z}}}))
|
||||
end,
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
local meta = clicker:get_meta()
|
||||
local is_attached_to = minetest.deserialize(meta:get_string("attached_to"))
|
||||
local is_attached = minetest.deserialize(meta:get_string("is_attached"))
|
||||
--minetest.debug(dump(is_attached_to))
|
||||
if is_attached_to == nil or is_attached_to == "" then
|
||||
chairs.sit_player(clicker, {pos, node.name, node.param1, node.param2}, {x=pos.x, y=pos.y+0.4, z=pos.z}, {x=81, y=81})
|
||||
if is_attached == nil or is_attached == "" then
|
||||
chairs.sit_player(clicker, node, {{{x=81, y=81}, frame_speed=15, frame_blend=0}})
|
||||
|
||||
elseif clicker:get_player_name() ~= is_attached_to[3] and is_attached_to ~= nil then
|
||||
minetest.chat_send_player(clicker:get_player_name(), "This bed is already busy!")
|
||||
elseif clicker:get_player_name() == is_attached_to[3] and pos == is_attached_to[1][1] and minetest.get_node(pos).name == is_attached_to[1][2] then
|
||||
minetest.debug("AAAAAAAAAAAAAAAAAAAAAAA")
|
||||
elseif is_attached ~= nil or is_attached ~= "" then
|
||||
chairs.standup_player(clicker)
|
||||
|
||||
end
|
||||
--[[if is_attached_to ~= nil then
|
||||
minetest.debug(clicker:get_player_name())
|
||||
minetest.debug(is_attached_to[3])
|
||||
minetest.debug(dump(pos))
|
||||
minetest.debug(dump(is_attached_to[1][1]))
|
||||
minetest.debug(minetest.get_node(pos).name)
|
||||
minetest.debug(is_attached_to[1][2])
|
||||
|
||||
end]]
|
||||
|
||||
|
||||
--[[if minetest.get_node(pos).name ~= node.name then
|
||||
is_chair_busy_by = nil
|
||||
clicker:set_physics_override({speed=1.0})
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
end]]
|
||||
|
||||
end
|
||||
})
|
||||
minetest.register_on_dignode(function (pos, oldnode, digger)
|
||||
local node = minetest.get_node(pos)
|
||||
local seats = minetest.get_meta(pos):get_string("seats_range")
|
||||
for seat_num, seat_data in pairs(seats) do
|
||||
if seat_data.is_busy.player_obj ~= nil then
|
||||
chairs.standup_player(seat_data.is_busy.player_obj)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function (player)
|
||||
local is_attached = player:get_meta():get_string("is_attached")
|
||||
|
||||
if is_attached ~= "" or is_attached ~= nil then
|
||||
local is_attached_to = is_attached.node
|
||||
chairs.standup_player(player)
|
||||
chairs.sit_player(player, is_attached_to, {{{x=81,y=81}, frame_speed=15, frame_blend=0}})
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
--[[local node = minetest.get_node(pos)
|
||||
local objects = minetest.get_objects_inside_radius({x = pos.x - 0.5, y = pos.y, z = pos.z - 0.5}, 1)
|
||||
for _, obj in ipairs(objects) do
|
||||
if obj:is_player() then
|
||||
|
@ -274,12 +320,7 @@ minetest.register_on_joinplayer(function (player)
|
|||
local meta = minetest.deserialize(player:get_meta():get_string("attached_to"))
|
||||
if meta ~= nil and meta ~= "" then
|
||||
local pos = player:get_pos()
|
||||
--minetest.debug(minetest.get_node({x=pos.x, y=pos.y, z = pos.z}).name)
|
||||
--minetest.debug(minetest.get_node(meta[1][1]).name)
|
||||
--minetest.debug(dump(meta[1][1]))
|
||||
--[[local is_action_executed = nil
|
||||
minetest.register_globalstep(function (dtime)
|
||||
local name = minetest.get_node(meta[1][1]).name]]
|
||||
|
||||
minetest.after(0, function()
|
||||
if minetest.get_node(meta[1][1]).name == meta[1][2] then
|
||||
--minetest.debug("DDDDDD!")
|
||||
|
@ -291,4 +332,4 @@ minetest.register_on_joinplayer(function (player)
|
|||
|
||||
|
||||
end
|
||||
end)
|
||||
end)]]
|
||||
|
|
2
init.lua
2
init.lua
|
@ -1,8 +1,10 @@
|
|||
local modpath = minetest.get_modpath("luxury_decor")
|
||||
|
||||
dofile(modpath.."/bedroom.lua")
|
||||
dofile(modpath.."/chairs.lua")
|
||||
dofile(modpath.."/tables.lua")
|
||||
dofile(modpath.."/kitchen_furniture.lua")
|
||||
dofile(modpath.."/lighting.lua")
|
||||
dofile(modpath.."/music.lua")
|
||||
dofile(modpath.."/redecorating.lua")
|
||||
dofile(modpath.."/shelves.lua")
|
||||
|
|
67
lighting.lua
67
lighting.lua
|
@ -40,7 +40,7 @@ minetest.register_node("luxury_decor:luxury_desk_lamp_on", {
|
|||
groups = {choppy = 2.5, not_in_creative_inventory=1},
|
||||
drawtype = "mesh",
|
||||
drop = "luxury_decor:luxury_desk_lamp_off",
|
||||
light_source = 10,
|
||||
light_source = 7,
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -94,3 +94,68 @@ minetest.register_node("luxury_decor:iron_chandelier", {
|
|||
sounds = default.node_sound_wood_defaults()
|
||||
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("luxury_decor:wall_glass_lamp_off", {
|
||||
description = "Wall Glass Lamp",
|
||||
visual_scale = 0.5,
|
||||
mesh = "wall_glass_lamp.obj",
|
||||
inventory_image = "wall_glass_lamp_inv.png",
|
||||
tiles = {"wall_glass_lamp.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {choppy = 2.5},
|
||||
drawtype = "mesh",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
--[[{-0.65, -0.3, -1.46, 0.65, 1.4, -1.66},
|
||||
{-0.65, -0.3, 0.46, 0.65, 1.4, 0.66}]]
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, {name="luxury_decor:wall_glass_lamp_on"})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("luxury_decor:wall_glass_lamp_on", {
|
||||
description = "Wall Glass Lamp",
|
||||
visual_scale = 0.5,
|
||||
mesh = "wall_glass_lamp.obj",
|
||||
inventory_image = "wall_glass_lamp_inv.png",
|
||||
tiles = {"wall_glass_lamp.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {choppy = 2.5, not_in_creative_inventory=1},
|
||||
drawtype = "mesh",
|
||||
drop = "luxury_decor:luxury_desk_lamp_off",
|
||||
light_source = 11,
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
--[[{-0.65, -0.3, -1.46, 0.65, 1.4, -1.66},
|
||||
{-0.65, -0.3, 0.46, 0.65, 1.4, 0.66}]]
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, {name="luxury_decor:wal_glass_lamp_off"})
|
||||
end
|
||||
})
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
local flowers_list = {
|
||||
name = {"rose", "tulip_black", "tulip", "geranium"},
|
||||
desc = {"Rose", "Tulip Black", "Tulip", "Geranium"}
|
||||
}
|
||||
|
||||
minetest.register_node("luxury_decor:glass_vase", {
|
||||
description = "Glass Vase",
|
||||
visual_scale = 0.5,
|
||||
mesh = "glass_vase.obj",
|
||||
tiles = {"glass_vase.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 1.5},
|
||||
drawtype = "mesh",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
--[[{-0.65, -0.3, -1.46, 0.65, 1.4, -1.66},
|
||||
{-0.65, -0.3, 0.46, 0.65, 1.4, 0.66}]]
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
for _, flower in ipairs(flowers_list.name) do
|
||||
if "flowers:" .. flower == node.name then
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:glass_vase_with_"..flower)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
for ind, f in ipairs(flowers_list.name) do
|
||||
minetest.register_node("luxury_decor:glass_vase_with_"..f, {
|
||||
description = "Glass Vase With " .. flowers_list.desc[ind],
|
||||
visual_scale = 0.5,
|
||||
mesh = "glass_vase.obj",
|
||||
tiles = {"glass_vase.png^flowers_"..f..".png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = {"luxury_decor:glass_vase", "luxury_decor:glass_vase_with_"..f},
|
||||
groups = {choppy = 1.5},
|
||||
drawtype = "mesh",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
--[[{-0.65, -0.3, -1.46, 0.65, 1.4, -1.66},
|
||||
{-0.65, -0.3, 0.46, 0.65, 1.4, 0.66}]]
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:glass_vase")
|
||||
|
||||
itemstack:add_item("flowers:" .. string.sub(node.name, 29))
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
local sofas_rgb_colors = {
|
||||
["black"] = "#000000",
|
||||
["red"] = "#FF0000",
|
||||
["green"] = "#00FF00",
|
||||
["white"] = "#FFFFFF",
|
||||
["blue"] = "#0000FF",
|
||||
["yellow"] = "#FFFF00",
|
||||
["magenta"] = "#FF00FF",
|
||||
["cyan"] = "#00FFFF",
|
||||
["dark_green"] = "#008000",
|
||||
["dark_grey"] = "#808080",
|
||||
["grey"] = "#COCOCO",
|
||||
["brown"] = "#A52A2A",
|
||||
["orange"] = "#FF4500",
|
||||
["pink"] = "#F08080",
|
||||
["violet"] = "#4B0082"
|
||||
}
|
||||
|
||||
local sofas_collision_boxes = {
|
||||
["small"] = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
},
|
||||
["middle"] = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||
},
|
||||
["long"] = {
|
||||
{-0.5, -0.5, -0.5, 2.5, 0.5, 0.5}
|
||||
},
|
||||
["corner1"] = {
|
||||
{-0.5, -0.5, -0.5, 2.5, 0.5, 0.5},
|
||||
{-0.5, -0.5, -1.5, 0.5, 0.5, -0.5}
|
||||
},
|
||||
["corner2"] = {
|
||||
{-0.5, -0.5, -0.5, 2.5, 0.5, 0.5},
|
||||
{1.5, -0.5, -1.5, 2.5, 0.5, 0.5}
|
||||
}
|
||||
}
|
||||
|
||||
for ind, sofa_type in pairs({"small", "middle", "long", "corner1", "corner2"}) do
|
||||
for color, rgb_code in pairs(sofas_rgb_colors) do
|
||||
for _, pillow_color in ipairs({"red", "green" , "blue", "yellow", "violet"}) do
|
||||
minetest.register_node("luxury_decor:simple_".. color .. "_" .. sofa_type .. "_sofa_with_" .. pillow_color .. "_pillows", {
|
||||
description = minetest.colorize(sofas_rgb_colors[color], "Simple " .. string.upper(color) .. " " .. string.upper(sofa_type) .. " Sofa"),
|
||||
visual_scale = 0.5,
|
||||
mesh = "simple_"..sofa_type.."_sofa.obj",
|
||||
tiles = {"simple_sofa.png^(simple_sofa_2.png^[colorize:" .. rgb_code .. ")^(simple_sofa_3.png^[colorize:" .. pillow_color .. ")"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 2.5},
|
||||
drawtype = "mesh",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = sofas_collision_boxes[sofa_type]
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = sofas_collision_boxes[sofa_type]
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
if string.find(itemstack:get_name(), "dye:") then
|
||||
local get_player_contr = clicker:get_player_control()
|
||||
|
||||
if get_player_contr.sneak then
|
||||
for _, p_color in ipairs({"red", "green", "blue", "yellow", "violet"}) do
|
||||
if itemstack:get_name() == "dye:" .. p_color then
|
||||
itemstack:take_item()
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:simple_" .. color .. "_" .. sofa_type .. "_sofa_with_" .. p_color .. "_pillows")
|
||||
end
|
||||
end
|
||||
else
|
||||
for color2, rgb_code in pairs(sofas_rgb_colors) do
|
||||
if "dye:" .. color2 == itemstack:get_name() then
|
||||
itemstack:take_item()
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:simple_" .. color2 .. "_" .. sofa_type .. "_sofa_with_" .. pillow_color .. "_pillows")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif string.find(itemstack:get_name(), "luxury_decor:simple_" .. color .. "_small_sofa_with_" .. pillow_color .. "_pillows") then
|
||||
local pos2 = clicker:get_pos()
|
||||
if pointed_thing.above.x ~= pointed_thing.under.x and pos2.x ~= pos.x and string.find(node.name, "_long_") == nil then
|
||||
local sofas_types_list = {"small", "middle", "long"}
|
||||
|
||||
itemstack:take_item()
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:simple_" .. color .. "_" .. sofas_types_list[ind+1] .. "_sofa_with_" .. pillow_color .. "_pillows")
|
||||
|
||||
elseif pointed_thing.above.z ~= pointed_thing.under.z and string.find(node.name, "_long_") ~= nil then
|
||||
local dir = clicker:get_look_dir()
|
||||
if dir.x > 0 then
|
||||
itemstack:take_item()
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:simple_" .. color .. "_corner1_sofa_with_" .. pillow_color .. "_pillows")
|
||||
elseif dir.x < 0 then
|
||||
itemstack:take_item()
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:simple_" .. color .. "_corner2_sofa_with_" .. pillow_color .. "_pillows")
|
||||
end
|
||||
end
|
||||
else
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--[[for _, color in ipairs(sofas_rgb_colors) do
|
||||
if color == "red" or color == "green" or color == "blue" or color == "yellow" or color == "violet" then
|
||||
for _, sofa_type in ipairs({"small", "middle", "long", "corner1", "corner2"}) do
|
||||
for _, pillow_color in ipairs({"red", "green", "blue", "yellow", "violet"}) do
|
||||
minetest.register_node("luxury_decor:simple_".. color .. "_" .. sofa_type .. "_sofa", {
|
||||
description = minetest.colorize(sofas_rgb_colors[color], "Simple " .. string.upper(color) .. " " .. string.upper(sofa_type) .. " Sofa",
|
||||
visual_scale = 0.5,
|
||||
mesh = "simple_"..sofa_type.."_sofa.obj",
|
||||
tiles = {""})
|
||||
})]]
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -10,4 +10,4 @@ Ke 0.000000 0.000000 0.000000
|
|||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd /home/andrey/opt/minetest/mods/luxury_decor/textures/simple_armchair.png
|
||||
map_Kd /home/andrey/opt/minetest/mods/luxury_decor/textures/simple_sofa.png
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
39
music.lua
39
music.lua
|
@ -4,7 +4,6 @@ minetest.register_node("luxury_decor:grand_piano", {
|
|||
mesh = "grand_piano.obj",
|
||||
inventory_image = "grand_piano_inv.png",
|
||||
tiles = {"grand_piano.png"},
|
||||
--inventory_image = "simple_wooden_table_inv.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 3},
|
||||
|
@ -23,5 +22,41 @@ minetest.register_node("luxury_decor:grand_piano", {
|
|||
{-1.4, -0.5, -1.4, 1.4, 0.4, 1.4}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults()
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:grand_piano_opened")
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("luxury_decor:grand_piano_opened", {
|
||||
description = "Grand Piano",
|
||||
visual_scale = 0.5,
|
||||
mesh = "grand_piano_opened.obj",
|
||||
inventory_image = "grand_piano_opened_inv.png",
|
||||
tiles = {"grand_piano.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 3, not_in_creative_inventory=1},
|
||||
drawtype = "mesh",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-1.4, -0.5, -1.4, 1.4, 0.4, 1.4},
|
||||
--[[{-0.65, -0.3, -1.46, 0.65, 1.4, -1.66},
|
||||
{-0.65, -0.3, 0.46, 0.65, 1.4, 0.66}]]
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-1.4, -0.5, -1.4, 1.4, 0.4, 1.4}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos, "luxury_decor:grand_piano")
|
||||
end
|
||||
})
|
||||
|
|
|
@ -10,6 +10,12 @@ minetest.register_node("luxury_decor:laminate", {
|
|||
{-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
})
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 182 B |
Binary file not shown.
Before Width: | Height: | Size: 545 B |
Loading…
Reference in New Issue