init.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. furniture = {}
  2. furniture.players = {}
  3. furniture.dyes = {
  4. {'grey', 'Grey', '#808080'},
  5. {'dark_grey', 'Dark Grey', '#404040'},
  6. {'black', 'Black', '#1a1a1a'},
  7. {'violet', 'Violet', '#480680'},
  8. {'blue', 'Blue', '#00519d'},
  9. {'cyan', 'Cyan', '#00959d'},
  10. {'dark_green', 'Dark Green', '#004d00'},
  11. {'green', 'Green', '#008000'},
  12. {'yellow', 'Yellow', '#ffff00'},
  13. {'brown', 'Brown', '#40230f'},
  14. {'orange', 'Orange', '#ff5600'},
  15. {'red', 'Red', '#c91818'},
  16. {'magenta', 'Magenta', '#d80481'},
  17. {'pink', 'Pink', '#ff7dc8'},
  18. {'white', 'White', '#ffffff'},
  19. }
  20. furniture.playing = function(player) -- Is player playing or building a level?
  21. local name = player:get_player_name()
  22. if minetest.check_player_privs(player, {creative = true}) then
  23. return false --Has creative, is building level
  24. else
  25. return true --Does not have creative, in playing level
  26. end
  27. end
  28. furniture.punch = function(pos, node, puncher, pointed_thing)
  29. if furniture.playing(puncher) then
  30. furniture.stash_punch(pos, node, puncher, pointed_thing)
  31. else
  32. local def = minetest.registered_nodes[node.name]
  33. local paramtype2 = def.paramtype2
  34. if paramtype2 == 'colorfacedir' then
  35. furniture.dye_more(pos, node, puncher, pointed_thing)
  36. end
  37. end
  38. end
  39. furniture.right_click = function(pos, node, clicker)
  40. if furniture.playing(clicker) then
  41. --nothing yet
  42. else
  43. furniture.dye_less(pos, node, clicker)
  44. end
  45. end
  46. furniture.stash_punch = function(pos, node, puncher, pointed_thing)
  47. local meta = minetest.get_meta(pos)
  48. local inv = meta:get_inventory()
  49. if not inv:is_empty('stash') then
  50. local name = puncher:get_player_name()
  51. local player_attributes = puncher:get_meta()
  52. local luck = (player_attributes:get_int('luck') or 1) * 10
  53. local chance = math.random(0,105)
  54. if luck >= chance then
  55. local stuff = inv:get_list('stash')
  56. local random = math.random(1,8)
  57. local item = stuff[random]
  58. local drop = item:get_name()
  59. local player_inv = puncher:get_inventory()
  60. if player_inv:room_for_item('main', drop) then
  61. player_inv:add_item('main', drop)
  62. else
  63. minetest.chat_send_player(name, 'You don\'t have room for that.')
  64. end
  65. end
  66. end
  67. end
  68. furniture.dye_more = function(pos, node, puncher, pointed_thing)
  69. local player = puncher:get_player_name()
  70. local wield = puncher:get_wielded_item()
  71. local wield_name = wield:get_name()
  72. if minetest.is_protected(pos, player) and not minetest.check_player_privs(puncher, 'protection_bypass') or wield_name == 'creative:tool_breaking' then
  73. return
  74. end
  75. minetest.swap_node(pos, {name = node.name, param2 = node.param2+32})
  76. end
  77. furniture.dye_less = function(pos, node, clicker)
  78. local player = clicker:get_player_name()
  79. if minetest.is_protected(pos, player) and not minetest.check_player_privs(clicker, 'protection_bypass') then
  80. return
  81. end
  82. minetest.swap_node(pos, {name = node.name, param2 = node.param2-32})
  83. end
  84. dofile(minetest.get_modpath('furniture')..'/bathroom.lua') --Things you'd find in a bathroom
  85. dofile(minetest.get_modpath('furniture')..'/bedroom.lua') --Things you'd find in a bedroom.
  86. dofile(minetest.get_modpath('furniture')..'/curtains.lua')
  87. dofile(minetest.get_modpath('furniture')..'/fences.lua')
  88. dofile(minetest.get_modpath('furniture')..'/formspecs.lua') --Formspecs for the nodes.
  89. dofile(minetest.get_modpath('furniture')..'/kitchen.lua') --appliances and counters
  90. dofile(minetest.get_modpath('furniture')..'/library.lua') --Books things.
  91. dofile(minetest.get_modpath('furniture')..'/medical.lua') --Stuff you might find in a hospital
  92. dofile(minetest.get_modpath('furniture')..'/misc.lua') --Miscilanious things that don't particularly fit any single category
  93. dofile(minetest.get_modpath('furniture')..'/news.lua')
  94. dofile(minetest.get_modpath('furniture')..'/office.lua') --Things you'd find in an office.
  95. dofile(minetest.get_modpath('furniture')..'/outdoors.lua')
  96. dofile(minetest.get_modpath('furniture')..'/pallet_racking.lua') --Who'd think you'd need so stinking many nodes to represent four different bases.
  97. dofile(minetest.get_modpath('furniture')..'/retail_shelving.lua') --Shelves like you'd find in a store.
  98. dofile(minetest.get_modpath('furniture')..'/ropebox.lua')
  99. dofile(minetest.get_modpath('furniture')..'/seating.lua') --chairs, benches, stools
  100. dofile(minetest.get_modpath('furniture')..'/storage.lua') --Chests, boxes, etc.
  101. dofile(minetest.get_modpath('furniture')..'/tables.lua') --Not sure if I'll ever have more than one table.
  102. dofile(minetest.get_modpath('furniture')..'/traffic_signs.lua')
  103. dofile(minetest.get_modpath('furniture')..'/workshop.lua')