2019-05-27 02:02:29 +02:00
|
|
|
-- Home decor seating
|
|
|
|
-- forked from the previous lrfurn mod
|
|
|
|
|
2019-04-21 17:25:21 +02:00
|
|
|
local S = homedecor.gettext
|
2019-05-27 02:02:29 +02:00
|
|
|
local modpath = minetest.get_modpath("homedecor_seating")
|
2017-01-29 22:41:03 +01:00
|
|
|
|
2015-04-07 04:49:46 +02:00
|
|
|
lrfurn = {}
|
2015-05-15 10:45:21 +02:00
|
|
|
screwdriver = screwdriver or {}
|
2015-04-07 04:49:46 +02:00
|
|
|
|
2017-02-22 22:38:19 +01:00
|
|
|
lrfurn.fdir_to_right = {
|
2015-04-07 04:49:46 +02:00
|
|
|
{ 1, 0 },
|
|
|
|
{ 0, -1 },
|
|
|
|
{ -1, 0 },
|
2017-02-22 22:38:19 +01:00
|
|
|
{ 0, 1 },
|
2015-04-07 04:49:46 +02:00
|
|
|
}
|
|
|
|
|
2017-01-25 10:22:28 +01:00
|
|
|
lrfurn.colors = {
|
2017-01-30 22:46:04 +01:00
|
|
|
"black",
|
|
|
|
"brown",
|
|
|
|
"blue",
|
|
|
|
"cyan",
|
|
|
|
"dark_grey",
|
|
|
|
"dark_green",
|
|
|
|
"green",
|
|
|
|
"grey",
|
|
|
|
"magenta",
|
|
|
|
"orange",
|
|
|
|
"pink",
|
|
|
|
"red",
|
|
|
|
"violet",
|
|
|
|
"white",
|
|
|
|
"yellow",
|
2015-09-23 07:29:06 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 22:38:19 +01:00
|
|
|
function lrfurn.check_right(pos, fdir, long, placer)
|
2015-04-07 04:49:46 +02:00
|
|
|
if not fdir or fdir > 3 then fdir = 0 end
|
|
|
|
|
2017-02-22 22:38:19 +01:00
|
|
|
local pos2 = { x = pos.x + lrfurn.fdir_to_right[fdir+1][1], y=pos.y, z = pos.z + lrfurn.fdir_to_right[fdir+1][2] }
|
|
|
|
local pos3 = { x = pos.x + lrfurn.fdir_to_right[fdir+1][1] * 2, y=pos.y, z = pos.z + lrfurn.fdir_to_right[fdir+1][2] * 2 }
|
2015-04-07 04:49:46 +02:00
|
|
|
|
|
|
|
local node2 = minetest.get_node(pos2)
|
2015-07-21 11:08:40 +02:00
|
|
|
if node2 and node2.name ~= "air" then
|
|
|
|
return false
|
|
|
|
elseif minetest.is_protected(pos2, placer:get_player_name()) then
|
|
|
|
if not long then
|
2017-08-12 22:30:46 +02:00
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where other end goes!"))
|
2015-07-21 11:08:40 +02:00
|
|
|
else
|
2017-08-12 22:30:46 +02:00
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the middle or far end goes!"))
|
2015-07-21 11:08:40 +02:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
2015-04-07 04:49:46 +02:00
|
|
|
|
|
|
|
if long then
|
|
|
|
local node3 = minetest.get_node(pos3)
|
2015-07-21 11:08:40 +02:00
|
|
|
if node3 and node3.name ~= "air" then
|
|
|
|
return false
|
|
|
|
elseif minetest.is_protected(pos3, placer:get_player_name()) then
|
2017-08-12 22:30:46 +02:00
|
|
|
minetest.chat_send_player(placer:get_player_name(), S("Someone else owns the spot where the other end goes!"))
|
2015-07-21 11:08:40 +02:00
|
|
|
return false
|
|
|
|
end
|
2015-04-07 04:49:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2017-02-22 22:38:19 +01:00
|
|
|
function lrfurn.fix_sofa_rotation_nsew(pos, placer, itemstack, pointed_thing)
|
|
|
|
local node = minetest.get_node(pos)
|
2018-08-22 11:08:48 +02:00
|
|
|
local colorbits = node.param2 - (node.param2 % 8)
|
2017-02-22 22:38:19 +01:00
|
|
|
local yaw = placer:get_look_yaw()
|
|
|
|
local dir = minetest.yaw_to_dir(yaw-1.5)
|
|
|
|
local fdir = minetest.dir_to_wallmounted(dir)
|
2018-08-22 11:08:48 +02:00
|
|
|
minetest.swap_node(pos, { name = node.name, param2 = fdir+colorbits })
|
2017-02-22 22:38:19 +01:00
|
|
|
end
|
|
|
|
|
2019-05-27 02:02:29 +02:00
|
|
|
dofile(modpath.."/longsofas.lua")
|
|
|
|
dofile(modpath.."/sofas.lua")
|
|
|
|
dofile(modpath.."/armchairs.lua")
|
|
|
|
dofile(modpath.."/misc.lua")
|