From 8a394747931e77303044def73e41e19dff47b52b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 19 Aug 2020 19:14:37 +0200 Subject: [PATCH] Add smoke particles at torches --- mods/CORE/mcl_particles/init.lua | 33 +++++++----- .../textures/mcl_particles_smoke.png | Bin 945 -> 126 bytes .../textures/mcl_particles_smoke_anim.png | Bin 0 -> 216 bytes mods/ITEMS/mcl_furnaces/init.lua | 4 +- mods/ITEMS/mcl_torches/init.lua | 48 ++++++++++++++++-- 5 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png diff --git a/mods/CORE/mcl_particles/init.lua b/mods/CORE/mcl_particles/init.lua index 4a89d733e..d3b4d02a5 100644 --- a/mods/CORE/mcl_particles/init.lua +++ b/mods/CORE/mcl_particles/init.lua @@ -1,12 +1,15 @@ -local particle_nodes = {} - mcl_particles = {} +-- Table of particlespawner IDs on a per-node hash basis +-- Keys: node position hashes +-- Values: Tables of particlespawner IDs (each node pos can have an arbitrary number of particlespawners) +local particle_nodes = {} + -- Node particles can be disabled via setting local node_particles_allowed = minetest.settings:get_bool("mcl_node_particles", true) -- Add a particlespawner that is assigned to a given node position. --- * pos: Node positon. MUST use rounded values! +-- * pos: Node positon. MUST use integer values! -- * particlespawner_definition: definition for minetest.add_particlespawner -- NOTE: All particlespawners are automatically removed on shutdown. -- Returns particlespawner ID on succcess and nil on failure @@ -22,22 +25,28 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition) if id == -1 then return end - particle_nodes[poshash] = id + if not particle_nodes[poshash] then + particle_nodes[poshash] = {} + end + table.insert(particle_nodes[poshash], id) return id end --- Deleted a particlespawner that is assigned to a node position, if one exists. --- Otherwise, this does nothing. --- pos: Node positon. MUST use rounded values! --- Returns true if particlespawner could be removed and false if none existed -function mcl_particles.delete_node_particlespawner(pos) +-- Deletes all particlespawners that are assigned to a node position. +-- If no particlespawners exist for this position, nothing happens. +-- pos: Node positon. MUST use integer values! +-- Returns true if particlespawner could be removed and false if not +function mcl_particles.delete_node_particlespawners(pos) if not node_particles_allowed then return false end local poshash = minetest.hash_node_position(pos) - local id = particle_nodes[poshash] - if id then - minetest.delete_particlespawner(id) + local ids = particle_nodes[poshash] + if ids then + for i=1, #ids do + minetest.delete_particlespawner(ids[i]) + end + particle_nodes[poshash] = nil return true end return false diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_smoke.png b/mods/CORE/mcl_particles/textures/mcl_particles_smoke.png index 6551db5b553170a796f8b03c61228a83aefeb18e..709cecf16169d37e4d88e24b78c2483dc67bc1e1 100644 GIT binary patch delta 108 zcmV-y0F(c*2Y!$kWM006mRRu}*P01Qw}R7C&)0Mpacs;a7rii(QA>N)@b00DGT zPE!Ct=GbNc001CKL_t(|0b^hdU=Urx5dDfFN1Gu>nqg%;gVh=a{to~|a0Xwis{#rD O0000nzVPdm$asOrq|@Iy|{4Tz<~?5sJIokB5vFY4ivX2 zZbei?0T=FpTT#Tl_ujbm?Z43HiD>vC?I(i7D*(XN6tWe7SHM6Qr49gKFc?CikVGOu z5Jcq(h%^qF-p&wgQ+Wb1y?tVcx3js(WfW$=`y`b9hL!k8q;XJ&`Z!OQ;lZAa)WnBm zt;Yt{XOYy)P0&61pMF^xn3BBgCmAZ0`r-XAVzHRd=Z~?oHzyglhlHVi9XS2pzY=7B zhjGc$sXmggwtm8XB6Knp#>~2n0e~TU$p* zM^{%@PfrhtL=yD%^$iRR3=Iv9jEszpjZr9+iHV7+si~QnnYp>Sg@uKsrKOdXm9@1s z8jZHGv9YzawX?IsU@-Rf_6`mXj*gB_PEO9w&Mq!4uCA_bZf@@G?pQ3=!^6YV)6>h# z%iG)A$H&Ll*VoU_&)?raARqvT!vzKg;_>*PprBwvaBxUSNN8wiSXfwicz8ra1c5+^ zjEszmii(boj){qhjg5_qi;ItsPe@2eOiUyai6jy!DJdyAIXNXIB{embOeUwLrKP8* zQz(>-jEv08%&e@e?Ck8EoSfX;+`PQJ{QP_>m0D0xP*_+*vMwHIUEj` z%WZ0EYHn_BX=!O~ZEb67U0q$>-Q7JsJ-xlXeSLlX{rv+21AIPz zaBy&FXlQtNcw}T`baZrVY;1gdoG>vlF*!LY5D2EGrlzN-g+k%X%#27Rnw_1Uo12@T zpI=y5SX^9OT3T9OUS3&QSzTRSTU%RSU*Fi+*xcOQ+S=OQ-rm{S+1=gU+uPgU-#<7w zI6OQ&IyyQ&K0Y})IXyi+J3Bi+Kfk!RxV*f)y1Kf)z7~tcH#ax8x3_nMySw}Q`-g{z z$H&K~r>E!V=a-ik2!i;FunGXc*8n4=F@PWlV6j-}|6($k%(oxE%LM?)AmA#fpn~@# zm3QFtk3EzJsAyD9;`?*yZ-+nYp|n|&ftXotJ?DhQ{qyM8H^l(``s-Z)001D=k#MG} GUG#s@J|Lz5 diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png b/mods/CORE/mcl_particles/textures/mcl_particles_smoke_anim.png new file mode 100644 index 0000000000000000000000000000000000000000..6c85a6feb9d0a654c51b7738e7e43336653ddf0c GIT binary patch literal 216 zcmV;}04M*6P)fC!|ll$A6RRuT>< znd>hJ72<;KWe)q>(7