Move all backend and API code into "ikea" mod, flatten namespaces.
|
@ -0,0 +1,8 @@
|
||||||
|
function ikea.is_open()
|
||||||
|
local tod = minetest.get_timeofday()
|
||||||
|
if tod >= (7 / 24) and tod <= (23 / 24) then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,82 @@
|
||||||
|
local department_defaults = {
|
||||||
|
name = "rename me",
|
||||||
|
get_schematic = function(edges)
|
||||||
|
local schem = {size = {x = 1, y = 1, z = 1}, data = {{name = "ikea:error"}}}
|
||||||
|
return schem, nil
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_place = function(context, vm, x, z)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
function ikea.register_department(def_raw)
|
||||||
|
def_raw = def_raw or {}
|
||||||
|
|
||||||
|
-- Use new table to avoid changing the defaults table
|
||||||
|
local def = {}
|
||||||
|
table.key_merge(def, department_defaults)
|
||||||
|
table.key_merge(def, def_raw)
|
||||||
|
|
||||||
|
table.insert(ikea.mapgen_options.departments, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
local light_defaults = {
|
||||||
|
description = "Default Description For Lights",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "error.obj",
|
||||||
|
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
|
||||||
|
use_texture_alpha = true,
|
||||||
|
collision_box = nil,
|
||||||
|
selection_box = nil,
|
||||||
|
light_source = minetest.LIGHT_MAX,
|
||||||
|
groups = {static = 1, ikea_light = 1},
|
||||||
|
}
|
||||||
|
|
||||||
|
function ikea.register_light(name, def_raw)
|
||||||
|
def_raw = def_raw or {}
|
||||||
|
|
||||||
|
-- Use new table to avoid changing the defaults table
|
||||||
|
local def = {}
|
||||||
|
table.key_merge(def, light_defaults)
|
||||||
|
table.key_merge(def, def_raw)
|
||||||
|
|
||||||
|
-- Register base light node
|
||||||
|
minetest.register_node(":" .. name, def)
|
||||||
|
|
||||||
|
-- Register off version of it with no emitted light
|
||||||
|
local def_off = def
|
||||||
|
def_off.light_source = 0
|
||||||
|
|
||||||
|
-- Make semi-transparent bits invisible
|
||||||
|
def_off.use_texture_alpha = false
|
||||||
|
|
||||||
|
minetest.register_node(":" .. name .. "_off", def_off)
|
||||||
|
end
|
||||||
|
|
||||||
|
local kit_defaults = {
|
||||||
|
description = "Default Description For Furniture Kits",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "error.obj",
|
||||||
|
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
|
||||||
|
groups = {carryable = 1},
|
||||||
|
after_dig_node = util.leave_behind,
|
||||||
|
}
|
||||||
|
|
||||||
|
function ikea.register_kit(name, def_raw)
|
||||||
|
def_raw = def_raw or {}
|
||||||
|
|
||||||
|
-- Use new table to avoid changing the defaults table
|
||||||
|
local def = {}
|
||||||
|
table.key_merge(def, kit_defaults)
|
||||||
|
table.key_merge(def, def_raw)
|
||||||
|
|
||||||
|
minetest.register_node(":" .. name, def)
|
||||||
|
|
||||||
|
-- Register Kit Into Global Table
|
||||||
|
table.insert(ikea.registered_kits, {furniture_node = name})
|
||||||
|
ikea.registered_boxes[name] = {contents = def.contents or {{name = name}}}
|
||||||
|
end
|
|
@ -0,0 +1,65 @@
|
||||||
|
ikea.registered_kits = {}
|
||||||
|
ikea.registered_boxes = {}
|
||||||
|
|
||||||
|
minetest.register_node("ikea:box", {
|
||||||
|
description = "Cardboard Box",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {type = "fixed", fixed = {-6 / 16, -0.499, -6 / 16, 6 / 16, 4 / 16, 6 / 16}},
|
||||||
|
tiles = {
|
||||||
|
{name = "ikea_box_top.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_bottom.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_side.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_side.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_front.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_front.png", backface_culling = false},
|
||||||
|
},
|
||||||
|
groups = {carryable = 1},
|
||||||
|
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
local furniture_node = minetest.get_meta(pos):get_string("furniture_node")
|
||||||
|
local contents = ikea.registered_boxes[furniture_node].contents
|
||||||
|
minetest.swap_node(pos, {name = "ikea:box_open"})
|
||||||
|
|
||||||
|
for _, v in pairs(contents) do
|
||||||
|
local vel = math.random(5, 8)
|
||||||
|
minetest.spawn_item(pos, v):set_velocity({x = 0, y = vel, z = 0})
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.get_node_timer(pos):start(5)
|
||||||
|
end,
|
||||||
|
|
||||||
|
preserve_metadata = function(pos, oldnode, oldmeta, drops)
|
||||||
|
drops[1]:get_meta():set_string("furniture_node", oldmeta.furniture_node)
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
|
minetest.get_meta(pos):set_string("furniture_node", itemstack:get_meta():get_string("furniture_node"))
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_dig_node = util.leave_behind,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("ikea:box_open", {
|
||||||
|
description = "Cardboard Box, Open (You Hacker!)",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {type = "fixed", fixed = {-6 / 16, -0.499, -6 / 16, 6 / 16, 8 / 16, 6 / 16}},
|
||||||
|
tiles = {
|
||||||
|
{name = "ikea_box_top.png^[opacity:0", backface_culling = false},
|
||||||
|
{name = "ikea_box_bottom.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_side.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_side.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_open_back.png", backface_culling = false},
|
||||||
|
{name = "ikea_box_open_front.png", backface_culling = false},
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1},
|
||||||
|
drop = "",
|
||||||
|
|
||||||
|
on_timer = function(pos, elapsed)
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
end,
|
||||||
|
})
|
|
@ -1,19 +1,11 @@
|
||||||
ikea = {}
|
ikea = {}
|
||||||
|
local modpath = minetest.get_modpath("ikea")
|
||||||
|
|
||||||
minetest.register_node(":ikea:error", {
|
dofile(modpath .. "/nodes.lua")
|
||||||
drawtype = "mesh",
|
dofile(modpath .. "/mapgen.lua")
|
||||||
mesh = "error.obj",
|
dofile(modpath .. "/time.lua")
|
||||||
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
|
dofile(modpath .. "/light.lua")
|
||||||
pointable = false,
|
dofile(modpath .. "/furniture.lua")
|
||||||
walkable = false,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(":ikea:invisible_wall", {
|
dofile(modpath .. "/api/register.lua")
|
||||||
paramtype = "light",
|
dofile(modpath .. "/api/global_state.lua")
|
||||||
description = "Invisible Node For Collisions (You Hacker!)",
|
|
||||||
drawtype = "airlike",
|
|
||||||
walkable = true,
|
|
||||||
pointable = false,
|
|
||||||
is_ground_content = true,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
})
|
|
||||||
|
|
|
@ -1,56 +1,20 @@
|
||||||
ikea.light = {}
|
|
||||||
local sound_gain = 0.005
|
local sound_gain = 0.005
|
||||||
|
|
||||||
local light_defaults = {
|
|
||||||
description = "Default Description For Lights",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "mesh",
|
|
||||||
mesh = "error.obj",
|
|
||||||
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
|
|
||||||
use_texture_alpha = true,
|
|
||||||
collision_box = nil,
|
|
||||||
selection_box = nil,
|
|
||||||
light_source = minetest.LIGHT_MAX,
|
|
||||||
groups = {static = 1, ikea_light = 1},
|
|
||||||
}
|
|
||||||
|
|
||||||
function ikea.light.register_light(name, def_raw)
|
|
||||||
def_raw = def_raw or {}
|
|
||||||
|
|
||||||
-- Use new table to avoid changing the defaults table
|
|
||||||
local def = {}
|
|
||||||
table.key_merge(def, light_defaults)
|
|
||||||
table.key_merge(def, def_raw)
|
|
||||||
|
|
||||||
-- Register base light node
|
|
||||||
minetest.register_node(":" .. name, def)
|
|
||||||
|
|
||||||
-- Register off version of it with no emitted light
|
|
||||||
local def_off = def
|
|
||||||
def_off.light_source = 0
|
|
||||||
|
|
||||||
-- Make semi-transparent bits invisible
|
|
||||||
def_off.use_texture_alpha = false
|
|
||||||
|
|
||||||
minetest.register_node(":" .. name .. "_off", def_off)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function toggle_light(pos, node, play_sound)
|
local function toggle_light(pos, node, play_sound)
|
||||||
local store_tod = ikea.time.get_storetime()
|
local is_open = ikea.is_open()
|
||||||
local is_off = false
|
local is_off = false
|
||||||
if node.name:sub(-4) == "_off" then
|
if node.name:sub(-4) == "_off" then
|
||||||
is_off = true
|
is_off = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_off and store_tod == 1 then
|
if is_off and is_open then
|
||||||
minetest.swap_node(pos, {name = node.name:sub(0, -5)})
|
minetest.swap_node(pos, {name = node.name:sub(0, -5)})
|
||||||
|
|
||||||
if play_sound then
|
if play_sound then
|
||||||
minetest.sound_play({name = "ikea_light_toggle", pos = pos, max_hear_distance = 150, gain = sound_gain, pitch = 1.0})
|
minetest.sound_play({name = "ikea_light_toggle", pos = pos, max_hear_distance = 150, gain = sound_gain, pitch = 1.0})
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif not is_off and store_tod == 0 then
|
elseif not is_off and not is_open then
|
||||||
minetest.swap_node(pos, {name = node.name .. "_off"})
|
minetest.swap_node(pos, {name = node.name .. "_off"})
|
||||||
|
|
||||||
if play_sound then
|
if play_sound then
|
||||||
|
@ -73,7 +37,7 @@ minetest.register_abm({
|
||||||
-- Toggle the lights loaded in without sound
|
-- Toggle the lights loaded in without sound
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
label = "Light Updater LBM",
|
label = "Light Updater LBM",
|
||||||
name = "ikea_light:light_toggle",
|
name = "ikea:light_toggle",
|
||||||
nodenames = {"group:ikea_light"},
|
nodenames = {"group:ikea_light"},
|
||||||
run_at_every_load = true,
|
run_at_every_load = true,
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
ikea.mapgen = {}
|
ikea.mapgen_options = {departments = {}, min_size = 16, max_size = 32}
|
||||||
ikea.mapgen.options = {departments = {}, min_size = 16, max_size = 32}
|
|
||||||
local ceiling_height = 50
|
local ceiling_height = 50
|
||||||
local ceiling_schematic = schematic.new({x = 16, y = 1, z = 16}, "mapgen:ceiling")
|
local ceiling_schematic = schematic.new({x = 16, y = 1, z = 16}, "ikea:ceiling")
|
||||||
|
|
||||||
local modpath = minetest.get_modpath("ikea_mapgen")
|
|
||||||
dofile(modpath .. "/functions.lua")
|
|
||||||
|
|
||||||
minetest.register_node(":mapgen:ceiling", {
|
|
||||||
paramtype = "light",
|
|
||||||
description = "Ceiling Node (You Hacker!)",
|
|
||||||
tiles = {{name = "ikea_mapgen_ceiling.png", scale = 16, align_style = "world"}},
|
|
||||||
groups = {static = 1},
|
|
||||||
sunlight_propagates = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Department Map Generation Logic
|
-- Department Map Generation Logic
|
||||||
-- Originally Written By Warr1024
|
-- Originally Written By Warr1024
|
||||||
|
@ -85,7 +73,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
for x = minp.x, maxp.x, 16 do
|
for x = minp.x, maxp.x, 16 do
|
||||||
local mapblock_x = x / 16
|
local mapblock_x = x / 16
|
||||||
local mapblock_z = z / 16
|
local mapblock_z = z / 16
|
||||||
local department, edges = get_department(ikea.mapgen.options, mapblock_x, mapblock_z)
|
local department, edges = get_department(ikea.mapgen_options, mapblock_x, mapblock_z)
|
||||||
local schem, context = department.get_schematic(edges, x, z)
|
local schem, context = department.get_schematic(edges, x, z)
|
||||||
|
|
||||||
minetest.place_schematic_on_vmanip(vm, {x = x, y = 0, z = z}, schem, 0, nil, true, "")
|
minetest.place_schematic_on_vmanip(vm, {x = x, y = 0, z = z}, schem, 0, nil, true, "")
|
|
@ -0,0 +1,25 @@
|
||||||
|
minetest.register_node("ikea:error", {
|
||||||
|
drawtype = "mesh",
|
||||||
|
mesh = "error.obj",
|
||||||
|
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
|
||||||
|
pointable = false,
|
||||||
|
walkable = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("ikea:invisible_wall", {
|
||||||
|
paramtype = "light",
|
||||||
|
description = "Invisible Node For Collisions (You Hacker!)",
|
||||||
|
drawtype = "airlike",
|
||||||
|
walkable = true,
|
||||||
|
pointable = false,
|
||||||
|
is_ground_content = true,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("ikea:ceiling", {
|
||||||
|
paramtype = "light",
|
||||||
|
description = "Ceiling Node (You Hacker!)",
|
||||||
|
tiles = {{name = "ikea_ceiling.png", scale = 16, align_style = "world"}},
|
||||||
|
groups = {static = 1},
|
||||||
|
sunlight_propagates = true,
|
||||||
|
})
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 643 B After Width: | Height: | Size: 643 B |
Before Width: | Height: | Size: 619 B After Width: | Height: | Size: 619 B |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -1,23 +1,11 @@
|
||||||
ikea.time = {}
|
|
||||||
|
|
||||||
local day_color = "#414141"
|
local day_color = "#414141"
|
||||||
local night_color = "#303030"
|
local night_color = "#303030"
|
||||||
|
|
||||||
-- Returns 1 for open hours and 0 for closed
|
|
||||||
function ikea.time.get_storetime()
|
|
||||||
local tod = minetest.get_timeofday()
|
|
||||||
local store_tod = 0
|
|
||||||
if tod >= (7 / 24) and tod <= (23 / 24) then
|
|
||||||
store_tod = 1
|
|
||||||
end
|
|
||||||
return store_tod
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Sets the skybox and global light level for player
|
-- Sets the skybox and global light level for player
|
||||||
local function update_player_time(player)
|
local function update_player_time(player)
|
||||||
local time = ikea.time.get_storetime()
|
local is_open = ikea.is_open()
|
||||||
|
|
||||||
if time == 1 then
|
if is_open then
|
||||||
player:override_day_night_ratio(0.7)
|
player:override_day_night_ratio(0.7)
|
||||||
player:set_sky(day_color, "plain", {}, false)
|
player:set_sky(day_color, "plain", {}, false)
|
||||||
else
|
else
|
||||||
|
@ -37,19 +25,19 @@ minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
|
|
||||||
if timer >= 1 then
|
if timer >= 1 then
|
||||||
local store_tod = ikea.time.get_storetime()
|
local is_open = ikea.is_open()
|
||||||
|
|
||||||
if store_tod ~= old_time then
|
if is_open ~= old_time then
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
update_player_time(player)
|
update_player_time(player)
|
||||||
|
|
||||||
-- Play a "power down" sound whenever it become night
|
-- Play a "power down" sound whenever it become night
|
||||||
if store_tod == 0 and old_time == 1 then
|
if not is_open and old_time then
|
||||||
minetest.sound_play({name = "ikea_time_power_down", gain = 0.15, pitch = 1.0})
|
minetest.sound_play({name = "ikea_power_down", gain = 0.15, pitch = 1.0})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
old_time = store_tod
|
old_time = is_open
|
||||||
end
|
end
|
||||||
end)
|
end)
|
|
@ -8,7 +8,7 @@ local vedbo_nodebox = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ikea.furniture.register_kit("chairs:vedbo", {
|
ikea.register_kit("chairs:vedbo", {
|
||||||
description = "Vedbo Chair (Pink)",
|
description = "Vedbo Chair (Pink)",
|
||||||
mesh = "ikea_chairs_vedbo.obj",
|
mesh = "ikea_chairs_vedbo.obj",
|
||||||
tiles = {"ikea_chairs_vedbo.png"},
|
tiles = {"ikea_chairs_vedbo.png"},
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = ikea_chairs
|
name = ikea_chairs
|
||||||
depends = ikea_furniture
|
depends = ikea
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
ikea.furniture = {}
|
|
||||||
ikea.furniture.registered_kits = {}
|
|
||||||
ikea.furniture.registered_boxes = {}
|
|
||||||
|
|
||||||
local function leave_behind(pos, oldnode, oldmetadata, digger)
|
|
||||||
if oldmetadata.fields.leave_behind then
|
|
||||||
minetest.set_node(pos, {name = oldmetadata.fields.leave_behind})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node(":furniture:box", {
|
|
||||||
description = "Cardboard Box",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = {type = "fixed", fixed = {-6 / 16, -0.499, -6 / 16, 6 / 16, 4 / 16, 6 / 16}},
|
|
||||||
tiles = {
|
|
||||||
{name = "ikea_furniture_box_top.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_bottom.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_side.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_side.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_front.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_front.png", backface_culling = false},
|
|
||||||
},
|
|
||||||
groups = {carryable = 1},
|
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|
||||||
local furniture_node = minetest.get_meta(pos):get_string("furniture_node")
|
|
||||||
local contents = ikea.furniture.registered_boxes[furniture_node].contents
|
|
||||||
minetest.swap_node(pos, {name = "furniture:box_open"})
|
|
||||||
|
|
||||||
for _, v in pairs(contents) do
|
|
||||||
local vel = math.random(5, 8)
|
|
||||||
minetest.spawn_item(pos, v):set_velocity({x = 0, y = vel, z = 0})
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.get_node_timer(pos):start(5)
|
|
||||||
end,
|
|
||||||
|
|
||||||
preserve_metadata = function(pos, oldnode, oldmeta, drops)
|
|
||||||
drops[1]:get_meta():set_string("furniture_node", oldmeta.furniture_node)
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
||||||
minetest.get_meta(pos):set_string("furniture_node", itemstack:get_meta():get_string("furniture_node"))
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_dig_node = leave_behind,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(":furniture:box_open", {
|
|
||||||
description = "Cardboard Box, Open (You Hacker!)",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = {type = "fixed", fixed = {-6 / 16, -0.499, -6 / 16, 6 / 16, 8 / 16, 6 / 16}},
|
|
||||||
tiles = {
|
|
||||||
{name = "ikea_furniture_box_top.png^[opacity:0", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_bottom.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_side.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_side.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_back_open.png", backface_culling = false},
|
|
||||||
{name = "ikea_furniture_box_front_open.png", backface_culling = false},
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1},
|
|
||||||
drop = "",
|
|
||||||
|
|
||||||
on_timer = function(pos, elapsed)
|
|
||||||
minetest.set_node(pos, {name = "air"})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
local kit_defaults = {
|
|
||||||
description = "Default Description For Furniture Kits",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "mesh",
|
|
||||||
mesh = "error.obj",
|
|
||||||
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
|
|
||||||
groups = {carryable = 1},
|
|
||||||
|
|
||||||
after_dig_node = leave_behind,
|
|
||||||
}
|
|
||||||
|
|
||||||
function ikea.furniture.register_kit(name, def_raw)
|
|
||||||
def_raw = def_raw or {}
|
|
||||||
|
|
||||||
-- Use new table to avoid changing the defaults table
|
|
||||||
local def = {}
|
|
||||||
table.key_merge(def, kit_defaults)
|
|
||||||
table.key_merge(def, def_raw)
|
|
||||||
|
|
||||||
minetest.register_node(":" .. name, def)
|
|
||||||
|
|
||||||
-- Register Kit Into Global Table
|
|
||||||
table.insert(ikea.furniture.registered_kits, {furniture_node = name})
|
|
||||||
ikea.furniture.registered_boxes[name] = {contents = def.contents or {{name = name}}}
|
|
||||||
end
|
|
|
@ -1,2 +0,0 @@
|
||||||
name = ikea_furniture
|
|
||||||
depends = ikea
|
|
Before Width: | Height: | Size: 626 B |
|
@ -1,2 +0,0 @@
|
||||||
name = ikea_light
|
|
||||||
depends = ikea
|
|
|
@ -1,27 +0,0 @@
|
||||||
local department_defaults = {
|
|
||||||
name = "rename me",
|
|
||||||
get_schematic = function(edges)
|
|
||||||
local schematic = {size = {x = 1, y = 1, z = 1}, data = {{name = "ikea:error"}}}
|
|
||||||
return schematic, nil
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_place = function(context, vm, x, z)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
function ikea.mapgen.register_department(def_raw)
|
|
||||||
def_raw = def_raw or {}
|
|
||||||
|
|
||||||
-- Use new table to avoid changing the defaults table
|
|
||||||
local def = {}
|
|
||||||
table.key_merge(def, department_defaults)
|
|
||||||
table.key_merge(def, def_raw)
|
|
||||||
|
|
||||||
table.insert(ikea.mapgen.options.departments, def)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ikea.mapgen.every_n_mapblocks(n)
|
|
||||||
return function(value)
|
|
||||||
return (value / 16) % n == 0
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
name = ikea_mapgen
|
|
||||||
description = Mapgen definitions and utilities
|
|
||||||
depends = ikea
|
|
|
@ -10,7 +10,7 @@ minetest.register_node(":showroom:floor", {
|
||||||
|
|
||||||
schems.floor = schematic.new({x = 16, y = 1, z = 16}, "showroom:floor")
|
schems.floor = schematic.new({x = 16, y = 1, z = 16}, "showroom:floor")
|
||||||
|
|
||||||
ikea.mapgen.register_department({
|
ikea.register_department({
|
||||||
name = "showroom",
|
name = "showroom",
|
||||||
|
|
||||||
get_schematic = function(edges, x, z)
|
get_schematic = function(edges, x, z)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = ikea_showroom
|
name = ikea_showroom
|
||||||
depends = ikea_mapgen,ikea_furniture,ikea_light
|
depends = ikea
|
||||||
|
|
|
@ -247,7 +247,7 @@ minetest.register_entity("ikea_staff:member", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.hostile = ikea.time.get_storetime() == 0
|
self.hostile = ikea.is_open()
|
||||||
-- BUG: When it becomes day, if a staff member is following a player, they just walk in a line forever
|
-- BUG: When it becomes day, if a staff member is following a player, they just walk in a line forever
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = ikea_staff
|
name = ikea_staff
|
||||||
depends = ikea, ikea_time
|
depends = ikea
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
name = ikea_time
|
|
||||||
depends = ikea
|
|
|
@ -1,4 +1,4 @@
|
||||||
local should_place_aisle = ikea.mapgen.every_n_mapblocks(4)
|
local should_place_aisle = util.every_n_mapblocks(4)
|
||||||
local RackContentNoise = PerlinNoise({
|
local RackContentNoise = PerlinNoise({
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 15,
|
scale = 15,
|
||||||
|
@ -27,10 +27,10 @@ local function place_rack_contents(vm, pos, rotate)
|
||||||
|
|
||||||
local noise = RackContentNoise:get_2d(local_pos)
|
local noise = RackContentNoise:get_2d(local_pos)
|
||||||
local large_num = 100000
|
local large_num = 100000
|
||||||
local furniture_id = (math.floor(noise * large_num) % (#ikea.furniture.registered_kits)) + 1
|
local furniture_id = (math.floor(noise * large_num) % (#ikea.registered_kits)) + 1
|
||||||
|
|
||||||
local box_node = {name = "furniture:box"}
|
local box_node = {name = "ikea:box"}
|
||||||
local furniture_node = {name = ikea.furniture.registered_kits[furniture_id].furniture_node, param2 = rotation}
|
local furniture_node = {name = ikea.registered_kits[furniture_id].furniture_node, param2 = rotation}
|
||||||
local filler_node = {name = "ikea:invisible_wall"}
|
local filler_node = {name = "ikea:invisible_wall"}
|
||||||
|
|
||||||
local schem = {
|
local schem = {
|
||||||
|
@ -49,7 +49,7 @@ local function place_rack_contents(vm, pos, rotate)
|
||||||
|
|
||||||
for j = 1, #box_positions do
|
for j = 1, #box_positions do
|
||||||
local meta = minetest.get_meta(box_positions[j])
|
local meta = minetest.get_meta(box_positions[j])
|
||||||
meta:set_string("furniture_node", ikea.furniture.registered_kits[furniture_id].furniture_node)
|
meta:set_string("furniture_node", ikea.registered_kits[furniture_id].furniture_node)
|
||||||
meta:set_string("leave_behind", "ikea:invisible_wall")
|
meta:set_string("leave_behind", "ikea:invisible_wall")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ local function place_rack_contents(vm, pos, rotate)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ikea.mapgen.register_department({
|
ikea.register_department({
|
||||||
name = "warehouse",
|
name = "warehouse",
|
||||||
|
|
||||||
get_schematic = function(edges, x, z)
|
get_schematic = function(edges, x, z)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = ikea_warehouse
|
name = ikea_warehouse
|
||||||
depends = ikea_mapgen,ikea_furniture,ikea_light
|
depends = ikea
|
||||||
|
|
|
@ -18,7 +18,7 @@ minetest.register_node(":warehouse:rack", {
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
ikea.light.register_light("warehouse:light", {
|
ikea.register_light("warehouse:light", {
|
||||||
description = "Lights That Light The Warehouse",
|
description = "Lights That Light The Warehouse",
|
||||||
mesh = "ikea_warehouse_light.obj",
|
mesh = "ikea_warehouse_light.obj",
|
||||||
tiles = {{name = "ikea_warehouse_light.png", backface_culling = true}},
|
tiles = {{name = "ikea_warehouse_light.png", backface_culling = true}},
|
||||||
|
|
|
@ -19,8 +19,8 @@ end
|
||||||
|
|
||||||
function music.play()
|
function music.play()
|
||||||
-- Queue up another play() if it's night
|
-- Queue up another play() if it's night
|
||||||
local store_time = ikea.time.get_storetime()
|
local is_open = ikea.is_open()
|
||||||
if store_time == 0 then
|
if not is_open then
|
||||||
minetest.after(30, music.play)
|
minetest.after(30, music.play)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -71,8 +71,8 @@ local old_time = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if timer >= 1 then
|
if timer >= 1 then
|
||||||
local store_time = ikea.time.get_storetime()
|
local is_open = ikea.is_open()
|
||||||
if store_time == 0 and old_time == 1 then
|
if is_open and old_time then
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local handle = music.handles[player:get_player_name()]
|
local handle = music.handles[player:get_player_name()]
|
||||||
if handle then
|
if handle then
|
||||||
|
@ -81,7 +81,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
old_time = store_time
|
old_time = is_open
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = music
|
name = music
|
||||||
depends = ikea_time
|
depends = ikea
|
||||||
|
|
|
@ -15,3 +15,15 @@ function util.node_or_ignore(node)
|
||||||
return {name = "ignore"}
|
return {name = "ignore"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function util.every_n_mapblocks(n)
|
||||||
|
return function(value)
|
||||||
|
return (value / 16) % n == 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function util.leave_behind(pos, oldnode, oldmetadata, digger)
|
||||||
|
if oldmetadata.fields.leave_behind then
|
||||||
|
minetest.set_node(pos, {name = oldmetadata.fields.leave_behind})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|