pumpkin.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. minetest.register_craftitem("farming:pumpkin_seed", {
  2. description = "Pumpkin Seed",
  3. inventory_image = "farming_pumpkin_seed.png",
  4. on_place = function(itemstack, placer, pointed_thing)
  5. local above = minetest.env:get_node(pointed_thing.above)
  6. if above.name == "air" then
  7. above.name = "farming:pumpkin_1"
  8. minetest.env:set_node(pointed_thing.above, above)
  9. itemstack:take_item(1)
  10. return itemstack
  11. end
  12. end
  13. })
  14. minetest.register_node("farming:pumpkin_1", {
  15. paramtype = "light",
  16. sunlight_propagates = true,
  17. drawtype = "nodebox",
  18. drop = "",
  19. tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
  20. node_box = {
  21. type = "fixed",
  22. fixed = {
  23. {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
  24. },
  25. },
  26. selection_box = {
  27. type = "fixed",
  28. fixed = {
  29. {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
  30. },
  31. },
  32. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, not_in_creative_inventory=1},
  33. sounds = default.node_sound_wood_defaults(),
  34. })
  35. minetest.register_node("farming:pumpkin_2", {
  36. paramtype = "light",
  37. sunlight_propagates = true,
  38. drawtype = "nodebox",
  39. drop = "",
  40. tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
  41. node_box = {
  42. type = "fixed",
  43. fixed = {
  44. {-0.35, -0.5, -0.35, 0.35, 0.2, 0.35}
  45. },
  46. },
  47. selection_box = {
  48. type = "fixed",
  49. fixed = {
  50. {-0.35, -0.5, -0.35, 0.35, 0.2, 0.35}
  51. },
  52. },
  53. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, not_in_creative_inventory=1},
  54. sounds = default.node_sound_wood_defaults(),
  55. })
  56. minetest.register_node("farming:pumpkin", {
  57. description = "Pumpkin",
  58. paramtype2 = "facedir",
  59. tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
  60. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
  61. sounds = default.node_sound_wood_defaults(),
  62. on_punch = function(pos, node, puncher)
  63. local tool = puncher:get_wielded_item():get_name()
  64. if tool and tool == "default:sword_wood" or tool == "default:sword_stone" or tool == "default:sword_steel" then
  65. node.name = "farming:pumpkin_face"
  66. minetest.env:set_node(pos, node)
  67. puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed"))
  68. if math.random(1, 5) == 1 then
  69. puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed"))
  70. end
  71. end
  72. end
  73. })
  74. farming:add_plant("farming:pumpkin", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20)
  75. minetest.register_node("farming:pumpkin_face", {
  76. description = "Pumpkin",
  77. paramtype2 = "facedir",
  78. tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"},
  79. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
  80. sounds = default.node_sound_wood_defaults(),
  81. })
  82. minetest.register_node("farming:pumpkin_face_light", {
  83. description = "Pumpkin",
  84. paramtype2 = "facedir",
  85. light_source = LIGHT_MAX-2,
  86. tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"},
  87. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
  88. sounds = default.node_sound_wood_defaults(),
  89. })
  90. minetest.register_craft({
  91. type = "shapeless",
  92. output = "farming:pumpkin_face_light",
  93. recipe = {"farming:pumpkin_face", "default:torch"}
  94. })
  95. -- ========= BIG PUMPKIN =========
  96. minetest.register_node("farming:big_pumpkin", {
  97. description = "Big Pumpkin",
  98. paramtype2 = "facedir",
  99. tiles = {"farming_pumpkin_big_side.png"},
  100. selection_box = {
  101. type = "fixed",
  102. fixed = {
  103. {-1, -0.5, -1, 1, 1.5, 1}
  104. }
  105. },
  106. groups = {choppy=1, oddly_breakable_by_hand=1, flammable=2},
  107. sounds = default.node_sound_wood_defaults(),
  108. after_place_node = function(pos, placer)
  109. for dx=-1,1 do
  110. for dy=0,1 do
  111. for dz=-1,1 do
  112. pos.x = pos.x+dx
  113. pos.y = pos.y+dy
  114. pos.z = pos.z+dz
  115. if dx ~= 0 or dy ~= 0 or dz ~= 0 then
  116. if minetest.env:get_node(pos).name ~= "air" then
  117. pos.x = pos.x-dx
  118. pos.y = pos.y-dy
  119. pos.z = pos.z-dz
  120. minetest.env:remove_node(pos)
  121. minetest.after(0.1, function(placer)
  122. local inv = placer:get_inventory()
  123. local index = placer:get_wield_index()
  124. inv:set_stack("main", index, ItemStack("farming:big_pumpkin"))
  125. end, placer)
  126. return
  127. end
  128. end
  129. pos.x = pos.x-dx
  130. pos.y = pos.y-dy
  131. pos.z = pos.z-dz
  132. end
  133. end
  134. end
  135. for dy=0,1 do
  136. pos.y = pos.y+dy
  137. pos.z = pos.z+1
  138. minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=2})
  139. pos.x = pos.x-1
  140. minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=2})
  141. pos.x = pos.x+1
  142. pos.z = pos.z-2
  143. minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=4})
  144. pos.x = pos.x+1
  145. minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=4})
  146. pos.z = pos.z+1
  147. minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=3})
  148. pos.z = pos.z+1
  149. minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=3})
  150. pos.z = pos.z-1
  151. pos.x = pos.x-2
  152. minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=1})
  153. pos.z = pos.z-1
  154. minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=1})
  155. pos.z = pos.z+1
  156. pos.x = pos.x+1
  157. pos.y = pos.y-dy
  158. end
  159. pos.y = pos.y+1
  160. minetest.env:set_node(pos, {name="farming:big_pumpkin_top"})
  161. end,
  162. after_destruct = function(pos, oldnode)
  163. for dx=-1,1 do
  164. for dy=0,1 do
  165. for dz=-1,1 do
  166. pos.x = pos.x+dx
  167. pos.y = pos.y+dy
  168. pos.z = pos.z+dz
  169. local name = minetest.env:get_node(pos).name
  170. if string.find(name, "farming:big_pumpkin") then
  171. minetest.env:remove_node(pos)
  172. end
  173. pos.x = pos.x-dx
  174. pos.y = pos.y-dy
  175. pos.z = pos.z-dz
  176. end
  177. end
  178. end
  179. end
  180. })
  181. minetest.register_node("farming:big_pumpkin_side", {
  182. paramtype = "light",
  183. sunlight_propagates = true,
  184. paramtype2 = "facedir",
  185. tiles = {"farming_pumpkin_big_top_side.png", "farming_pumpkin_big_side.png"},
  186. drawtype = "nodebox",
  187. node_box = {
  188. type = "fixed",
  189. fixed = {
  190. {-0.5, -0.5, 0, 0.5, 0.5, 0.5}
  191. }
  192. },
  193. selection_box = {
  194. type = "fixed",
  195. fixed = {
  196. {0, 0, 0, 0, 0, 0}
  197. }
  198. },
  199. groups = {not_in_creative_inventory=1},
  200. })
  201. minetest.register_node("farming:big_pumpkin_corner", {
  202. paramtype = "light",
  203. sunlight_propagates = true,
  204. paramtype2 = "facedir",
  205. tiles = {"farming_pumpkin_big_top_corner.png", "farming_pumpkin_big_side.png"},
  206. drawtype = "nodebox",
  207. node_box = {
  208. type = "fixed",
  209. fixed = {
  210. {-0.5, -0.5, 0, 0, 0.5, 0.5}
  211. }
  212. },
  213. selection_box = {
  214. type = "fixed",
  215. fixed = {
  216. {0, 0, 0, 0, 0, 0}
  217. }
  218. },
  219. groups = {not_in_creative_inventory=1},
  220. })
  221. minetest.register_node("farming:big_pumpkin_top", {
  222. paramtype = "light",
  223. sunlight_propagates = true,
  224. tiles = {"farming_pumpkin_big_top.png"},
  225. selection_box = {
  226. type = "fixed",
  227. fixed = {
  228. {0, 0, 0, 0, 0, 0}
  229. }
  230. },
  231. groups = {not_in_creative_inventory=1},
  232. })
  233. minetest.register_craft({
  234. type = "shapeless",
  235. output = "farming:big_pumpkin",
  236. recipe = {"bucket:bucket_water", "farming:pumpkin"},
  237. replacements = {
  238. {"bucket:bucket_water", "bucket:bucket_empty"}
  239. }
  240. })
  241. -- ========= SCARECROW =========
  242. local box1 = {
  243. {-1, -8, -1, 1, 8, 1},
  244. }
  245. local box2 = {
  246. {-1, -8, -1, 1, 8, 1},
  247. {-12, -8, -1, 12, -7, 1},
  248. {-5, -2, -5, 5, 8, 5}
  249. }
  250. for j,list in ipairs(box1) do
  251. for i,int in ipairs(list) do
  252. list[i] = int/16
  253. end
  254. box1[j] = list
  255. end
  256. for j,list in ipairs(box2) do
  257. for i,int in ipairs(list) do
  258. list[i] = int/16
  259. end
  260. box2[j] = list
  261. end
  262. minetest.register_node("farming:scarecrow", {
  263. description = "Scarecrow",
  264. paramtype = "light",
  265. sunlight_propagates = true,
  266. paramtype2 = "facedir",
  267. tiles = {"farming_scarecrow_top.png", "farming_scarecrow_top.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_front.png"},
  268. drawtype = "nodebox",
  269. node_box = {
  270. type = "fixed",
  271. fixed = box2
  272. },
  273. selection_box = {
  274. type = "fixed",
  275. fixed = {
  276. {-12/16, -1.5, -0.5, 12/16, 0.5, 0.5}
  277. }
  278. },
  279. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
  280. after_place_node = function(pos, placer)
  281. local node = minetest.env:get_node(pos)
  282. local param2 = node.param2
  283. pos.y = pos.y+1
  284. if minetest.env:get_node(pos).name ~= "air" then
  285. pos.y = pos.y-1
  286. minetest.env:remove_node(pos)
  287. minetest.after(0.1, function(placer)
  288. local inv = placer:get_inventory()
  289. local index = placer:get_wield_index()
  290. inv:set_stack("main", index, ItemStack("farming:scarecrow"))
  291. end, placer)
  292. return
  293. end
  294. minetest.env:set_node(pos, node)
  295. pos.y = pos.y-1
  296. node.name = "farming:scarecrow_bottom"
  297. minetest.env:set_node(pos, node)
  298. end,
  299. after_destruct = function(pos, oldnode)
  300. pos.y = pos.y-1
  301. if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then
  302. minetest.env:remove_node(pos)
  303. end
  304. end
  305. })
  306. minetest.register_node("farming:scarecrow_bottom", {
  307. paramtype = "light",
  308. sunlight_propagates = true,
  309. paramtype2 = "facedir",
  310. tiles = {"default_wood.png"},
  311. drawtype = "nodebox",
  312. node_box = {
  313. type = "fixed",
  314. fixed = box1
  315. },
  316. groups = {not_in_creative_inventory=1},
  317. selection_box = {
  318. type = "fixed",
  319. fixed = {
  320. {0, 0, 0, 0, 0, 0}
  321. }
  322. }
  323. })
  324. minetest.register_craft({
  325. output = "farming:scarecrow",
  326. recipe = {
  327. {"", "farming:pumpkin_face", "",},
  328. {"default:stick", "default:stick", "default:stick",},
  329. {"", "default:stick", "",}
  330. }
  331. })
  332. minetest.register_node("farming:scarecrow_light", {
  333. description = "Scarecrow",
  334. paramtype = "light",
  335. sunlight_propagates = true,
  336. paramtype2 = "facedir",
  337. light_source = LIGHT_MAX-2,
  338. tiles = {"farming_scarecrow_top.png", "farming_scarecrow_top.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_front_light.png"},
  339. drawtype = "nodebox",
  340. node_box = {
  341. type = "fixed",
  342. fixed = box2
  343. },
  344. selection_box = {
  345. type = "fixed",
  346. fixed = {
  347. {-12/16, -1.5, -0.5, 12/16, 0.5, 0.5}
  348. }
  349. },
  350. groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
  351. after_place_node = function(pos, placer)
  352. local node = minetest.env:get_node(pos)
  353. local param2 = node.param2
  354. pos.y = pos.y+1
  355. if minetest.env:get_node(pos).name ~= "air" then
  356. pos.y = pos.y-1
  357. minetest.env:remove_node(pos)
  358. minetest.after(0.1, function(placer)
  359. local inv = placer:get_inventory()
  360. local index = placer:get_wield_index()
  361. inv:set_stack("main", index, ItemStack("farming:scarecrow_light"))
  362. end, placer)
  363. return
  364. end
  365. minetest.env:set_node(pos, node)
  366. pos.y = pos.y-1
  367. node.name = "farming:scarecrow_bottom"
  368. minetest.env:set_node(pos, node)
  369. end,
  370. after_destruct = function(pos, oldnode)
  371. pos.y = pos.y-1
  372. if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then
  373. minetest.env:remove_node(pos)
  374. end
  375. end
  376. })
  377. minetest.register_craft({
  378. output = "farming:scarecrow_light",
  379. recipe = {
  380. {"", "farming:pumpkin_face_light", "",},
  381. {"default:stick", "default:stick", "default:stick",},
  382. {"", "default:stick", "",}
  383. }
  384. })
  385. -- ========= FUEL =========
  386. minetest.register_craft({
  387. type = "fuel",
  388. recipe = "farming:pumpkin_seed",
  389. burntime = 1
  390. })
  391. minetest.register_craft({
  392. type = "fuel",
  393. recipe = "farming:pumpkin",
  394. burntime = 5
  395. })
  396. minetest.register_craft({
  397. type = "fuel",
  398. recipe = "farming:pumpkin_face",
  399. burntime = 5
  400. })
  401. minetest.register_craft({
  402. type = "fuel",
  403. recipe = "farming:pumpkin_face_light",
  404. burntime = 7
  405. })
  406. minetest.register_craft({
  407. type = "fuel",
  408. recipe = "farming:big_pumpkin",
  409. burntime = 10
  410. })
  411. minetest.register_craft({
  412. type = "fuel",
  413. recipe = "farming:scarecrow",
  414. burntime = 5
  415. })
  416. minetest.register_craft({
  417. type = "fuel",
  418. recipe = "farming:scarecrow_light",
  419. burntime = 5
  420. })