Add Showroom Furniture
parent
144f21862c
commit
2306a14c2a
|
@ -1,4 +1,16 @@
|
|||
local schems = {}
|
||||
local modpath = minetest.get_modpath("ikea_showroom")
|
||||
local schems = dofile(modpath .. "/schematics.lua")
|
||||
|
||||
local Perlin = PerlinNoise({
|
||||
offset = 0,
|
||||
scale = 15,
|
||||
spread = {x = 10, y = 10, z = 10},
|
||||
seed = 2,
|
||||
octaves = 2,
|
||||
persistence = 3,
|
||||
lacunarity = 2,
|
||||
flags = "defaults, absvalue",
|
||||
})
|
||||
|
||||
minetest.register_node(":showroom:floor", {
|
||||
paramtype = "light",
|
||||
|
@ -8,11 +20,13 @@ minetest.register_node(":showroom:floor", {
|
|||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
schems.floor = schematic.new({x = 16, y = 1, z = 16}, "showroom:floor")
|
||||
|
||||
ikea.register_department({
|
||||
name = "showroom",
|
||||
get_schematic = function(edges, x, z)
|
||||
return schems.floor, nil
|
||||
if edges.e or edges.w or edges.n or edges.s then
|
||||
return schems.floor, nil
|
||||
else
|
||||
return schems.get(Perlin, x, z), nil
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
local schems = {}
|
||||
schems.floor = schematic.new({x = 16, y = 1, z = 16}, "showroom:floor")
|
||||
|
||||
local rooms = {"lounge", "kitchen", "bedroom"}
|
||||
local display_tables = {
|
||||
{
|
||||
name = "Table and Chairs",
|
||||
nodes = {
|
||||
{pos = {x = 1, y = 0, z = 2}, type = "chair"},
|
||||
{pos = {x = 2, y = 0, z = 2}, type = "chair"},
|
||||
{pos = {x = 1, y = 0, z = 1}, type = "table"},
|
||||
},
|
||||
rooms = {"lounge", "kitchen"},
|
||||
},
|
||||
{
|
||||
name = "Sofa and Chairs",
|
||||
nodes = {{pos = {x = 1, y = 0, z = 2}, type = "sofa"}, {pos = {x = 1, y = 0, z = 1}, type = "table"}},
|
||||
rooms = {"lounge"},
|
||||
},
|
||||
{
|
||||
name = "Bed and Nightstands",
|
||||
nodes = {
|
||||
{pos = {x = 2, y = 0, z = 1}, type = "bed"},
|
||||
{pos = {x = 0, y = 0, z = 2}, type = "nightstand"},
|
||||
{pos = {x = 4, y = 0, z = 2}, type = "nightstand"},
|
||||
},
|
||||
rooms = {"bedroom"},
|
||||
},
|
||||
}
|
||||
|
||||
function schems.get(Perlin, x, z)
|
||||
local room_name = rooms[util.bound_perlin(Perlin, #rooms, x, 0, z) + 1]
|
||||
local applicable_displays = table.search(display_tables, {includes = {rooms = {room_name}}})
|
||||
local combined_schem = schematic.new({x = 16, y = 16, z = 16, "air"})
|
||||
schematic.fill_area(combined_schem, "showroom:floor", {x = 0, y = 0, z = 0}, {x = 15, y = 0, z = 15})
|
||||
|
||||
for x2 = 0, 15, 8 do
|
||||
for z2 = 0, 15, 8 do
|
||||
local display = applicable_displays[util.bound_perlin(Perlin, #applicable_displays, x2, 1, z2) + 1]
|
||||
|
||||
for _, v in ipairs(display.nodes) do
|
||||
local applicable_furniture = table.search(ikea.registered_furniture, {includes = {tags = {v.type, room_name}}})
|
||||
local id = util.bound_perlin(Perlin, #applicable_furniture, x + x2, 2, z + z2) + 1
|
||||
|
||||
local index = schematic.index(combined_schem, vector.add(v.pos, {x = x2, y = 1, z = z2}))
|
||||
combined_schem.data[index] = {name = applicable_furniture[id].node_name}
|
||||
end
|
||||
end
|
||||
end
|
||||
return combined_schem
|
||||
end
|
||||
|
||||
return schems
|
|
@ -13,7 +13,7 @@ local landskrona_nodebox = {
|
|||
local landskrona_blue_name = "Landskrona Sofa (Blue)"
|
||||
ikea.register_furniture({ -- Furniture Registration
|
||||
name = landskrona_blue_name,
|
||||
tags = {"chair", "lounge"},
|
||||
tags = {"sofa", "lounge"},
|
||||
box_contents = {"sofas:landskrona"},
|
||||
node_name = "sofas:landskrona",
|
||||
size_x = 2,
|
||||
|
|
Loading…
Reference in New Issue