added animation particles of fire and smoke

This commit is contained in:
Pavel Litvinoff 2017-02-13 19:44:20 +02:00
parent 1437b37f08
commit 41c99e7762
6 changed files with 31 additions and 32 deletions

View File

@ -1,6 +1,6 @@
Minetest mod "New Campfire" Minetest mod "New Campfire"
====================== ======================
Version: 0.1.1 Version: 0.2.0
# License of source code: # License of source code:
- Copyright (C) 2017 Pavel Litvinoff <googolgl@gmail.com> - Copyright (C) 2017 Pavel Litvinoff <googolgl@gmail.com>
@ -11,7 +11,7 @@ Version: 0.1.1
- License of media (models): CC BY-SA - License of media (models): CC BY-SA
# Notice: # Notice:
- This mod is only useable with Minetest 0.4.14 or above! - This mod is only useable with Minetest 0.4.15-dev or above!
# Description: # Description:
- You can craft and use better campfire. - You can craft and use better campfire.
@ -19,8 +19,8 @@ Version: 0.1.1
# Using the mod: # Using the mod:
- To use the campfire, you have to craft one. You need 2 stick and 3 stone to craft it following way: - To use the campfire, you have to craft one. You need 2 stick and 3 stone to craft it following way:
``` ```
group:stick default:stick
group:stone group:stick group:stone group:stone default:stick group:stone
group:stone group:stone
``` ```
- Just rightclick with a flint_and_steel in your hand on the campfire and it will flame. - Just rightclick with a flint_and_steel in your hand on the campfire and it will flame.
@ -30,9 +30,12 @@ group:stone group:stick group:stone
- Release - Release
#### [0.1.1] - 2017-02-08 #### [0.1.1] - 2017-02-08
- add initllib support - added initllib support
- improved texture fire - improved texture fire
#### [0.2.0] - 2017-02-13
- added animation particles of fire and smoke
# Links: # Links:
- Forum Topic: - Forum Topic:
- <https://forum.minetest.net/viewtopic.php?f=9&t=16611> - <https://forum.minetest.net/viewtopic.php?f=9&t=16611>

View File

