nodes_furniture.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. ---------------------------------------------------------------------------------------
  2. -- furniture
  3. ---------------------------------------------------------------------------------------
  4. -- contains:
  5. -- * a bed seperated into foot and head reagion so that it can be placed manually; it has
  6. -- no other functionality than decoration!
  7. -- * a sleeping mat - mostly for NPC that cannot afford a bet yet
  8. -- * bench - if you don't have 3dforniture:chair, then this is the next best thing
  9. -- * table - very simple one
  10. -- * shelf - for stroring things; this one is 3d
  11. -- * stovepipe - so that the smoke from the furnace can get away
  12. -- * washing place - put it over a water source and you can 'wash' yourshelf
  13. ---------------------------------------------------------------------------------------
  14. -- TODO: change the textures of the bed (make the clothing white, foot path not entirely covered with cloth)
  15. local S = cottages.S
  16. -- a bed without functionality - just decoration
  17. minetest.register_node("cottages:bed_foot", {
  18. description = S("Bed (foot region)"),
  19. drawtype = "nodebox",
  20. tiles = {"cottages_beds_bed_top_bottom.png", cottages.texture_furniture, "cottages_beds_bed_side.png", "cottages_beds_bed_side.png", "cottages_beds_bed_side.png", "cottages_beds_bed_side.png"},
  21. paramtype = "light",
  22. paramtype2 = "facedir",
  23. groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
  24. sounds = cottages.sounds.wood,
  25. node_box = {
  26. type = "fixed",
  27. fixed = {
  28. -- bed
  29. {-0.5, 0.0, -0.5, 0.5, 0.3, 0.5},
  30. -- stützen
  31. {-0.5, -0.5, -0.5, -0.4, 0.5, -0.4},
  32. { 0.4,-0.5, -0.5, 0.5, 0.5, -0.4},
  33. -- Querstrebe
  34. {-0.4, 0.3, -0.5, 0.4, 0.5, -0.4}
  35. }
  36. },
  37. selection_box = {
  38. type = "fixed",
  39. fixed = {
  40. {-0.5, -0.5, -0.5, 0.5, 0.3, 0.5},
  41. }
  42. },
  43. is_ground_content = false,
  44. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  45. return cottages.sleep_in_bed( pos, node, clicker, itemstack, pointed_thing );
  46. end
  47. })
  48. -- the bed is split up in two parts to avoid destruction of blocks on placement
  49. minetest.register_node("cottages:bed_head", {
  50. description = S("Bed (head region)"),
  51. drawtype = "nodebox",
  52. tiles = {"cottages_beds_bed_top_top.png", cottages.texture_furniture, "cottages_beds_bed_side_top_r.png", "cottages_beds_bed_side_top_l.png", cottages.texture_furniture, "cottages_beds_bed_side.png"},
  53. paramtype = "light",
  54. paramtype2 = "facedir",
  55. groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
  56. sounds = cottages.sounds.wood,
  57. node_box = {
  58. type = "fixed",
  59. fixed = {
  60. -- bed
  61. {-0.5, 0.0, -0.5, 0.5, 0.3, 0.5},
  62. -- stützen
  63. {-0.5,-0.5, 0.4, -0.4, 0.5, 0.5},
  64. { 0.4,-0.5, 0.4, 0.5, 0.5, 0.5},
  65. -- Querstrebe
  66. {-0.4, 0.3, 0.4, 0.4, 0.5, 0.5}
  67. }
  68. },
  69. selection_box = {
  70. type = "fixed",
  71. fixed = {
  72. {-0.5, -0.5, -0.5, 0.5, 0.3, 0.5},
  73. }
  74. },
  75. is_ground_content = false,
  76. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  77. return cottages.sleep_in_bed( pos, node, clicker, itemstack, pointed_thing );
  78. end
  79. })
  80. -- the basic version of a bed - a sleeping mat
  81. -- to facilitate upgrade path straw mat -> sleeping mat -> bed, this uses a nodebox
  82. minetest.register_node("cottages:sleeping_mat", {
  83. description = S("sleeping mat"),
  84. drawtype = 'nodebox',
  85. tiles = { 'cottages_sleepingmat.png' }, -- done by VanessaE
  86. wield_image = 'cottages_sleepingmat.png',
  87. inventory_image = 'cottages_sleepingmat.png',
  88. sunlight_propagates = true,
  89. paramtype = 'light',
  90. paramtype2 = "facedir",
  91. walkable = false,
  92. groups = { snappy = 3 },
  93. sounds = cottages.sounds.leaves,
  94. selection_box = {
  95. type = "wallmounted",
  96. },
  97. node_box = {
  98. type = "fixed",
  99. fixed = {
  100. {-0.48, -0.5,-0.48, 0.48, -0.5+1/16, 0.48},
  101. }
  102. },
  103. selection_box = {
  104. type = "fixed",
  105. fixed = {
  106. {-0.48, -0.5,-0.48, 0.48, -0.5+2/16, 0.48},
  107. }
  108. },
  109. is_ground_content = false,
  110. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  111. return cottages.sleep_in_bed( pos, node, clicker, itemstack, pointed_thing );
  112. end
  113. })
  114. -- this one has a pillow for the head; thus, param2 becomes visible to the builder, and mobs may use it as a bed
  115. minetest.register_node("cottages:sleeping_mat_head", {
  116. description = S("sleeping mat with pillow"),
  117. drawtype = 'nodebox',
  118. tiles = { 'cottages_sleepingmat.png' }, -- done by VanessaE
  119. wield_image = 'cottages_sleepingmat.png',
  120. inventory_image = 'cottages_sleepingmat.png',
  121. sunlight_propagates = true,
  122. paramtype = 'light',
  123. paramtype2 = "facedir",
  124. groups = { snappy = 3 },
  125. sounds = cottages.sounds.leaves,
  126. node_box = {
  127. type = "fixed",
  128. fixed = {
  129. {-0.48, -0.5,-0.48, 0.48, -0.5+1/16, 0.48},
  130. {-0.34, -0.5+1/16,-0.12, 0.34, -0.5+2/16, 0.34},
  131. }
  132. },
  133. selection_box = {
  134. type = "fixed",
  135. fixed = {
  136. {-0.48, -0.5,-0.48, 0.48, -0.5+2/16, 0.48},
  137. }
  138. },
  139. is_ground_content = false,
  140. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  141. return cottages.sleep_in_bed( pos, node, clicker, itemstack, pointed_thing );
  142. end
  143. })
  144. -- furniture; possible replacement: 3dforniture:chair
  145. minetest.register_node("cottages:bench", {
  146. drawtype = "nodebox",
  147. description = S("simple wooden bench"),
  148. tiles = {"cottages_minimal_wood.png", "cottages_minimal_wood.png", "cottages_minimal_wood.png", "cottages_minimal_wood.png", "cottages_minimal_wood.png", "cottages_minimal_wood.png"},
  149. paramtype = "light",
  150. paramtype2 = "facedir",
  151. groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
  152. sounds = cottages.sounds.wood,
  153. node_box = {
  154. type = "fixed",
  155. fixed = {
  156. -- sitting area
  157. {-0.5, -0.15, 0.1, 0.5, -0.05, 0.5},
  158. -- stützen
  159. {-0.4, -0.5, 0.2, -0.3, -0.15, 0.4},
  160. { 0.3, -0.5, 0.2, 0.4, -0.15, 0.4},
  161. }
  162. },
  163. selection_box = {
  164. type = "fixed",
  165. fixed = {
  166. {-0.5, -0.5, 0, 0.5, 0, 0.5},
  167. }
  168. },
  169. is_ground_content = false,
  170. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  171. return cottages.sit_on_bench( pos, node, clicker, itemstack, pointed_thing );
  172. end,
  173. })
  174. -- a simple table; possible replacement: 3dforniture:table
  175. local cottages_table_def = {
  176. description = S("table"),
  177. drawtype = "nodebox",
  178. -- top, bottom, side1, side2, inner, outer
  179. tiles = {"cottages_minimal_wood.png"},
  180. paramtype = "light",
  181. paramtype2 = "facedir",
  182. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  183. node_box = {
  184. type = "fixed",
  185. fixed = {
  186. { -0.1, -0.5, -0.1, 0.1, 0.3, 0.1},
  187. { -0.5, 0.48, -0.5, 0.5, 0.4, 0.5},
  188. },
  189. },
  190. selection_box = {
  191. type = "fixed",
  192. fixed = {
  193. { -0.5, -0.5, -0.5, 0.5, 0.4, 0.5},
  194. },
  195. },
  196. is_ground_content = false,
  197. }
  198. -- search for the workbench in AdventureTest
  199. local workbench = minetest.registered_nodes[ "workbench:3x3"];
  200. if( workbench ) then
  201. cottages_table_def.tiles = {workbench.tiles[1], cottages_table_def.tiles[1]};
  202. cottages_table_def.on_rightclick = workbench.on_rightclick;
  203. end
  204. -- search for the workbench from RealTEst
  205. workbench = minetest.registered_nodes[ "workbench:work_bench_birch"];
  206. if( workbench ) then
  207. cottages_table_def.tiles = {workbench.tiles[1], cottages_table_def.tiles[1]};
  208. cottages_table_def.on_construct = workbench.on_construct;
  209. cottages_table_def.can_dig = workbench.can_dig;
  210. cottages_table_def.on_metadata_inventory_take = workbench.on_metadata_inventory_take;
  211. cottages_table_def.on_metadata_inventory_move = workbench.on_metadata_inventory_move;
  212. cottages_table_def.on_metadata_inventory_put = workbench.on_metadata_inventory_put;
  213. end
  214. minetest.register_node("cottages:table", cottages_table_def );
  215. -- looks better than two slabs impersonating a shelf; also more 3d than a bookshelf
  216. -- the infotext shows if it's empty or not
  217. minetest.register_node("cottages:shelf", {
  218. description = S("open storage shelf"),
  219. drawtype = "nodebox",
  220. -- top, bottom, side1, side2, inner, outer
  221. tiles = {"cottages_minimal_wood.png"},
  222. paramtype = "light",
  223. paramtype2 = "facedir",
  224. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  225. node_box = {
  226. type = "fixed",
  227. fixed = {
  228. { -0.5, -0.5, -0.3, -0.4, 0.5, 0.5},
  229. { 0.4, -0.5, -0.3, 0.5, 0.5, 0.5},
  230. { -0.5, -0.2, -0.3, 0.5, -0.1, 0.5},
  231. { -0.5, 0.3, -0.3, 0.5, 0.4, 0.5},
  232. },
  233. },
  234. selection_box = {
  235. type = "fixed",
  236. fixed = {
  237. { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  238. },
  239. },
  240. on_construct = function(pos)
  241. local meta = minetest.get_meta(pos);
  242. local spos = pos.x .. "," .. pos.y .. "," .. pos.z
  243. meta:set_string("formspec",
  244. "size[8,8]"..
  245. "list[current_name;main;0,0;8,3;]"..
  246. "list[current_player;main;0,4;8,4;]"..
  247. "listring[nodemeta:" .. spos .. ";main]" ..
  248. "listring[current_player;main]")
  249. meta:set_string("infotext", S("open storage shelf"))
  250. local inv = meta:get_inventory();
  251. inv:set_size("main", 24);
  252. end,
  253. can_dig = function( pos,player )
  254. local meta = minetest.get_meta( pos );
  255. local inv = meta:get_inventory();
  256. return inv:is_empty("main");
  257. end,
  258. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  259. local meta = minetest.get_meta( pos );
  260. meta:set_string('infotext', S('open storage shelf (in use)'));
  261. end,
  262. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  263. local meta = minetest.get_meta( pos );
  264. local inv = meta:get_inventory();
  265. if( inv:is_empty("main")) then
  266. meta:set_string('infotext', S('open storage shelf (empty)'));
  267. end
  268. end,
  269. is_ground_content = false,
  270. })
  271. -- so that the smoke from a furnace can get out of a building
  272. minetest.register_node("cottages:stovepipe", {
  273. description = S("stovepipe"),
  274. drawtype = "nodebox",
  275. tiles = {"cottages_steel_block.png"},
  276. paramtype = "light",
  277. paramtype2 = "facedir",
  278. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  279. node_box = {
  280. type = "fixed",
  281. fixed = {
  282. { 0.20, -0.5, 0.20, 0.45, 0.5, 0.45},
  283. },
  284. },
  285. selection_box = {
  286. type = "fixed",
  287. fixed = {
  288. { 0.20, -0.5, 0.20, 0.45, 0.5, 0.45},
  289. },
  290. },
  291. is_ground_content = false,
  292. })
  293. -- this washing place can be put over a water source (it is open at the bottom)
  294. minetest.register_node("cottages:washing", {
  295. description = S("washing place"),
  296. drawtype = "nodebox",
  297. -- top, bottom, side1, side2, inner, outer
  298. tiles = {"cottages_clay.png"},
  299. paramtype = "light",
  300. paramtype2 = "facedir",
  301. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  302. node_box = {
  303. type = "fixed",
  304. fixed = {
  305. { -0.5, -0.5, -0.5, 0.5, -0.2, -0.2},
  306. { -0.5, -0.5, -0.2, -0.4, 0.2, 0.5},
  307. { 0.4, -0.5, -0.2, 0.5, 0.2, 0.5},
  308. { -0.4, -0.5, 0.4, 0.4, 0.2, 0.5},
  309. { -0.4, -0.5, -0.2, 0.4, 0.2, -0.1},
  310. },
  311. },
  312. selection_box = {
  313. type = "fixed",
  314. fixed = {
  315. { -0.5, -0.5, -0.5, 0.5, 0.2, 0.5},
  316. },
  317. },
  318. on_rightclick = function(pos, node, player)
  319. -- works only with water beneath
  320. local node_under = minetest.get_node( {x=pos.x, y=(pos.y-1), z=pos.z} );
  321. if( not( node_under ) or node_under.name == "ignore" or (node_under.name ~= 'default:water_source' and node_under.name ~= 'default:water_flowing')) then
  322. minetest.chat_send_player( player:get_player_name(), S("Sorry. This washing place is out of water. Please place it above water!"));
  323. else
  324. minetest.chat_send_player( player:get_player_name(), S("You feel much cleaner after some washing."));
  325. end
  326. end,
  327. is_ground_content = false,
  328. })
  329. ---------------------------------------------------------------------------------------
  330. -- functions for sitting or sleeping
  331. ---------------------------------------------------------------------------------------
  332. cottages.allow_sit = function( player )
  333. -- no check possible
  334. if( not( player.get_player_velocity )) then
  335. return true;
  336. end
  337. local velo = player:get_player_velocity();
  338. if( not( velo )) then
  339. return false;
  340. end
  341. local max_velo = 0.0001;
  342. if( math.abs(velo.x) < max_velo
  343. and math.abs(velo.y) < max_velo
  344. and math.abs(velo.z) < max_velo ) then
  345. return true;
  346. end
  347. return false;
  348. end
  349. cottages.sit_on_bench = function( pos, node, clicker, itemstack, pointed_thing )
  350. if( not( clicker ) or not( default.player_get_animation ) or not( cottages.allow_sit( clicker ))) then
  351. return;
  352. end
  353. local animation = default.player_get_animation( clicker );
  354. local pname = clicker:get_player_name();
  355. if( animation and animation.animation=="sit") then
  356. default.player_attached[pname] = false
  357. clicker:set_pos({x=pos.x,y=pos.y-0.5,z=pos.z})
  358. clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
  359. clicker:set_physics_override(1, 1, 1)
  360. default.player_set_animation(clicker, "stand", 30)
  361. else
  362. -- the bench is not centered; prevent the player from sitting on air
  363. local p2 = {x=pos.x, y=pos.y, z=pos.z};
  364. if not( node ) or node.param2 == 0 then
  365. p2.z = p2.z+0.3;
  366. elseif node.param2 == 1 then
  367. p2.x = p2.x+0.3;
  368. elseif node.param2 == 2 then
  369. p2.z = p2.z-0.3;
  370. elseif node.param2 == 3 then
  371. p2.x = p2.x-0.3;
  372. end
  373. clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0})
  374. clicker:set_pos( p2 )
  375. default.player_set_animation(clicker, "sit", 30)
  376. clicker:set_physics_override(0, 0, 0)
  377. default.player_attached[pname] = true
  378. end
  379. end
  380. cottages.sleep_in_bed = function( pos, node, clicker, itemstack, pointed_thing )
  381. if( not( clicker ) or not( node ) or not( node.name ) or not( pos ) or not( cottages.allow_sit( clicker))) then
  382. return;
  383. end
  384. local animation = default.player_get_animation( clicker );
  385. local pname = clicker:get_player_name();
  386. local p_above = minetest.get_node( {x=pos.x, y=pos.y+1, z=pos.z});
  387. if( not( p_above) or not( p_above.name ) or p_above.name ~= 'air' ) then
  388. minetest.chat_send_player( pname, "This place is too narrow for sleeping. At least for you!");
  389. return;
  390. end
  391. local place_name = 'place';
  392. -- if only one node is present, the player can only sit;
  393. -- sleeping requires a bed head+foot or two sleeping mats
  394. local allow_sleep = false;
  395. local new_animation = 'sit';
  396. -- let players get back up
  397. if( animation and animation.animation=="lay" ) then
  398. default.player_attached[pname] = false
  399. clicker:set_pos({x=pos.x,y=pos.y-0.5,z=pos.z})
  400. clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
  401. clicker:set_physics_override(1, 1, 1)
  402. default.player_set_animation(clicker, "stand", 30)
  403. minetest.chat_send_player( pname, 'That was enough sleep for now. You stand up again.');
  404. return;
  405. end
  406. local second_node_pos = {x=pos.x, y=pos.y, z=pos.z};
  407. -- the node that will contain the head of the player
  408. local p = {x=pos.x, y=pos.y, z=pos.z};
  409. -- the player's head is pointing in this direction
  410. local dir = node.param2;
  411. -- it would be odd to sleep in half a bed
  412. if( node.name=='cottages:bed_head' ) then
  413. if( node.param2==0 ) then
  414. second_node_pos.z = pos.z-1;
  415. elseif( node.param2==1) then
  416. second_node_pos.x = pos.x-1;
  417. elseif( node.param2==2) then
  418. second_node_pos.z = pos.z+1;
  419. elseif( node.param2==3) then
  420. second_node_pos.x = pos.x+1;
  421. end
  422. local node2 = minetest.get_node( second_node_pos );
  423. if( not( node2 ) or not( node2.param2 ) or not( node.param2 )
  424. or node2.name ~= 'cottages:bed_foot'
  425. or node2.param2 ~= node.param2 ) then
  426. allow_sleep = false;
  427. else
  428. allow_sleep = true;
  429. end
  430. place_name = 'bed';
  431. -- if the player clicked on the foot of the bed, locate the head
  432. elseif( node.name=='cottages:bed_foot' ) then
  433. if( node.param2==2 ) then
  434. second_node_pos.z = pos.z-1;
  435. elseif( node.param2==3) then
  436. second_node_pos.x = pos.x-1;
  437. elseif( node.param2==0) then
  438. second_node_pos.z = pos.z+1;
  439. elseif( node.param2==1) then
  440. second_node_pos.x = pos.x+1;
  441. end
  442. local node2 = minetest.get_node( second_node_pos );
  443. if( not( node2 ) or not( node2.param2 ) or not( node.param2 )
  444. or node2.name ~= 'cottages:bed_head'
  445. or node2.param2 ~= node.param2 ) then
  446. allow_sleep = false;
  447. else
  448. allow_sleep = true;
  449. end
  450. if( allow_sleep==true ) then
  451. p = {x=second_node_pos.x, y=second_node_pos.y, z=second_node_pos.z};
  452. end
  453. place_name = 'bed';
  454. elseif( node.name=='cottages:sleeping_mat' or node.name=='cottages:straw_mat' or node.name=='cottages:sleeping_mat_head') then
  455. place_name = 'mat';
  456. dir = node.param2;
  457. allow_sleep = false;
  458. -- search for a second mat right next to this one
  459. local offset = {{x=0,z=-1}, {x=-1,z=0}, {x=0,z=1}, {x=1,z=0}};
  460. for i,off in ipairs( offset ) do
  461. node2 = minetest.get_node( {x=pos.x+off.x, y=pos.y, z=pos.z+off.z} );
  462. if( node2.name == 'cottages:sleeping_mat' or node2.name=='cottages:straw_mat' or node.name=='cottages:sleeping_mat_head' ) then
  463. -- if a second mat is found, sleeping is possible
  464. allow_sleep = true;
  465. dir = i-1;
  466. end
  467. end
  468. end
  469. -- set the right height for the bed
  470. if( place_name=='bed' ) then
  471. p.y = p.y+0.4;
  472. end
  473. if( allow_sleep==true ) then
  474. -- set the right position (middle of the bed)
  475. if( dir==0 ) then
  476. p.z = p.z-0.5;
  477. elseif( dir==1 ) then
  478. p.x = p.x-0.5;
  479. elseif( dir==2 ) then
  480. p.z = p.z+0.5;
  481. elseif( dir==3 ) then
  482. p.x = p.x+0.5;
  483. end
  484. end
  485. if( default.player_attached[pname] and animation.animation=="sit") then
  486. -- just changing the animation...
  487. if( allow_sleep==true ) then
  488. default.player_set_animation(clicker, "lay", 30)
  489. clicker:set_eye_offset({x=0,y=-14,z=2}, {x=0,y=0,z=0})
  490. minetest.chat_send_player( pname, 'You lie down and take a nap. A right-click will wake you up.');
  491. return;
  492. -- no sleeping on this place
  493. else
  494. default.player_attached[pname] = false
  495. clicker:set_pos({x=pos.x,y=pos.y-0.5,z=pos.z})
  496. clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
  497. clicker:set_physics_override(1, 1, 1)
  498. default.player_set_animation(clicker, "stand", 30)
  499. minetest.chat_send_player( pname, 'That was enough sitting around for now. You stand up again.');
  500. return;
  501. end
  502. end
  503. clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0})
  504. clicker:set_pos( p );
  505. default.player_set_animation(clicker, new_animation, 30)
  506. clicker:set_physics_override(0, 0, 0)
  507. default.player_attached[pname] = true
  508. if( allow_sleep==true) then
  509. minetest.chat_send_player( pname, 'Aaah! What a comftable '..place_name..'. A second right-click will let you sleep.');
  510. else
  511. minetest.chat_send_player( pname, 'Comftable, but not good enough for a nap. Right-click again if you want to get back up.');
  512. end
  513. end
  514. ---------------------------------------------------------------------------------------
  515. -- crafting receipes
  516. ---------------------------------------------------------------------------------------
  517. minetest.register_craft({
  518. output = "cottages:bed_foot",
  519. recipe = {
  520. {cottages.craftitem_wool, "", "", },
  521. {cottages.craftitem_wood, "", "", },
  522. {cottages.craftitem_stick, "", "", }
  523. }
  524. })
  525. minetest.register_craft({
  526. output = "cottages:bed_head",
  527. recipe = {
  528. {"", "", cottages.craftitem_wool, },
  529. {"", cottages.craftitem_stick, cottages.craftitem_wood, },
  530. {"", "", cottages.craftitem_stick, }
  531. }
  532. })
  533. minetest.register_craft({
  534. output = "cottages:sleeping_mat 3",
  535. recipe = {
  536. {"cottages:wool_tent", "cottages:straw_mat","cottages:straw_mat" }
  537. }
  538. })
  539. minetest.register_craft({
  540. output = "cottages:sleeping_mat_head",
  541. recipe = {
  542. {"cottages:sleeping_mat","cottages:straw_mat" }
  543. }
  544. })
  545. minetest.register_craft({
  546. output = "cottages:table",
  547. recipe = {
  548. {"", cottages.craftitem_slab_wood, "", },
  549. {"", cottages.craftitem_stick, "" }
  550. }
  551. })
  552. minetest.register_craft({
  553. output = "cottages:bench",
  554. recipe = {
  555. {"", cottages.craftitem_wood, "", },
  556. {cottages.craftitem_stick, "", cottages.craftitem_stick, }
  557. }
  558. })
  559. minetest.register_craft({
  560. output = "cottages:shelf",
  561. recipe = {
  562. {cottages.craftitem_stick, cottages.craftitem_wood, cottages.craftitem_stick, },
  563. {cottages.craftitem_stick, cottages.craftitem_wood, cottages.craftitem_stick, },
  564. {cottages.craftitem_stick, "", cottages.craftitem_stick}
  565. }
  566. })
  567. minetest.register_craft({
  568. output = "cottages:washing 2",
  569. recipe = {
  570. {cottages.craftitem_stick, },
  571. {cottages.craftitem_clay, },
  572. }
  573. })
  574. minetest.register_craft({
  575. output = "cottages:stovepipe 2",
  576. recipe = {
  577. {cottages.craftitem_steel, '', cottages.craftitem_steel},
  578. }
  579. })