Fix typos in doc/lua-api.txt

This commit is contained in:
sfan5 2014-07-05 12:19:55 +02:00
parent 2fee2baf98
commit 5f9962e1cc
1 changed files with 82 additions and 83 deletions

View File

@ -51,7 +51,7 @@ where gameid is unique to each game.
The game directory contains the file game.conf, which contains these fields: The game directory contains the file game.conf, which contains these fields:
name = <Human-readable full name of the game> name = <Human-readable full name of the game>
eg. e.g.
name = Minetest name = Minetest
The game directory can contain the file minetest.conf, which will be used The game directory can contain the file minetest.conf, which will be used
@ -66,14 +66,14 @@ Generic:
$path_user/mods/ <-- User-installed mods $path_user/mods/ <-- User-installed mods
$worldpath/worldmods/ $worldpath/worldmods/
In a run-in-place version (eg. the distributed windows version): In a run-in-place version (e.g. the distributed windows version):
minetest-0.4.x/games/gameid/mods/ minetest-0.4.x/games/gameid/mods/
minetest-0.4.x/mods/gameid/ <-- User-installed mods minetest-0.4.x/mods/ <-- User-installed mods
minetest-0.4.x/worlds/worldname/worldmods/ minetest-0.4.x/worlds/worldname/worldmods/
On an installed version on linux: On an installed version on Linux:
/usr/share/minetest/games/gameid/mods/ /usr/share/minetest/games/gameid/mods/
~/.minetest/mods/gameid/ <-- User-installed mods ~/.minetest/mods/ <-- User-installed mods
~/.minetest/worlds/worldname/worldmods ~/.minetest/worlds/worldname/worldmods
Mod load path for world-specific games Mod load path for world-specific games
@ -81,7 +81,7 @@ Mod load path for world-specific games
It is possible to include a game in a world; in this case, no mods or It is possible to include a game in a world; in this case, no mods or
games are loaded or checked from anywhere else. games are loaded or checked from anywhere else.
This is useful for eg. adventure worlds. This is useful for e.g. adventure worlds.
This happens if the following directory exists: This happens if the following directory exists:
$world/game/ $world/game/
@ -127,7 +127,7 @@ screenshot.png:
A screenshot shown in modmanager within mainmenu. A screenshot shown in modmanager within mainmenu.
description.txt: description.txt:
File containing desctiption to be shown within mainmenu. File containing description to be shown within mainmenu.
init.lua: init.lua:
The main Lua script. Running this script should register everything it The main Lua script. Running this script should register everything it
@ -170,30 +170,30 @@ convert_to.
This can be used for maintaining backwards compatibility. This can be used for maintaining backwards compatibility.
This can be also used for setting quick access names for things, eg. if This can be also used for setting quick access names for things, e.g. if
you have an item called epiclylongmodname:stuff, you could do you have an item called epiclylongmodname:stuff, you could do
minetest.register_alias("stuff", "epiclylongmodname:stuff") minetest.register_alias("stuff", "epiclylongmodname:stuff")
and be able to use "/giveme stuff". and be able to use "/giveme stuff".
Textures Textures
-------- --------
Mods should generally prefix their textures with modname_, eg. given Mods should generally prefix their textures with modname_, e.g. given
the mod name "foomod", a texture could be called the mod name "foomod", a texture could be called
"foomod_foothing.png" "foomod_foothing.png"
Textures are referred to by their complete name, or alternatively by Textures are referred to by their complete name, or alternatively by
stripping out the file extension: stripping out the file extension:
eg. foomod_foothing.png e.g. foomod_foothing.png
eg. foomod_foothing e.g. foomod_foothing
Sounds Sounds
------- -------
Only OGG files are supported. Only OGG Vorbis files are supported.
For positional playing of sounds, only single-channel (mono) files are For positional playing of sounds, only single-channel (mono) files are
supported. Otherwise OpenAL will play them non-positionally. supported. Otherwise OpenAL will play them non-positionally.
Mods should generally prefix their sounds with modname_, eg. given Mods should generally prefix their sounds with modname_, e.g. given
the mod name "foomod", a sound could be called the mod name "foomod", a sound could be called
"foomod_foosound.ogg" "foomod_foosound.ogg"
@ -210,11 +210,11 @@ from the available ones of the following files:
foomod_foosound.9.ogg foomod_foosound.9.ogg
Examples of sound parameter tables: Examples of sound parameter tables:
-- Play locationless on all clients -- Play location-less on all clients
{ {
gain = 1.0, -- default gain = 1.0, -- default
} }
-- Play locationless to a player -- Play location-less to a player
{ {
to_player = name, to_player = name,
gain = 1.0, -- default gain = 1.0, -- default
@ -234,11 +234,11 @@ Examples of sound parameter tables:
} }
SimpleSoundSpec: SimpleSoundSpec:
eg. "" e.g. ""
eg. "default_place_node" e.g. "default_place_node"
eg. {} e.g. {}
eg. {name="default_place_node"} e.g. {name="default_place_node"}
eg. {name="default_place_node", gain=1.0} e.g. {name="default_place_node", gain=1.0}
Registered definitions of stuff Registered definitions of stuff
-------------------------------- --------------------------------
@ -259,7 +259,7 @@ minetest.register_craftitem(name, item definition)
-> minetest.registered_items[name] -> minetest.registered_items[name]
Note that in some cases you will stumble upon things that are not contained Note that in some cases you will stumble upon things that are not contained
in these tables (eg. when a mod has been removed). Always check for in these tables (e.g. when a mod has been removed). Always check for
existence before trying to access the fields. existence before trying to access the fields.
Example: If you want to check the drawtype of a node, you could do: Example: If you want to check the drawtype of a node, you could do:
@ -384,7 +384,7 @@ A box is defined as:
A box of a regular node would look like: A box of a regular node would look like:
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
type = "leveled" is same as "fixed", but y2 will be automaticaly setted to level from param2 type = "leveled" is same as "fixed", but y2 will be automatically set to level from param2
Ore types Ore types
--------------- ---------------
@ -561,16 +561,16 @@ Craftitem (register_craftitem):
Items and item stacks can exist in three formats: Items and item stacks can exist in three formats:
Serialized; This is called stackstring or itemstring: Serialized; This is called stackstring or itemstring:
eg. 'default:dirt 5' e.g. 'default:dirt 5'
eg. 'default:pick_wood 21323' e.g. 'default:pick_wood 21323'
eg. 'default:apple' e.g. 'default:apple'
Table format: Table format:
eg. {name="default:dirt", count=5, wear=0, metadata=""} e.g. {name="default:dirt", count=5, wear=0, metadata=""}
^ 5 dirt nodes ^ 5 dirt nodes
eg. {name="default:pick_wood", count=1, wear=21323, metadata=""} e.g. {name="default:pick_wood", count=1, wear=21323, metadata=""}
^ a wooden pick about 1/3 weared out ^ a wooden pick about 1/3 worn out
eg. {name="default:apple", count=1, wear=0, metadata=""} e.g. {name="default:apple", count=1, wear=0, metadata=""}
^ an apple. ^ an apple.
ItemStack: ItemStack:
@ -604,7 +604,7 @@ You can read the rating of a group for an item or a node by using
Groups of items Groups of items
---------------- ----------------
Groups of items can define what kind of an item it is (eg. wool). Groups of items can define what kind of an item it is (e.g. wool).
Groups of nodes Groups of nodes
---------------- ----------------
@ -617,7 +617,7 @@ For entities, groups are, as of now, used only for calculating damage.
The rating is the percentage of damage caused by tools with this damage group. The rating is the percentage of damage caused by tools with this damage group.
See "Entity damage mechanism". See "Entity damage mechanism".
object.get_armor_groups() -> a group-rating table (eg. {fleshy=100}) object.get_armor_groups() -> a group-rating table (e.g. {fleshy=100})
object.set_armor_groups({fleshy=30, cracky=80}) object.set_armor_groups({fleshy=30, cracky=80})
Groups of tools Groups of tools
@ -648,8 +648,8 @@ Special groups
--------------- ---------------
- immortal: Disables the group damage system for an entity - immortal: Disables the group damage system for an entity
- level: Can be used to give an additional sense of progression in the game. - level: Can be used to give an additional sense of progression in the game.
- A larger level will cause eg. a weapon of a lower level make much less - A larger level will cause e.g. a weapon of a lower level make much less
damage, and get weared out much faster, or not be able to get drops damage, and get worn out much faster, or not be able to get drops
from destroyed nodes. from destroyed nodes.
- 0 is something that is directly accessible at the start of gameplay - 0 is something that is directly accessible at the start of gameplay
- There is no upper limit - There is no upper limit
@ -672,9 +672,9 @@ Known damage and digging time defining groups
---------------------------------------------- ----------------------------------------------
- crumbly: dirt, sand - crumbly: dirt, sand
- cracky: tough but crackable stuff like stone. - cracky: tough but crackable stuff like stone.
- snappy: something that can be cut using fine tools; eg. leaves, small - snappy: something that can be cut using fine tools; e.g. leaves, small
plants, wire, sheets of metal plants, wire, sheets of metal
- choppy: something that can be cut using force; eg. trees, wooden planks - choppy: something that can be cut using force; e.g. trees, wooden planks
- fleshy: Living things like animals and the player. This could imply - fleshy: Living things like animals and the player. This could imply
some blood effects when hitting. some blood effects when hitting.
- explody: Especially prone to explosions - explody: Especially prone to explosions
@ -693,7 +693,7 @@ Item groups are often used for defining, well, //groups of items//.
- eatable: anything that can be eaten. Rating might define HP gain in half - eatable: anything that can be eaten. Rating might define HP gain in half
hearts. hearts.
- flammable: can be set on fire. Rating might define the intensity of the - flammable: can be set on fire. Rating might define the intensity of the
fire, affecting eg. the speed of the spreading of an open fire. fire, affecting e.g. the speed of the spreading of an open fire.
- wool: any wool (any origin, any color) - wool: any wool (any origin, any color)
- metal: any metal - metal: any metal
- weapon: any weapon - weapon: any weapon
@ -726,12 +726,12 @@ groups to enable interaction with tools.
**Full punch interval**: **Full punch interval**:
When used as a weapon, the tool will do full damage if this time is spent When used as a weapon, the tool will do full damage if this time is spent
between punches. If eg. half the time is spent, the tool will do half between punches. If e.g. half the time is spent, the tool will do half
damage. damage.
**Maximum drop level** **Maximum drop level**
Suggests the maximum level of node, when dug with the tool, that will drop Suggests the maximum level of node, when dug with the tool, that will drop
it's useful item. (eg. iron ore to drop a lump of iron). it's useful item. (e.g. iron ore to drop a lump of iron).
- This is not automated; it is the responsibility of the node definition - This is not automated; it is the responsibility of the node definition
to implement this to implement this
@ -750,7 +750,7 @@ be able to dig.
**Digging times** **Digging times**
List of digging times for different ratings of the group, for nodes of the List of digging times for different ratings of the group, for nodes of the
maximum level. maximum level.
* For example, as a lua table, ''times={2=2.00, 3=0.70}''. This would * For example, as a Lua table, ''times={2=2.00, 3=0.70}''. This would
result in the tool to be able to dig nodes that have a rating of 2 or 3 result in the tool to be able to dig nodes that have a rating of 2 or 3
for this group, and unable to dig the rating 1, which is the toughest. for this group, and unable to dig the rating 1, which is the toughest.
Unless there is a matching group that enables digging otherwise. Unless there is a matching group that enables digging otherwise.
@ -769,7 +769,7 @@ tool_capabilities = {
damage_groups = {fleshy=2}, damage_groups = {fleshy=2},
} }
This makes the tool be able to dig nodes that fullfill both of these: This makes the tool be able to dig nodes that fulfill both of these:
- Have the **crumbly** group - Have the **crumbly** group
- Have a **level** group less or equal to 2 - Have a **level** group less or equal to 2
@ -801,12 +801,12 @@ damage = 0
foreach group in cap.damage_groups: foreach group in cap.damage_groups:
damage += cap.damage_groups[group] * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0) damage += cap.damage_groups[group] * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
* (object.armor_groups[group] / 100.0) * (object.armor_groups[group] / 100.0)
-- Where object.armor_groups[group] is 0 for inexisting values -- Where object.armor_groups[group] is 0 for inexistent values
return damage return damage
Client predicts damage based on damage groups. Because of this, it is able to Client predicts damage based on damage groups. Because of this, it is able to
give an immediate response when an entity is damaged or dies; the response is give an immediate response when an entity is damaged or dies; the response is
pre-defined somehow (eg. by defining a sprite animation) (not implemented; pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
TODO). TODO).
- Currently a smoke puff will appear when an entity dies. - Currently a smoke puff will appear when an entity dies.
@ -987,7 +987,7 @@ label[<X>,<Y>;<label>]
^ Position and size units are inventory slots ^ Position and size units are inventory slots
vertlabel[<X>,<Y>;<label>] vertlabel[<X>,<Y>;<label>]
^ Textual label drawn verticaly ^ Textual label drawn vertically
^ x and y work as per field ^ x and y work as per field
^ label is the text on the label ^ label is the text on the label
^ Position and size units are inventory slots ^ Position and size units are inventory slots
@ -1008,8 +1008,8 @@ image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>
^ x, y, w, h, and name work as per button ^ x, y, w, h, and name work as per button
^ texture name is the filename of an image ^ texture name is the filename of an image
^ Position and size units are inventory slots ^ Position and size units are inventory slots
^ noclip true meand imagebutton doesn't need to be within specified formsize ^ noclip=true means imagebutton doesn't need to be within specified formsize
^ drawborder draw button bodrer or not ^ drawborder draw button border or not
^ pressed texture name is the filename of an image on pressed state ^ pressed texture name is the filename of an image on pressed state
item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>] item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]
@ -1026,7 +1026,7 @@ image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
^ When clicked, fields will be sent and the form will quit. ^ When clicked, fields will be sent and the form will quit.
textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>] textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]
^Scrollabel itemlist showing arbitrary text elements ^ Scrollable item list showing arbitrary text elements
^ x and y position the itemlist relative to the top left of the menu ^ x and y position the itemlist relative to the top left of the menu
^ w and h are the size of the itemlist ^ w and h are the size of the itemlist
^ name fieldname sent to server on doubleclick value is current selected element ^ name fieldname sent to server on doubleclick value is current selected element
@ -1034,7 +1034,7 @@ textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]
^ if you want a listelement to start with # write ## ^ if you want a listelement to start with # write ##
textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>] textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]
^Scrollabel itemlist showing arbitrary text elements ^ Scrollable itemlist showing arbitrary text elements
^ x and y position the itemlist relative to the top left of the menu ^ x and y position the itemlist relative to the top left of the menu
^ w and h are the size of the itemlist ^ w and h are the size of the itemlist
^ name fieldname sent to server on doubleclick value is current selected element ^ name fieldname sent to server on doubleclick value is current selected element
@ -1047,7 +1047,7 @@ textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<sele
tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>] tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]
^ show a tabHEADER at specific position (ignores formsize) ^ show a tabHEADER at specific position (ignores formsize)
^ x and y position the itemlist relative to the top left of the menu ^ x and y position the itemlist relative to the top left of the menu
^ name fieldname data is transfered to lua ^ name fieldname data is transfered to Lua
^ caption 1... name shown on top of tab ^ caption 1... name shown on top of tab
^ current_tab index of selected tab 1... ^ current_tab index of selected tab 1...
^ transparent (optional) show transparent ^ transparent (optional) show transparent
@ -1063,15 +1063,14 @@ dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]
^ show a dropdown field ^ show a dropdown field
^ x and y position of dropdown ^ x and y position of dropdown
^ width of dropdown ^ width of dropdown
^ fieldname data is transfered to lua ^ fieldname data is transfered to Lua
^ items to be shown in dropdown ^ items to be shown in dropdown
^ index of currently selected dropdown item ^ index of currently selected dropdown item
^ color in hexadecimal format RRGGBB (only)
checkbox[<X>,<Y>;<name>;<label>;<selected>;<tooltip>] checkbox[<X>,<Y>;<name>;<label>;<selected>;<tooltip>]
^ show a checkbox ^ show a checkbox
^ x and y position of checkbox ^ x and y position of checkbox
^ name fieldname data is transfered to lua ^ name fieldname data is transfered to Lua
^ label to be shown left of checkbox ^ label to be shown left of checkbox
^ selected (optional) true/false ^ selected (optional) true/false
^ tooltip (optional) ^ tooltip (optional)
@ -1159,7 +1158,7 @@ vector.length(v) -> number
vector.normalize(v) -> vector vector.normalize(v) -> vector
vector.round(v) -> vector vector.round(v) -> vector
vector.equals(v1, v2) -> bool vector.equals(v1, v2) -> bool
For the folowing x can be either a vector or a number. For the following functions x can be either a vector or a number.
vector.add(v, x) -> vector vector.add(v, x) -> vector
vector.subtract(v, x) -> vector vector.subtract(v, x) -> vector
vector.multiply(v, x) -> vector vector.multiply(v, x) -> vector
@ -1173,11 +1172,11 @@ dump(obj, dumped={})
^ Return object serialized as a string ^ Return object serialized as a string
math.hypot(x, y) math.hypot(x, y)
^ Get the hypotenuse of a triangle with legs x and y. ^ Get the hypotenuse of a triangle with legs x and y.
Usefull for distance calculation. Useful for distance calculation.
string:split(separator) string:split(separator)
^ eg. string:split("a,b", ",") == {"a","b"} ^ e.g. string:split("a,b", ",") == {"a","b"}
string:trim() string:trim()
^ eg. string.trim("\n \t\tfoo bar\t ") == "foo bar" ^ e.g. string.trim("\n \t\tfoo bar\t ") == "foo bar"
minetest.pos_to_string({x=X,y=Y,z=Z}) -> "(X,Y,Z)" minetest.pos_to_string({x=X,y=Y,z=Z}) -> "(X,Y,Z)"
^ Convert position to a printable string ^ Convert position to a printable string
minetest.string_to_pos(string) -> position minetest.string_to_pos(string) -> position
@ -1191,11 +1190,11 @@ minetest namespace reference
----------------------------- -----------------------------
Utilities: Utilities:
minetest.get_current_modname() -> string minetest.get_current_modname() -> string
minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname" minetest.get_modpath(modname) -> e.g. "/home/user/.minetest/usermods/modname"
^ Useful for loading additional .lua modules or static data from mod ^ Useful for loading additional .lua modules or static data from mod
minetest.get_modnames() -> list of installed mods minetest.get_modnames() -> list of installed mods
^ Return a list of installed mods, sorted alphabetically ^ Return a list of installed mods, sorted alphabetically
minetest.get_worldpath() -> eg. "/home/user/.minetest/world" minetest.get_worldpath() -> e.g. "/home/user/.minetest/world"
^ Useful for storing custom data ^ Useful for storing custom data
minetest.is_singleplayer() minetest.is_singleplayer()
minetest.features minetest.features
@ -1206,7 +1205,7 @@ minetest.has_feature(arg) -> bool, missing_features
minetest.get_player_information(playername) minetest.get_player_information(playername)
^ table containing information about player peer: ^ table containing information about player peer:
{ {
address = "127.0.0.1", -- ip address of client address = "127.0.0.1", -- IP address of client
ip_version = 4, -- IPv4 / IPv6 ip_version = 4, -- IPv4 / IPv6
min_rtt = 0.01, -- minimum round trip time min_rtt = 0.01, -- minimum round trip time
max_rtt = 0.2, -- maximum round trip time max_rtt = 0.2, -- maximum round trip time
@ -1395,9 +1394,9 @@ minetest.set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
minetest.get_timeofday() minetest.get_timeofday()
minetest.get_gametime(): returns the time, in seconds, since the world was created minetest.get_gametime(): returns the time, in seconds, since the world was created
minetest.find_node_near(pos, radius, nodenames) -> pos or nil minetest.find_node_near(pos, radius, nodenames) -> pos or nil
^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt" ^ nodenames: e.g. {"ignore", "group:tree"} or "default:dirt"
minetest.find_nodes_in_area(minp, maxp, nodenames) -> list of positions minetest.find_nodes_in_area(minp, maxp, nodenames) -> list of positions
^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt" ^ nodenames: e.g. {"ignore", "group:tree"} or "default:dirt"
minetest.get_perlin(seeddiff, octaves, persistence, scale) minetest.get_perlin(seeddiff, octaves, persistence, scale)
^ Return world-specific perlin noise (int(worldseed)+seeddiff) ^ Return world-specific perlin noise (int(worldseed)+seeddiff)
minetest.get_voxel_manip() minetest.get_voxel_manip()
@ -1452,7 +1451,7 @@ minetest.add_node_level(pos, level)
Inventory: Inventory:
minetest.get_inventory(location) -> InvRef minetest.get_inventory(location) -> InvRef
^ location = eg. {type="player", name="celeron55"} ^ location = e.g. {type="player", name="celeron55"}
{type="node", pos={x=, y=, z=}} {type="node", pos={x=, y=, z=}}
{type="detached", name="creative"} {type="detached", name="creative"}
minetest.create_detached_inventory(name, callbacks) -> InvRef minetest.create_detached_inventory(name, callbacks) -> InvRef
@ -1525,7 +1524,7 @@ minetest.handle_node_drops(pos, drops, digger)
^ drops: list of itemstrings ^ drops: list of itemstrings
^ Handles drops from nodes after digging: Default action is to put them into ^ Handles drops from nodes after digging: Default action is to put them into
digger's inventory digger's inventory
^ Can be overridden to get different functionality (eg. dropping items on ^ Can be overridden to get different functionality (e.g. dropping items on
ground) ground)
Rollback: Rollback:
@ -1612,7 +1611,7 @@ minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)
^ probability_list is an array of tables containing two fields, pos and prob. ^ probability_list is an array of tables containing two fields, pos and prob.
^ pos is the 3d vector specifying the absolute coordinates of the node being modified, ^ pos is the 3d vector specifying the absolute coordinates of the node being modified,
^ and prob is the integer value from 0 to 255 of the probability (see: Schematic specifier). ^ and prob is the integer value from 0 to 255 of the probability (see: Schematic specifier).
^ If there are two or more entries with the same pos value, the last occuring in the array is used. ^ If there are two or more entries with the same pos value, the last entry is used.
^ If pos is not inside the box formed by p1 and p2, it is ignored. ^ If pos is not inside the box formed by p1 and p2, it is ignored.
^ If probability_list is nil, no probabilities are applied. ^ If probability_list is nil, no probabilities are applied.
^ Slice probability works in the same manner, except takes a field called ypos instead which indicates ^ Slice probability works in the same manner, except takes a field called ypos instead which indicates
@ -1628,12 +1627,12 @@ minetest.place_schematic(pos, schematic, rotation, replacements, force_placement
^ force_placement is a boolean indicating whether nodes other than air and ^ force_placement is a boolean indicating whether nodes other than air and
^ ignore are replaced by the schematic ^ ignore are replaced by the schematic
Random: Misc.:
minetest.get_connected_players() -> list of ObjectRefs minetest.get_connected_players() -> list of ObjectRefs
minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
^ Gives a unique hash number for a node position (16+16+16=48bit) ^ Gives a unique hash number for a node position (16+16+16=48bit)
minetest.get_position_from_hash(hash) -> postion minetest.get_position_from_hash(hash) -> position
^ Inverse transform of minetest.hash_node_postion ^ Inverse transform of minetest.hash_node_position
minetest.get_item_group(name, group) -> rating minetest.get_item_group(name, group) -> rating
^ Get rating of a group of an item. (0 = not in group) ^ Get rating of a group of an item. (0 = not in group)
minetest.get_node_group(name, group) -> rating minetest.get_node_group(name, group) -> rating
@ -1655,7 +1654,7 @@ minetest.write_json(data[, styled]) -> string or nil and error message
^ Warning: JSON is more strict than the Lua table format. ^ Warning: JSON is more strict than the Lua table format.
1. You can only use strings and positive integers of at least one as keys. 1. You can only use strings and positive integers of at least one as keys.
2. You can not mix string and integer keys. 2. You can not mix string and integer keys.
This is due to the fact that Javascript has two distinct array and object values. This is due to the fact that JSON has two distinct array and object values.
^ Example: write_json({10, {a = false}}) -> "[10, {\"a\": false}]" ^ Example: write_json({10, {a = false}}) -> "[10, {\"a\": false}]"
minetest.serialize(table) -> string minetest.serialize(table) -> string
^ Convert a table containing tables, strings, numbers, booleans and nils ^ Convert a table containing tables, strings, numbers, booleans and nils
@ -1669,7 +1668,7 @@ minetest.deserialize(string) -> table
^ Example: deserialize('print("foo")') -> nil (function call fails) ^ Example: deserialize('print("foo")') -> nil (function call fails)
^ error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value) ^ error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)
minetest.is_protected(pos, name) -> bool minetest.is_protected(pos, name) -> bool
^ This function should be overriden by protection mods and should be used to ^ This function should be overridden by protection mods and should be used to
check if a player can interact at a position. check if a player can interact at a position.
^ This function should call the old version of itself if the position is not ^ This function should call the old version of itself if the position is not
protected by the mod. protected by the mod.
@ -1699,7 +1698,7 @@ minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orie
The above four options are mutually-exclusive; the last in the list takes The above four options are mutually-exclusive; the last in the list takes
precedence over the first. precedence over the first.
force_facedir: if true, forcably reset the facedir to north when placing on force_facedir: if true, forcefully reset the facedir to north when placing on
the floor or ceiling the floor or ceiling
minetest.rotate_node(itemstack, placer, pointed_thing) minetest.rotate_node(itemstack, placer, pointed_thing)
@ -1738,7 +1737,7 @@ minetest.registered_entities
minetest.object_refs minetest.object_refs
^ List of object references, indexed by active object id ^ List of object references, indexed by active object id
minetest.luaentities minetest.luaentities
^ List of lua entities, indexed by active object id ^ List of Lua entities, indexed by active object id
Class reference Class reference
---------------- ----------------
@ -1767,7 +1766,7 @@ methods:
^ will trigger the node's on_timer function after timeout-elapsed seconds ^ will trigger the node's on_timer function after timeout-elapsed seconds
- start(timeout) - start(timeout)
^ start a timer ^ start a timer
^ equivelent to set(timeout,0) ^ equivalent to set(timeout,0)
- stop() - stop()
^ stops the timer ^ stops the timer
- get_timeout() -> current timeout in seconds - get_timeout() -> current timeout in seconds
@ -2215,7 +2214,7 @@ Item definition (register_node, register_craftitem, register_tool)
description = "Steel Axe", description = "Steel Axe",
groups = {}, -- key=name, value=rating; rating=1..3. groups = {}, -- key=name, value=rating; rating=1..3.
if rating not applicable, use 1. if rating not applicable, use 1.
eg. {wool=1, fluffy=3} e.g. {wool=1, fluffy=3}
{soil=2, outerspace=1, crumbly=1} {soil=2, outerspace=1, crumbly=1}
{bendy=2, snappy=1}, {bendy=2, snappy=1},
{hard=1, metal=1, spikes=1} {hard=1, metal=1, spikes=1}
@ -2256,7 +2255,7 @@ Item definition (register_node, register_craftitem, register_tool)
^ default: nil ^ default: nil
^ Function must return either nil if no item shall be removed from ^ Function must return either nil if no item shall be removed from
inventory, or an itemstack to replace the original itemstack. inventory, or an itemstack to replace the original itemstack.
eg. itemstack:take_item(); return itemstack e.g. itemstack:take_item(); return itemstack
^ Otherwise, the function is free to do what it wants. ^ Otherwise, the function is free to do what it wants.
^ The default functions handle regular use cases. ^ The default functions handle regular use cases.
after_use = func(itemstack, user, node, digparams), after_use = func(itemstack, user, node, digparams),
@ -2302,7 +2301,7 @@ Node definition (register_node)
post_effect_color = {a=0, r=0, g=0, b=0}, -- If player is inside node post_effect_color = {a=0, r=0, g=0, b=0}, -- If player is inside node
paramtype = "none", -- See "Nodes" paramtype = "none", -- See "Nodes"
paramtype2 = "none", -- See "Nodes" paramtype2 = "none", -- See "Nodes"
is_ground_content = true, -- If false, cavegen will not carve through this is_ground_content = true, -- If false, the cave generator will not carve through this
sunlight_propagates = false, -- If true, sunlight will go infinitely through this sunlight_propagates = false, -- If true, sunlight will go infinitely through this
walkable = true, -- If true, objects collide with node walkable = true, -- If true, objects collide with node
pointable = true, -- If true, can be pointed at pointable = true, -- If true, can be pointed at
@ -2316,8 +2315,8 @@ Node definition (register_node)
liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7) liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
liquid_renewable = true, -- Can new liquid source be created by placing two or more sources nearby? liquid_renewable = true, -- Can new liquid source be created by placing two or more sources nearby?
freezemelt = "", -- water for snow/ice, ice/snow for water freezemelt = "", -- water for snow/ice, ice/snow for water
leveled = 0, -- Block contain level in param2. value - default level, used for snow. Dont forget use "leveled" type nodebox leveled = 0, -- Block contain level in param2. value - default level, used for snow. Don't forget use "leveled" type nodebox
liquid_range = 8, -- number of flowing nodes arround source (max. 8) liquid_range = 8, -- number of flowing nodes around source (max. 8)
drowning = 0, -- Player will take this amount of damage if no bubbles are left drowning = 0, -- Player will take this amount of damage if no bubbles are left
light_source = 0, -- Amount of light emitted by node light_source = 0, -- Amount of light emitted by node
damage_per_second = 0, -- If player is inside node, this damage is caused damage_per_second = 0, -- If player is inside node, this damage is caused
@ -2379,7 +2378,7 @@ Node definition (register_node)
on_receive_fields = func(pos, formname, fields, sender), on_receive_fields = func(pos, formname, fields, sender),
^ fields = {name1 = value1, name2 = value2, ...} ^ fields = {name1 = value1, name2 = value2, ...}
^ Called when an UI form (eg. sign text input) returns data ^ Called when an UI form (e.g. sign text input) returns data
^ default: nil ^ default: nil
allow_metadata_inventory_move = func(pos, from_list, from_index, allow_metadata_inventory_move = func(pos, from_list, from_index,
@ -2416,7 +2415,7 @@ Recipe for register_craft: (shaped)
recipe = { recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'}, {'default:cobble', 'default:cobble', 'default:cobble'},
{'', 'default:stick', ''}, {'', 'default:stick', ''},
{'', 'default:stick', ''}, -- Also groups; eg. 'group:crumbly' {'', 'default:stick', ''}, -- Also groups; e.g. 'group:crumbly'
}, },
replacements = <optional list of item pairs, replacements = <optional list of item pairs,
replace one input item with another item on crafting> replace one input item with another item on crafting>
@ -2538,7 +2537,7 @@ Decoration definition (register_decoration)
replacements = {{"oldname", "convert_to"}, ...}, replacements = {{"oldname", "convert_to"}, ...},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
^ Flags for schematic decorations. See 'Schematic attributes'. ^ Flags for schematic decorations. See 'Schematic attributes'.
rotation = "90" --rotate schematic 90 degrees on placement rotation = "90" -- rotate schematic 90 degrees on placement
^ Rotation can be "0", "90", "180", "270", or "random". ^ Rotation can be "0", "90", "180", "270", or "random".
} }
@ -2612,10 +2611,10 @@ Particle definition (add_particle)
texture = "image.png", texture = "image.png",
^ Uses texture (string) ^ Uses texture (string)
playername = "singleplayer" playername = "singleplayer"
^ Playername is optional, if specified spawns particle only on the player's client ^ optional, if specified spawns particle only on the player's client
} }
Particlespawner definition (add_particlespawner) ParticleSpawner definition (add_particlespawner)
{ {
amount = 1, amount = 1,
time = 1, time = 1,
@ -2630,11 +2629,11 @@ Particlespawner definition (add_particlespawner)
maxexptime = 1, maxexptime = 1,
minsize = 1, minsize = 1,
maxsize = 1, maxsize = 1,
^ The particle's properties are random values in between the boundings: ^ The particle's properties are random values in between the bounds:
^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
^ minsize/maxsize, minexptime/maxexptime (expirationtime) ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
collisiondetection = false, collisiondetection = false,
^ collisiondetection: if true uses collisiondetection ^ collisiondetection: if true uses collision detection
vertical = false, vertical = false,
^ vertical: if true faces player using y axis only ^ vertical: if true faces player using y axis only
texture = "image.png", texture = "image.png",