Add portal ignition sparks

This commit is contained in:
Treer 2019-07-22 22:55:13 +10:00 committed by SmallJoker
parent 27a660b731
commit 7cff6b8cc2
2 changed files with 47 additions and 6 deletions

View File

@ -23,7 +23,8 @@ local S = minetest.get_translator("nether")
-- Global Nether namespace -- Global Nether namespace
nether = {} nether = {}
nether.path = minetest.get_modpath("nether") nether.modname = minetest.get_current_modname()
nether.path = minetest.get_modpath(nether.modname)
nether.get_translator = S nether.get_translator = S
-- Settings -- Settings
@ -108,5 +109,31 @@ The expedition parties have found no diamonds or gold, and after an experienced
destination_pos.y = nether.find_surface_target_y(destination_pos.x, destination_pos.z, "nether_portal") destination_pos.y = nether.find_surface_target_y(destination_pos.x, destination_pos.z, "nether_portal")
return destination_pos return destination_pos
end end
end,
on_ignite = function(portalDef, anochorPos, orientation)
local make_sparks_fly = function(pos)
minetest.add_particlespawner({
amount = 14,
time = 0.1,
minpos = {x = pos.x - 0.25, y = pos.y - 0.25, z = pos.z - 0.25},
maxpos = {x = pos.x + 0.25, y = pos.y + 0.25, z = pos.z + 0.25},
minvel = {x = -5, y = -1, z = -5},
maxvel = {x = 5, y = 1, z = 5},
minacc = {x = 0, y = 0, z = 0},
maxacc = {x = 0, y = 0, z = 0},
minexptime = 0.1,
maxexptime = 0.5,
minsize = 0.2,
maxsize = 0.8,
collisiondetection = false,
texture = portalDef.particle_texture .. "^[colorize:#F4F:alpha",
glow = 8
})
end end
portalDef.shape.apply_func_to_wormhole_nodes(anochorPos, orientation, make_sparks_fly)
end
}) })

View File

@ -68,11 +68,19 @@ Used by `nether.register_portal`.
wormhole_node_color = 0, wormhole_node_color = 0,
-- A value from 0 to 7 corresponding to the color of pixels in -- A value from 0 to 7 corresponding to the color of pixels in
-- nether_portals_palette.png -- nether_portals_palette.png:
-- 0 traditional/magenta
-- 1 black
-- 2 blue
-- 3 green
-- 4 cyan
-- 5 red
-- 6 yellow
-- 7 white
particle_color = "#808", particle_color = "#808",
-- Optional. Will default to the same colour as wormhole_node_color if -- Optional. Will default to a colour matching the wormhole_node_color
-- not specified. -- if not specified.
frame_node_name = "default:obsidian", frame_node_name = "default:obsidian",
-- Required. For best results, have your portal constructed of a -- Required. For best results, have your portal constructed of a
@ -98,6 +106,9 @@ Used by `nether.register_portal`.
-- Return an anchorPos or anchorPos, orientation -- Return an anchorPos or anchorPos, orientation
-- If orientation is not specified then the orientation of the surface -- If orientation is not specified then the orientation of the surface
-- portal will be used. -- portal will be used.
-- If the location of an existing portal is returned then include the
-- orientation, otherwise the existing portal could be overwritten by
-- a new one with the orientation of the surface portal.
find_surface_anchorPos = function(realm_anchorPos), find_surface_anchorPos = function(realm_anchorPos),
-- Optional. If you don't implement this then a position near the -- Optional. If you don't implement this then a position near the
@ -105,6 +116,9 @@ Used by `nether.register_portal`.
-- Return an anchorPos or (anchorPos, orientation) -- Return an anchorPos or (anchorPos, orientation)
-- If orientation is not specified then the orientation of the realm -- If orientation is not specified then the orientation of the realm
-- portal will be used. -- portal will be used.
-- If the location of an existing portal is returned then include the
-- orientation, otherwise the existing portal could be overwritten by
-- a new one with the orientation of the realm portal.
on_run_wormhole = function(portalDef, anochorPos, orientation), on_run_wormhole = function(portalDef, anochorPos, orientation),
-- invoked once per second per portal -- invoked once per second per portal