initial commit
commit
de92c558a5
|
@ -0,0 +1,71 @@
|
||||||
|
----------------------------------
|
||||||
|
Particles for Minetest
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||||
|
|
||||||
|
Source Code: https://github.com/cornernote/minetest-infinite_chest
|
||||||
|
License: GPLv3
|
||||||
|
|
||||||
|
|
||||||
|
Inspired by Particles by sfan5: http://minetest.net/forum/viewtopic.php?id=1129
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------------
|
||||||
|
Description
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Creates 3D textured particles after digging nodes.
|
||||||
|
|
||||||
|
The particles scatter in random directions and bounce a little when they hit the ground.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------------
|
||||||
|
Modders Guide
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
If you want particles in your mod then simply add this line:
|
||||||
|
|
||||||
|
particles.register_dig_particle(node,texture,[params])
|
||||||
|
- node = the name of the node (your_mod:your_node)
|
||||||
|
- texture = a png file without the .png extension
|
||||||
|
- params = (optional) additional params that will be added to the entity table
|
||||||
|
|
||||||
|
EG:
|
||||||
|
create particles of wood after digging a bookshelf:
|
||||||
|
particles.register_dig_particle("default:bookshelf","default_wood")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------------
|
||||||
|
License
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------------
|
||||||
|
Credits
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Thank you to the minetest community who has shared their code and knowledge with me.
|
||||||
|
|
||||||
|
Special thanks in this mod to:
|
||||||
|
sfan5 - coded the original particles mod which i stole and made into this one
|
|
@ -0,0 +1,81 @@
|
||||||
|
--[[
|
||||||
|
|
||||||
|
Particles for Minetest
|
||||||
|
|
||||||
|
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||||
|
Source Code: https://github.com/cornernote/minetest-particles
|
||||||
|
License: GPLv3
|
||||||
|
|
||||||
|
API
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- expose api
|
||||||
|
particles = {}
|
||||||
|
|
||||||
|
-- dig_particles
|
||||||
|
particles.dig_particles = 8
|
||||||
|
|
||||||
|
-- registered_dig_particles
|
||||||
|
particles.registered_dig_particles = {nodes={},textures={}}
|
||||||
|
|
||||||
|
-- register_dig_particle
|
||||||
|
particles.register_dig_particle = function(node,texture,params)
|
||||||
|
particles.registered_dig_particles.nodes[node] = texture
|
||||||
|
if particles.registered_dig_particles.textures[texture] ~= nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
particles.registered_dig_particles.textures[texture] = true
|
||||||
|
local entity = {}
|
||||||
|
local size = math.random(9,17)/100
|
||||||
|
entity.visual_size = {x=size, y=size}
|
||||||
|
entity.visual = "cube"
|
||||||
|
entity.physical = true
|
||||||
|
entity.collisionbox = {-0.01,-0.01,-0.01,0.01,0.01,0.01}
|
||||||
|
entity.textures = {texture..".png",texture..".png",texture..".png",texture..".png",texture..".png",texture..".png"}
|
||||||
|
for i=1,particles.dig_particles do
|
||||||
|
entity.timer = math.random(100,150)/100
|
||||||
|
entity.bounce = math.random(50,70)/100
|
||||||
|
entity.on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer - dtime
|
||||||
|
if self.timer < 0 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
if self.timer < self.bounce then
|
||||||
|
self.bounce = 0
|
||||||
|
self.object:setvelocity({x=math.random()/10,y=math.random()+1,z=math.random()/10})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
entity.on_activate = function(self, staticdata)
|
||||||
|
self.object:setacceleration({x=0, y=-7-(math.random()*2), z=0})
|
||||||
|
end
|
||||||
|
if params~=nil then for k,v in pairs(params) do
|
||||||
|
entity[k]=v
|
||||||
|
end end
|
||||||
|
minetest.register_entity("particles:"..texture..i, entity)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- on_dignode
|
||||||
|
particles.on_dignode = function(pos, oldnode, digger)
|
||||||
|
if not particles.registered_dig_particles.nodes[oldnode.name] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local location = {}
|
||||||
|
local node = ""
|
||||||
|
for i=1,particles.dig_particles do
|
||||||
|
location.pos = {
|
||||||
|
x = pos.x+1-(math.random()*1.5),
|
||||||
|
y = pos.y+math.random()/2,
|
||||||
|
z = pos.z+1-(math.random()*1.5)
|
||||||
|
}
|
||||||
|
location.vel = {
|
||||||
|
x = math.random(-100,100)/100,
|
||||||
|
y = math.random()*2,
|
||||||
|
z = math.random(-100,100)/100
|
||||||
|
}
|
||||||
|
node = "particles:"..particles.registered_dig_particles.nodes[oldnode.name]..i
|
||||||
|
e = minetest.env:add_entity(location.pos, node)
|
||||||
|
e:setvelocity(location.vel)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
default
|
|
@ -0,0 +1,60 @@
|
||||||
|
--[[
|
||||||
|
|
||||||
|
Particles for Minetest
|
||||||
|
|
||||||
|
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||||
|
Source Code: https://github.com/cornernote/minetest-particles
|
||||||
|
License: GPLv3
|
||||||
|
|
||||||
|
MAIN LOADER
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- load api
|
||||||
|
dofile(minetest.get_modpath("particles").."/api.lua")
|
||||||
|
|
||||||
|
-- register dig particles for default nodes
|
||||||
|
particles.register_dig_particle("default:bookshelf","default_wood")
|
||||||
|
particles.register_dig_particle("default:brick","default_brick")
|
||||||
|
particles.register_dig_particle("default:cactus","default_cactus")
|
||||||
|
particles.register_dig_particle("default:chest","default_wood")
|
||||||
|
particles.register_dig_particle("default:chest_locked","default_wood")
|
||||||
|
particles.register_dig_particle("default:clay","default_clay")
|
||||||
|
particles.register_dig_particle("default:cobble","default_cobble")
|
||||||
|
particles.register_dig_particle("default:desert_sand","default_desert_sand")
|
||||||
|
particles.register_dig_particle("default:desert_stone","default_desert_stone")
|
||||||
|
particles.register_dig_particle("default:dirt","default_dirt")
|
||||||
|
particles.register_dig_particle("default:dirt_with_grass","default_dirt")
|
||||||
|
particles.register_dig_particle("default:dirt_with_grass_footsteps","default_dirt")
|
||||||
|
particles.register_dig_particle("default:dry_shrub","default_dirt")
|
||||||
|
particles.register_dig_particle("default:fence_wood","default_wood")
|
||||||
|
particles.register_dig_particle("default:furnace","default_cobble")
|
||||||
|
particles.register_dig_particle("default:glass","default_glass")
|
||||||
|
particles.register_dig_particle("default:gravel","default_gravel")
|
||||||
|
particles.register_dig_particle("default:junglegrass","default_dirt")
|
||||||
|
particles.register_dig_particle("default:jungletree","default_jungletree")
|
||||||
|
particles.register_dig_particle("default:ladder","default_wood")
|
||||||
|
particles.register_dig_particle("default:leaves","default_leaves")
|
||||||
|
particles.register_dig_particle("default:mese","default_mese")
|
||||||
|
particles.register_dig_particle("default:mossycobble","default_mossycobble")
|
||||||
|
particles.register_dig_particle("default:papyrus","default_papyrus")
|
||||||
|
particles.register_dig_particle("default:rail","default_rail")
|
||||||
|
particles.register_dig_particle("default:sand","default_sand")
|
||||||
|
particles.register_dig_particle("default:sandstone","default_sandstone")
|
||||||
|
particles.register_dig_particle("default:sapling","default_dirt")
|
||||||
|
particles.register_dig_particle("default:sign_wall","default_wood")
|
||||||
|
particles.register_dig_particle("default:steelblock","default_steelblock")
|
||||||
|
particles.register_dig_particle("default:stone","default_stone")
|
||||||
|
particles.register_dig_particle("default:stone_with_coal","default_stone")
|
||||||
|
particles.register_dig_particle("default:stone_with_iron","default_stone")
|
||||||
|
particles.register_dig_particle("default:torch","default_wood")
|
||||||
|
particles.register_dig_particle("default:tree","default_tree")
|
||||||
|
particles.register_dig_particle("default:wood","default_wood")
|
||||||
|
|
||||||
|
-- register_on_dignode
|
||||||
|
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||||
|
particles.on_dignode(pos, oldnode, digger)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- log that we started
|
||||||
|
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))
|
Loading…
Reference in New Issue