Soaking "tickle" API, standardize particles
This commit is contained in:
parent
ea2ccc972e
commit
acd4156ed8
@ -1,8 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local error, math, minetest, nodecore, pairs, type, vector
|
||||
= error, math, minetest, nodecore, pairs, type, vector
|
||||
local math_floor, math_sqrt
|
||||
= math.floor, math.sqrt
|
||||
local error, math, minetest, nodecore, pairs, string, type, vector
|
||||
= error, math, minetest, nodecore, pairs, string, type, vector
|
||||
local math_floor, math_sqrt, string_format
|
||||
= math.floor, math.sqrt, string.format
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local metacache = {}
|
||||
@ -170,3 +170,48 @@ function nodecore.soaking_abm_push(pos, fieldname, qty)
|
||||
pending = nil
|
||||
end
|
||||
end
|
||||
|
||||
function nodecore.soaking_abm_tickle(pos, fieldname, rate)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local tickletime = meta:get_float(fieldname .. "tickle")
|
||||
if not (tickletime and tickletime > 0
|
||||
and tickletime < nodecore.gametime) then
|
||||
tickletime = nodecore.gametime
|
||||
end
|
||||
meta:set_float(fieldname .. "tickle", nodecore.gametime)
|
||||
local qty = ((nodecore.gametime - tickletime) ^ 0.5) * rate
|
||||
nodecore.log("action", string_format("abm push %0.2f for %q at %s",
|
||||
qty, fieldname, minetest.pos_to_string(pos)))
|
||||
nodecore.soaking_abm_push(pos, fieldname, qty)
|
||||
return qty
|
||||
end
|
||||
|
||||
do
|
||||
local zero = {x = 0, y = 0, z = 0}
|
||||
function nodecore.soaking_particles(pos, amount, time, width, nodename)
|
||||
nodename = nodename or minetest.get_node(pos).name
|
||||
local def = minetest.registered_items[nodename]
|
||||
if not def then return end
|
||||
nodecore.digparticles(def,
|
||||
{
|
||||
amount = amount,
|
||||
time = time,
|
||||
minpos = {
|
||||
x = pos.x - width,
|
||||
y = pos.y + 33/64,
|
||||
z = pos.z - width
|
||||
},
|
||||
maxpos = {
|
||||
x = pos.x + width,
|
||||
y = pos.y + 33/64,
|
||||
z = pos.z + width
|
||||
},
|
||||
minvel = zero,
|
||||
maxvel = zero,
|
||||
minexptime = 0.25,
|
||||
maxexptime = 1,
|
||||
minsize = 3 * width,
|
||||
maxsize = 9 * width,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -8,28 +8,7 @@ local math_random, table_concat
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function growparticles(pos, rate, width)
|
||||
local zero = {x = 0, y = 0, z = 0}
|
||||
nodecore.digparticles(minetest.registered_items[modname .. ":leaves_bud"],
|
||||
{
|
||||
amount = rate,
|
||||
time = 10,
|
||||
minpos = {
|
||||
x = pos.x - width,
|
||||
y = pos.y + 33/64,
|
||||
z = pos.z - width
|
||||
},
|
||||
maxpos = {
|
||||
x = pos.x + width,
|
||||
y = pos.y + 33/64,
|
||||
z = pos.z + width
|
||||
},
|
||||
minvel = zero,
|
||||
maxvel = zero,
|
||||
minexptime = 0.25,
|
||||
maxexptime = 1,
|
||||
minsize = 3 * width,
|
||||
maxsize = 9 * width,
|
||||
})
|
||||
nodecore.soaking_particles(pos, rate, 10, width, modname .. ":leaves_bud")
|
||||
end
|
||||
|
||||
local sproutcost = 2000
|
||||
|
@ -40,29 +40,8 @@ nodecore.register_craft({
|
||||
local soil = def.groups.soil or 0
|
||||
if soil > 2 then
|
||||
nodecore.soaking_abm_push(pos, "eggcorn", (soil - 2) * 500)
|
||||
local zero = {x = 0, y = 0, z = 0}
|
||||
nodecore.digparticles(minetest.registered_items[
|
||||
modname .. ":leaves_bud"],
|
||||
{
|
||||
amount = (soil - 2) * 10,
|
||||
time = 0.5,
|
||||
minpos = {
|
||||
x = pos.x - 0.45,
|
||||
y = pos.y + 33/64,
|
||||
z = pos.z - 0.45
|
||||
},
|
||||
maxpos = {
|
||||
x = pos.x + 0.45,
|
||||
y = pos.y + 33/64,
|
||||
z = pos.z + 0.45
|
||||
},
|
||||
minvel = zero,
|
||||
maxvel = zero,
|
||||
minexptime = 0.25,
|
||||
maxexptime = 1,
|
||||
minsize = 3 * 0.45,
|
||||
maxsize = 9 * 0.45,
|
||||
})
|
||||
nodecore.soaking_particles(pos, (soil - 2) * 10,
|
||||
0.5, .45, modname .. ":leaves_bud")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user