More scaling refinements.

- Cannot do "floor feeling" if floor is already lit.
- No need for steady-state particles on "floor feeling" nodes.
This commit is contained in:
Aaron Suen 2019-11-10 10:03:15 -05:00
parent 52dcebc696
commit a90d49404b
3 changed files with 32 additions and 30 deletions

View File

@ -5,6 +5,23 @@ local minetest, nodecore
local modname = minetest.get_current_modname()
function nodecore.scaling_particles(pos, def)
minetest.add_particlespawner(nodecore.underride(def or {}, {
texture = "[combine:1x1^[noalpha",
collisiondetection = false,
amount = 5,
time = 1,
minpos = {x = pos.x - 0.4, y = pos.y - 0.4, z = pos.z - 0.4},
maxpos = {x = pos.x + 0.4, y = pos.y + 0.4, z = pos.z + 0.4},
minvel = {x = -0.02, y = -0.02, z = -0.02},
maxvel = {x = 0.02, y = 0.02, z = 0.02},
minexptime = 1,
maxexptime = 1,
minsize = 0.2,
maxsize = 0.25
}))
end
local function issolid(pos, node)
node = node or minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
@ -30,6 +47,7 @@ local function tryreplace(pos, newname, rootpos)
pos = rootpos,
node = minetest.get_node(rootpos).name
}))
nodecore.scaling_particles(pos)
return true
end
@ -52,23 +70,8 @@ function nodecore.scaling_apply(pointed)
if ok then tryreplace({x = pos.x, y = pos.y - 1, z = pos.z}, "hang", pos) end
return ok
elseif pointed.under.y < pointed.above.y and issolid(pointed.under) then
return tryreplace(pos, "floor", pointed.under)
if (minetest.get_node_light(pointed.above) or 1) < 1 then
return tryreplace(pos, "floor", pointed.under)
end
end
end
function nodecore.scaling_particles(pos, def)
minetest.add_particlespawner(nodecore.underride(def or {}, {
texture = "[combine:1x1^[noalpha",
collisiondetection = false,
amount = 5,
time = 1,
minpos = {x = pos.x - 0.4, y = pos.y - 0.4, z = pos.z - 0.4},
maxpos = {x = pos.x + 0.4, y = pos.y + 0.4, z = pos.z + 0.4},
minvel = {x = -0.02, y = -0.02, z = -0.02},
maxvel = {x = 0.02, y = 0.02, z = 0.02},
minexptime = 1,
maxexptime = 1,
minsize = 0.2,
maxsize = 0.25
}))
end

View File

@ -5,7 +5,7 @@ local minetest
local modname = minetest.get_current_modname()
local function reg(name, vis, climb, lv)
local function reg(name, climb, light, fx, lv)
local def = {
drawtype = "airlike",
paramtype = "light",
@ -14,17 +14,17 @@ local function reg(name, vis, climb, lv)
pointable = false,
buildable_to = true,
air_equivalent = true,
groups = {[modname] = lv}
climbable = climb and true or nil,
light_source = light or nil,
groups = {
[modname] = lv,
[modname .. "_fx"] = fx and 1 or nil
}
}
if vis then
def.light_source = 1
def.groups[modname .. "_fx"] = 1
end
def.climbable = (not not climb) or nil
return minetest.register_node(modname .. ":" .. name, def)
end
reg("ceil", true, true, 4)
reg("wall", true, true, 3)
reg("floor", true, false, 2)
reg("hang", false, true, 1)
reg("ceil", true, 1, true, 4)
reg("wall", true, 1, true, 3)
reg("floor", nil, 1, nil, 2)
reg("hang", true, nil, nil, 1)

View File

@ -52,7 +52,6 @@ hand.on_place = function(stack, player, pointed, ...)
cache[pname] = nil
if nodecore.scaling_apply(pointed) then
nodecore.scaling_particles(pointed.above)
return nodecore.scaling_particles(pointed.above, {
time = 0.1,
amount = 40,