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 zcmdnUUN=D^jft6ofnjH2m;{jG3GfMV1=5!1$UZ@$o`aczf#LH-znu&W%nSiOA+A8~s#U8lU%uSc)%E}X|Jl1Qbk5t-zhcj- z3r~P-AmiML-A^Cg+PZ4)G$EbKS{B(HN#R&xS2Rp)@oZX^yyBd?Un$T{SFc{(ym|AaNt4RU%dM=e ztgWqWY;0_8ZSCyr?CtFx92^`S9i5zizxw0|Ej90|SGCf`WsCLqbAALqo&D!otJDBO)RqBO{}tqN1atV`5@r zV`Jmu;^O1u6A}^<6BCn?l9H2?Q&Lh=Q&ZE@($dq@GcqzVGc&WYva++Yb8>QWb93|Z z^78ZZ3knJf3k!>iii(SiOG-*gOH0ej%79LeQ*zrcIkZefo?UGiJ`5IcwG|V93vzGiUDHx%1}Dn?Ha4f&~i} zE?l^1(W1qR>lZIsvSjJfrOTErTfThxiWMtXu3QO>{?)5juUWHZ?b@~L)~#E=e*K0G z8#Zp-xM|ZSV6bo5vSsVmt=qP3+rEAKjvYI8?%cU+*RI{WckkJ=XYby<`}XbIzkmOM z0|yQsJb38Pp~Hs{A31X5=+UFVC_jGu_=yuIPM$n@>eQ*zr%#_bbLQ;Xv-RiBojZU2 z{Dlh_E?&HN>Cz=&y1R1a3NV7NUAuPu`t=((Zrr?i^VY3fw{PFRbLY<8yLa#1yLbQo z{Ra;oJbd`@(W6I?A3uKbgPoF(|_Wb$t7cXACeEIU#t5>gIzkc)P&D*zc-@SYH z{{8z8A3l8i`0>-HPoF=3{_^DuFb#hD_U-%k??38){P_9v=dWMCe*gac=g*(NfB*jb z_YauFj@`0f3d{+nB|(0{3_v~uFiwFKaR3-->-dzIW&jP)_H=O!shA_%`(6V?X?Hl5?L7^=1+Sc`3-fq~c`C6W50YfaS>5meiJ_b)$KbLh*2~7ad CJ|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 zcmeAS@N?(olHy`uVBq!ia0vp^96;>A#0(^(vhGO&DV_kI5LY05`SRset5$UZ!TwiP zKt5whkY6x^!?PP{Ku(pXi(^OyV^RWdf31t~u@93(iHG=5!L&Cn;