library.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. minetest.register_node('furniture:lectern', {
  2. _doc_items_crafting = 'This is crafted in the Woodworking Station.',
  3. description = 'Lectern',
  4. drawtype = 'mesh',
  5. mesh = 'furniture_lectern.obj',
  6. tiles = {'furniture_lectern.png',},
  7. overlay_tiles = {{name='furniture_lectern_overlay.png', color='white'}},
  8. sounds = default.node_sound_wood_defaults(),
  9. paramtype2 = 'colorfacedir',
  10. palette = 'furniture_stain_palette.png',
  11. paramtype = 'light',
  12. selection_box = {
  13. type = 'fixed',
  14. fixed = {-.3, -.5, -.3, .3, .5, .3},
  15. },
  16. collision_box = {
  17. type = 'fixed',
  18. fixed = {-.3, -.5, -.3, .3, .5, .3},
  19. },
  20. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  21. after_place_node = function(pos, placer)
  22. local meta = minetest.get_meta(pos)
  23. meta:set_string('owner', placer:get_player_name())
  24. meta:set_string('infotext', '')
  25. meta:set_string('title', '')
  26. meta:set_string('content', '')
  27. end,
  28. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  29. local name = clicker:get_player_name()
  30. local meta = minetest.get_meta(pos)
  31. local owner = meta:get_string('owner')
  32. local title = meta:get_string('title')
  33. local content = meta:get_string('content')
  34. if owner == name then
  35. meta:set_string('formspec', furniture.lectern_edit_sign(title, content))
  36. else
  37. meta:set_string('formspec', furniture.lectern_view_sign(title, content))
  38. end
  39. end,
  40. on_receive_fields = function(pos, formname, fields, sender)
  41. local meta = minetest.get_meta(pos)
  42. if fields ['save'] then
  43. local player_name = sender:get_player_name()
  44. meta:set_string('infotext', fields.title)
  45. meta:set_string('title', fields.title)
  46. meta:set_string('content', fields.content)
  47. minetest.log("action", (player_name or "").." wrote \""..fields.title.."\" to lectern at "..minetest.pos_to_string(pos))
  48. end
  49. end,
  50. })
  51. minetest.register_node('furniture:lectern_encyclopedia', {
  52. description = 'Lectern with Encyclopedia',
  53. drawtype = 'mesh',
  54. mesh = 'furniture_lectern.obj',
  55. tiles = {'furniture_lectern.png',},
  56. overlay_tiles = {{name='furniture_lectern_encylopedia_overlay.png', color='white'}},
  57. sounds = default.node_sound_wood_defaults(),
  58. paramtype2 = 'colorfacedir',
  59. palette = 'furniture_stain_palette.png',
  60. paramtype = 'light',
  61. selection_box = {
  62. type = 'fixed',
  63. fixed = {-.3, -.5, -.3, .3, .5, .3},
  64. },
  65. collision_box = {
  66. type = 'fixed',
  67. fixed = {-.3, -.5, -.3, .3, .5, .3},
  68. },
  69. groups = {oddly_breakable_by_hand = 2, choppy=3, stainable=1},
  70. on_rightclick = function(pos, node, clicker)
  71. doc.show_doc(clicker:get_player_name())
  72. end,
  73. })