From 5beb878ec65e339884f59725855d067f162d04c7 Mon Sep 17 00:00:00 2001 From: TheRandomLegoBrick Date: Fri, 12 Aug 2022 11:05:54 -0700 Subject: [PATCH] Add campfire smoke --- mods/ITEMS/mcl_campfires/init.lua | 76 +++++++++++++++++- mods/ITEMS/mcl_campfires/textures/desktop.ini | 2 + .../textures/mcl_campfires_smoke_0.png | Bin 0 -> 235 bytes .../textures/mcl_campfires_smoke_1.png | Bin 0 -> 266 bytes .../textures/mcl_campfires_smoke_10.png | Bin 0 -> 203 bytes .../textures/mcl_campfires_smoke_11.png | Bin 0 -> 165 bytes .../textures/mcl_campfires_smoke_2.png | Bin 0 -> 303 bytes .../textures/mcl_campfires_smoke_3.png | Bin 0 -> 294 bytes .../textures/mcl_campfires_smoke_4.png | Bin 0 -> 308 bytes .../textures/mcl_campfires_smoke_5.png | Bin 0 -> 298 bytes .../textures/mcl_campfires_smoke_6.png | Bin 0 -> 298 bytes .../textures/mcl_campfires_smoke_7.png | Bin 0 -> 256 bytes .../textures/mcl_campfires_smoke_8.png | Bin 0 -> 259 bytes .../textures/mcl_campfires_smoke_9.png | Bin 0 -> 240 bytes mods/ITEMS/mcl_farming/wheat.lua | 13 +++ 15 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 mods/ITEMS/mcl_campfires/textures/desktop.ini create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_0.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_1.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_10.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_11.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_2.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_3.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_4.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_5.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_6.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_7.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_8.png create mode 100644 mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_9.png diff --git a/mods/ITEMS/mcl_campfires/init.lua b/mods/ITEMS/mcl_campfires/init.lua index e51ec9f54..a3ed657f6 100644 --- a/mods/ITEMS/mcl_campfires/init.lua +++ b/mods/ITEMS/mcl_campfires/init.lua @@ -3,13 +3,84 @@ -- |||||||||||||||||||||||||||||||| -- TO-DO: --- * Add Smoke Particles -- * Add Spark Particles -- * Add Cooking Meat -- * Add Working Sounds local S = minetest.get_translator(minetest.get_current_modname()) + +mcl_campfires = {} + +function mcl_campfires.register_smoke(pos) + local meta = minetest.get_meta(pos) + + -- delete existing spawner + local existing_spawner = meta:get_int("smoke_particlespawner") + if existing_spawner ~= 0 then + minetest.delete_particlespawner(existing_spawner) + end + + -- velocity: 0.5 + -- acceleration: 0.1 + ------------------------ + -- 7 seconds ~= 10 nodes + -- 12 seconds ~= 20 nodes + + local time = 7 + if minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "mcl_farming:hay_block" then + time = 12 + end + + -- create new spawner + local smokeID = minetest.add_particlespawner({ + time = 0, + ammount = 0.2, + collisiondetection = true, + texture = "mcl_campfires_smoke_4.png", + texpool = { + { name = "mcl_campfires_smoke_0.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_2.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_3.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_4.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_5.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_7.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_8.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_9.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_1.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_10.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_11.png", alpha_tween = {1, 0}}, + }, + + minpos = {x=pos.x - 0.25, y=pos.y + 0.25, z=pos.z - 0.25}, + maxpos = {x=pos.x + 0.25, y=pos.y + 0.25, z=pos.z + 0.25}, + minvel = {x=0, y=1, z=0}, + maxvel = {x=0, y=1, z=0}, + minacc = {x=0, y=0.1, z=0}, + maxacc = {x=0, y=0.1, z=0}, + minexptime = time, + maxexptime = time, + minsize = 12, + maxsize = 12, + }) + + -- save the id in meta + meta:set_int("smoke_particlespawner", smokeID) + + return smokeID +end + +function mcl_campfires.remove_smoke(pos) + local meta = minetest.get_meta(pos) + local smokeID = meta:get_int("smoke_particlespawner") + + -- end function if smoke doesnt exist + if not smokeID then return 0 end + + return minetest.delete_particlespawner(smokeID) +end + + local campfires = { { name = "Campfire", lightlevel = 15, techname = "campfire", damage = 1, drops = "mcl_core:charcoal_lump 2" }, { name = "Soul Campfire", lightlevel = 10, techname = "soul_campfire", damage = 2, drops = "mcl_blackstone:soul_soil" }, @@ -76,11 +147,14 @@ for _, campfire in pairs(campfires) do groups = { handy=1, axey=1, material_wood=1, campfire=1, lit_campfire=1 }, paramtype = "light", paramtype2 = "facedir", + on_construct = mcl_campfires.register_smoke, + on_destruct = mcl_campfires.remove_smoke, on_rightclick = function (pos, node, player, itemstack, pointed_thing) if player:get_wielded_item():get_name():find("shovel") then node.name = "mcl_campfires:" .. campfire.techname minetest.set_node(pos, node) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) + mcl_campfires.remove_smoke(pos) end end, drop = campfire.drops, diff --git a/mods/ITEMS/mcl_campfires/textures/desktop.ini b/mods/ITEMS/mcl_campfires/textures/desktop.ini new file mode 100644 index 000000000..96ab76a82 --- /dev/null +++ b/mods/ITEMS/mcl_campfires/textures/desktop.ini @@ -0,0 +1,2 @@ +[LocalizedFileNames] +big_smoke_4.png=@big_smoke_4.png,0 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_0.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_0.png new file mode 100644 index 0000000000000000000000000000000000000000..454a97d7a25c2cc8ac7b059dd29d21329ee14c86 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n6^E#lOLmF93zIJzX3_EKVmU zNU$E3U2@dre|kbf!iVzm|NY*)%64aKY;1Vu@2g1!3MN$i{Kb3t*j#JFE5?GC&Ky5{ z*dY64&>XRi3BoSd{=7Ubz9YQD?7_Fc>;>OWU(c5~;_509x3A7QN@4-KoY{YVphGrK W)La-{@A?yHErX}4pUXO@geCw3DN%L+ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_1.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_1.png new file mode 100644 index 0000000000000000000000000000000000000000..93c7491f6af35118515ec12e8aa931ab94165cf9 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9FfW39%pYe1ncPZ!4!i_^&o z609Q3ZaGc=-o5*O)YVlYZeQJD1wE}p2H7Wr+!pbAba(#i_ckPH;^!}3 zW-}?Z{>uzAl2V>4U*-Vi8r@Xxnn2s~9|8{an^LB{Ts5^N?D{ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_10.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_10.png new file mode 100644 index 0000000000000000000000000000000000000000..0d8f732ce17b595ce9e565d8e1ae35bca032c4f4 GIT binary patch literal 203 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9GC*6JPa4g!U|JzX3_EKVmU zNU%1G{Mfzwzx%SwNsInJ4m#a&UZ5~guxQL70(Y)*K0-AbW|YuPgf#4n9GCrF)yAR{@1oJzX3_EKVmU zNU&~U{rB$OfA;;_Gd_4mNo4$WUv`p7BvX#Hgo&Yk3P)aV{=9IY1_n=8KbLh*2~7a{ CJ}vbC literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_2.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_2.png new file mode 100644 index 0000000000000000000000000000000000000000..2bf0d0c02bc8633a436f133a2ca8e0040f85a66e GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9E^;hY&w(LkZ~o-U3d7N_q9 z8S))6;IUDjH{nFE-GL(~_^m!M%=jsvTz{dLYhj(jr|Qe&Z)JAjYs%rFwa}hKI8B!+x6z_7s$yt ttHxR<4g69#--@pIdiu>V-5>ssc$Jg0{@w|>9|LqcgQu&X%Q~loCIErCbIbq$ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_3.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_3.png new file mode 100644 index 0000000000000000000000000000000000000000..aaa332d3d7a60f3fa964624a07772da406129b0d GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9FP(d}nl-vEV{dAc};Se#By zkl1qI{@uU(_wW8)@AOKdFjGuiwDEKNzPiI7K0Qrt6Bb{WxFY>v8pEcvlzpv?hwItc z*hHFVTrgdJ)aC#2)D=5+=(Je~?|L?U{r!ZmuTNjkf6x{ok@5F<7K4xA8G#h3NST|e zJ~wiluDAF+{(9*2^!~s?l@OJ{JL|HpxGnHIe7|Y`zJm$;>w{F%+(}xja^WzDW3epoQL70(Y)*K0-AbW|YuPgf#4n9E+t|e}%(}6-;JY5_^EKVN{ z+AVlkfk$*_Pr`gHu?34#n5XhgxH9vqswnr4OE;}2sQoyiZZ`KShrs)nwsRTY@s);s zanYPVGd#j6#F=HD#zPy~@_S_mDw*zmYkLvdZ2vxd)qSHK;{Ag2BN-VO7O|!Kz7ncf z6jHwG>Hp9NYcgxRf1c4+c%@vPuCUwlzG;M(CTAV%OuWO>$Z5Q|M wI2AehiJVFI6wgo3QL70(Y)*K0-AbW|YuPgf#4n9F{U9H4sd!W!NPZ!4!i_^&o z5}z6br?>3i{kxtG2nquQ+orF-Z_v@*WpE~HlZdmeu-)aOuC5Xjcs;v2|M_2F{rB$O z|3s;cjUZJycXmz|T+Pjqd5mqw2205_;jmv%lPi8KkZ921;5NzGGOthZ@agIO55+bf zFjeF{B=WeJ^P0mJgA2dvA00AvOS!Hf&9V8(k=E=Ui{yic9A4WqGczAqnK3ItOknDS i1U5zHlCy_d7#I#sOw5tobfXIBY6eeNKbLh*2~7Y{Wom!` literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_6.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_6.png new file mode 100644 index 0000000000000000000000000000000000000000..dfb9023a1e8d3e0bfa16bcab9e7e0e7c57c67110 GIT binary patch literal 298 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9FHrNu|rzXuAf@^oqOrgnQyx% z2o-Iz>i2NY&eh=RFgbrHr&WSEV6NEZ+~ORWKd_IZey-U$=cS-)}N%7Y{oUQu>bTxygtDnm{r-UW|u<>xJ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_7.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_7.png new file mode 100644 index 0000000000000000000000000000000000000000..1b1fb466bc6185f4beca9cd496e005723fd9b84f GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9F14N`ejVAB8q literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_8.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_8.png new file mode 100644 index 0000000000000000000000000000000000000000..903f3571afe903e04966da7b29d64118201fa1b6 GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9FX=I#SkTY*B&o-U3d7N?UF zBv?h5-D)QNd-v}DQCC-qxP5hpHxxeib6dpg(cSs)|EI6gY=wb>J8mr1elF=3v*Vb@ z1%~?a@BevtcnZ#*U`sS^;k?^0U0?pNY22=&d5q6mr?0;+AkQYo79|kgae9$N*I90# x8zzTE_SO8H@$l*C<2>qmG082GW?UHz3~LIkuS;lpc>{lqSv3Fv literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_9.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_9.png new file mode 100644 index 0000000000000000000000000000000000000000..f12057b471584d8d09afb0b8bb6a0860a99ad236 GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf#4n9FX6}?mE?*WAhJY5_^EKVmU zNU$>VOB8xWNM!sK7oVOgATF9%@$(n&;bU{HH?B%OsP^LhyMOU9AuWwS@bKwta~=aT zvjZ)@AD*5*&Z8f{KXFINQ=2=inT8ktpZs*_^z?p72_W!`*>TLH