2019-07-05 15:22:22 +02:00
|
|
|
Portal API Reference
|
|
|
|
====================
|
|
|
|
|
|
|
|
The portal system used to get to the Nether can be used to create portals
|
|
|
|
to other realms.
|
|
|
|
|
2019-07-21 05:06:04 +02:00
|
|
|
Portal code is more efficient when each type of portal uses a different type
|
|
|
|
of node to build its frame out of, however it is possible to register more than
|
|
|
|
one kind of portal with the same frame material — such as obsidian — provided
|
|
|
|
the size of the PortalShape is distinct from any other type of portal that is
|
2019-07-24 12:08:04 +02:00
|
|
|
using the same node as its frame, and portal sizes remain small.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
Helper functions
|
|
|
|
----------------
|
|
|
|
|
2019-07-13 09:22:17 +02:00
|
|
|
* `nether.volume_is_natural(minp, maxp)`: returns a boolean
|
2019-07-05 15:22:22 +02:00
|
|
|
* use this when determining where to spawn a portal, to avoid overwriting
|
|
|
|
player builds. It checks the area for any nodes that aren't ground or
|
|
|
|
trees.
|
|
|
|
|
2019-07-16 13:39:16 +02:00
|
|
|
* `nether.find_surface_target_y(target_x, target_z, portal_name)`: returns a
|
|
|
|
suitable anchorPos
|
2019-07-21 05:06:04 +02:00
|
|
|
* Can be used when implementing custom find_surface_anchorPos() functions
|
|
|
|
* portal_name is optional, providing it allows existing portals on the
|
2019-07-13 09:22:17 +02:00
|
|
|
surface to be reused.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-13 09:22:17 +02:00
|
|
|
* `nether.find_nearest_working_portal(portal_name, anchorPos, distance_limit, y_factor)`: returns
|
|
|
|
an anchorPos, or nil if no portal was found within the the distance_limit.
|
|
|
|
* A y_factor of 0 means y does not affect the distance_limit, a y_factor
|
2019-07-16 13:39:16 +02:00
|
|
|
of 1 means y is included (the default if y_factor is nil), and a y_factor
|
|
|
|
of 2 would squash the search-sphere by a factor of 2 on the y-axis, etc.
|
|
|
|
* Only portals in the same realm as the anchorPos will be returned, even if
|
|
|
|
y_factor is 0.
|
|
|
|
* Pass a nil (or negative) distance_limit to indicate no distance limit
|
2019-07-05 15:22:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
API functions
|
|
|
|
-------------
|
|
|
|
|
2019-07-21 05:06:04 +02:00
|
|
|
Call these functions only at load time:
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-21 05:06:04 +02:00
|
|
|
* `nether.register_portal(name, portal_definition)`
|
2019-07-05 15:22:22 +02:00
|
|
|
* Returns true on success. Can return false if the portal definition
|
|
|
|
clashes with a portal already registered by another mod, e.g. if the size
|
|
|
|
and frame node is not unique.
|
|
|
|
* `nether.unregister_portal(name)`
|
|
|
|
* Unregisters the portal from the engine, and deletes the entry with key
|
|
|
|
`name` from `nether.registered_portals` and associated internal tables.
|
|
|
|
* Returns true on success
|
2019-07-27 11:50:59 +02:00
|
|
|
* register_portal_ignition_item(name, ignition_failure_sound)
|
|
|
|
* ignition_failure_sound is optional, it plays any time an attempt to use
|
|
|
|
the item occurs if a portal is not ignited.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Portal definition
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
Used by `nether.register_portal`.
|
|
|
|
|
|
|
|
{
|
2019-07-27 11:50:59 +02:00
|
|
|
shape = PortalShape_Traditional,
|
2019-07-05 15:22:22 +02:00
|
|
|
-- optional.
|
|
|
|
|
2019-07-27 11:50:59 +02:00
|
|
|
wormhole_node_name = "nether:portal",
|
2019-07-05 15:22:22 +02:00
|
|
|
-- optional. Allows a custom wormhole node to be specified.
|
|
|
|
-- Useful if you want the portals to have a different post_effect_color
|
|
|
|
-- or texture.
|
|
|
|
|
2019-07-27 11:50:59 +02:00
|
|
|
wormhole_node_color = 0,
|
2019-07-13 09:22:17 +02:00
|
|
|
-- A value from 0 to 7 corresponding to the color of pixels in
|
2019-07-22 14:55:13 +02:00
|
|
|
-- nether_portals_palette.png:
|
2019-07-27 11:50:59 +02:00
|
|
|
-- 0 traditional/magenta
|
|
|
|
-- 1 black
|
|
|
|
-- 2 blue
|
|
|
|
-- 3 green
|
|
|
|
-- 4 cyan
|
|
|
|
-- 5 red
|
|
|
|
-- 6 yellow
|
|
|
|
-- 7 white
|
|
|
|
|
|
|
|
particle_color = "#808",
|
2019-07-22 14:55:13 +02:00
|
|
|
-- Optional. Will default to a colour matching the wormhole_node_color
|
|
|
|
-- if not specified.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-27 11:50:59 +02:00
|
|
|
particle_texture = "image.png",
|
|
|
|
-- Optional. Animation and particle scale may also be specified, e.g:
|
|
|
|
-- particle_texture = {
|
|
|
|
-- name = "nether_particle_anim1.png",
|
|
|
|
-- animation = {
|
|
|
|
-- type = "vertical_frames",
|
|
|
|
-- aspect_w = 7,
|
|
|
|
-- aspect_h = 7,
|
|
|
|
-- length = 1,
|
|
|
|
-- },
|
|
|
|
-- scale = 1.5
|
|
|
|
-- },
|
|
|
|
-- See lua_api.txt for Tile Animation definition
|
|
|
|
|
|
|
|
frame_node_name = "default:obsidian",
|
2019-07-13 09:22:17 +02:00
|
|
|
-- Required. For best results, have your portal constructed of a
|
|
|
|
-- material nobody else is using.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-21 05:06:04 +02:00
|
|
|
sounds = {
|
|
|
|
ambient = <SimpleSoundSpec>,
|
|
|
|
-- if the ambient SimpleSoundSpec is a table it can also contain a
|
|
|
|
-- "length" int, which is the number of seconds to wait before
|
|
|
|
-- repeating the ambient sound. Default is 3.
|
|
|
|
ignite = <SimpleSoundSpec>,
|
|
|
|
extinguish = <SimpleSoundSpec>,
|
|
|
|
teleport = <SimpleSoundSpec>,
|
|
|
|
}
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-13 09:22:17 +02:00
|
|
|
within_realm = function(pos),
|
|
|
|
-- Required. Return true if a portal at pos is in the realm, rather
|
|
|
|
than the surface world.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-27 11:50:59 +02:00
|
|
|
find_realm_anchorPos = function(surface_anchorPos),
|
2019-07-13 09:22:17 +02:00
|
|
|
-- Required. Return a position in the realm that a portal created at
|
|
|
|
-- surface_anchorPos will link to.
|
2019-07-16 13:39:16 +02:00
|
|
|
-- Return an anchorPos or anchorPos, orientation
|
|
|
|
-- If orientation is not specified then the orientation of the surface
|
2019-07-22 14:55:13 +02:00
|
|
|
-- 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.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-27 11:50:59 +02:00
|
|
|
find_surface_anchorPos = function(realm_anchorPos),
|
2019-07-21 05:06:04 +02:00
|
|
|
-- Optional. If you don't implement this then a position near the
|
|
|
|
-- surface will be picked.
|
|
|
|
-- Return an anchorPos or (anchorPos, orientation)
|
2019-07-16 13:39:16 +02:00
|
|
|
-- If orientation is not specified then the orientation of the realm
|
|
|
|
-- portal will be used.
|
2019-07-22 14:55:13 +02:00
|
|
|
-- 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.
|
2019-07-05 15:22:22 +02:00
|
|
|
|
2019-07-27 11:50:59 +02:00
|
|
|
on_run_wormhole = function(portalDef, anochorPos, orientation),
|
2019-07-17 15:07:05 +02:00
|
|
|
-- invoked once per second per portal
|
2019-07-27 11:50:59 +02:00
|
|
|
on_extinguish = function(portalDef, anochorPos, orientation),
|
2019-07-17 15:07:05 +02:00
|
|
|
-- invoked when a portal is extinguished, including when the portal
|
|
|
|
-- it connected to was extinguished.
|
2019-07-21 05:06:04 +02:00
|
|
|
on_player_teleported = function(portalDef, player, oldPos, newPos),
|
|
|
|
-- invoked immediately after a player is teleported
|
|
|
|
on_ignite = function(portalDef, anochorPos, orientation)
|
|
|
|
-- invoked when a player or mesecon ignites a portal
|
2019-07-27 11:50:59 +02:00
|
|
|
on_created = function(portalDef, anochorPos, orientation)
|
2019-07-21 05:06:04 +02:00
|
|
|
-- invoked when a portal's remote twin is created, usually when a
|
|
|
|
-- player travels through a portal for the first time.
|
2019-07-27 11:50:59 +02:00
|
|
|
}
|