hemp.lua 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. local S = farming.intllib
  2. -- hemp seeds
  3. minetest.register_node("farming:seed_hemp", {
  4. description = S("Hemp Seed"),
  5. tiles = {"farming_hemp_seed.png"},
  6. inventory_image = "farming_hemp_seed.png",
  7. wield_image = "farming_hemp_seed.png",
  8. drawtype = "signlike",
  9. groups = {seed = 1, snappy = 3, attached_node = 1},
  10. paramtype = "light",
  11. paramtype2 = "wallmounted",
  12. walkable = false,
  13. sunlight_propagates = true,
  14. selection_box = farming.select,
  15. on_place = function(itemstack, placer, pointed_thing)
  16. return farming.place_seed(itemstack, placer, pointed_thing, "farming:hemp_1")
  17. end
  18. })
  19. -- harvested hemp
  20. minetest.register_craftitem("farming:hemp_leaf", {
  21. description = S("Hemp Leaf"),
  22. inventory_image = "farming_hemp_leaf.png"
  23. })
  24. -- hemp oil
  25. minetest.register_node("farming:hemp_oil", {
  26. description = S("Bottle of Hemp Oil"),
  27. drawtype = "plantlike",
  28. tiles = {"farming_hemp_oil.png"},
  29. inventory_image = "farming_hemp_oil.png",
  30. wield_image = "farming_hemp_oil.png",
  31. paramtype = "light",
  32. is_ground_content = false,
  33. walkable = false,
  34. selection_box = {
  35. type = "fixed",
  36. fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
  37. },
  38. groups = {food_oil = 1, vessel = 1, dig_immediate = 3, attached_node = 1},
  39. sounds = default.node_sound_glass_defaults()
  40. })
  41. minetest.register_craft( {
  42. output = "farming:hemp_oil",
  43. recipe = {
  44. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  45. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  46. {"", "vessels:glass_bottle", ""}
  47. }
  48. })
  49. minetest.register_craft( {
  50. output = "farming:hemp_oil",
  51. recipe = {
  52. {"farming:seed_hemp", "farming:seed_hemp", "farming:seed_hemp"},
  53. {"farming:seed_hemp", "farming:seed_hemp", "farming:seed_hemp"},
  54. {"farming:seed_hemp", "vessels:glass_bottle", "farming:seed_hemp"}
  55. }
  56. })
  57. minetest.register_craft({
  58. type = "fuel",
  59. recipe = "farming:hemp_oil",
  60. burntime = 20,
  61. replacements = {{"farming:hemp_oil", "vessels:glass_bottle"}}
  62. })
  63. -- hemp fibre
  64. minetest.register_craftitem("farming:hemp_fibre", {
  65. description = S("Hemp Fibre"),
  66. inventory_image = "farming_hemp_fibre.png"
  67. })
  68. minetest.register_craft( {
  69. output = "farming:hemp_fibre 8",
  70. recipe = {
  71. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  72. {"farming:hemp_leaf", "group:water_bucket", "farming:hemp_leaf"},
  73. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
  74. },
  75. replacements = {{"group:water_bucket", "bucket:bucket_empty"}}
  76. })
  77. if minetest.get_modpath("bucket_wooden") then
  78. minetest.register_craft( {
  79. output = "farming:hemp_fibre 8",
  80. recipe = {
  81. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  82. {"farming:hemp_leaf", "group:water_bucket_wooden", "farming:hemp_leaf"},
  83. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
  84. },
  85. replacements = {{"group:water_bucket_wooden", "bucket_wooden:bucket_empty"}}
  86. })
  87. end
  88. -- hemp block
  89. minetest.register_node("farming:hemp_block", {
  90. description = S("Hemp Block"),
  91. tiles = {"farming_hemp_block.png"},
  92. paramtype = "light",
  93. groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2}
  94. })
  95. minetest.register_craft( {
  96. output = "farming:hemp_block",
  97. recipe = {
  98. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
  99. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
  100. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"}
  101. }
  102. })
  103. -- check and register stairs
  104. if minetest.global_exists("stairs") then
  105. if stairs.mod and stairs.mod == "redo" then
  106. stairs.register_all("hemp_block", "farming:hemp_block",
  107. {snappy = 1, flammable = 2},
  108. {"farming_hemp_block.png"},
  109. "Hemp Block",
  110. default.node_sound_leaves_defaults())
  111. else
  112. stairs.register_stair_and_slab("hemp_block", "farming:hemp_block",
  113. {snappy = 1, flammable = 2},
  114. {"farming_hemp_block.png"},
  115. "Hemp Block Stair",
  116. "Hemp Block Slab",
  117. default.node_sound_leaves_defaults())
  118. end
  119. end
  120. -- paper
  121. minetest.register_craft( {
  122. output = "default:paper 3",
  123. recipe = {
  124. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"}
  125. }
  126. })
  127. -- string
  128. minetest.register_craft( {
  129. output = "farming:cotton 3",
  130. recipe = {
  131. {"farming:hemp_fibre"},
  132. {"farming:hemp_fibre"},
  133. {"farming:hemp_fibre"}
  134. }
  135. })
  136. -- hemp rope
  137. minetest.register_node("farming:hemp_rope", {
  138. description = S("Hemp Rope"),
  139. walkable = false,
  140. climbable = true,
  141. sunlight_propagates = true,
  142. paramtype = "light",
  143. tiles = {"farming_hemp_rope.png"},
  144. wield_image = "farming_hemp_rope.png",
  145. inventory_image = "farming_hemp_rope.png",
  146. drawtype = "plantlike",
  147. groups = {flammable = 2, choppy = 3, oddly_breakable_by_hand = 3},
  148. sounds = default.node_sound_leaves_defaults(),
  149. selection_box = {
  150. type = "fixed",
  151. fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}
  152. }
  153. })
  154. -- string
  155. minetest.register_craft( {
  156. output = "farming:hemp_rope 6",
  157. recipe = {
  158. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
  159. {"farming:cotton", "farming:cotton", "farming:cotton"},
  160. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"}
  161. }
  162. })
  163. -- hemp definition
  164. local def = {
  165. drawtype = "plantlike",
  166. tiles = {"farming_hemp_1.png"},
  167. paramtype = "light",
  168. sunlight_propagates = true,
  169. walkable = false,
  170. buildable_to = true,
  171. drop = "",
  172. selection_box = farming.select,
  173. groups = {
  174. snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  175. not_in_creative_inventory = 1, growing = 1
  176. },
  177. sounds = default.node_sound_leaves_defaults()
  178. }
  179. -- stage 1
  180. minetest.register_node("farming:hemp_1", table.copy(def))
  181. -- stage 2
  182. def.tiles = {"farming_hemp_2.png"}
  183. minetest.register_node("farming:hemp_2", table.copy(def))
  184. -- stage 3
  185. def.tiles = {"farming_hemp_3.png"}
  186. minetest.register_node("farming:hemp_3", table.copy(def))
  187. -- stage 4
  188. def.tiles = {"farming_hemp_4.png"}
  189. minetest.register_node("farming:hemp_4", table.copy(def))
  190. -- stage 5
  191. def.tiles = {"farming_hemp_5.png"}
  192. minetest.register_node("farming:hemp_5", table.copy(def))
  193. -- stage 6
  194. def.tiles = {"farming_hemp_6.png"}
  195. def.drop = {
  196. items = {
  197. {items = {"farming:hemp_leaf"}, rarity = 2},
  198. {items = {"farming:seed_hemp"}, rarity = 1}
  199. }
  200. }
  201. minetest.register_node("farming:hemp_6", table.copy(def))
  202. -- stage 7
  203. def.tiles = {"farming_hemp_7.png"}
  204. def.drop = {
  205. items = {
  206. {items = {"farming:hemp_leaf"}, rarity = 1},
  207. {items = {"farming:hemp_leaf"}, rarity = 3},
  208. {items = {"farming:seed_hemp"}, rarity = 1},
  209. {items = {"farming:seed_hemp"}, rarity = 3}
  210. }
  211. }
  212. minetest.register_node("farming:hemp_7", table.copy(def))
  213. -- stage 8 (final)
  214. def.tiles = {"farming_hemp_8.png"}
  215. def.groups.growing = nil
  216. def.drop = {
  217. items = {
  218. {items = {"farming:hemp_leaf 2"}, rarity = 1},
  219. {items = {"farming:hemp_leaf"}, rarity = 2},
  220. {items = {"farming:seed_hemp"}, rarity = 1},
  221. {items = {"farming:seed_hemp"}, rarity = 2}
  222. }
  223. }
  224. minetest.register_node("farming:hemp_8", table.copy(def))
  225. -- add to registered_plants
  226. farming.registered_plants["farming:hemp"] = {
  227. crop = "farming:hemp",
  228. seed = "farming:seed_hemp",
  229. mminlight = farming.min_light,
  230. maxlight = farming.max_light,
  231. steps = 8
  232. }