diff --git a/lua_api.html b/lua_api.html index f106404..6d385e4 100644 --- a/lua_api.html +++ b/lua_api.html @@ -9,7 +9,10 @@ layout: default
If you have any difficulty in understanding this, please read Programming in Lua.
init.lua
scripts in a shared environment.
The game directory can contain the file minetest.conf, which will be used to set default settings when running the particular game.
+Games can provide custom main menu images. They are put inside a menu
directory inside the game directory.
The images are named $identifier.png
, where $identifier
is one of overlay,background,footer,header
.
+If you want to specify multiple images for one identifier, add additional images named like $identifier.$n.png
, with an ascending number $n starting with 1,
+and a random image will be chosen from the provided ones.
Generic:
minetest.register_on_chat_message(func(name, message))
true
to mark the message as handled, which means that it will not be sent to other playersminetest.register_on_player_receive_fields(func(player, formname, fields))
minetest.auth_reload
call the authetification handler.
minetest.request_shutdown()
: request for server shutdownminetest.request_shutdown([message],[reconnect])
: request for server shutdown. Will display message
to clients,
+ and reconnect
== true displays a reconnect button.minetest.get_server_status()
: returns server status stringminetest.auth_reload
call the authetification handler.
minetest.add_particlespawner(particlespawner definition)
ParticleSpawner
, an object that spawns an amount of particles over time
secondsid
id
, and -1 if adding didn't succeedDeprecated: minetest.add_particlespawner(amount, time,
minpos, maxpos,
minvel, maxvel,
@@ -2811,6 +2825,9 @@ and minetest.auth_reload
call the authetification handler.
-
minetest.is_protected(pos, name)
: returns boolean
+- Returns true, if player
name
shouldn't be abled to dig at pos
or do other
+ actions, defineable by mods, due to some mod-defined ownership-like concept.
+ Returns false or nil, if the player is allowed to do such actions.
- This function should be overridden by protection mods and should be used to
check if a player can interact at a position.
- This function should call the old version of itself if the position is not
@@ -3059,6 +3076,7 @@ Can be gotten via
minetest.get_node_timer(pos)
.
Player-only (no-op for other objects)
get_player_name()
: returns ""
if is not a player
+get_player_velocity()
: returns nil
if is not a player otherwise a table {x, y, z} representing the player's instantaneous velocity in nodes/s
get_look_dir()
: get camera direction as a unit vector
get_look_pitch()
: pitch in radians
get_look_yaw()
: yaw in radians (wraps around pretty randomly as of now)
@@ -3220,11 +3238,35 @@ Can be gotten via minetest.get_node_timer(pos)
.
+AreaStore
+A fast access data structure to store areas, and find areas near a given position or area.
+Every area has a data
string attribute to store additional information.
+You can create an empty AreaStore
by calling AreaStore()
, or AreaStore(type_name)
.
+If you chose the parameter-less constructor, a fast implementation will be automatically chosen for you.
+Methods
+
+get_area(id, include_borders, include_data)
: returns the area with the id id
. (optional) Boolean values include_borders
and include_data
control what's copied.
+get_areas_for_pos(pos, include_borders, include_data)
: returns all areas that contain the position pos
. (optional) Boolean values include_borders
and include_data
control what's copied.
+get_areas_in_area(edge1, edge2, accept_overlap, include_borders, include_data)
: returns all areas that contain all nodes inside the area specified by edge1
and edge2
(inclusive). If accept_overlap
is true, also areas are returned that have nodes in common with the specified area. (optional) Boolean values include_borders
and include_data
control what's copied.
+insert_area(edge1, edge2, data)
: inserts an area into the store. Returns the id if successful, nil otherwise. The (inclusive) positions edge1
and edge2
describe the area, data
+is a string stored with the area.
+reserve(count)
: reserves resources for at most count
many contained areas. Only needed for efficiency, and only some implementations profit.
+remove_area(id)
: removes the area with the given id from the store, returns success.
+set_cache_params(params)
: sets params for the included prefiltering cache. Calling invalidates the cache, so that its elements have to be newly generated.
+params
:
+ {
+ enabled = boolean, -- whether to enable, default true
+ block_radius = number, -- the radius (in nodes) of the areas the cache generates prefiltered lists for, minimum 16, default 64
+ limit = number, -- the cache's size, minimum 20, default 1000
+ }
+
+
+
ItemStack
An ItemStack
is a stack of items.
It can be created via ItemStack(x)
, where x is an ItemStack
,
an itemstring, a table or nil
.
-Methods
+Methods
is_empty()
: Returns true
if stack is empty.
get_name()
: Returns item name (e.g. "default:stone"
).
@@ -3264,7 +3306,7 @@ an itemstring, a table or nil
.
A 16-bit pseudorandom number generator.
Uses a well-known LCG algorithm introduced by K&R.
It can be created via PseudoRandom(seed)
.
-Methods
+Methods
next()
: return next integer random number [0
...32767
]
next(min, max)
: return next integer random number [min
...max
]
@@ -3277,7 +3319,7 @@ Uses a well-known LCG algorithm introduced by K&R.
A 32-bit pseudorandom number generator.
Uses PCG32, an algorithm of the permuted congruential generator family, offering very strong randomness.
It can be created via PcgRandom(seed)
or PcgRandom(seed, sequence)
.
-Methods
+Methods
next()
: return next integer random number [-2147483648
...2147483647
]
next(min, max)
: return next integer random number [min
...max
]
@@ -3293,7 +3335,7 @@ It can be created via PerlinNoise(seed, octaves, persistence, scale)
PerlinNoise(noiseparams)
.
Alternatively with minetest.get_perlin(seeddiff, octaves, persistence, scale)
or minetest.get_perlin(noiseparams)
.
-get2d(pos)
: returns 2D noise value at pos={x=,y=}
get3d(pos)
: returns 3D noise value at pos={x=,y=,z=}
nil
is returned).
For each of the functions with an optional buffer
parameter: If buffer
is not
nil, this table will be used to store the result instead of creating a new table.
get2dMap(pos)
: returns a <size.x>
times <size.y>
2D array of 2D noise
with values starting at pos={x=,y=}
An interface to the MapVoxelManipulator
for Lua.
It can be created via VoxelManip()
or minetest.get_voxel_manip()
.
The map will be pre-loaded if two positions are passed to either.
read_from_map(p1, p2)
: Reads a chunk of map from the map containing the
region formed by p1
and p2
.A helper class for voxel areas.
It can be created via VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}
.
The coordinates are inclusive, like most other things in Minetest.
getExtent()
: returns a 3D vector containing the size of the area formed by
MinEdge
and MaxEdge
Settings
An interface to read config files in the format of minetest.conf
.
It can be created via Settings(filename)
.
get(key)
: returns a valueget_bool(key)
: returns a boolean"image.png"
{name="image.png", animation={Tile Animation definition}}
{name="image.png", backface_culling=bool}
{name="image.png", backface_culling=bool, tileable_vertical=bool,
+ tileable_horizontal=bool}