New, fancier portal particle effects
This commit is contained in:
parent
33ced0ac75
commit
a57fe9a3c8
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
||||
name = nc_skyrealm
|
||||
depends = nc_api_all, nc_terrain, nc_sponge, nc_tree, nc_lode, nc_lux, nc_concrete, nc_fire
|
||||
optional_depends = nc_guide
|
||||
min_minetest_version = 5.3
|
||||
min_minetest_version = 5.8
|
||||
|
66
portal.lua
66
portal.lua
@ -1,8 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ipairs, math, minetest, nodecore, pairs, vector
|
||||
= ipairs, math, minetest, nodecore, pairs, vector
|
||||
local math_random
|
||||
= math.random
|
||||
local ipairs, math, minetest, nodecore, pairs, tostring, vector
|
||||
= ipairs, math, minetest, nodecore, pairs, tostring, vector
|
||||
local math_ceil, math_cos, math_pi, math_random
|
||||
= math.ceil, math.cos, math.pi, math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -43,8 +43,19 @@ local function portalemerge(pos, ipos)
|
||||
end
|
||||
end
|
||||
|
||||
local w = 16
|
||||
local frames = 32
|
||||
local base = nodecore.tmod(modname .. "_particle.png"):resize(w, w)
|
||||
local txr = nodecore.tmod:combine(w, frames * w)
|
||||
for i = 0, frames - 1 do
|
||||
local o = math_ceil((1 - math_cos(i * math_pi * 2 / frames)) * 128)
|
||||
if o > 255 then o = 255 end
|
||||
txr = txr:layer(0, w * i, base:opacity(o))
|
||||
end
|
||||
txr = tostring(txr)
|
||||
|
||||
local function portaltick(pos, att, stack)
|
||||
if api.in_sky_realm(pos) then return end
|
||||
local inert = stack or att or api.in_sky_realm(pos)
|
||||
local assign = getassign(stack and stack:get_meta()
|
||||
or minetest.get_meta(pos), nil, true)
|
||||
if assign then
|
||||
@ -61,16 +72,41 @@ local function portaltick(pos, att, stack)
|
||||
end
|
||||
return minetest.add_particlespawner({
|
||||
time = 1,
|
||||
amount = 50,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minacc = {x = -0.2, y = -0.2, z = -0.2},
|
||||
maxacc = {x = 0.2, y = 0.2, z = 0.2},
|
||||
minexptime = 1,
|
||||
maxexptime = 5,
|
||||
minsize = 0.2,
|
||||
maxsize = 1,
|
||||
texture = modname .. "_particle.png",
|
||||
amount = inert and 50 or 100,
|
||||
exptime = {
|
||||
min = 1,
|
||||
max = 5,
|
||||
bias = 1
|
||||
},
|
||||
size = {
|
||||
min = 0.2,
|
||||
max = inert and 1 or 2
|
||||
},
|
||||
minvel = vector.new(-0.1, -0.1, -0.1),
|
||||
maxvel = vector.new(0.1, 0.1, 0.1),
|
||||
minacc = vector.new(-0.1, -0.1, -0.1),
|
||||
maxacc = vector.new(0.1, 0.1, 0.1),
|
||||
texture = txr,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
length = -1
|
||||
},
|
||||
pos = pos,
|
||||
radius = {
|
||||
min = 1,
|
||||
max = inert and 2 or 8,
|
||||
bias = 1
|
||||
},
|
||||
attract = (not inert) and {
|
||||
kind = "point",
|
||||
strength = {
|
||||
min = 0.25,
|
||||
max = 2,
|
||||
bias = 1
|
||||
},
|
||||
origin = pos
|
||||
} or nil,
|
||||
collisiondetection = true,
|
||||
collision_removal = true,
|
||||
attached = att
|
||||
|
Loading…
x
Reference in New Issue
Block a user