Bugfix Release 1.1.2. The cabinet sink water sound is now looped, fixed the three level rack formspec
This commit is contained in:
parent
0087608bcc
commit
701a85bd10
@ -1,10 +1,11 @@
|
||||
# MultiDecor 1.1.1. Modpack For Minetest.
|
||||
# MultiDecor 1.1.2. Modpack For Minetest.
|
||||
![logo](https://user-images.githubusercontent.com/25750346/185758916-9acf0ba5-5953-484f-825c-347c6ca7cddd.png)
|
||||
|
||||
## Description
|
||||
This modpack adds various detailed furniture components, decorations and exterior stuff with various designs and styles of each epoch. Inspired by Homedecor and based on my abandoned Luxury Decor. Currently it contains the decor stuff only of "modern" style. A simple cheap style without any quaintness and luxury. In future there will be added still few sorts of that: baroque, high-tech, classic and royal.
|
||||
|
||||
## Changelog List
|
||||
#### [17.08.23] Release 1.1.2.
|
||||
#### [16.08.23] Release 1.1.1.
|
||||
#### [09.03.23] Release 1.1.0.
|
||||
#### [22.01.23] Release 1.0.5.
|
||||
|
@ -38,10 +38,21 @@ function multidecor.register.register_type(type_name)
|
||||
table.insert(multidecor.register.supported_types, type_name)
|
||||
end
|
||||
|
||||
-- Checks whether type with 'type_name' name is registered
|
||||
function multidecor.register.check_for_type(type_name)
|
||||
for _, type in ipairs(multidecor.register.supported_types) do
|
||||
if type == type_name then
|
||||
-- Checks whether the given 'name' is in the category with 'category_id' (whether it is registered there).
|
||||
-- 'category_id': '0' - types, '1' - styles, '2' - materials
|
||||
function multidecor.register.category_contains(name, category_id)
|
||||
local lookup_t
|
||||
|
||||
if category_id == 0 then
|
||||
lookup_t = multidecor.register.supported_types
|
||||
elseif category_id == 1 then
|
||||
lookup_t = multidecor.register.supported_styles
|
||||
elseif category_id == 2 then
|
||||
lookup_t = multidecor.register.supported_materials
|
||||
end
|
||||
|
||||
for _, cat_name in ipairs(lookup_t) do
|
||||
if cat_name == name then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -49,15 +60,37 @@ function multidecor.register.check_for_type(type_name)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Checks whether style with 'style_name' name is registered
|
||||
function multidecor.register.check_for_style(style_name)
|
||||
for _, style in ipairs(multidecor.register.supported_styles) do
|
||||
if style == style_name then
|
||||
return true
|
||||
-- Returns the name from category with 'category_id' for the node with 'name' name.
|
||||
-- 'category_id': '0' - types, '1' - styles, '2' - materials
|
||||
function multidecor.register.get_name_from_category(name, category_id)
|
||||
local def = minetest.registered_nodes[name]
|
||||
|
||||
local ret_cat = ""
|
||||
|
||||
local lookup_t
|
||||
|
||||
if category_id == 0 then
|
||||
lookup_t = multidecor.register.supported_types
|
||||
elseif category_id == 1 then
|
||||
lookup_t = multidecor.register.supported_styles
|
||||
elseif category_id == 2 then
|
||||
lookup_t = multidecor.register.supported_materials
|
||||
end
|
||||
|
||||
for _, cat in ipairs(lookup_t) do
|
||||
if def.groups[cat] then
|
||||
ret_cat = cat
|
||||
end
|
||||
end
|
||||
|
||||
return ret_cat
|
||||
end
|
||||
|
||||
return false
|
||||
function multidecor.register.build_description(name, base_desc)
|
||||
local style = multidecor.register.get_name_from_category(name, 1)
|
||||
local material = multidecor.register.get_name_from_category(name, 2)
|
||||
|
||||
return base_desc .. "\nStyle: " .. style .. (material ~= "" and "\nMaterial: " .. material or "")
|
||||
end
|
||||
|
||||
--[[def:
|
||||
@ -101,8 +134,8 @@ end
|
||||
function multidecor.register.register_furniture_unit(name, def, craft_def)
|
||||
local f_def = {}
|
||||
|
||||
assert(multidecor.register.check_for_type(def.type), "The type with a name \"" .. def.type .. "\" is not registered!")
|
||||
assert(multidecor.register.check_for_style(def.style), "The style with a name \"" .. def.style .. "\" is not registered!")
|
||||
assert(multidecor.register.category_contains(def.type, 0), "The type with a name \"" .. def.type .. "\" is not registered!")
|
||||
assert(multidecor.register.category_contains(def.style, 1), "The style with a name \"" .. def.style .. "\" is not registered!")
|
||||
|
||||
f_def.description = def.description
|
||||
f_def.visual_scale = def.visual_scale or 0.4
|
||||
@ -139,7 +172,7 @@ function multidecor.register.register_furniture_unit(name, def, craft_def)
|
||||
elseif def.material == "plastic" then
|
||||
f_def.groups.snappy = 1.5
|
||||
end
|
||||
|
||||
|
||||
f_def.description = f_def.description .. "\nStyle: " .. def.style .. (def.material and "\nMaterial: " .. def.material or "")
|
||||
if def.bounding_boxes then
|
||||
if f_def.drawtype == "nodebox" then
|
||||
@ -327,7 +360,7 @@ end
|
||||
function multidecor.register.register_garniture(def)
|
||||
local cmn_def = {}
|
||||
|
||||
assert(multidecor.register.check_for_style(def.style), "The style with a name \"" .. def.style .. "\" is not registered!")
|
||||
assert(multidecor.register.category_contains(def.style, 1), "The style with a name \"" .. def.style .. "\" is not registered!")
|
||||
|
||||
cmn_def.style = def.style
|
||||
cmn_def.material = def.material
|
||||
|
@ -77,6 +77,50 @@ function multidecor.shelves.rotate_shelf_bbox(obj)
|
||||
})
|
||||
end
|
||||
|
||||
-- Builds formspec string for the shelf with 'shelf_num' number. The inventory can be detached and node.
|
||||
function multidecor.shelves.build_formspec(pos, common_name, data, shelf_num, detached)
|
||||
if detached == nil then
|
||||
detached = true
|
||||
end
|
||||
|
||||
local inv_name = multidecor.helpers.build_name_from_tmp(common_name, "inv", shelf_num, pos)
|
||||
local list_name = multidecor.helpers.build_name_from_tmp(common_name, "list", shelf_num, pos)
|
||||
local list_type = data.invlist_type or "storage"
|
||||
|
||||
local padding = 0.25
|
||||
local list_w = list_type == "storage" and data.inv_size.w or 1
|
||||
local list_h = list_type == "storage" and data.inv_size.h or 1
|
||||
local width = list_w > 8 and list_w or 8
|
||||
local fs_size = {
|
||||
w = width+1+(width-1)*padding,
|
||||
h = list_h+5.5+(list_h-1)*padding+3*padding
|
||||
}
|
||||
fs_size.h = list_type == "cooker" and fs_size.h + 1 or fs_size.h
|
||||
local player_list_y = list_h+1+(list_h-1)*padding + (list_type == "cooker" and 1 or 0)
|
||||
local list_x = list_type == "cooker" and fs_size.w/2-0.5 or 0.5
|
||||
local list_y = list_type == "cooker" and 1 or 0.5
|
||||
|
||||
local fs =
|
||||
("formspec_version[4]size[%f,%f]"):format(fs_size.w, fs_size.h) ..
|
||||
("list[current_player;main;0.5,%f;8,4;]"):format(player_list_y)
|
||||
|
||||
if detached then
|
||||
fs = fs .. ("list[detached:%s;%s;%f,%f;%f,%f;]"):format(inv_name, list_name, list_x, list_y, list_w, list_h)
|
||||
else
|
||||
fs = fs .. ("list[nodemeta:%f,%f,%f;%s;0.5,0.5;%u,%u;]"):format(pos.x, pos.y, pos.z, list_name, list_w, list_h)
|
||||
end
|
||||
|
||||
if list_type == "trash" then
|
||||
fs = fs .. "image[0.5,0.5;1,1;multidecor_trash_icon.png;]"
|
||||
end
|
||||
|
||||
if list_type == "cooker" then
|
||||
fs = fs .. "image[0.5,1;1,1;multidecor_cooker_fire_off.png;]"
|
||||
end
|
||||
|
||||
return fs
|
||||
end
|
||||
|
||||
-- Animates opening or closing the shelf 'obj'. The action directly depends on 'dir_sign' value ('1' is open, '-1' is close)
|
||||
function multidecor.shelves.open_shelf(obj, dir_sign)
|
||||
local self = obj:get_luaentity()
|
||||
@ -130,41 +174,13 @@ function multidecor.shelves.set_shelves(pos)
|
||||
end
|
||||
|
||||
for i, shelf_data in ipairs(def.add_properties.shelves_data) do
|
||||
local inv_name = multidecor.helpers.build_name_from_tmp(def.add_properties.shelves_data.common_name, "inv", i, pos)
|
||||
local list_name = multidecor.helpers.build_name_from_tmp(def.add_properties.shelves_data.common_name, "list", i, pos)
|
||||
local list_type = shelf_data.invlist_type or "storage"
|
||||
|
||||
local padding = 0.25
|
||||
local list_w = list_type == "storage" and shelf_data.inv_size.w or 1
|
||||
local list_h = list_type == "storage" and shelf_data.inv_size.h or 1
|
||||
local width = list_w > 8 and list_w or 8
|
||||
local fs_size = {
|
||||
w = width+1+(width-1)*padding,
|
||||
h = list_h+5.5+(list_h-1)*padding+3*padding
|
||||
}
|
||||
fs_size.h = shelf_data.invlist_type == "cooker" and fs_size.h + 1 or fs_size.h
|
||||
local player_list_y = list_h+1+(list_h-1)*padding + (shelf_data.invlist_type == "cooker" and 1 or 0)
|
||||
local list_x = shelf_data.invlist_type == "cooker" and fs_size.w/2-0.5 or 0.5
|
||||
local list_y = shelf_data.invlist_type == "cooker" and 1 or 0.5
|
||||
|
||||
local fs = [[
|
||||
formspec_version[4]size[%f,%f]
|
||||
list[detached:%s;%s;%f,%f;%f,%f;]
|
||||
list[current_player;main;0.5,%f;8,4;]
|
||||
]]
|
||||
|
||||
if list_type == "trash" then
|
||||
fs = fs .. "image[0.5,0.5;1,1;multidecor_trash_icon.png;]"
|
||||
end
|
||||
|
||||
if list_type == "cooker" then
|
||||
fs = fs .. "image[0.5,1;1,1;multidecor_cooker_fire_off.png;]"
|
||||
end
|
||||
|
||||
fs = fs:format(
|
||||
fs_size.w, fs_size.h,
|
||||
inv_name, list_name, list_x, list_y,
|
||||
list_w, list_h, player_list_y)
|
||||
local fs = multidecor.shelves.build_formspec(
|
||||
pos,
|
||||
def.add_properties.shelves_data.common_name,
|
||||
shelf_data,
|
||||
i
|
||||
)
|
||||
|
||||
local obj = minetest.add_entity(vector.add(pos, shelf_data.pos), shelf_data.object, minetest.serialize({fs, {name=node.name, pos=pos}, 0, i}))
|
||||
|
||||
local move_dist
|
||||
|
@ -147,7 +147,7 @@ local cmpnts = {
|
||||
|
||||
meta:set_string("water_stream_id", tonumber(id))
|
||||
|
||||
local sound_handle = minetest.sound_play("multidecor_tap", {pos=pos, max_hear_distance=12})
|
||||
local sound_handle = minetest.sound_play("multidecor_tap", {pos=pos, fade=1.0, max_hear_distance=12, loop=true})
|
||||
meta:set_string("sound_handle", minetest.serialize(sound_handle))
|
||||
end
|
||||
end,
|
||||
|
@ -263,7 +263,6 @@ multidecor.register.register_furniture_unit("alarm_clock", {
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("is_activated", "false")
|
||||
meta:set_int("nodetime_elapsed", -1)
|
||||
end,
|
||||
on_rightclick = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -271,9 +270,11 @@ multidecor.register.register_furniture_unit("alarm_clock", {
|
||||
if meta:get_string("is_activated") == "false" then
|
||||
meta:set_string("is_activated", "true")
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
|
||||
local handle = minetest.sound_play("multidecor_clock_ticking", {pos=pos, fade=1.0, max_hear_distance=10, loop=true})
|
||||
meta:set_string("sound_handle", minetest.serialize(handle))
|
||||
else
|
||||
meta:set_string("is_activated", "false")
|
||||
meta:set_int("nodetime_elapsed", -1)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
|
||||
local handle = minetest.deserialize(meta:get_string("sound_handle"))
|
||||
@ -286,18 +287,9 @@ multidecor.register.register_furniture_unit("alarm_clock", {
|
||||
on_timer = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local elapsed = meta:get_int("nodetime_elapsed")
|
||||
elapsed = elapsed + 1
|
||||
meta:set_int("nodetime_elapsed", elapsed)
|
||||
|
||||
local hours, minutes, seconds = get_current_time()
|
||||
meta:set_string("infotext", get_formatted_time_str(hours, minutes))
|
||||
|
||||
if elapsed % 8 == 0 then
|
||||
local handle = minetest.sound_play("multidecor_clock_ticking", {pos=pos, fade=1.0, max_hear_distance=10})
|
||||
meta:set_string("sound_handle", minetest.serialize(handle))
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmeta)
|
||||
|
@ -1,18 +1,8 @@
|
||||
local function get_shelf_formspec(name, pos, w, h)
|
||||
local listname = multidecor.helpers.build_name_from_tmp(name, "list", 1, pos)
|
||||
return table.concat({
|
||||
"formspec_version[5]",
|
||||
"size[11,9]",
|
||||
("list[nodemeta:%f,%f,%f;%s;0.5,0.5;%u,%u;]"):format(pos.x, pos.y, pos.z, listname, w, h),
|
||||
"list[current_player;main;0.5,3.5;8,4;]"
|
||||
}, "")
|
||||
end
|
||||
|
||||
local shelf_on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
local add_props = minetest.registered_nodes[name].add_properties
|
||||
meta:set_string("formspec", get_shelf_formspec(name, pos, add_props.inv_size.w, add_props.inv_size.h))
|
||||
meta:set_string("formspec", multidecor.shelves.build_formspec(pos, name, add_props, 1, false))
|
||||
|
||||
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||
local list_name = multidecor.helpers.build_name_from_tmp(name, "list", 1, pos)
|
||||
|
Loading…
x
Reference in New Issue
Block a user