From b6fb2c83e02b2865d6207583d6e07c054e229fb1 Mon Sep 17 00:00:00 2001 From: kaadmy Date: Mon, 26 Oct 2015 15:03:42 -0700 Subject: [PATCH] added particles while underwater or eating --- mods/default/player.lua | 23 ++++++++++++++++++++++- mods/default/textures/magicpuff.png | Bin 0 -> 252 bytes mods/default/textures/magicpuff.xcf | Bin 0 -> 842 bytes mods/hunger/init.lua | 20 ++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 mods/default/textures/magicpuff.png create mode 100644 mods/default/textures/magicpuff.xcf diff --git a/mods/default/player.lua b/mods/default/player.lua index 068cfd5..e6fe802 100644 --- a/mods/default/player.lua +++ b/mods/default/player.lua @@ -3,6 +3,8 @@ local player_lastsound = {} local player_health = {} local player_lastpos = {} +local particlespawners = {} + local enable_flowing_water_sound = minetest.setting_getbool("enable_flowing_water_sound") if enable_flowing_water_sound == nil then enable_flowing_water_sound = true end @@ -57,9 +59,28 @@ local function step(dtime) }) player_lastsound[name] = 0 end + + particlespawners[name] = minetest.add_particlespawner( + { + amount = 5, + time = 0.1, + minpos = {x = player_pos.x - 0.2, y = player_pos.y - 0.3, z = player_pos.z - 0.3}, + maxpos = {x = player_pos.x + 0.3, y = player_pos.y + 0.3, z = player_pos.z + 0.3}, + minvel = {x = -0.5, y = 0, z = -0.5}, + maxvel = {x = 0.5, y = 0, z = 0.5}, + minacc = {x = -0.5, y = 4, z = -0.5}, + maxacc = {x = 0.5, y = 1, z = 0.5}, + minexptime = 0.3, + maxexptime = 0.8, + minsize = 0.7, + maxsize = 2.4, + texture = "bubble.png" + }) + + minetest.after(0.15, function() minetest.delete_particlespawner(particlespawners[name]) end) elseif flowing_water_pos then if player_lastsound[name] > 3.3 then - + local c = true for _, p in pairs(player_positions) do if (p.x * player_pos.x) + (p.y * player_pos.y) + (p.z * player_pos.z) < 256 then diff --git a/mods/default/textures/magicpuff.png b/mods/default/textures/magicpuff.png new file mode 100644 index 0000000000000000000000000000000000000000..41834467190742ad8919a8909e594f21147a9196 GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~mz1cb^pPcfXMsYJC9V-A&iT2ysd*&~&PAz-C8;S2 z<(VZJ3hti10pX2&;y^_yo-U3d5|?}XHu5$Y@UYzP(A?A(yt%Rcq>AJ*=^bf&>pzNU zXiRi?wCZy7ws?s){U-%E#R1Wqwmq5i_Vb0i`R0#r0v##A7MhwC6l!VR@b#!RPxQK; ow}Jm&7JO5>+H?3Ld)q^%$r0w!$zN6{0PSP&boFyt=akR{0E;$O;{X5v literal 0 HcmV?d00001 diff --git a/mods/default/textures/magicpuff.xcf b/mods/default/textures/magicpuff.xcf new file mode 100644 index 0000000000000000000000000000000000000000..4ca417e1899ddd82f7ac18fba2eabf672e683d08 GIT binary patch literal 842 zcmZ`%O-{l<82zSVMU?pO%Ec^Ufq`%XT@V+Oc!gTpG6_)9)(AIn=>a^0hv-3Aaty}z zwH>Sxzx3;S^S<{wO{bBbE#%S2ERr(&<^^x;_SPD ze*|ntcx=y)XR~0QVNE=|d`to_3&!$IXA?PkQqMd&FRXgzML{o0^q4ic1$EMFH4S7M zPxZLl>V%OWPvb;(3g{)#izoZ{{i61eK{e_k`m!f#=kkBT(Pg^ud_9lk!0rWcwNI?H z-s@avQqTQKka9i_!!*ctFUaY?QmOoo@^`38d|3vx=fhvr&EmwL@Q@FJ%SH3S7&JSX zv-7y(0J^L3R*j$3_-T!|Yy1qHpKI#~g!ka8{}iP{PH~)A*tdq)SysbJbKZIFnk^Y& z#88+u88h5$hK2w`Tt8^_(umECn{O!>Idb`$@|<%y0gBuXtzH_D%U!i4B@}XMO-gZ2 d5unKJ(CVcTIn^Rz8gyVBIy3_9fH$DE=o=YvuQmVx literal 0 HcmV?d00001 diff --git a/mods/hunger/init.lua b/mods/hunger/init.lua index 740c2ce..fba7879 100644 --- a/mods/hunger/init.lua +++ b/mods/hunger/init.lua @@ -11,6 +11,7 @@ hunger.active = {} -- how a player has been active recently hunger.moving = {} -- how much the player is moving hunger.saturation = {} -- how saturated with food the player is +local particlespawners = {} local player_step = {} local player_health_step = {} local player_bar = {} @@ -162,6 +163,25 @@ if minetest.setting_getbool("enable_damage") and minetest.setting_getbool("hunge headpos.y = headpos.y + 1 minetest.sound_play("hunger_eat", {pos = headpos, max_hear_distance = 8}) + particlespawners[name] = minetest.add_particlespawner( + { + amount = 10, + time = 0.1, + minpos = {x = headpos.x - 0.3, y = headpos.y - 0.3, z = headpos.z - 0.3}, + maxpos = {x = headpos.x + 0.3, y = headpos.y + 0.3, z = headpos.z + 0.3}, + minvel = {x = -1, y = -1, z = -1}, + maxvel = {x = 1, y = 0, z = 1}, + minacc = {x = 0, y = 6, z = 0}, + maxacc = {x = 0, y = 1, z = 0}, + minexptime = 0.5, + maxexptime = 1, + minsize = 0.5, + maxsize = 2, + texture = "magicpuff.png" + }) + + minetest.after(0.15, function() minetest.delete_particlespawner(particlespawners[name]) end) + player_effects.apply_effect(player, "hunger_eating") hunger.update_bar(player)