forked from minetest-mods/nether
API improvements
Improvements found while using the portals API in another mod (cloudlands): * remote_portal_checkup() will check the whole portal and frame for mapgen overwrites. * Allow find_realm_anchorPos() to return nil if no realm location could be found (portal will fail to ignite). * Allow create_book_of_portals() to be invoked [indirectly] by other mods. Also lowers nether_book_close.png to be 4bpp
This commit is contained in:
parent
32e5d818e8
commit
7939161535
@ -1,10 +1,9 @@
|
|||||||
Nether Mod for Minetest, with Portal API.
|
Nether Mod for Minetest, with Portals API.
|
||||||
|
|
||||||
See portal_api.txt for how to create custom portals to your own realms.
|
See portal_api.txt for how to create custom portals to your own realms.
|
||||||
|
|
||||||
A Book of Portals item (nether:book_of_portals) is created which
|
See settingtypes.txt or go to "Settings"->"All Settings"->"Mods"->"nether"
|
||||||
provides players with portal recipes, by default it can be found in
|
in the game to view the options provided by this mod.
|
||||||
dungeon chests.
|
|
||||||
|
|
||||||
|
|
||||||
## License of source code:
|
## License of source code:
|
||||||
|
@ -104,8 +104,8 @@ stairs.register_stair_and_slab(
|
|||||||
"nether:brick",
|
"nether:brick",
|
||||||
{cracky = 2, level = 2},
|
{cracky = 2, level = 2},
|
||||||
{"nether_brick.png"},
|
{"nether_brick.png"},
|
||||||
S("Nether stair"),
|
S("Nether Stair"),
|
||||||
S("Nether slab"),
|
S("Nether Slab"),
|
||||||
default.node_sound_stone_defaults()
|
default.node_sound_stone_defaults()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1178,7 +1178,13 @@ local function remote_portal_checkup(elapsed, portal_definition, anchorPos, orie
|
|||||||
local wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(anchorPos, orientation)
|
local wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(anchorPos, orientation)
|
||||||
local wormhole_node = minetest.get_node_or_nil(wormholePos)
|
local wormhole_node = minetest.get_node_or_nil(wormholePos)
|
||||||
|
|
||||||
if wormhole_node == nil or wormhole_node.name ~= portal_definition.wormhole_node_name then
|
local portalFound, portalLit = false, false
|
||||||
|
if wormhole_node ~= nil and wormhole_node.name == portal_definition.wormhole_node_name then
|
||||||
|
-- a wormhole node was there, but check the whole frame is intact
|
||||||
|
portalFound, portalLit = is_portal_at_anchorPos(portal_definition, anchorPos, orientation, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not portalFound or not portalLit then
|
||||||
-- ruh roh
|
-- ruh roh
|
||||||
local message = "Newly created portal at " .. minetest.pos_to_string(anchorPos) .. " was overwritten. Attempting to recreate. Issue spotted after " .. elapsed .. " seconds"
|
local message = "Newly created portal at " .. minetest.pos_to_string(anchorPos) .. " was overwritten. Attempting to recreate. Issue spotted after " .. elapsed .. " seconds"
|
||||||
minetest.log("warning", message)
|
minetest.log("warning", message)
|
||||||
@ -1312,22 +1318,27 @@ local function ignite_portal(ignition_pos, ignition_node_name)
|
|||||||
if DEBUG and destination_orientation == nil then minetest.chat_send_all("No destination_orientation given") end
|
if DEBUG and destination_orientation == nil then minetest.chat_send_all("No destination_orientation given") end
|
||||||
if destination_orientation == nil then destination_orientation = orientation end
|
if destination_orientation == nil then destination_orientation = orientation end
|
||||||
|
|
||||||
local destination_wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(destination_anchorPos, destination_orientation)
|
if destination_anchorPos == nil then
|
||||||
if DEBUG then minetest.chat_send_all("Destination set to " .. minetest.pos_to_string(destination_anchorPos)) end
|
if DEBUG then minetest.chat_send_all("No portal destination available here!") end
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
local destination_wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(destination_anchorPos, destination_orientation)
|
||||||
|
if DEBUG then minetest.chat_send_all("Destination set to " .. minetest.pos_to_string(destination_anchorPos)) end
|
||||||
|
|
||||||
-- ignition/BURN_BABY_BURN
|
-- ignition/BURN_BABY_BURN
|
||||||
set_portal_metadata_and_ignite(portal_definition, anchorPos, orientation, destination_wormholePos)
|
set_portal_metadata_and_ignite(portal_definition, anchorPos, orientation, destination_wormholePos)
|
||||||
|
|
||||||
if portal_definition.sounds.ignite ~= nil then
|
if portal_definition.sounds.ignite ~= nil then
|
||||||
local local_wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(anchorPos, orientation)
|
local local_wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(anchorPos, orientation)
|
||||||
minetest.sound_play(portal_definition.sounds.ignite, {pos = local_wormholePos, max_hear_distance = 20})
|
minetest.sound_play(portal_definition.sounds.ignite, {pos = local_wormholePos, max_hear_distance = 20})
|
||||||
|
end
|
||||||
|
|
||||||
|
if portal_definition.on_ignite ~= nil then
|
||||||
|
portal_definition.on_ignite(portal_definition, anchorPos, orientation)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if portal_definition.on_ignite ~= nil then
|
|
||||||
portal_definition.on_ignite(portal_definition, anchorPos, orientation)
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1737,7 +1748,7 @@ local function create_book_of_portals()
|
|||||||
|
|
||||||
|
|
||||||
create_book(
|
create_book(
|
||||||
"nether:book_of_portals",
|
":nether:book_of_portals",
|
||||||
S("Book of Portals"),
|
S("Book of Portals"),
|
||||||
"nether_book_of_portals.png",
|
"nether_book_of_portals.png",
|
||||||
S("A definitive guide to Rifts and Portals"),
|
S("A definitive guide to Rifts and Portals"),
|
||||||
@ -2160,6 +2171,8 @@ end
|
|||||||
-- portal_name is optional, providing it allows existing portals on the surface to be reused.
|
-- portal_name is optional, providing it allows existing portals on the surface to be reused.
|
||||||
function nether.find_surface_target_y(target_x, target_z, portal_name)
|
function nether.find_surface_target_y(target_x, target_z, portal_name)
|
||||||
|
|
||||||
|
assert(target_x ~= nil and target_z ~= nil, "Arguments `target_x` and `target_z` cannot be nil when calling find_surface_target_y()")
|
||||||
|
|
||||||
-- default to starting the search at -16 (probably underground) if we don't know the
|
-- default to starting the search at -16 (probably underground) if we don't know the
|
||||||
-- surface, like paramat's original code from before get_spawn_level() was available:
|
-- surface, like paramat's original code from before get_spawn_level() was available:
|
||||||
-- https://github.com/minetest-mods/nether/issues/5#issuecomment-506983676
|
-- https://github.com/minetest-mods/nether/issues/5#issuecomment-506983676
|
||||||
@ -2215,6 +2228,7 @@ function nether.find_nearest_working_portal(portal_name, anchorPos, distance_lim
|
|||||||
|
|
||||||
local portal_definition = nether.registered_portals[portal_name]
|
local portal_definition = nether.registered_portals[portal_name]
|
||||||
assert(portal_definition ~= nil, "find_nearest_working_portal() called with portal_name '" .. portal_name .. "', but no portal is registered with that name.")
|
assert(portal_definition ~= nil, "find_nearest_working_portal() called with portal_name '" .. portal_name .. "', but no portal is registered with that name.")
|
||||||
|
assert(anchorPos ~= nil, "Argument `anchorPos` cannot be nil when calling find_nearest_working_portal()")
|
||||||
|
|
||||||
local contenders = list_closest_portals(portal_definition, anchorPos, distance_limit, y_factor)
|
local contenders = list_closest_portals(portal_definition, anchorPos, distance_limit, y_factor)
|
||||||
|
|
||||||
|
@ -22,11 +22,6 @@ one kind of portal with the same frame material — such as obsidian — provide
|
|||||||
the size of the PortalShape is distinct from any other type of portal that is
|
the size of the PortalShape is distinct from any other type of portal that is
|
||||||
using the same node for its frame, and portal sizes remain small.
|
using the same node for its frame, and portal sizes remain small.
|
||||||
|
|
||||||
Stone is not a good choice for portal frame nodes as the Minetest engine may
|
|
||||||
convert it into terrain nodes if the biome-pass occurs after the portal is
|
|
||||||
created. Similarly, avoid using nodes which may be replaced by ABMs or
|
|
||||||
docoration functions without triggering the node's `on_destruct` handler.
|
|
||||||
|
|
||||||
|
|
||||||
Realms
|
Realms
|
||||||
------
|
------
|
||||||
@ -200,7 +195,9 @@ Used by `nether.register_portal`.
|
|||||||
|
|
||||||
within_realm = function(pos),
|
within_realm = function(pos),
|
||||||
-- Required. Return true if a portal at pos is in the realm, rather
|
-- Required. Return true if a portal at pos is in the realm, rather
|
||||||
than the surface world.
|
-- than the surface world.
|
||||||
|
-- Ideally implementations are fast, as this function can be used to
|
||||||
|
-- sift through a list of portals.
|
||||||
|
|
||||||
find_realm_anchorPos = function(surface_anchorPos),
|
find_realm_anchorPos = function(surface_anchorPos),
|
||||||
-- Required. Return a position in the realm that a portal created at
|
-- Required. Return a position in the realm that a portal created at
|
||||||
|
@ -15,5 +15,5 @@ nether_realm_enabled (Enable Nether realm & portal) bool true
|
|||||||
# Enables the Floatlands portal api code example
|
# Enables the Floatlands portal api code example
|
||||||
nether_enable_portal_example_floatlands (Enable example portal: Floatlands) bool false
|
nether_enable_portal_example_floatlands (Enable example portal: Floatlands) bool false
|
||||||
|
|
||||||
# Enables the Surface travel portal api code example
|
# Enables the Surface-travel portal api code example
|
||||||
nether_enable_portal_example_surfacetravel (Enable example portal: Surface travel) bool false
|
nether_enable_portal_example_surfacetravel (Enable example portal: Surface-travel) bool false
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 961 B |
Loading…
Reference in New Issue
Block a user