diff --git a/lua_api.html b/lua_api.html index 8986bb9..eb767d4 100644 --- a/lua_api.html +++ b/lua_api.html @@ -4,7 +4,7 @@ layout: default ---
If you have any difficulty in understanding this, please read Programming in Lua.
direction
is a unit vector, pointing from the source of the punch to
the punched object.damage
damage that will be done to entity
-Return value of this function will determin if damage is done by this function
+Return value of this function will determin if damage is done by this function
(retval true) or shall be done by engine (retval false)To punch an entity/object in Lua, call:
@@ -1596,8 +1610,8 @@ Return value of this function will determin if damage is done by this functionThe instance of a node in the world normally only contains the three values
mentioned in "Nodes". However, it is possible to insert extra data into a
-node. It is called "node metadata"; See "NodeMetaRef
".
Metadata contains two things:
+node. It is called "node metadata"; SeeNodeMetaRef
.
+Node metadata contains two things:
Item stacks can store metadata too. See ItemStackMetaRef
.
Item metadata only contains a key-value store.
+Some of the values in the key-value store are handled specially:
+description
: Set the itemstack's description. Defaults to idef.descriptionExample stuff:
+local meta = stack:get_meta()
+meta:set_string("key", "value")
+print(dump(meta:to_table()))
+
Formspec defines a menu. Currently not much else than inventories are supported. It is a string, with a somewhat strange format.
@@ -3187,6 +3213,14 @@ andminetest.auth_reload
call the authetification handler.
minetest.get_mod_storage()
:StorageRef
minetest.get_connected_players()
: returns list of ObjectRefs
NodeMetaRef
Node metadata: reference extra data and functionality stored in a node.
-Can be gotten via minetest.get_meta(pos)
.
MetaDataRef
See StorageRef
, NodeMetaRef
and ItemStackMetaRef
.
set_string(name, value)
minetest.get_meta(pos)
.
get_int(name)
set_float(name, value)
get_float(name)
get_inventory()
: returns InvRef
to_table()
: returns nil
or {fields = {...}, inventory = {list1 = {}, ...}}
to_table()
: returns nil
or a table with keys:
+from_table(nil or {})
true
on successNodeMetaRef
Node metadata: reference extra data and functionality stored in a node.
+Can be obtained via minetest.get_meta(pos)
.
get_inventory()
: returns InvRef
ItemStackMetaRef
ItemStack metadata: reference extra data and functionality stored in a stack.
+Can be obtained via item:get_meta()
.
StorageRef
Mod metadata: per mod metadata, saved automatically.
+Can be obtained via minetest.get_mod_storage()
during load time.
NodeTimerRef
Node Timers: a high resolution persistent per-node timer.
Can be gotten via minetest.get_node_timer(pos)
.
set(timeout,elapsed)
minetest.get_node_timer(pos)
.
ObjectRef
Moving things in the game are generally these.
This is basically a reference to a C++ ServerActiveObject
remove()
: remove object (after returning from Lua)minetest.get_node_timer(pos)
.
InvRef
An InvRef
is a reference to an inventory.
is_empty(listname)
: return true
if list is emptyget_size(listname)
: get size of a listdata
string attribute to store additional informat
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.
-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.
@@ -3792,7 +3850,7 @@ chosen for you.
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
.
is_empty()
: Returns true
if stack is empty.get_name()
: Returns item name (e.g. "default:stone"
).nil
.
set_count(count)
: Returns boolean whether item was clearedget_wear()
: Returns tool wear (0
-65535
), 0
for non-tools.set_wear(wear)
: Returns boolean whether item was clearedget_metadata()
: Returns metadata (a string attached to an item stack).set_metadata(metadata)
: Returns true.get_meta()
: Returns ItemStackMetaRef. See section for more detailsget_metadata()
: (DEPRECATED) Returns metadata (a string attached to an item stack).set_metadata(metadata)
: (DEPRECATED) Returns true.clear()
: removes all items from the stack, making it empty.replace(item)
: replace the contents of this stack.item
can also be an itemstring or table.nil
.
A 16-bit pseudorandom number generator. Uses a well-known LCG algorithm introduced by K&R.
It can be created via PseudoRandom(seed)
.
next()
: return next integer random number [0
...32767
]next(min, max)
: return next integer random number [min
...max
]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)
.
next()
: return next integer random number [-2147483648
...2147483647
]next(min, max)
: return next integer random number [min
...max
]Interface for the operating system's crypto-secure PRNG.
It can be created via SecureRandom()
. The constructor returns nil if a secure random device cannot be
be found on the system.
next_bytes([count])
: return next count
(default 1, capped at 2048) many random bytes, as a string.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=}
read_from_map(p1, p2)
: Loads a chunk of map into the VoxelManip object 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)
.