@ -1,36 +1,35 @@
-- VARIABLES
new_campfire = {}
-- Load support for intllib. -- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua") local S, NS = dofile(MP.."/intllib.lua")
-- VARIABLES
new_campfire = {}
local id = {}
-- FUNCTIONS -- FUNCTIONS
local function fire_particles_on(pos) -- 3 layers of fire local function fire_particles_on(pos) -- 3 layers of fire
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
id = minetest.add_particlespawner({ -- 1 layer big particles fire local id = minetest.add_particlespawner({ -- 1 layer big particles fire
amount = 33, amount = 26,
time = 3, time = 3,
minpos = {x = pos.x - 0.2, y = pos.y - 0.4, z = pos.z - 0.2}, minpos = {x = pos.x - 0.2, y = pos.y - 0.4, z = pos.z - 0.2},
maxpos = {x = pos.x + 0.2, y = pos.y, z = pos.z + 0.2}, maxpos = {x = pos.x + 0.2, y = pos.y - 0.1, z = pos.z + 0.2},
minvel = {x= 0, y= 0, z= 0}, minvel = {x= 0, y= 0, z= 0},
maxvel = {x= 0, y= 0.1, z= 0}, maxvel = {x= 0, y= 0.1, z= 0},
minacc = {x= 0, y= 0, z= 0}, minacc = {x= 0, y= 0, z= 0},
maxacc = {x= 0, y= 1, z= 0}, maxacc = {x= 0, y= 0.5, z= 0},
minexptime = 0.3, minexptime = 0.3,
maxexptime = 0.3, maxexptime = 0.6,
minsize = 2, minsize = 2,
maxsize = 4, maxsize = 5,
collisiondetection = false, collisiondetection = false,
vertical = true, vertical = true,
texture = "cfire.png", texture = "anim_cfire.png",
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 0.7,},
-- playername = "singleplayer" -- playername = "singleplayer"
}) })
-- print(id)
meta:set_int("layer_1", id) meta:set_int("layer_1", id)
id = minetest.add_particlespawner({ -- 2 layer smol particles fire local id = minetest.add_particlespawner({ -- 2 layer smol particles fire
amount = 3, amount = 3,
time = 3, time = 3,
minpos = {x = pos.x - 0.1, y = pos.y, z = pos.z - 0.1}, minpos = {x = pos.x - 0.1, y = pos.y, z = pos.z - 0.1},
@ -40,22 +39,22 @@ local function fire_particles_on(pos) -- 3 layers of fire
minacc = {x= 0, y= 0, z= 0}, minacc = {x= 0, y= 0, z= 0},
maxacc = {x= 0, y= 1, z= 0}, maxacc = {x= 0, y= 1, z= 0},
minexptime = 0.3, minexptime = 0.3,
maxexptime = 0.3, maxexptime = 0.5,
minsize = 0.3, minsize = 0.5,
maxsize = 0.7, maxsize = 0.7,
collisiondetection = false, collisiondetection = false,
vertical = true, vertical = true,
texture = "cfire.png", texture = "anim_cfire.png",
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 0.6,},
-- playername = "singleplayer" -- показывать только определенному игроку. -- playername = "singleplayer" -- показывать только определенному игроку.
}) })
-- print(id)
meta:set_int("layer_2", id) meta:set_int("layer_2", id)
id = minetest.add_particlespawner({ --3 layer smoke local id = minetest.add_particlespawner({ --3 layer smoke
amount = 6, amount = 6,
time = 3, time = 3,
minpos = {x = pos.x - 0.1, y = pos.y - 0.2, z = pos.z - 0.1}, minpos = {x = pos.x - 0.1, y = pos.y - 0.2, z = pos.z - 0.1},
maxpos = {x = pos.x + 0.1, y = pos.y + 0.4, z = pos.z + 0.1}, maxpos = {x = pos.x + 0.2, y = pos.y + 0.4, z = pos.z + 0.2},
minvel = {x= 0, y= 0, z= 0}, minvel = {x= 0, y= 0, z= 0},
maxvel = {x= 0, y= 0.1, z= 0}, maxvel = {x= 0, y= 0.1, z= 0},
minacc = {x= 0, y= 0, z= 0}, minacc = {x= 0, y= 0, z= 0},
@ -66,10 +65,10 @@ local function fire_particles_on(pos) -- 3 layers of fire
maxsize = 4, maxsize = 4,
collisiondetection = true, collisiondetection = true,
vertical = true, vertical = true,
texture = "smoke.png", texture = "anim_smoke.png",
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 0.7,},
-- playername = "singleplayer" -- playername = "singleplayer"
}) })
-- print(id)
meta:set_int("layer_3", id) meta:set_int("layer_3", id)
end end
@ -124,14 +123,12 @@ minetest.register_node('new_campfire:campfire', {
size = 4, size = 4,
collisiondetection = true, collisiondetection = true,
vertical = true, vertical = true,
texture = "smoke.png", texture = "anim_smoke.png",
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 2.5,},
-- playername = "singleplayer" -- playername = "singleplayer"
}) })
end end
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
end,
}) })
minetest.register_node('new_campfire:campfire_active', { minetest.register_node('new_campfire:campfire_active', {
@ -173,7 +170,6 @@ minetest.register_node('new_campfire:campfire_active', {
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local handle = minetest.sound_play("fire_small",{pos=pos, max_hear_distance = 18, loop=false, gain=0.1}) local handle = minetest.sound_play("fire_small",{pos=pos, max_hear_distance = 18, loop=false, gain=0.1})
meta:set_int("handle", handle) meta:set_int("handle", handle)
-- print (handle)
minetest.get_node_timer(pos):start(6) minetest.get_node_timer(pos):start(6)
end, end,
}) })
@ -205,7 +201,7 @@ minetest.register_abm({
minetest.register_craft({ minetest.register_craft({
output = "new_campfire:campfire", output = "new_campfire:campfire",
recipe = { recipe = {
{'', 'group:stick', ''}, {'', 'default:stick', ''},
{'group:stone','default:stick', 'group:stone'}, {'group:stone','default:stick', 'group:stone'},
{'', 'group:stone', ''}, {'', 'group:stone', ''},
} }

BIN
textures/anim_cfire.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

BIN
textures/anim_smoke.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B