lua_api.txt 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644
  1. Minetest Lua Modding API Reference 0.4.9
  2. ========================================
  3. More information at http://www.minetest.net/
  4. Developer Wiki: http://dev.minetest.net/
  5. Introduction
  6. -------------
  7. Content and functionality can be added to Minetest 0.4 by using Lua
  8. scripting in run-time loaded mods.
  9. A mod is a self-contained bunch of scripts, textures and other related
  10. things that is loaded by and interfaces with Minetest.
  11. Mods are contained and ran solely on the server side. Definitions and media
  12. files are automatically transferred to the client.
  13. If you see a deficiency in the API, feel free to attempt to add the
  14. functionality in the engine and API. You can send such improvements as
  15. source code patches to <celeron55@gmail.com>.
  16. Programming in Lua
  17. -------------------
  18. If you have any difficulty in understanding this, please read:
  19. http://www.lua.org/pil/
  20. Startup
  21. --------
  22. Mods are loaded during server startup from the mod load paths by running
  23. the init.lua scripts in a shared environment.
  24. Paths
  25. -----
  26. RUN_IN_PLACE=1: (Windows release, local build)
  27. $path_user: Linux: <build directory>
  28. Windows: <build directory>
  29. $path_share: Linux: <build directory>
  30. Windows: <build directory>
  31. RUN_IN_PLACE=0: (Linux release)
  32. $path_share: Linux: /usr/share/minetest
  33. Windows: <install directory>/minetest-0.4.x
  34. $path_user: Linux: ~/.minetest
  35. Windows: C:/users/<user>/AppData/minetest (maybe)
  36. Games
  37. -----
  38. Games are looked up from:
  39. $path_share/games/gameid/
  40. $path_user/games/gameid/
  41. where gameid is unique to each game.
  42. The game directory contains the file game.conf, which contains these fields:
  43. name = <Human-readable full name of the game>
  44. eg.
  45. name = Minetest
  46. The game directory can contain the file minetest.conf, which will be used
  47. to set default settings when running the particular game.
  48. Mod load path
  49. -------------
  50. Generic:
  51. $path_share/games/gameid/mods/
  52. $path_share/mods/
  53. $path_user/games/gameid/mods/
  54. $path_user/mods/ <-- User-installed mods
  55. $worldpath/worldmods/
  56. In a run-in-place version (eg. the distributed windows version):
  57. minetest-0.4.x/games/gameid/mods/
  58. minetest-0.4.x/mods/gameid/ <-- User-installed mods
  59. minetest-0.4.x/worlds/worldname/worldmods/
  60. On an installed version on linux:
  61. /usr/share/minetest/games/gameid/mods/
  62. ~/.minetest/mods/gameid/ <-- User-installed mods
  63. ~/.minetest/worlds/worldname/worldmods
  64. Mod load path for world-specific games
  65. --------------------------------------
  66. It is possible to include a game in a world; in this case, no mods or
  67. games are loaded or checked from anywhere else.
  68. This is useful for eg. adventure worlds.
  69. This happens if the following directory exists:
  70. $world/game/
  71. Mods should be then be placed in:
  72. $world/game/mods/
  73. Modpack support
  74. ----------------
  75. Mods can be put in a subdirectory, if the parent directory, which otherwise
  76. should be a mod, contains a file named modpack.txt. This file shall be
  77. empty, except for lines starting with #, which are comments.
  78. Mod directory structure
  79. ------------------------
  80. mods
  81. |-- modname
  82. | |-- depends.txt
  83. | |-- screenshot.png
  84. | |-- description.txt
  85. | |-- init.lua
  86. | |-- textures
  87. | | |-- modname_stuff.png
  88. | | `-- modname_something_else.png
  89. | |-- sounds
  90. | |-- media
  91. | `-- <custom data>
  92. `-- another
  93. modname:
  94. The location of this directory can be fetched by using
  95. minetest.get_modpath(modname)
  96. depends.txt:
  97. List of mods that have to be loaded before loading this mod.
  98. A single line contains a single modname.
  99. Optional dependencies can be defined by appending a question mark
  100. to a single modname. Their meaning is that if the specified mod
  101. is missing, that does not prevent this mod from being loaded.
  102. screenshot.png:
  103. A screenshot shown in modmanager within mainmenu.
  104. description.txt:
  105. File containing desctiption to be shown within mainmenu.
  106. init.lua:
  107. The main Lua script. Running this script should register everything it
  108. wants to register. Subsequent execution depends on minetest calling the
  109. registered callbacks.
  110. minetest.setting_get(name) and minetest.setting_getbool(name) can be used
  111. to read custom or existing settings at load time, if necessary.
  112. textures, sounds, media:
  113. Media files (textures, sounds, whatever) that will be transferred to the
  114. client and will be available for use by the mod.
  115. Naming convention for registered textual names
  116. ----------------------------------------------
  117. Registered names should generally be in this format:
  118. "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
  119. This is to prevent conflicting names from corrupting maps and is
  120. enforced by the mod loader.
  121. Example: mod "experimental", ideal item/node/entity name "tnt":
  122. -> the name should be "experimental:tnt".
  123. Enforcement can be overridden by prefixing the name with ":". This can
  124. be used for overriding the registrations of some other mod.
  125. Example: Any mod can redefine experimental:tnt by using the name
  126. ":experimental:tnt" when registering it.
  127. (also that mod is required to have "experimental" as a dependency)
  128. The ":" prefix can also be used for maintaining backwards compatibility.
  129. Aliases
  130. -------
  131. Aliases can be added by using minetest.register_alias(name, convert_to)
  132. This will make Minetest to convert things called name to things called
  133. convert_to.
  134. This can be used for maintaining backwards compatibility.
  135. This can be also used for setting quick access names for things, eg. if
  136. you have an item called epiclylongmodname:stuff, you could do
  137. minetest.register_alias("stuff", "epiclylongmodname:stuff")
  138. and be able to use "/giveme stuff".
  139. Textures
  140. --------
  141. Mods should generally prefix their textures with modname_, eg. given
  142. the mod name "foomod", a texture could be called
  143. "foomod_foothing.png"
  144. Textures are referred to by their complete name, or alternatively by
  145. stripping out the file extension:
  146. eg. foomod_foothing.png
  147. eg. foomod_foothing
  148. Sounds
  149. -------
  150. Only OGG files are supported.
  151. For positional playing of sounds, only single-channel (mono) files are
  152. supported. Otherwise OpenAL will play them non-positionally.
  153. Mods should generally prefix their sounds with modname_, eg. given
  154. the mod name "foomod", a sound could be called
  155. "foomod_foosound.ogg"
  156. Sounds are referred to by their name with a dot, a single digit and the
  157. file extension stripped out. When a sound is played, the actual sound file
  158. is chosen randomly from the matching sounds.
  159. When playing the sound "foomod_foosound", the sound is chosen randomly
  160. from the available ones of the following files:
  161. foomod_foosound.ogg
  162. foomod_foosound.0.ogg
  163. foomod_foosound.1.ogg
  164. ...
  165. foomod_foosound.9.ogg
  166. Examples of sound parameter tables:
  167. -- Play locationless on all clients
  168. {
  169. gain = 1.0, -- default
  170. }
  171. -- Play locationless to a player
  172. {
  173. to_player = name,
  174. gain = 1.0, -- default
  175. }
  176. -- Play in a location
  177. {
  178. pos = {x=1,y=2,z=3},
  179. gain = 1.0, -- default
  180. max_hear_distance = 32, -- default
  181. }
  182. -- Play connected to an object, looped
  183. {
  184. object = <an ObjectRef>,
  185. gain = 1.0, -- default
  186. max_hear_distance = 32, -- default
  187. loop = true, -- only sounds connected to objects can be looped
  188. }
  189. SimpleSoundSpec:
  190. eg. ""
  191. eg. "default_place_node"
  192. eg. {}
  193. eg. {name="default_place_node"}
  194. eg. {name="default_place_node", gain=1.0}
  195. Registered definitions of stuff
  196. --------------------------------
  197. Anything added using certain minetest.register_* functions get added to
  198. the global minetest.registered_* tables.
  199. minetest.register_entity(name, prototype table)
  200. -> minetest.registered_entities[name]
  201. minetest.register_node(name, node definition)
  202. -> minetest.registered_items[name]
  203. -> minetest.registered_nodes[name]
  204. minetest.register_tool(name, item definition)
  205. -> minetest.registered_items[name]
  206. minetest.register_craftitem(name, item definition)
  207. -> minetest.registered_items[name]
  208. Note that in some cases you will stumble upon things that are not contained
  209. in these tables (eg. when a mod has been removed). Always check for
  210. existence before trying to access the fields.
  211. Example: If you want to check the drawtype of a node, you could do:
  212. local function get_nodedef_field(nodename, fieldname)
  213. if not minetest.registered_nodes[nodename] then
  214. return nil
  215. end
  216. return minetest.registered_nodes[nodename][fieldname]
  217. end
  218. local drawtype = get_nodedef_field(nodename, "drawtype")
  219. Example: minetest.get_item_group(name, group) has been implemented as:
  220. function minetest.get_item_group(name, group)
  221. if not minetest.registered_items[name] or not
  222. minetest.registered_items[name].groups[group] then
  223. return 0
  224. end
  225. return minetest.registered_items[name].groups[group]
  226. end
  227. Nodes
  228. ------
  229. Nodes are the bulk data of the world: cubes and other things that take the
  230. space of a cube. Huge amounts of them are handled efficiently, but they
  231. are quite static.
  232. The definition of a node is stored and can be accessed by name in
  233. minetest.registered_nodes[node.name]
  234. See "Registered definitions of stuff".
  235. Nodes are passed by value between Lua and the engine.
  236. They are represented by a table:
  237. {name="name", param1=num, param2=num}
  238. param1 and param2 are 8 bit integers. The engine uses them for certain
  239. automated functions. If you don't use these functions, you can use them to
  240. store arbitrary values.
  241. The functions of param1 and param2 are determined by certain fields in the
  242. node definition:
  243. param1 is reserved for the engine when paramtype != "none":
  244. paramtype = "light"
  245. ^ The value stores light with and without sun in it's
  246. upper and lower 4 bits.
  247. param2 is reserved for the engine when any of these are used:
  248. liquidtype == "flowing"
  249. ^ The level and some flags of the liquid is stored in param2
  250. drawtype == "flowingliquid"
  251. ^ The drawn liquid level is read from param2
  252. drawtype == "torchlike"
  253. drawtype == "signlike"
  254. paramtype2 == "wallmounted"
  255. ^ The rotation of the node is stored in param2. You can make this value
  256. by using minetest.dir_to_wallmounted().
  257. paramtype2 == "facedir"
  258. ^ The rotation of the node is stored in param2. Furnaces and chests are
  259. rotated this way. Can be made by using minetest.dir_to_facedir().
  260. Values range 0 - 23
  261. facedir modulo 4 = axisdir
  262. 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
  263. facedir's two less significant bits are rotation around the axis
  264. paramtype2 == "leveled"
  265. ^ The drawn node level is read from param2, like flowingliquid
  266. Nodes can also contain extra data. See "Node Metadata".
  267. Node drawtypes
  268. ---------------
  269. There are a bunch of different looking node types. These are mostly just
  270. copied from Minetest 0.3; more may be made in the future.
  271. Look for examples in games/minimal or games/minetest_game.
  272. - normal
  273. - airlike
  274. - liquid
  275. - flowingliquid
  276. - glasslike
  277. - glasslike_framed
  278. - allfaces
  279. - allfaces_optional
  280. - torchlike
  281. - signlike
  282. - plantlike
  283. - fencelike
  284. - raillike
  285. - nodebox -- See below. EXPERIMENTAL
  286. Node boxes
  287. -----------
  288. Node selection boxes are defined using "node boxes"
  289. The "nodebox" node drawtype allows defining visual of nodes consisting of
  290. arbitrary number of boxes. It allows defining stuff like stairs. Only the
  291. "fixed" and "leveled" box type is supported for these.
  292. ^ Please note that this is still experimental, and may be incompatibly
  293. changed in the future.
  294. A nodebox is defined as any of:
  295. {
  296. -- A normal cube; the default in most things
  297. type = "regular"
  298. }
  299. {
  300. -- A fixed box (facedir param2 is used, if applicable)
  301. type = "fixed",
  302. fixed = box OR {box1, box2, ...}
  303. }
  304. {
  305. -- A box like the selection box for torches
  306. -- (wallmounted param2 is used, if applicable)
  307. type = "wallmounted",
  308. wall_top = box,
  309. wall_bottom = box,
  310. wall_side = box
  311. }
  312. A box is defined as:
  313. {x1, y1, z1, x2, y2, z2}
  314. A box of a regular node would look like:
  315. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  316. type = "leveled" is same as "fixed", but y2 will be automaticaly setted to level from param2
  317. Ore types
  318. ---------------
  319. These tell in what manner the ore is generated.
  320. All default ores are of the uniformly-distributed scatter type.
  321. - scatter
  322. Randomly chooses a location and generates a cluster of ore.
  323. If noise_params is specified, the ore will be placed if the 3d perlin noise at
  324. that point is greater than the noise_threshhold, giving the ability to create a non-equal
  325. distribution of ore.
  326. - sheet
  327. Creates a sheet of ore in a blob shape according to the 2d perlin noise described by noise_params.
  328. The relative height of the sheet can be controlled by the same perlin noise as well, by specifying
  329. a non-zero 'scale' parameter in noise_params. IMPORTANT: The noise is not transformed by offset or
  330. scale when comparing against the noise threshhold, but scale is used to determine relative height.
  331. The height of the blob is randomly scattered, with a maximum height of clust_size.
  332. clust_scarcity and clust_num_ores are ignored.
  333. This is essentially an improved version of the so-called "stratus" ore seen in some unofficial mods.
  334. - claylike - NOT YET IMPLEMENTED
  335. Places ore if there are no more than clust_scarcity number of specified nodes within a Von Neumann
  336. neighborhood of clust_size radius.
  337. Ore attributes
  338. -------------------
  339. See section Flag Specifier Format.
  340. Currently supported flags: absheight
  341. - absheight
  342. Also produce this same ore between the height range of -height_max and -height_min.
  343. Useful for having ore in sky realms without having to duplicate ore entries.
  344. Decoration types
  345. -------------------
  346. The varying types of decorations that can be placed.
  347. The default value is simple, and is currently the only type supported.
  348. - simple
  349. Creates a 1xHx1 column of a specified node (or a random node from a list, if a decoration
  350. list is specified). Can specify a certain node it must spawn next to, such as water or lava,
  351. for example. Can also generate a decoration of random height between a specified lower and
  352. upper bound. This type of decoration is intended for placement of grass, flowers, cacti,
  353. papyrus, and so on.
  354. - schematic
  355. Copies a box of MapNodes from a specified schematic file (or raw description). Can specify a
  356. probability of a node randomly appearing when placed. This decoration type is intended to be used
  357. for multi-node sized discrete structures, such as trees, cave spikes, rocks, and so on.
  358. Schematic specifier
  359. --------------------
  360. A schematic specifier identifies a schematic by either a filename to a Minetest Schematic file (.mts)
  361. or through raw data supplied through Lua, in the form of a table. This table must specify two fields:
  362. - The 'size' field is a 3d vector containing the dimensions of the provided schematic.
  363. - The 'data' field is a flat table of MapNodes making up the schematic, in the order of [z [y [x]]].
  364. Important: The default value for param1 in MapNodes here is 255, which represents "always place".
  365. In the bulk MapNode data, param1, instead of the typical light values, instead represents the
  366. probability of that node appearing in the structure.
  367. When passed to minetest.create_schematic, probability is an integer value ranging from 0 to 255:
  368. - A probability value of 0 means that node will never appear (0% chance).
  369. - A probability value of 255 means the node will always appear (100% chance).
  370. - If the probability value p is greater than 0, then there is a (p / 256 * 100)% chance that node
  371. will appear when the schematic is placed on the map.
  372. Important note: Node aliases cannot be used for a raw schematic provided when registering as a decoration.
  373. Schematic attributes
  374. ---------------------
  375. See section Flag Specifier Format.
  376. Currently supported flags: place_center_x, place_center_y, place_center_z
  377. - place_center_x
  378. Placement of this decoration is centered along the X axis.
  379. - place_center_y
  380. Placement of this decoration is centered along the Y axis.
  381. - place_center_z
  382. Placement of this decoration is centered along the Z axis.
  383. HUD element types
  384. -------------------
  385. The position field is used for all element types.
  386. To account for differing resolutions, the position coordinates are the percentage of the screen,
  387. ranging in value from 0 to 1.
  388. The name field is not yet used, but should contain a description of what the HUD element represents.
  389. The direction field is the direction in which something is drawn.
  390. 0 draws from left to right, 1 draws from right to left, 2 draws from top to bottom, and 3 draws from bottom to top.
  391. The alignment field specifies how the item will be aligned. It ranges from -1 to 1,
  392. with 0 being the center, -1 is moved to the left/up, and 1 is to the right/down. Fractional
  393. values can be used.
  394. The offset field specifies a pixel offset from the position. Contrary to position,
  395. the offset is not scaled to screen size. This allows for some precisely-positioned
  396. items in the HUD.
  397. Note offset WILL adapt to screen dpi as well as user defined scaling factor!
  398. Below are the specific uses for fields in each type; fields not listed for that type are ignored.
  399. Note: Future revisions to the HUD API may be incompatible; the HUD API is still in the experimental stages.
  400. - image
  401. Displays an image on the HUD.
  402. - scale: The scale of the image, with 1 being the original texture size.
  403. Only the X coordinate scale is used (positive values)
  404. Negative values represent that percentage of the screen it
  405. should take; e.g. x=-100 means 100% (width)
  406. - text: The name of the texture that is displayed.
  407. - alignment: The alignment of the image.
  408. - offset: offset in pixels from position.
  409. - text
  410. Displays text on the HUD.
  411. - scale: Defines the bounding rectangle of the text.
  412. A value such as {x=100, y=100} should work.
  413. - text: The text to be displayed in the HUD element.
  414. - number: An integer containing the RGB value of the color used to draw the text.
  415. Specify 0xFFFFFF for white text, 0xFF0000 for red, and so on.
  416. - alignment: The alignment of the text.
  417. - offset: offset in pixels from position.
  418. - statbar
  419. Displays a horizontal bar made up of half-images.
  420. - text: The name of the texture that is used.
  421. - number: The number of half-textures that are displayed.
  422. If odd, will end with a vertically center-split texture.
  423. - direction
  424. - offset: offset in pixels from position.
  425. - size: If used will force full-image size to this value (override texture pack image size)
  426. - inventory
  427. - text: The name of the inventory list to be displayed.
  428. - number: Number of items in the inventory to be displayed.
  429. - item: Position of item that is selected.
  430. - direction
  431. - waypoint
  432. Displays distance to selected world position.
  433. - name: The name of the waypoint.
  434. - text: Distance suffix. Can be blank.
  435. - number: An integer containing the RGB value of the color used to draw the text.
  436. - world_pos: World position of the waypoint.
  437. Representations of simple things
  438. --------------------------------
  439. Position/vector:
  440. {x=num, y=num, z=num}
  441. For helper functions see "Vector helpers".
  442. pointed_thing:
  443. {type="nothing"}
  444. {type="node", under=pos, above=pos}
  445. {type="object", ref=ObjectRef}
  446. Flag Specifier Format
  447. -----------------------
  448. Flags using the standardized flag specifier format can be specified in either of two ways, by string or table.
  449. The string format is a comma-delimited set of flag names; whitespace and unrecognized flag fields are ignored.
  450. Specifying a flag in the string sets the flag, and specifying a flag prefixed by the string "no" explicitly
  451. clears the flag from whatever the default may be.
  452. In addition to the standard string flag format, the schematic flags field can also be a table of flag names
  453. to boolean values representing whether or not the flag is set. Additionally, if a field with the flag name
  454. prefixed with "no" is present, mapped to a boolean of any value, the specified flag is unset.
  455. e.g. A flag field of value
  456. {place_center_x = true, place_center_y=false, place_center_z=true}
  457. is equivalent to
  458. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  459. which is equivalent to
  460. "place_center_x, noplace_center_y, place_center_z"
  461. or even
  462. "place_center_x, place_center_z"
  463. since, by default, no schematic attributes are set.
  464. Items
  465. ------
  466. Node (register_node):
  467. A node from the world
  468. Tool (register_tool):
  469. A tool/weapon that can dig and damage things according to tool_capabilities
  470. Craftitem (register_craftitem):
  471. A miscellaneous item
  472. Items and item stacks can exist in three formats:
  473. Serialized; This is called stackstring or itemstring:
  474. eg. 'default:dirt 5'
  475. eg. 'default:pick_wood 21323'
  476. eg. 'default:apple'
  477. Table format:
  478. eg. {name="default:dirt", count=5, wear=0, metadata=""}
  479. ^ 5 dirt nodes
  480. eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  481. ^ a wooden pick about 1/3 weared out
  482. eg. {name="default:apple", count=1, wear=0, metadata=""}
  483. ^ an apple.
  484. ItemStack:
  485. C++ native format with many helper methods. Useful for converting between
  486. formats. See the Class reference section for details.
  487. When an item must be passed to a function, it can usually be in any of
  488. these formats.
  489. Groups
  490. -------
  491. In a number of places, there is a group table. Groups define the
  492. properties of a thing (item, node, armor of entity, capabilities of
  493. tool) in such a way that the engine and other mods can can interact with
  494. the thing without actually knowing what the thing is.
  495. Usage:
  496. - Groups are stored in a table, having the group names with keys and the
  497. group ratings as values. For example:
  498. groups = {crumbly=3, soil=1}
  499. ^ Default dirt
  500. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  501. ^ A more special dirt-kind of thing
  502. - Groups always have a rating associated with them. If there is no
  503. useful meaning for a rating for an enabled group, it shall be 1.
  504. - When not defined, the rating of a group defaults to 0. Thus when you
  505. read groups, you must interpret nil and 0 as the same value, 0.
  506. You can read the rating of a group for an item or a node by using
  507. minetest.get_item_group(itemname, groupname)
  508. Groups of items
  509. ----------------
  510. Groups of items can define what kind of an item it is (eg. wool).
  511. Groups of nodes
  512. ----------------
  513. In addition to the general item things, groups are used to define whether
  514. a node is destroyable and how long it takes to destroy by a tool.
  515. Groups of entities
  516. -------------------
  517. For entities, groups are, as of now, used only for calculating damage.
  518. The rating is the percentage of damage caused by tools with this damage group.
  519. See "Entity damage mechanism".
  520. object.get_armor_groups() -> a group-rating table (eg. {fleshy=100})
  521. object.set_armor_groups({fleshy=30, cracky=80})
  522. Groups of tools
  523. ----------------
  524. Groups in tools define which groups of nodes and entities they are
  525. effective towards.
  526. Groups in crafting recipes
  527. ---------------------------
  528. An example: Make meat soup from any meat, any water and any bowl
  529. {
  530. output = 'food:meat_soup_raw',
  531. recipe = {
  532. {'group:meat'},
  533. {'group:water'},
  534. {'group:bowl'},
  535. },
  536. -- preserve = {'group:bowl'}, -- Not implemented yet (TODO)
  537. }
  538. An another example: Make red wool from white wool and red dye
  539. {
  540. type = 'shapeless',
  541. output = 'wool:red',
  542. recipe = {'wool:white', 'group:dye,basecolor_red'},
  543. }
  544. Special groups
  545. ---------------
  546. - immortal: Disables the group damage system for an entity
  547. - level: Can be used to give an additional sense of progression in the game.
  548. - A larger level will cause eg. a weapon of a lower level make much less
  549. damage, and get weared out much faster, or not be able to get drops
  550. from destroyed nodes.
  551. - 0 is something that is directly accessible at the start of gameplay
  552. - There is no upper limit
  553. - dig_immediate: (player can always pick up node without tool wear)
  554. - 2: node is removed without tool wear after 0.5 seconds or so
  555. (rail, sign)
  556. - 3: node is removed without tool wear immediately (torch)
  557. - disable_jump: Player (and possibly other things) cannot jump from node
  558. - fall_damage_add_percent: damage speed = speed * (1 + value/100)
  559. - bouncy: value is bounce speed in percent
  560. - falling_node: if there is no walkable block under the node it will fall
  561. - attached_node: if the node under it is not a walkable block the node will be
  562. dropped as an item. If the node is wallmounted the
  563. wallmounted direction is checked.
  564. - soil: saplings will grow on nodes in this group
  565. - connect_to_raillike: makes nodes of raillike drawtype connect to
  566. other group members with same drawtype
  567. Known damage and digging time defining groups
  568. ----------------------------------------------
  569. - crumbly: dirt, sand
  570. - cracky: tough but crackable stuff like stone.
  571. - snappy: something that can be cut using fine tools; eg. leaves, small
  572. plants, wire, sheets of metal
  573. - choppy: something that can be cut using force; eg. trees, wooden planks
  574. - fleshy: Living things like animals and the player. This could imply
  575. some blood effects when hitting.
  576. - explody: Especially prone to explosions
  577. - oddly_breakable_by_hand:
  578. Can be added to nodes that shouldn't logically be breakable by the
  579. hand but are. Somewhat similar to dig_immediate, but times are more
  580. like {[1]=3.50,[2]=2.00,[3]=0.70} and this does not override the
  581. speed of a tool if the tool can dig at a faster speed than this
  582. suggests for the hand.
  583. Examples of custom groups
  584. --------------------------
  585. Item groups are often used for defining, well, //groups of items//.
  586. - meat: any meat-kind of a thing (rating might define the size or healing
  587. ability or be irrelevant - it is not defined as of yet)
  588. - eatable: anything that can be eaten. Rating might define HP gain in half
  589. hearts.
  590. - flammable: can be set on fire. Rating might define the intensity of the
  591. fire, affecting eg. the speed of the spreading of an open fire.
  592. - wool: any wool (any origin, any color)
  593. - metal: any metal
  594. - weapon: any weapon
  595. - heavy: anything considerably heavy
  596. Digging time calculation specifics
  597. -----------------------------------
  598. Groups such as **crumbly**, **cracky** and **snappy** are used for this
  599. purpose. Rating is 1, 2 or 3. A higher rating for such a group implies
  600. faster digging time.
  601. The **level** group is used to limit the toughness of nodes a tool can dig
  602. and to scale the digging times / damage to a greater extent.
  603. ^ PLEASE DO UNDERSTAND THIS, otherwise you cannot use the system to it's
  604. full potential.
  605. Tools define their properties by a list of parameters for groups. They
  606. cannot dig other groups; thus it is important to use a standard bunch of
  607. groups to enable interaction with tools.
  608. **Tools define:**
  609. * Full punch interval
  610. * Maximum drop level
  611. * For an arbitrary list of groups:
  612. * Uses (until the tool breaks)
  613. * Maximum level (usually 0, 1, 2 or 3)
  614. * Digging times
  615. * Damage groups
  616. **Full punch interval**:
  617. When used as a weapon, the tool will do full damage if this time is spent
  618. between punches. If eg. half the time is spent, the tool will do half
  619. damage.
  620. **Maximum drop level**
  621. Suggests the maximum level of node, when dug with the tool, that will drop
  622. it's useful item. (eg. iron ore to drop a lump of iron).
  623. - This is not automated; it is the responsibility of the node definition
  624. to implement this
  625. **Uses**
  626. Determines how many uses the tool has when it is used for digging a node,
  627. of this group, of the maximum level. For lower leveled nodes, the use count
  628. is multiplied by 3^leveldiff.
  629. - uses=10, leveldiff=0 -> actual uses: 10
  630. - uses=10, leveldiff=1 -> actual uses: 30
  631. - uses=10, leveldiff=2 -> actual uses: 90
  632. **Maximum level**
  633. Tells what is the maximum level of a node of this group that the tool will
  634. be able to dig.
  635. **Digging times**
  636. List of digging times for different ratings of the group, for nodes of the
  637. maximum level.
  638. * For example, as a lua table, ''times={2=2.00, 3=0.70}''. This would
  639. result in the tool to be able to dig nodes that have a rating of 2 or 3
  640. for this group, and unable to dig the rating 1, which is the toughest.
  641. Unless there is a matching group that enables digging otherwise.
  642. **Damage groups**
  643. List of damage for groups of entities. See "Entity damage mechanism".
  644. Example definition of the capabilities of a tool
  645. -------------------------------------------------
  646. tool_capabilities = {
  647. full_punch_interval=1.5,
  648. max_drop_level=1,
  649. groupcaps={
  650. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  651. }
  652. damage_groups = {fleshy=2},
  653. }
  654. This makes the tool be able to dig nodes that fullfill both of these:
  655. - Have the **crumbly** group
  656. - Have a **level** group less or equal to 2
  657. Table of resulting digging times:
  658. crumbly 0 1 2 3 4 <- level
  659. -> 0 - - - - -
  660. 1 0.80 1.60 1.60 - -
  661. 2 0.60 1.20 1.20 - -
  662. 3 0.40 0.80 0.80 - -
  663. level diff: 2 1 0 -1 -2
  664. Table of resulting tool uses:
  665. -> 0 - - - - -
  666. 1 180 60 20 - -
  667. 2 180 60 20 - -
  668. 3 180 60 20 - -
  669. Notes:
  670. - At crumbly=0, the node is not diggable.
  671. - At crumbly=3, the level difference digging time divider kicks in and makes
  672. easy nodes to be quickly breakable.
  673. - At level > 2, the node is not diggable, because it's level > maxlevel
  674. Entity damage mechanism
  675. ------------------------
  676. Damage calculation:
  677. damage = 0
  678. foreach group in cap.damage_groups:
  679. damage += cap.damage_groups[group] * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
  680. * (object.armor_groups[group] / 100.0)
  681. -- Where object.armor_groups[group] is 0 for inexisting values
  682. return damage
  683. Client predicts damage based on damage groups. Because of this, it is able to
  684. give an immediate response when an entity is damaged or dies; the response is
  685. pre-defined somehow (eg. by defining a sprite animation) (not implemented;
  686. TODO).
  687. - Currently a smoke puff will appear when an entity dies.
  688. The group **immortal** completely disables normal damage.
  689. Entities can define a special armor group, which is **punch_operable**. This
  690. group disables the regular damage mechanism for players punching it by hand or
  691. a non-tool item, so that it can do something else than take damage.
  692. On the Lua side, every punch calls ''entity:on_punch(puncher,
  693. time_from_last_punch, tool_capabilities, direction)''. This should never be
  694. called directly, because damage is usually not handled by the entity itself.
  695. * ''puncher'' is the object performing the punch. Can be nil. Should never be
  696. accessed unless absolutely required, to encourage interoperability.
  697. * ''time_from_last_punch'' is time from last punch (by puncher) or nil.
  698. * ''tool_capabilities'' can be nil.
  699. * ''direction'' is a unit vector, pointing from the source of the punch to
  700. the punched object.
  701. To punch an entity/object in Lua, call ''object:punch(puncher,
  702. time_from_last_punch, tool_capabilities, direction)''.
  703. * Return value is tool wear.
  704. * Parameters are equal to the above callback.
  705. * If ''direction'' is nil and ''puncher'' is not nil, ''direction'' will be
  706. automatically filled in based on the location of ''puncher''.
  707. Node Metadata
  708. -------------
  709. The instance of a node in the world normally only contains the three values
  710. mentioned in "Nodes". However, it is possible to insert extra data into a
  711. node. It is called "node metadata"; See "NodeMetaRef".
  712. Metadata contains two things:
  713. - A key-value store
  714. - An inventory
  715. Some of the values in the key-value store are handled specially:
  716. - formspec: Defines a right-click inventory menu. See "Formspec".
  717. - infotext: Text shown on the screen when the node is pointed at
  718. Example stuff:
  719. local meta = minetest.get_meta(pos)
  720. meta:set_string("formspec",
  721. "size[8,9]"..
  722. "list[context;main;0,0;8,4;]"..
  723. "list[current_player;main;0,5;8,4;]")
  724. meta:set_string("infotext", "Chest");
  725. local inv = meta:get_inventory()
  726. inv:set_size("main", 8*4)
  727. print(dump(meta:to_table()))
  728. meta:from_table({
  729. inventory = {
  730. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "", [5] = "", [6] = "", [7] = "", [8] = "", [9] = "", [10] = "", [11] = "", [12] = "", [13] = "", [14] = "default:cobble", [15] = "", [16] = "", [17] = "", [18] = "", [19] = "", [20] = "default:cobble", [21] = "", [22] = "", [23] = "", [24] = "", [25] = "", [26] = "", [27] = "", [28] = "", [29] = "", [30] = "", [31] = "", [32] = ""}
  731. },
  732. fields = {
  733. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  734. infotext = "Chest"
  735. }
  736. })
  737. Formspec
  738. --------
  739. Formspec defines a menu. Currently not much else than inventories are
  740. supported. It is a string, with a somewhat strange format.
  741. Spaces and newlines can be inserted between the blocks, as is used in the
  742. examples.
  743. Examples:
  744. - Chest:
  745. size[8,9]
  746. list[context;main;0,0;8,4;]
  747. list[current_player;main;0,5;8,4;]
  748. - Furnace:
  749. size[8,9]
  750. list[context;fuel;2,3;1,1;]
  751. list[context;src;2,1;1,1;]
  752. list[context;dst;5,1;2,2;]
  753. list[current_player;main;0,5;8,4;]
  754. - Minecraft-like player inventory
  755. size[8,7.5]
  756. image[1,0.6;1,2;player.png]
  757. list[current_player;main;0,3.5;8,4;]
  758. list[current_player;craft;3,0;3,3;]
  759. list[current_player;craftpreview;7,1;1,1;]
  760. Elements:
  761. size[<W>,<H>,<fixed_size>]
  762. ^ Define the size of the menu in inventory slots
  763. ^ fixed_size true/false (optional)
  764. ^ deprecated: invsize[<W>,<H>;]
  765. list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]
  766. list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]
  767. ^ Show an inventory list
  768. listcolors[<slot_bg_normal>;<slot_bg_hover>]
  769. ^ Sets background color of slots in HEX-Color format
  770. ^ Sets background color of slots on mouse hovering
  771. listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]
  772. ^ Sets background color of slots in HEX-Color format
  773. ^ Sets background color of slots on mouse hovering
  774. ^ Sets color of slots border
  775. listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]
  776. ^ Sets background color of slots in HEX-Color format
  777. ^ Sets background color of slots on mouse hovering
  778. ^ Sets color of slots border
  779. ^ Sets default background color of tooltips
  780. ^ Sets default font color of tooltips
  781. tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>,<fontcolor>]
  782. ^ Adds tooltip for an element
  783. ^ <bgcolor> tooltip background color in HEX-Color format (optional)
  784. ^ <fontcolor> tooltip font color in HEX-Color format (optional)
  785. image[<X>,<Y>;<W>,<H>;<texture name>]
  786. ^ Show an image
  787. ^ Position and size units are inventory slots
  788. item_image[<X>,<Y>;<W>,<H>;<item name>]
  789. ^ Show an inventory image of registered item/node
  790. ^ Position and size units are inventory slots
  791. bgcolor[<color>;<fullscreen>]
  792. ^ Sets background color of formspec in HEX-Color format
  793. ^ If true the background color is drawn fullscreen (does not effect the size of the formspec)
  794. background[<X>,<Y>;<W>,<H>;<texture name>]
  795. ^ Use a background. Inventory rectangles are not drawn then.
  796. ^ Position and size units are inventory slots
  797. ^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px
  798. background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]
  799. ^ Use a background. Inventory rectangles are not drawn then.
  800. ^ Position and size units are inventory slots
  801. ^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px
  802. ^ If true the background is clipped to formspec size (x and y are used as offset values, w and h are ignored)
  803. pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]
  804. ^ Textual password style field; will be sent to server when a button is clicked
  805. ^ x and y position the field relative to the top left of the menu
  806. ^ w and h are the size of the field
  807. ^ fields are a set height, but will be vertically centred on h
  808. ^ Position and size units are inventory slots
  809. ^ name is the name of the field as returned in fields to on_receive_fields
  810. ^ label, if not blank, will be text printed on the top left above the field
  811. field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
  812. ^ Textual field; will be sent to server when a button is clicked
  813. ^ x and y position the field relative to the top left of the menu
  814. ^ w and h are the size of the field
  815. ^ fields are a set height, but will be vertically centred on h
  816. ^ Position and size units are inventory slots
  817. ^ name is the name of the field as returned in fields to on_receive_fields
  818. ^ label, if not blank, will be text printed on the top left above the field
  819. ^ default is the default value of the field
  820. ^ default may contain variable references such as '${text}' which
  821. will fill the value from the metadata value 'text'
  822. ^ Note: no extra text or more than a single variable is supported ATM.
  823. field[<name>;<label>;<default>]
  824. ^ as above but without position/size units
  825. ^ special field for creating simple forms, such as sign text input
  826. ^ must be used without a size[] element
  827. ^ a 'Proceed' button will be added automatically
  828. textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
  829. ^ same as fields above, but with multi-line input
  830. label[<X>,<Y>;<label>]
  831. ^ x and y work as per field
  832. ^ label is the text on the label
  833. ^ Position and size units are inventory slots
  834. vertlabel[<X>,<Y>;<label>]
  835. ^ Textual label drawn verticaly
  836. ^ x and y work as per field
  837. ^ label is the text on the label
  838. ^ Position and size units are inventory slots
  839. button[<X>,<Y>;<W>,<H>;<name>;<label>]
  840. ^ Clickable button. When clicked, fields will be sent.
  841. ^ x, y and name work as per field
  842. ^ w and h are the size of the button
  843. ^ label is the text on the button
  844. ^ Position and size units are inventory slots
  845. image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
  846. ^ x, y, w, h, and name work as per button
  847. ^ texture name is the filename of an image
  848. ^ Position and size units are inventory slots
  849. image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]
  850. ^ x, y, w, h, and name work as per button
  851. ^ texture name is the filename of an image
  852. ^ Position and size units are inventory slots
  853. ^ noclip true meand imagebutton doesn't need to be within specified formsize
  854. ^ drawborder draw button bodrer or not
  855. ^ pressed texture name is the filename of an image on pressed state
  856. item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]
  857. ^ x, y, w, h, name and label work as per button
  858. ^ item name is the registered name of an item/node,
  859. tooltip will be made out of its descritption
  860. to override it use tooltip element
  861. ^ Position and size units are inventory slots
  862. button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]
  863. ^ When clicked, fields will be sent and the form will quit.
  864. image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
  865. ^ When clicked, fields will be sent and the form will quit.
  866. textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]
  867. ^Scrollabel itemlist showing arbitrary text elements
  868. ^ x and y position the itemlist relative to the top left of the menu
  869. ^ w and h are the size of the itemlist
  870. ^ name fieldname sent to server on doubleclick value is current selected element
  871. ^ listelements can be prepended by #color in hexadecimal format RRGGBB (only),
  872. ^ if you want a listelement to start with # write ##
  873. textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]
  874. ^Scrollabel itemlist showing arbitrary text elements
  875. ^ x and y position the itemlist relative to the top left of the menu
  876. ^ w and h are the size of the itemlist
  877. ^ name fieldname sent to server on doubleclick value is current selected element
  878. ^ listelements can be prepended by #RRGGBB (only) in hexadecimal format
  879. ^ if you want a listelement to start with # write ##
  880. ^ index to be selected within textlist
  881. ^ true/false draw transparent background
  882. ^ see also minetest.explode_textlist_event (main menu: engine.explode_textlist_event)
  883. tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]
  884. ^ show a tabHEADER at specific position (ignores formsize)
  885. ^ x and y position the itemlist relative to the top left of the menu
  886. ^ name fieldname data is transfered to lua
  887. ^ caption 1... name shown on top of tab
  888. ^ current_tab index of selected tab 1...
  889. ^ transparent (optional) show transparent
  890. ^ draw_border (optional) draw border
  891. box[<X>,<Y>;<W>,<H>;<color>]
  892. ^ simple colored semitransparent box
  893. ^ x and y position the box relative to the top left of the menu
  894. ^ w and h are the size of box
  895. ^ color in HEX-Color format
  896. dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]
  897. ^ show a dropdown field
  898. ^ x and y position of dropdown
  899. ^ width of dropdown
  900. ^ fieldname data is transfered to lua
  901. ^ items to be shown in dropdown
  902. ^ index of currently selected dropdown item
  903. ^ color in hexadecimal format RRGGBB (only)
  904. checkbox[<X>,<Y>;<name>;<label>;<selected>;<tooltip>]
  905. ^ show a checkbox
  906. ^ x and y position of checkbox
  907. ^ name fieldname data is transfered to lua
  908. ^ label to be shown left of checkbox
  909. ^ selected (optional) true/false
  910. ^ tooltip (optional)
  911. table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]
  912. ^ show scrollable table using options defined by the previous tableoptions[]
  913. ^ displays cells as defined by the previous tablecolumns[]
  914. ^ x and y position the itemlist relative to the top left of the menu
  915. ^ w and h are the size of the itemlist
  916. ^ name fieldname sent to server on row select or doubleclick
  917. ^ cell 1...n cell contents given in row-major order
  918. ^ selected idx: index of row to be selected within table (first row = 1)
  919. ^ see also minetest.explode_table_event (main menu: engine.explode_table_event)
  920. tableoptions[<opt 1>;<opt 2>;...]
  921. ^ sets options for table[]:
  922. ^ color=#RRGGBB
  923. ^^ default text color (HEX-Color), defaults to #FFFFFF
  924. ^ background=#RRGGBB
  925. ^^ table background color (HEX-Color), defaults to #000000
  926. ^ border=<true/false>
  927. ^^ should the table be drawn with a border? (default true)
  928. ^ highlight=#RRGGBB
  929. ^^ highlight background color (HEX-Color), defaults to #466432
  930. ^ highlight_text=#RRGGBB
  931. ^^ highlight text color (HEX-Color), defaults to #FFFFFF
  932. ^ opendepth=<value>
  933. ^^ all subtrees up to depth < value are open (default value = 0)
  934. ^^ only useful when there is a column of type "tree"
  935. tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]
  936. ^ sets columns for table[]:
  937. ^ types: text, image, color, indent, tree
  938. ^^ text: show cell contents as text
  939. ^^ image: cell contents are an image index, use column options to define images
  940. ^^ color: cell contents are a HEX-Color and define color of following cell
  941. ^^ indent: cell contents are a number and define indentation of following cell
  942. ^^ tree: same as indent, but user can open and close subtrees (treeview-like)
  943. ^ column options:
  944. ^^ align=<value> for "text" and "image": content alignment within cells
  945. ^^ available values: left (default), center, right, inline
  946. ^^ width=<value> for "text" and "image": minimum width in em (default 0)
  947. ^^ for "indent" and "tree": indent width in em (default 1.5)
  948. ^^ padding=<value> padding left of the column, in em (default 0.5)
  949. ^^ exception: defaults to 0 for indent columns
  950. ^^ tooltip=<value> tooltip text (default empty)
  951. ^ "image" column options:
  952. ^^ 0=<value> sets image for image index 0
  953. ^^ 1=<value> sets image for image index 1
  954. ^^ 2=<value> sets image for image index 2
  955. ^^ and so on; defined indices need not be contiguous
  956. ^^ empty or non-numeric cells are treated as 0
  957. ^ "color" column options:
  958. ^^ span=<value> number of following columns to affect (default infinite)
  959. Note: do NOT use a element name starting with "key_" those names are reserved to
  960. pass key press events to formspec!
  961. Inventory location:
  962. - "context": Selected node metadata (deprecated: "current_name")
  963. - "current_player": Player to whom the menu is shown
  964. - "player:<name>": Any player
  965. - "nodemeta:<X>,<Y>,<Z>": Any node metadata
  966. - "detached:<name>": A detached inventory
  967. HEX-Color
  968. ---------
  969. #RGB
  970. ^ defines a color in hexadecimal format
  971. #RGBA
  972. ^ defines a color in hexadecimal format and alpha channel
  973. #RRGGBB
  974. ^ defines a color in hexadecimal format
  975. #RRGGBBAA
  976. ^ defines a color in hexadecimal format and alpha channel
  977. Vector helpers
  978. ---------------
  979. vector.new([x[, y, z]]) -> vector
  980. ^ x is a table or the x position.
  981. vector.direction(p1, p2) -> vector
  982. vector.distance(p1, p2) -> number
  983. vector.length(v) -> number
  984. vector.normalize(v) -> vector
  985. vector.round(v) -> vector
  986. vector.equals(v1, v2) -> bool
  987. For the folowing x can be either a vector or a number.
  988. vector.add(v, x) -> vector
  989. vector.subtract(v, x) -> vector
  990. vector.multiply(v, x) -> vector
  991. vector.divide(v, x) -> vector
  992. Helper functions
  993. -----------------
  994. dump2(obj, name="_", dumped={})
  995. ^ Return object serialized as a string, handles reference loops
  996. dump(obj, dumped={})
  997. ^ Return object serialized as a string
  998. math.hypot(x, y)
  999. ^ Get the hypotenuse of a triangle with legs x and y.
  1000. Usefull for distance calculation.
  1001. string:split(separator)
  1002. ^ eg. string:split("a,b", ",") == {"a","b"}
  1003. string:trim()
  1004. ^ eg. string.trim("\n \t\tfoo bar\t ") == "foo bar"
  1005. minetest.pos_to_string({x=X,y=Y,z=Z}) -> "(X,Y,Z)"
  1006. ^ Convert position to a printable string
  1007. minetest.string_to_pos(string) -> position
  1008. ^ Same but in reverse
  1009. minetest.formspec_escape(string) -> string
  1010. ^ escapes characters [ ] \ , ; that can not be used in formspecs
  1011. minetest.is_yes(arg)
  1012. ^ returns whether arg can be interpreted as yes
  1013. minetest namespace reference
  1014. -----------------------------
  1015. Utilities:
  1016. minetest.get_current_modname() -> string
  1017. minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
  1018. ^ Useful for loading additional .lua modules or static data from mod
  1019. minetest.get_modnames() -> list of installed mods
  1020. ^ Return a list of installed mods, sorted alphabetically
  1021. minetest.get_worldpath() -> eg. "/home/user/.minetest/world"
  1022. ^ Useful for storing custom data
  1023. minetest.is_singleplayer()
  1024. minetest.features
  1025. ^ table containing API feature flags: {foo=true, bar=true}
  1026. minetest.has_feature(arg) -> bool, missing_features
  1027. ^ arg: string or table in format {foo=true, bar=true}
  1028. ^ missing_features: {foo=true, bar=true}
  1029. minetest.get_player_information(playername)
  1030. ^ table containing information about player peer:
  1031. {
  1032. address = "127.0.0.1", -- ip address of client
  1033. ip_version = 4, -- IPv4 / IPv6
  1034. min_rtt = 0.01, -- minimum round trip time
  1035. max_rtt = 0.2, -- maximum round trip time
  1036. avg_rtt = 0.02, -- average round trip time
  1037. min_jitter = 0.01, -- minimum packet time jitter
  1038. max_jitter = 0.5, -- maximum packet time jitter
  1039. avg_jitter = 0.03, -- average packet time jitter
  1040. connection_uptime = 200, -- seconds since client connected
  1041. -- following information is available on debug build only!!!
  1042. -- DO NOT USE IN MODS
  1043. --ser_vers = 26, -- serialization version used by client
  1044. --prot_vers = 23, -- protocol version used by client
  1045. --major = 0, -- major version number
  1046. --minor = 4, -- minor version number
  1047. --patch = 10, -- patch version number
  1048. --vers_string = "0.4.9-git", -- full version string
  1049. --state = "Active" -- current client state
  1050. }
  1051. Logging:
  1052. minetest.debug(line)
  1053. ^ Always printed to stderr and logfile (print() is redirected here)
  1054. minetest.log(line)
  1055. minetest.log(loglevel, line)
  1056. ^ loglevel one of "error", "action", "info", "verbose"
  1057. Registration functions: (Call these only at load time)
  1058. minetest.register_entity(name, prototype table)
  1059. minetest.register_abm(abm definition)
  1060. minetest.register_node(name, node definition)
  1061. minetest.register_tool(name, item definition)
  1062. minetest.register_craftitem(name, item definition)
  1063. minetest.register_alias(name, convert_to)
  1064. minetest.register_craft(recipe)
  1065. minetest.register_ore(ore definition)
  1066. minetest.register_decoration(decoration definition)
  1067. minetest.override_item(name, redefinition)
  1068. ^ Overrides fields of an item registered with register_node/tool/craftitem.
  1069. ^ Note: Item must already be defined, (opt)depend on the mod defining it.
  1070. ^ Example: minetest.override_item("default:mese", {light_source=LIGHT_MAX})
  1071. Global callback registration functions: (Call these only at load time)
  1072. minetest.register_globalstep(func(dtime))
  1073. ^ Called every server step, usually interval of 0.1s
  1074. minetest.register_on_shutdown(func())
  1075. ^ Called before server shutdown
  1076. ^ WARNING: If the server terminates abnormally (i.e. crashes), the registered
  1077. callbacks WILL LIKELY NOT BE RUN. Data should be saved at
  1078. semi-frequent intervals as well as on server shutdown.
  1079. minetest.register_on_placenode(func(pos, newnode, placer, oldnode, itemstack, pointed_thing))
  1080. ^ Called when a node has been placed
  1081. ^ If return true no item is taken from itemstack
  1082. ^ Not recommended; use on_construct or after_place_node in node definition
  1083. ^ whenever possible
  1084. minetest.register_on_dignode(func(pos, oldnode, digger))
  1085. ^ Called when a node has been dug.
  1086. ^ Not recommended: Use on_destruct or after_dig_node in node definition
  1087. ^ whenever possible
  1088. minetest.register_on_punchnode(func(pos, node, puncher, pointed_thing))
  1089. ^ Called when a node is punched
  1090. minetest.register_on_generated(func(minp, maxp, blockseed))
  1091. ^ Called after generating a piece of world. Modifying nodes inside the area
  1092. is a bit faster than usually.
  1093. minetest.register_on_newplayer(func(ObjectRef))
  1094. ^ Called after a new player has been created
  1095. minetest.register_on_dieplayer(func(ObjectRef))
  1096. ^ Called when a player dies
  1097. minetest.register_on_respawnplayer(func(ObjectRef))
  1098. ^ Called when player is to be respawned
  1099. ^ Called _before_ repositioning of player occurs
  1100. ^ return true in func to disable regular player placement
  1101. minetest.register_on_prejoinplayer(func(name, ip))
  1102. ^ Called before a player joins the game
  1103. ^ If it returns a string, the player is disconnected with that string as reason
  1104. minetest.register_on_joinplayer(func(ObjectRef))
  1105. ^ Called when a player joins the game
  1106. minetest.register_on_leaveplayer(func(ObjectRef))
  1107. ^ Called when a player leaves the game
  1108. minetest.register_on_cheat(func(ObjectRef, cheat))
  1109. ^ Called when a player cheats
  1110. ^ cheat: {type="moved_too_fast"/"interacted_too_far"/"finished_unknown_dig"/"dug_unbreakable"/"dug_too_fast"}
  1111. minetest.register_on_chat_message(func(name, message))
  1112. ^ Called always when a player says something
  1113. minetest.register_on_player_receive_fields(func(player, formname, fields))
  1114. ^ Called when a button is pressed in player's inventory form
  1115. ^ Newest functions are called first
  1116. ^ If function returns true, remaining functions are not called
  1117. minetest.register_on_mapgen_init(func(MapgenParams))
  1118. ^ Called just before the map generator is initialized but before the environment is initialized
  1119. ^ MapgenParams consists of a table with the fields mgname, seed, water_level, and flags
  1120. minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))
  1121. ^ Called when player crafts something
  1122. ^ itemstack is the output
  1123. ^ old_craft_grid contains the recipe (Note: the one in the inventory is cleared)
  1124. ^ craft_inv is the inventory with the crafting grid
  1125. ^ Return either an ItemStack, to replace the output, or nil, to not modify it
  1126. minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))
  1127. ^ The same as before, except that it is called before the player crafts, to make
  1128. ^ craft prediction, and it should not change anything.
  1129. minetest.register_on_protection_violation(func(pos, name))
  1130. ^ Called by builtin and mods when a player violates protection at a position
  1131. (eg, digs a node or punches a protected entity).
  1132. ^ The registered functions can be called using minetest.record_protection_violation
  1133. ^ The provided function should check that the position is protected by the mod
  1134. calling this function before it prints a message, if it does, to allow for
  1135. multiple protection mods.
  1136. minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))
  1137. ^ Called when an item is eaten, by minetest.item_eat
  1138. ^ Return true or itemstack to cancel the default item eat response (ie: hp increase)
  1139. Other registration functions:
  1140. minetest.register_chatcommand(cmd, chatcommand definition)
  1141. minetest.register_privilege(name, definition)
  1142. ^ definition: "description text"
  1143. ^ definition: {
  1144. description = "description text",
  1145. give_to_singleplayer = boolean, -- default: true
  1146. }
  1147. minetest.register_authentication_handler(handler)
  1148. ^ See minetest.builtin_auth_handler in builtin.lua for reference
  1149. Setting-related:
  1150. minetest.setting_set(name, value)
  1151. minetest.setting_get(name) -> string or nil
  1152. minetest.setting_setbool(name, value)
  1153. minetest.setting_getbool(name) -> boolean value or nil
  1154. minetest.setting_get_pos(name) -> position or nil
  1155. minetest.setting_save() -> nil, save all settings to config file
  1156. Authentication:
  1157. minetest.notify_authentication_modified(name)
  1158. ^ Should be called by the authentication handler if privileges change.
  1159. ^ To report everybody, set name=nil.
  1160. minetest.get_password_hash(name, raw_password)
  1161. ^ Convert a name-password pair to a password hash that minetest can use
  1162. minetest.string_to_privs(str) -> {priv1=true,...}
  1163. minetest.privs_to_string(privs) -> "priv1,priv2,..."
  1164. ^ Convert between two privilege representations
  1165. minetest.set_player_password(name, password_hash)
  1166. minetest.set_player_privs(name, {priv1=true,...})
  1167. minetest.get_player_privs(name) -> {priv1=true,...}
  1168. minetest.auth_reload()
  1169. ^ These call the authentication handler
  1170. minetest.check_player_privs(name, {priv1=true,...}) -> bool, missing_privs
  1171. ^ A quickhand for checking privileges
  1172. minetest.get_player_ip(name) -> IP address string
  1173. Chat:
  1174. minetest.chat_send_all(text)
  1175. minetest.chat_send_player(name, text)
  1176. Environment access:
  1177. minetest.set_node(pos, node)
  1178. minetest.add_node(pos, node): alias set_node(pos, node)
  1179. ^ Set node at position (node = {name="foo", param1=0, param2=0})
  1180. minetest.swap_node(pos, node)
  1181. ^ Set node at position, but don't remove metadata
  1182. minetest.remove_node(pos)
  1183. ^ Equivalent to set_node(pos, "air")
  1184. minetest.get_node(pos)
  1185. ^ Returns {name="ignore", ...} for unloaded area
  1186. minetest.get_node_or_nil(pos)
  1187. ^ Returns nil for unloaded area
  1188. minetest.get_node_light(pos, timeofday) -> 0...15 or nil
  1189. ^ timeofday: nil = current time, 0 = night, 0.5 = day
  1190. minetest.place_node(pos, node)
  1191. ^ Place node with the same effects that a player would cause
  1192. minetest.dig_node(pos)
  1193. ^ Dig node with the same effects that a player would cause
  1194. minetest.punch_node(pos)
  1195. ^ Punch node with the same effects that a player would cause
  1196. minetest.get_meta(pos) -- Get a NodeMetaRef at that position
  1197. minetest.get_node_timer(pos) -- Get NodeTimerRef
  1198. minetest.add_entity(pos, name): Spawn Lua-defined entity at position
  1199. ^ Returns ObjectRef, or nil if failed
  1200. minetest.add_item(pos, item): Spawn item
  1201. ^ Returns ObjectRef, or nil if failed
  1202. minetest.get_player_by_name(name) -- Get an ObjectRef to a player
  1203. minetest.get_objects_inside_radius(pos, radius)
  1204. minetest.set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
  1205. minetest.get_timeofday()
  1206. minetest.get_gametime(): returns the time, in seconds, since the world was created
  1207. minetest.find_node_near(pos, radius, nodenames) -> pos or nil
  1208. ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
  1209. minetest.find_nodes_in_area(minp, maxp, nodenames) -> list of positions
  1210. ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
  1211. minetest.get_perlin(seeddiff, octaves, persistence, scale)
  1212. ^ Return world-specific perlin noise (int(worldseed)+seeddiff)
  1213. minetest.get_voxel_manip()
  1214. ^ Return voxel manipulator object
  1215. minetest.set_gen_notify(flags)
  1216. ^ Set the types of on-generate notifications that should be collected
  1217. ^ flags is a comma-delimited combination of:
  1218. ^ dungeon, temple, cave_begin, cave_end, large_cave_begin, large_cave_end
  1219. minetest.get_mapgen_object(objectname)
  1220. ^ Return requested mapgen object if available (see Mapgen objects)
  1221. minetest.set_mapgen_params(MapgenParams)
  1222. ^ Set map generation parameters
  1223. ^ Function cannot be called after the registration period; only initialization and on_mapgen_init
  1224. ^ Takes a table as an argument with the fields mgname, seed, water_level, and flags.
  1225. ^ Leave field unset to leave that parameter unchanged
  1226. ^ flags contains a comma-delimited string of flags to set, or if the prefix "no" is attached, clears instead.
  1227. ^ flags is in the same format and has the same options as 'mg_flags' in minetest.conf
  1228. minetest.set_noiseparam_defaults({np1=NoiseParams, np2= NoiseParams, ...})
  1229. ^ Sets the default value of a noiseparam setting
  1230. ^ Takes a table as an argument that maps one or more setting names to NoiseParams structures
  1231. ^ Possible setting names consist of any NoiseParams setting exposed through the global settings
  1232. minetest.clear_objects()
  1233. ^ clear all objects in the environments
  1234. minetest.line_of_sight(pos1, pos2, stepsize) -> true/false, pos
  1235. ^ Check if there is a direct line of sight between pos1 and pos2
  1236. ^ Returns the position of the blocking node when false
  1237. ^ pos1 First position
  1238. ^ pos2 Second position
  1239. ^ stepsize smaller gives more accurate results but requires more computing
  1240. time. Default is 1.
  1241. minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)
  1242. ^ -> table containing path
  1243. ^ returns a table of 3d points representing a path from pos1 to pos2 or nil
  1244. ^ pos1: start position
  1245. ^ pos2: end position
  1246. ^ searchdistance: number of blocks to search in each direction
  1247. ^ max_jump: maximum height difference to consider walkable
  1248. ^ max_drop: maximum height difference to consider droppable
  1249. ^ algorithm: A*_noprefetch(default), A*, Dijkstra
  1250. minetest.spawn_tree (pos, {treedef})
  1251. ^ spawns L-System tree at given pos with definition in treedef table
  1252. minetest.transforming_liquid_add(pos)
  1253. ^ add node to liquid update queue
  1254. minetest.get_node_max_level(pos)
  1255. ^ get max available level for leveled node
  1256. minetest.get_node_level(pos)
  1257. ^ get level of leveled node (water, snow)
  1258. minetest.set_node_level(pos, level)
  1259. ^ set level of leveled node, default level = 1, if totallevel > maxlevel returns rest (total-max).
  1260. minetest.add_node_level(pos, level)
  1261. ^ increase level of leveled node by level, default level = 1, if totallevel > maxlevel returns rest (total-max). can be negative for decreasing
  1262. Inventory:
  1263. minetest.get_inventory(location) -> InvRef
  1264. ^ location = eg. {type="player", name="celeron55"}
  1265. {type="node", pos={x=, y=, z=}}
  1266. {type="detached", name="creative"}
  1267. minetest.create_detached_inventory(name, callbacks) -> InvRef
  1268. ^ callbacks: See "Detached inventory callbacks"
  1269. ^ Creates a detached inventory. If it already exists, it is cleared.
  1270. Formspec:
  1271. minetest.show_formspec(playername, formname, formspec)
  1272. ^ playername: name of player to show formspec
  1273. ^ formname: name passed to on_player_receive_fields callbacks
  1274. ^ should follow "modname:<whatever>" naming convention
  1275. ^ formspec: formspec to display
  1276. minetest.formspec_escape(string) -> string
  1277. ^ escapes characters [ ] \ , ; that can not be used in formspecs
  1278. minetest.explode_table_event(string) -> table
  1279. ^ returns e.g. {type="CHG", row=1, column=2}
  1280. ^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
  1281. minetest.explode_textlist_event(string) -> table
  1282. ^ returns e.g. {type="CHG", index=1}
  1283. ^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
  1284. Item handling:
  1285. minetest.inventorycube(img1, img2, img3)
  1286. ^ Returns a string for making an image of a cube (useful as an item image)
  1287. minetest.get_pointed_thing_position(pointed_thing, above)
  1288. ^ Get position of a pointed_thing (that you can get from somewhere)
  1289. minetest.dir_to_facedir(dir, is6d)
  1290. ^ Convert a vector to a facedir value, used in param2 for paramtype2="facedir"; passing something non-nil/false for the optional second parameter causes it to take the y component into account
  1291. minetest.facedir_to_dir(facedir)
  1292. ^ Convert a facedir back into a vector aimed directly out the "back" of a node
  1293. minetest.dir_to_wallmounted(dir)
  1294. ^ Convert a vector to a wallmounted value, used for paramtype2="wallmounted"
  1295. minetest.get_node_drops(nodename, toolname)
  1296. ^ Returns list of item names.
  1297. ^ Note: This will be removed or modified in a future version.
  1298. minetest.get_craft_result(input) -> output, decremented_input
  1299. ^ input.method = 'normal' or 'cooking' or 'fuel'
  1300. ^ input.width = for example 3
  1301. ^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
  1302. stack 5, stack 6, stack 7, stack 8, stack 9 }
  1303. ^ output.item = ItemStack, if unsuccessful: empty ItemStack
  1304. ^ output.time = number, if unsuccessful: 0
  1305. ^ decremented_input = like input
  1306. minetest.get_craft_recipe(output) -> input
  1307. ^ returns last registered recipe for output item (node)
  1308. ^ output is a node or item type such as 'default:torch'
  1309. ^ input.method = 'normal' or 'cooking' or 'fuel'
  1310. ^ input.width = for example 3
  1311. ^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
  1312. stack 5, stack 6, stack 7, stack 8, stack 9 }
  1313. ^ input.items = nil if no recipe found
  1314. minetest.get_all_craft_recipes(query item) -> table or nil
  1315. ^ returns indexed table with all registered recipes for query item (node)
  1316. or nil if no recipe was found
  1317. recipe entry table:
  1318. {
  1319. method = 'normal' or 'cooking' or 'fuel'
  1320. width = 0-3, 0 means shapeless recipe
  1321. items = indexed [1-9] table with recipe items
  1322. output = string with item name and quantity
  1323. }
  1324. Example query for default:gold_ingot will return table:
  1325. {
  1326. 1={type = "cooking", width = 3, output = "default:gold_ingot",
  1327. items = {1 = "default:gold_lump"}},
  1328. 2={type = "normal", width = 1, output = "default:gold_ingot 9",
  1329. items = {1 = "default:goldblock"}}
  1330. }
  1331. minetest.handle_node_drops(pos, drops, digger)
  1332. ^ drops: list of itemstrings
  1333. ^ Handles drops from nodes after digging: Default action is to put them into
  1334. digger's inventory
  1335. ^ Can be overridden to get different functionality (eg. dropping items on
  1336. ground)
  1337. Rollback:
  1338. minetest.rollback_get_node_actions(pos, range, seconds, limit) -> {{actor, pos, time, oldnode, newnode}, ...}
  1339. ^ Find who has done something to a node, or near a node
  1340. ^ actor: "player:<name>", also "liquid".
  1341. minetest.rollback_revert_actions_by(actor, seconds) -> bool, log messages
  1342. ^ Revert latest actions of someone
  1343. ^ actor: "player:<name>", also "liquid".
  1344. Defaults for the on_* item definition functions:
  1345. (These return the leftover itemstack)
  1346. minetest.item_place_node(itemstack, placer, pointed_thing, param2)
  1347. ^ Place item as a node
  1348. ^ param2 overrides facedir and wallmounted param2
  1349. ^ returns itemstack, success
  1350. minetest.item_place_object(itemstack, placer, pointed_thing)
  1351. ^ Place item as-is
  1352. minetest.item_place(itemstack, placer, pointed_thing, param2)
  1353. ^ Use one of the above based on what the item is.
  1354. ^ Calls on_rightclick of pointed_thing.under if defined instead
  1355. ^ Note: is not called when wielded item overrides on_place
  1356. ^ param2 overrides facedir and wallmounted param2
  1357. ^ returns itemstack, success
  1358. minetest.item_drop(itemstack, dropper, pos)
  1359. ^ Drop the item
  1360. minetest.item_eat(hp_change, replace_with_item)
  1361. ^ Eat the item. replace_with_item can be nil.
  1362. Defaults for the on_punch and on_dig node definition callbacks:
  1363. minetest.node_punch(pos, node, puncher, pointed_thing)
  1364. ^ Calls functions registered by minetest.register_on_punchnode()
  1365. minetest.node_dig(pos, node, digger)
  1366. ^ Checks if node can be dug, puts item into inventory, removes node
  1367. ^ Calls functions registered by minetest.registered_on_dignodes()
  1368. Sounds:
  1369. minetest.sound_play(spec, parameters) -> handle
  1370. ^ spec = SimpleSoundSpec
  1371. ^ parameters = sound parameter table
  1372. minetest.sound_stop(handle)
  1373. Timing:
  1374. minetest.after(time, func, ...)
  1375. ^ Call function after time seconds
  1376. ^ Optional: Variable number of arguments that are passed to func
  1377. Server:
  1378. minetest.request_shutdown() -> request for server shutdown
  1379. minetest.get_server_status() -> server status string
  1380. Bans:
  1381. minetest.get_ban_list() -> ban list (same as minetest.get_ban_description(""))
  1382. minetest.get_ban_description(ip_or_name) -> ban description (string)
  1383. minetest.ban_player(name) -> ban a player
  1384. minetest.unban_player_or_ip(name) -> unban player or IP address
  1385. minetest.kick_player(name, [reason]) -> disconnect a player with a optional reason
  1386. Particles:
  1387. minetest.add_particle(particle definition)
  1388. ^ Deprecated: minetest.add_particle(pos, velocity, acceleration, expirationtime,
  1389. size, collisiondetection, texture, playername)
  1390. minetest.add_particlespawner(particlespawner definition)
  1391. ^ Add a particlespawner, an object that spawns an amount of particles over time seconds
  1392. ^ Returns an id
  1393. ^ Deprecated: minetest.add_particlespawner(amount, time,
  1394. minpos, maxpos,
  1395. minvel, maxvel,
  1396. minacc, maxacc,
  1397. minexptime, maxexptime,
  1398. minsize, maxsize,
  1399. collisiondetection, texture, playername)
  1400. minetest.delete_particlespawner(id, player)
  1401. ^ Delete ParticleSpawner with id (return value from add_particlespawner)
  1402. ^ If playername is specified, only deletes on the player's client,
  1403. ^ otherwise on all clients
  1404. Schematics:
  1405. minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)
  1406. ^ Create a schematic from the volume of map specified by the box formed by p1 and p2.
  1407. ^ Apply the specified probability values to the specified nodes in probability_list.
  1408. ^ probability_list is an array of tables containing two fields, pos and prob.
  1409. ^ pos is the 3d vector specifying the absolute coordinates of the node being modified,
  1410. ^ and prob is the integer value from 0 to 255 of the probability (see: Schematic specifier).
  1411. ^ If there are two or more entries with the same pos value, the last occuring in the array is used.
  1412. ^ If pos is not inside the box formed by p1 and p2, it is ignored.
  1413. ^ If probability_list is nil, no probabilities are applied.
  1414. ^ Slice probability works in the same manner, except takes a field called ypos instead which indicates
  1415. ^ the y position of the slice with a probability applied.
  1416. ^ If slice probability list is nil, no slice probabilities are applied.
  1417. ^ Saves schematic in the Minetest Schematic format to filename.
  1418. minetest.place_schematic(pos, schematic, rotation, replacements, force_placement)
  1419. ^ Place the schematic specified by schematic (see: Schematic specifier) at pos.
  1420. ^ Rotation can be "0", "90", "180", "270", or "random".
  1421. ^ If the rotation parameter is omitted, the schematic is not rotated.
  1422. ^ replacements = {{"oldname", "convert_to"}, ...}
  1423. ^ force_placement is a boolean indicating whether nodes other than air and
  1424. ^ ignore are replaced by the schematic
  1425. Random:
  1426. minetest.get_connected_players() -> list of ObjectRefs
  1427. minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
  1428. ^ Gives a unique hash number for a node position (16+16+16=48bit)
  1429. minetest.get_position_from_hash(hash) -> postion
  1430. ^ Inverse transform of minetest.hash_node_postion
  1431. minetest.get_item_group(name, group) -> rating
  1432. ^ Get rating of a group of an item. (0 = not in group)
  1433. minetest.get_node_group(name, group) -> rating
  1434. ^ Deprecated: An alias for the former.
  1435. minetest.get_content_id(name) -> integer
  1436. ^ Gets the internal content ID of name
  1437. minetest.get_name_from_content_id(content_id) -> string
  1438. ^ Gets the name of the content with that content ID
  1439. minetest.parse_json(string[, nullvalue]) -> something
  1440. ^ Convert a string containing JSON data into the Lua equivalent
  1441. ^ nullvalue: returned in place of the JSON null; defaults to nil
  1442. ^ On success returns a table, a string, a number, a boolean or nullvalue
  1443. ^ On failure outputs an error message and returns nil
  1444. ^ Example: parse_json("[10, {\"a\":false}]") -> {10, {a = false}}
  1445. minetest.write_json(data[, styled]) -> string or nil and error message
  1446. ^ Convert a Lua table into a JSON string
  1447. ^ styled: Outputs in a human-readable format if this is set, defaults to false
  1448. ^ Un-serializable things like functions and userdata are saved as null.
  1449. ^ Warning: JSON is more strict than the Lua table format.
  1450. 1. You can only use strings and positive integers of at least one as keys.
  1451. 2. You can not mix string and integer keys.
  1452. This is due to the fact that Javascript has two distinct array and object values.
  1453. ^ Example: write_json({10, {a = false}}) -> "[10, {\"a\": false}]"
  1454. minetest.serialize(table) -> string
  1455. ^ Convert a table containing tables, strings, numbers, booleans and nils
  1456. into string form readable by minetest.deserialize
  1457. ^ Example: serialize({foo='bar'}) -> 'return { ["foo"] = "bar" }'
  1458. minetest.deserialize(string) -> table
  1459. ^ Convert a string returned by minetest.deserialize into a table
  1460. ^ String is loaded in an empty sandbox environment.
  1461. ^ Will load functions, but they cannot access the global environment.
  1462. ^ Example: deserialize('return { ["foo"] = "bar" }') -> {foo='bar'}
  1463. ^ Example: deserialize('print("foo")') -> nil (function call fails)
  1464. ^ error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)
  1465. minetest.is_protected(pos, name) -> bool
  1466. ^ This function should be overriden by protection mods and should be used to
  1467. check if a player can interact at a position.
  1468. ^ This function should call the old version of itself if the position is not
  1469. protected by the mod.
  1470. ^ Example:
  1471. local old_is_protected = minetest.is_protected
  1472. function minetest.is_protected(pos, name)
  1473. if mymod:position_protected_from(pos, name) then
  1474. return true
  1475. end
  1476. return old_is_protected(pos, name)
  1477. end
  1478. minetest.record_protection_violation(pos, name)
  1479. ^ This function calls functions registered with
  1480. minetest.register_on_protection_violation.
  1481. minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orient_flags)
  1482. ^ Attempt to predict the desired orientation of the facedir-capable node
  1483. defined by itemstack, and place it accordingly (on-wall, on the floor, or
  1484. hanging from the ceiling). Stacks are handled normally if the infinitestacks
  1485. field is false or omitted (else, the itemstack is not changed). orient_flags
  1486. is an optional table containing extra tweaks to the placement code:
  1487. invert_wall: if true, place wall-orientation on the ground and ground-
  1488. orientation on the wall.
  1489. force_wall: if true, always place the node in wall orientation.
  1490. force_ceiling: if true, always place on the ceiling.
  1491. force_floor: if true, always place the node on the floor.
  1492. The above four options are mutually-exclusive; the last in the list takes
  1493. precedence over the first.
  1494. force_facedir: if true, forcably reset the facedir to north when placing on
  1495. the floor or ceiling
  1496. minetest.rotate_node(itemstack, placer, pointed_thing)
  1497. ^ calls rotate_and_place() with infinitestacks set according to the state of
  1498. the creative mode setting, and checks for "sneak" to set the invert_wall
  1499. parameter.
  1500. minetest.forceload_block(pos)
  1501. ^ forceloads the position pos.
  1502. ^ returns true if area could be forceloaded
  1503. minetest.forceload_free_block(pos)
  1504. ^ stops forceloading the position pos.
  1505. Please note that forceloaded areas are saved when the server restarts.
  1506. Global objects:
  1507. minetest.env - EnvRef of the server environment and world.
  1508. ^ Any function in the minetest namespace can be called using the syntax
  1509. minetest.env:somefunction(somearguments)
  1510. instead of
  1511. minetest.somefunction(somearguments)
  1512. ^ Deprecated, but support is not to be dropped soon
  1513. Global tables:
  1514. minetest.registered_items
  1515. ^ List of registered items, indexed by name
  1516. minetest.registered_nodes
  1517. ^ List of registered node definitions, indexed by name
  1518. minetest.registered_craftitems
  1519. ^ List of registered craft item definitions, indexed by name
  1520. minetest.registered_tools
  1521. ^ List of registered tool definitions, indexed by name
  1522. minetest.registered_entities
  1523. ^ List of registered entity prototypes, indexed by name
  1524. minetest.object_refs
  1525. ^ List of object references, indexed by active object id
  1526. minetest.luaentities
  1527. ^ List of lua entities, indexed by active object id
  1528. Class reference
  1529. ----------------
  1530. NodeMetaRef: Node metadata - reference extra data and functionality stored
  1531. in a node
  1532. - Can be gotten via minetest.get_nodemeta(pos)
  1533. methods:
  1534. - set_string(name, value)
  1535. - get_string(name)
  1536. - set_int(name, value)
  1537. - get_int(name)
  1538. - set_float(name, value)
  1539. - get_float(name)
  1540. - get_inventory() -> InvRef
  1541. - to_table() -> nil or {fields = {...}, inventory = {list1 = {}, ...}}
  1542. - from_table(nil or {})
  1543. ^ See "Node Metadata"
  1544. NodeTimerRef: Node Timers - a high resolution persistent per-node timer
  1545. - Can be gotten via minetest.get_node_timer(pos)
  1546. methods:
  1547. - set(timeout,elapsed)
  1548. ^ set a timer's state
  1549. ^ timeout is in seconds, and supports fractional values (0.1 etc)
  1550. ^ elapsed is in seconds, and supports fractional values (0.1 etc)
  1551. ^ will trigger the node's on_timer function after timeout-elapsed seconds
  1552. - start(timeout)
  1553. ^ start a timer
  1554. ^ equivelent to set(timeout,0)
  1555. - stop()
  1556. ^ stops the timer
  1557. - get_timeout() -> current timeout in seconds
  1558. ^ if timeout is 0, timer is inactive
  1559. - get_elapsed() -> current elapsed time in seconds
  1560. ^ the node's on_timer function will be called after timeout-elapsed seconds
  1561. - is_started() -> boolean state of timer
  1562. ^ returns true if timer is started, otherwise false
  1563. ObjectRef: Moving things in the game are generally these
  1564. (basically reference to a C++ ServerActiveObject)
  1565. methods:
  1566. - remove(): remove object (after returning from Lua)
  1567. - getpos() -> {x=num, y=num, z=num}
  1568. - setpos(pos); pos={x=num, y=num, z=num}
  1569. - moveto(pos, continuous=false): interpolated move
  1570. - punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1571. ^ puncher = an another ObjectRef,
  1572. ^ time_from_last_punch = time since last punch action of the puncher
  1573. ^ direction: can be nil
  1574. - right_click(clicker); clicker = an another ObjectRef
  1575. - get_hp(): returns number of hitpoints (2 * number of hearts)
  1576. - set_hp(hp): set number of hitpoints (2 * number of hearts)
  1577. - get_inventory() -> InvRef
  1578. - get_wield_list(): returns the name of the inventory list the wielded item is in
  1579. - get_wield_index(): returns the index of the wielded item
  1580. - get_wielded_item() -> ItemStack
  1581. - set_wielded_item(item): replaces the wielded item, returns true if successful
  1582. - set_armor_groups({group1=rating, group2=rating, ...})
  1583. - set_animation({x=1,y=1}, frame_speed=15, frame_blend=0)
  1584. - set_attach(parent, bone, position, rotation)
  1585. ^ bone = string
  1586. ^ position = {x=num, y=num, z=num} (relative)
  1587. ^ rotation = {x=num, y=num, z=num}
  1588. - set_detach()
  1589. - set_bone_position(bone, position, rotation)
  1590. ^ bone = string
  1591. ^ position = {x=num, y=num, z=num} (relative)
  1592. ^ rotation = {x=num, y=num, z=num}
  1593. - set_properties(object property table)
  1594. LuaEntitySAO-only: (no-op for other objects)
  1595. - setvelocity({x=num, y=num, z=num})
  1596. - getvelocity() -> {x=num, y=num, z=num}
  1597. - setacceleration({x=num, y=num, z=num})
  1598. - getacceleration() -> {x=num, y=num, z=num}
  1599. - setyaw(radians)
  1600. - getyaw() -> radians
  1601. - settexturemod(mod)
  1602. - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
  1603. - select_horiz_by_yawpitch=false)
  1604. ^ Select sprite from spritesheet with optional animation and DM-style
  1605. texture selection based on yaw relative to camera
  1606. - get_entity_name() (DEPRECATED: Will be removed in a future version)
  1607. - get_luaentity()
  1608. Player-only: (no-op for other objects)
  1609. - is_player(): true for players, false for others
  1610. - get_player_name(): returns "" if is not a player
  1611. - get_look_dir(): get camera direction as a unit vector
  1612. - get_look_pitch(): pitch in radians
  1613. - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
  1614. - set_look_pitch(radians): sets look pitch
  1615. - set_look_yaw(radians): sets look yaw
  1616. - get_breath() : returns players breath
  1617. - set_breath(value) : sets players breath
  1618. values: 0 player is drowning,
  1619. 1-10 number of bubbles remain,
  1620. 11 bubbles bar is not shown
  1621. - set_inventory_formspec(formspec)
  1622. ^ Redefine player's inventory form
  1623. ^ Should usually be called in on_joinplayer
  1624. - get_inventory_formspec() -> formspec string
  1625. - get_player_control(): returns table with player pressed keys
  1626. {jump=bool,right=bool,left=bool,LMB=bool,RMB=bool,sneak=bool,aux1=bool,down=bool,up=bool}
  1627. - get_player_control_bits(): returns integer with bit packed player pressed keys
  1628. bit nr/meaning: 0/up ,1/down ,2/left ,3/right ,4/jump ,5/aux1 ,6/sneak ,7/LMB ,8/RMB
  1629. - set_physics_override({
  1630. speed = 1.0, -- multiplier to default value
  1631. jump = 1.0, -- multiplier to default value
  1632. gravity = 1.0, -- multiplier to default value
  1633. sneak = true, -- whether player can sneak
  1634. sneak_glitch = true, -- whether player can use the sneak glitch
  1635. })
  1636. - hud_add(hud definition): add a HUD element described by HUD def, returns ID number on success
  1637. - hud_remove(id): remove the HUD element of the specified id
  1638. - hud_change(id, stat, value): change a value of a previously added HUD element
  1639. ^ element stat values: position, name, scale, text, number, item, dir
  1640. - hud_get(id): gets the HUD element definition structure of the specified ID
  1641. - hud_set_flags(flags): sets specified HUD flags to true/false
  1642. ^ flags: (is visible) hotbar, healthbar, crosshair, wielditem
  1643. ^ pass a table containing a true/false value of each flag to be set or unset
  1644. ^ if a flag is nil, the flag is not modified
  1645. - hud_get_flags(): returns a table containing status of hud flags
  1646. ^ returns { hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true }
  1647. - hud_set_hotbar_itemcount(count): sets number of items in builtin hotbar
  1648. ^ count: number of items, must be between 1 and 23
  1649. - hud_set_hotbar_image(texturename)
  1650. ^ sets background image for hotbar
  1651. - hud_set_hotbar_selected_image(texturename)
  1652. ^ sets image for selected item of hotbar
  1653. - hud_replace_builtin(name, hud definition)
  1654. ^ replace definition of a builtin hud element
  1655. ^ name: "breath" or "health"
  1656. ^ hud definition: definition to replace builtin definition
  1657. - set_sky(bgcolor, type, {texture names})
  1658. ^ bgcolor: {r=0...255, g=0...255, b=0...255} or nil, defaults to white
  1659. ^ Available types:
  1660. - "regular": Uses 0 textures, bgcolor ignored
  1661. - "skybox": Uses 6 textures, bgcolor used
  1662. - "plain": Uses 0 textures, bgcolor used
  1663. ^ Note: currently does not work directly in on_joinplayer; use
  1664. minetest.after(0) in there.
  1665. - override_day_night_ratio(ratio or nil)
  1666. ^ 0...1: Overrides day-night ratio, controlling sunlight to a specific amount
  1667. ^ nil: Disables override, defaulting to sunlight based on day-night cycle
  1668. - set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, frame_speed=30): set animation for player model in third person view
  1669. ^ stand/idle animation key frames
  1670. ^ walk animation key frames
  1671. ^ dig animation key frames
  1672. ^ walk+dig animation key frames
  1673. ^ animation frame speed
  1674. - set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0}): defines offset value for camera per player
  1675. ^ in first person view
  1676. ^ in third person view (max. values {x=-10/10,y=-10,15,z=-5/5})
  1677. InvRef: Reference to an inventory
  1678. methods:
  1679. - is_empty(listname): return true if list is empty
  1680. - get_size(listname): get size of a list
  1681. - set_size(listname, size): set size of a list
  1682. ^ returns false on error (e.g. invalid listname or listsize)
  1683. - get_width(listname): get width of a list
  1684. - set_width(listname, width): set width of list; currently used for crafting
  1685. - get_stack(listname, i): get a copy of stack index i in list
  1686. - set_stack(listname, i, stack): copy stack to index i in list
  1687. - get_list(listname): return full list
  1688. - set_list(listname, list): set full list (size will not change)
  1689. - get_lists(): returns list of inventory lists
  1690. - set_lists(lists): sets inventory lists (size will not change)
  1691. - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
  1692. - room_for_item(listname, stack): returns true if the stack of items
  1693. can be fully added to the list
  1694. - contains_item(listname, stack): returns true if the stack of items
  1695. can be fully taken from the list
  1696. remove_item(listname, stack): take as many items as specified from the list,
  1697. returns the items that were actually removed (as an ItemStack)
  1698. - get_location() -> location compatible to minetest.get_inventory(location)
  1699. -> {type="undefined"} in case location is not known
  1700. ItemStack: A stack of items.
  1701. - Can be created via ItemStack(itemstack or itemstring or table or nil)
  1702. methods:
  1703. - is_empty(): return true if stack is empty
  1704. - get_name(): returns item name (e.g. "default:stone")
  1705. - set_name(itemname)
  1706. - get_count(): returns number of items on the stack
  1707. - set_count(count)
  1708. - get_wear(): returns tool wear (0-65535), 0 for non-tools
  1709. - set_wear(wear)
  1710. - get_metadata(): returns metadata (a string attached to an item stack)
  1711. - set_metadata(metadata)
  1712. - clear(): removes all items from the stack, making it empty
  1713. - replace(item): replace the contents of this stack (item can also
  1714. be an itemstring or table)
  1715. - to_string(): returns the stack in itemstring form
  1716. - to_table(): returns the stack in Lua table form
  1717. - get_stack_max(): returns the maximum size of the stack (depends on the item)
  1718. - get_free_space(): returns get_stack_max() - get_count()
  1719. - is_known(): returns true if the item name refers to a defined item type
  1720. - get_definition(): returns the item definition table
  1721. - get_tool_capabilities(): returns the digging properties of the item,
  1722. ^ or those of the hand if none are defined for this item type
  1723. - add_wear(amount): increases wear by amount if the item is a tool
  1724. - add_item(item): put some item or stack onto this stack,
  1725. ^ returns leftover ItemStack
  1726. - item_fits(item): returns true if item or stack can be fully added to this one
  1727. - take_item(n): take (and remove) up to n items from this stack
  1728. ^ returns taken ItemStack
  1729. ^ if n is omitted, n=1 is used
  1730. - peek_item(n): copy (don't remove) up to n items from this stack
  1731. ^ returns copied ItemStack
  1732. ^ if n is omitted, n=1 is used
  1733. PseudoRandom: A pseudorandom number generator
  1734. - Can be created via PseudoRandom(seed)
  1735. methods:
  1736. - next(): return next integer random number [0...32767]
  1737. - next(min, max): return next integer random number [min...max]
  1738. (max - min) must be 32767 or <= 6553 due to the simple
  1739. implementation making bad distribution otherwise.
  1740. PerlinNoise: A perlin noise generator
  1741. - Can be created via PerlinNoise(seed, octaves, persistence, scale)
  1742. - Also minetest.get_perlin(seeddiff, octaves, persistence, scale)
  1743. methods:
  1744. - get2d(pos) -> 2d noise value at pos={x=,y=}
  1745. - get3d(pos) -> 3d noise value at pos={x=,y=,z=}
  1746. PerlinNoiseMap: A fast, bulk perlin noise generator
  1747. - Can be created via PerlinNoiseMap(noiseparams, size)
  1748. - Also minetest.get_perlin_map(noiseparams, size)
  1749. methods:
  1750. - get2dMap(pos) -> <size.x>X<size.y> 2d array of 2d noise values starting at pos={x=,y=}
  1751. - get3dMap(pos) -> <size.x>X<size.y>X<size.z> 3d array of 3d noise values starting at pos={x=,y=,z=}
  1752. - get2dMap_flat(pos) -> Flat <size.x * size.y> element array of 2d noise values starting at pos={x=,y=}
  1753. - get3dMap_flat(pos) -> Same as get2dMap_flat, but 3d noise
  1754. VoxelManip: An interface to the MapVoxelManipulator for Lua
  1755. - Can be created via VoxelManip()
  1756. - Also minetest.get_voxel_manip()
  1757. methods:
  1758. - read_from_map(p1, p2): Reads a chunk of map from the map containing the region formed by p1 and p2.
  1759. ^ returns actual emerged pmin, actual emerged pmax
  1760. - write_to_map(): Writes the data loaded from the VoxelManip back to the map.
  1761. ^ important: data must be set using VoxelManip:set_data before calling this
  1762. - get_data(): Gets the data read into the VoxelManip object
  1763. ^ returns raw node data is in the form of an array of node content ids
  1764. - set_data(data): Sets the data contents of the VoxelManip object
  1765. - update_map(): Update map after writing chunk back to map.
  1766. ^ To be used only by VoxelManip objects created by the mod itself; not a VoxelManip that was
  1767. ^ retrieved from minetest.get_mapgen_object
  1768. - set_lighting(light, p1, p2): Set the lighting within the VoxelManip to a uniform value
  1769. ^ light is a table, {day=<0...15>, night=<0...15>}
  1770. ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
  1771. ^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
  1772. - get_light_data(): Gets the light data read into the VoxelManip object
  1773. ^ Returns an array (indicies 1 to volume) of integers ranging from 0 to 255
  1774. ^ Each value is the bitwise combination of day and night light values (0..15 each)
  1775. ^ light = day + (night * 16)
  1776. - set_light_data(light_data): Sets the param1 (light) contents of each node in the VoxelManip
  1777. ^ expects lighting data in the same format that get_light_data() returns
  1778. - get_param2_data(): Gets the raw param2 data read into the VoxelManip object
  1779. - set_param2_data(param2_data): Sets the param2 contents of each node in the VoxelManip
  1780. - calc_lighting(p1, p2): Calculate lighting within the VoxelManip
  1781. ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
  1782. ^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
  1783. - update_liquids(): Update liquid flow
  1784. VoxelArea: A helper class for voxel areas
  1785. - Can be created via VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}
  1786. - Coordinates are *inclusive*, like most other things in Minetest
  1787. methods:
  1788. - getExtent(): returns a 3d vector containing the size of the area formed by MinEdge and MaxEdge
  1789. - getVolume(): returns the volume of the area formed by MinEdge and MaxEdge
  1790. - index(x, y, z): returns the index of an absolute position in a flat array starting at 1
  1791. ^ useful for things like VoxelManip, raw Schematic specifiers, PerlinNoiseMap:get2d/3dMap, and so on
  1792. - indexp(p): same as above, except takes a vector
  1793. - position(i): returns the absolute position vector corresponding to index i
  1794. - contains(x, y, z): check if (x,y,z) is inside area formed by MinEdge and MaxEdge
  1795. - containsp(p): same as above, except takes a vector
  1796. - containsi(i): same as above, except takes an index
  1797. - iter(minx, miny, minz, maxx, maxy, maxz): returns an iterator that returns indices
  1798. ^ from (minx,miny,minz) to (maxx,maxy,maxz) in the order of [z [y [x]]]
  1799. - iterp(minp, maxp): same as above, except takes a vector
  1800. Settings: An interface to read config files in the format of minetest.conf
  1801. - Can be created via Settings(filename)
  1802. methods:
  1803. - get(key) -> value
  1804. - get_bool(key) -> boolean
  1805. - set(key, value)
  1806. - remove(key) -> success
  1807. - get_names() -> {key1,...}
  1808. - write() -> success
  1809. ^ write changes to file
  1810. - to_table() -> {[key1]=value1,...}
  1811. Mapgen objects
  1812. ---------------
  1813. A mapgen object is a construct used in map generation. Mapgen objects can be used by an on_generate
  1814. callback to speed up operations by avoiding unnecessary recalculations; these can be retrieved using the
  1815. minetest.get_mapgen_object() function. If the requested Mapgen object is unavailable, or
  1816. get_mapgen_object() was called outside of an on_generate() callback, nil is returned.
  1817. The following Mapgen objects are currently available:
  1818. - voxelmanip
  1819. This returns three values; the VoxelManip object to be used, minimum and maximum emerged position, in that
  1820. order. All mapgens support this object.
  1821. - heightmap
  1822. Returns an array containing the y coordinates of the ground levels of nodes in the most recently
  1823. generated chunk by the current mapgen.
  1824. - biomemap
  1825. Returns an array containing the biome IDs of nodes in the most recently generated chunk by the
  1826. current mapgen.
  1827. - heatmap
  1828. Returns an array containing the temperature values of nodes in the most recently generated chunk by
  1829. the current mapgen.
  1830. - humiditymap
  1831. Returns an array containing the humidity values of nodes in the most recently generated chunk by the
  1832. current mapgen.
  1833. - gennotify
  1834. Returns a table mapping requested generation notification types to arrays of positions at which the
  1835. corresponding generated structures are located at within the current chunk. To set the capture of positions
  1836. of interest to be recorded on generate, use minetest.set_gen_notify().
  1837. Possible fields of the table returned are: dungeon, temple, cave_begin, cave_end, large_cave_begin, large_cave_end
  1838. Registered entities
  1839. --------------------
  1840. - Functions receive a "luaentity" as self:
  1841. - It has the member .name, which is the registered name ("mod:thing")
  1842. - It has the member .object, which is an ObjectRef pointing to the object
  1843. - The original prototype stuff is visible directly via a metatable
  1844. - Callbacks:
  1845. - on_activate(self, staticdata)
  1846. ^ Called when the object is instantiated.
  1847. - on_step(self, dtime)
  1848. ^ Called on every server tick (dtime is usually 0.1 seconds)
  1849. - on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
  1850. ^ Called when somebody punches the object.
  1851. ^ Note that you probably want to handle most punches using the
  1852. automatic armor group system.
  1853. ^ puncher: ObjectRef (can be nil)
  1854. ^ time_from_last_punch: Meant for disallowing spamming of clicks (can be nil)
  1855. ^ tool_capabilities: capability table of used tool (can be nil)
  1856. ^ dir: unit vector of direction of punch. Always defined. Points from
  1857. the puncher to the punched.
  1858. - on_rightclick(self, clicker)
  1859. - get_staticdata(self)
  1860. ^ Should return a string that will be passed to on_activate when
  1861. the object is instantiated the next time.
  1862. L-system trees
  1863. ---------------
  1864. treedef={
  1865. axiom, - string initial tree axiom
  1866. rules_a, - string rules set A
  1867. rules_b, - string rules set B
  1868. rules_c, - string rules set C
  1869. rules_d, - string rules set D
  1870. trunk, - string trunk node name
  1871. leaves, - string leaves node name
  1872. leaves2, - string secondary leaves node name
  1873. leaves2_chance,- num chance (0-100) to replace leaves with leaves2
  1874. angle, - num angle in deg
  1875. iterations, - num max # of iterations, usually 2 -5
  1876. random_level, - num factor to lower nr of iterations, usually 0 - 3
  1877. trunk_type, - string single/double/crossed) type of trunk: 1 node, 2x2 nodes or 3x3 in cross shape
  1878. thin_branches, - boolean true -> use thin (1 node) branches
  1879. fruit, - string fruit node name
  1880. fruit_chance, - num chance (0-100) to replace leaves with fruit node
  1881. seed, - num random seed
  1882. }
  1883. Key for Special L-System Symbols used in Axioms
  1884. G - move forward one unit with the pen up
  1885. F - move forward one unit with the pen down drawing trunks and branches
  1886. f - move forward one unit with the pen down drawing leaves (100% chance)
  1887. T - move forward one unit with the pen down drawing trunks only
  1888. R - move forward one unit with the pen down placing fruit
  1889. A - replace with rules set A
  1890. B - replace with rules set B
  1891. C - replace with rules set C
  1892. D - replace with rules set D
  1893. a - replace with rules set A, chance 90%
  1894. b - replace with rules set B, chance 80%
  1895. c - replace with rules set C, chance 70%
  1896. d - replace with rules set D, chance 60%
  1897. + - yaw the turtle right by angle parameter
  1898. - - yaw the turtle left by angle parameter
  1899. & - pitch the turtle down by angle parameter
  1900. ^ - pitch the turtle up by angle parameter
  1901. / - roll the turtle to the right by angle parameter
  1902. * - roll the turtle to the left by angle parameter
  1903. [ - save in stack current state info
  1904. ] - recover from stack state info
  1905. Example usage: spawn small apple tree
  1906. apple_tree={
  1907. axiom="FFFFFAFFBF",
  1908. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  1909. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  1910. trunk="default:tree",
  1911. leaves="default:leaves",
  1912. angle=30,
  1913. iterations=2,
  1914. random_level=0,
  1915. trunk_type="single",
  1916. thin_branches=true,
  1917. fruit_chance=10,
  1918. fruit="default:apple"
  1919. }
  1920. minetest.spawn_tree(pos,apple_tree)
  1921. Definition tables
  1922. ------------------
  1923. Object Properties
  1924. {
  1925. hp_max = 1,
  1926. physical = true,
  1927. collide_with_objects = true, -- collide with other objects if physical=true
  1928. weight = 5,
  1929. collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
  1930. visual = "cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem",
  1931. visual_size = {x=1, y=1},
  1932. mesh = "model",
  1933. textures = {}, -- number of required textures depends on visual
  1934. colors = {}, -- number of required colors depends on visual
  1935. spritediv = {x=1, y=1},
  1936. initial_sprite_basepos = {x=0, y=0},
  1937. is_visible = true,
  1938. makes_footstep_sound = false,
  1939. automatic_rotate = false,
  1940. stepheight = 0,
  1941. automatic_face_movement_dir = 0.0,
  1942. ^ automatically set yaw to movement direction; offset in degrees; false to disable
  1943. }
  1944. Entity definition (register_entity)
  1945. {
  1946. (Deprecated: Everything in object properties is read directly from here)
  1947. initial_properties = <initial object properties>,
  1948. on_activate = function(self, staticdata, dtime_s),
  1949. on_step = function(self, dtime),
  1950. on_punch = function(self, hitter),
  1951. on_rightclick = function(self, clicker),
  1952. get_staticdata = function(self),
  1953. ^ Called sometimes; the string returned is passed to on_activate when
  1954. the entity is re-activated from static state
  1955. # Also you can define arbitrary member variables here
  1956. myvariable = whatever,
  1957. }
  1958. ABM (ActiveBlockModifier) definition (register_abm)
  1959. {
  1960. -- In the following two fields, also group:groupname will work.
  1961. nodenames = {"default:lava_source"},
  1962. neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
  1963. ^ If left out or empty, any neighbor will do
  1964. interval = 1.0, -- (operation interval)
  1965. chance = 1, -- (chance of trigger is 1.0/this)
  1966. action = func(pos, node, active_object_count, active_object_count_wider),
  1967. }
  1968. Item definition (register_node, register_craftitem, register_tool)
  1969. {
  1970. description = "Steel Axe",
  1971. groups = {}, -- key=name, value=rating; rating=1..3.
  1972. if rating not applicable, use 1.
  1973. eg. {wool=1, fluffy=3}
  1974. {soil=2, outerspace=1, crumbly=1}
  1975. {bendy=2, snappy=1},
  1976. {hard=1, metal=1, spikes=1}
  1977. inventory_image = "default_tool_steelaxe.png",
  1978. wield_image = "",
  1979. wield_scale = {x=1,y=1,z=1},
  1980. stack_max = 99,
  1981. range = 4.0,
  1982. liquids_pointable = false,
  1983. tool_capabilities = {
  1984. full_punch_interval = 1.0,
  1985. max_drop_level=0,
  1986. groupcaps={
  1987. -- For example:
  1988. snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
  1989. choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
  1990. },
  1991. damage_groups = {groupname=damage},
  1992. }
  1993. node_placement_prediction = nil,
  1994. ^ If nil and item is node, prediction is made automatically
  1995. ^ If nil and item is not a node, no prediction is made
  1996. ^ If "" and item is anything, no prediction is made
  1997. ^ Otherwise should be name of node which the client immediately places
  1998. on ground when the player places the item. Server will always update
  1999. actual result to client in a short moment.
  2000. sound = {
  2001. place = <SimpleSoundSpec>,
  2002. }
  2003. on_place = func(itemstack, placer, pointed_thing),
  2004. ^ Shall place item and return the leftover itemstack
  2005. ^ default: minetest.item_place
  2006. on_drop = func(itemstack, dropper, pos),
  2007. ^ Shall drop item and return the leftover itemstack
  2008. ^ default: minetest.item_drop
  2009. on_use = func(itemstack, user, pointed_thing),
  2010. ^ default: nil
  2011. ^ Function must return either nil if no item shall be removed from
  2012. inventory, or an itemstack to replace the original itemstack.
  2013. eg. itemstack:take_item(); return itemstack
  2014. ^ Otherwise, the function is free to do what it wants.
  2015. ^ The default functions handle regular use cases.
  2016. after_use = func(itemstack, user, node, digparams),
  2017. ^ default: nil
  2018. ^ If defined, should return an itemstack and will be called instead of
  2019. wearing out the tool. If returns nil, does nothing.
  2020. If after_use doesn't exist, it is the same as:
  2021. function(itemstack, user, node, digparams)
  2022. itemstack:add_wear(digparams.wear)
  2023. return itemstack
  2024. end
  2025. }
  2026. Tile definition:
  2027. - "image.png"
  2028. - {name="image.png", animation={Tile Animation definition}}
  2029. - {name="image.png", backface_culling=bool}
  2030. ^ backface culling only supported in special tiles
  2031. - deprecated still supported field names:
  2032. - image -> name
  2033. Tile animation definition:
  2034. - {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}
  2035. Node definition (register_node)
  2036. {
  2037. <all fields allowed in item definitions>,
  2038. drawtype = "normal", -- See "Node drawtypes"
  2039. visual_scale = 1.0,
  2040. ^ Supported for drawtypes "plantlike", "signlike", "torchlike".
  2041. ^ For plantlike, the image will start at the bottom of the node; for the
  2042. ^ other drawtypes, the image will be centered on the node.
  2043. ^ Note that positioning for "torchlike" may still change.
  2044. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  2045. ^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
  2046. ^ List can be shortened to needed length
  2047. special_tiles = {tile definition 1, Tile definition 2},
  2048. ^ Special textures of node; used rarely (old field name: special_materials)
  2049. ^ List can be shortened to needed length
  2050. alpha = 255,
  2051. use_texture_alpha = false, -- Use texture's alpha channel
  2052. post_effect_color = {a=0, r=0, g=0, b=0}, -- If player is inside node
  2053. paramtype = "none", -- See "Nodes"
  2054. paramtype2 = "none", -- See "Nodes"
  2055. is_ground_content = true, -- If false, cavegen will not carve through this
  2056. sunlight_propagates = false, -- If true, sunlight will go infinitely through this
  2057. walkable = true, -- If true, objects collide with node
  2058. pointable = true, -- If true, can be pointed at
  2059. diggable = true, -- If false, can never be dug
  2060. climbable = false, -- If true, can be climbed on (ladder)
  2061. buildable_to = false, -- If true, placed nodes can replace this node
  2062. drop = "", -- alternatively drop = { max_items = ..., items = { ... } }
  2063. liquidtype = "none", -- "none"/"source"/"flowing"
  2064. liquid_alternative_flowing = "", -- Flowing version of source liquid
  2065. liquid_alternative_source = "", -- Source version of flowing liquid
  2066. liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
  2067. liquid_renewable = true, -- Can new liquid source be created by placing two or more sources nearby?
  2068. freezemelt = "", -- water for snow/ice, ice/snow for water
  2069. leveled = 0, -- Block contain level in param2. value - default level, used for snow. Dont forget use "leveled" type nodebox
  2070. liquid_range = 8, -- number of flowing nodes arround source (max. 8)
  2071. drowning = 0, -- Player will take this amount of damage if no bubbles are left
  2072. light_source = 0, -- Amount of light emitted by node
  2073. damage_per_second = 0, -- If player is inside node, this damage is caused
  2074. node_box = {type="regular"}, -- See "Node boxes"
  2075. selection_box = {type="regular"}, -- See "Node boxes"
  2076. ^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used
  2077. legacy_facedir_simple = false, -- Support maps made in and before January 2012
  2078. legacy_wallmounted = false, -- Support maps made in and before January 2012
  2079. sounds = {
  2080. footstep = <SimpleSoundSpec>,
  2081. dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
  2082. dug = <SimpleSoundSpec>,
  2083. place = <SimpleSoundSpec>,
  2084. },
  2085. on_construct = func(pos),
  2086. ^ Node constructor; always called after adding node
  2087. ^ Can set up metadata and stuff like that
  2088. ^ default: nil
  2089. on_destruct = func(pos),
  2090. ^ Node destructor; always called before removing node
  2091. ^ default: nil
  2092. after_destruct = func(pos, oldnode),
  2093. ^ Node destructor; always called after removing node
  2094. ^ default: nil
  2095. after_place_node = func(pos, placer, itemstack, pointed_thing),
  2096. ^ Called after constructing node when node was placed using
  2097. minetest.item_place_node / minetest.place_node
  2098. ^ If return true no item is taken from itemstack
  2099. ^ default: nil
  2100. after_dig_node = func(pos, oldnode, oldmetadata, digger),
  2101. ^ oldmetadata is in table format
  2102. ^ Called after destructing node when node was dug using
  2103. minetest.node_dig / minetest.dig_node
  2104. ^ default: nil
  2105. can_dig = function(pos,player)
  2106. ^ returns true if node can be dug, or false if not
  2107. ^ default: nil
  2108. on_punch = func(pos, node, puncher, pointed_thing),
  2109. ^ default: minetest.node_punch
  2110. ^ By default: Calls minetest.register_on_punchnode callbacks
  2111. on_rightclick = func(pos, node, clicker, itemstack, pointed_thing),
  2112. ^ default: nil
  2113. ^ if defined, itemstack will hold clicker's wielded item
  2114. ^ Shall return the leftover itemstack
  2115. ^ Note: pointed_thing can be nil, if a mod calls this function
  2116. on_dig = func(pos, node, digger),
  2117. ^ default: minetest.node_dig
  2118. ^ By default: checks privileges, wears out tool and removes node
  2119. on_timer = function(pos,elapsed),
  2120. ^ default: nil
  2121. ^ called by NodeTimers, see minetest.get_node_timer and NodeTimerRef
  2122. ^ elapsed is the total time passed since the timer was started
  2123. ^ return true to run the timer for another cycle with the same timeout value
  2124. on_receive_fields = func(pos, formname, fields, sender),
  2125. ^ fields = {name1 = value1, name2 = value2, ...}
  2126. ^ Called when an UI form (eg. sign text input) returns data
  2127. ^ default: nil
  2128. allow_metadata_inventory_move = func(pos, from_list, from_index,
  2129. to_list, to_index, count, player),
  2130. ^ Called when a player wants to move items inside the inventory
  2131. ^ Return value: number of items allowed to move
  2132. allow_metadata_inventory_put = func(pos, listname, index, stack, player),
  2133. ^ Called when a player wants to put something into the inventory
  2134. ^ Return value: number of items allowed to put
  2135. ^ Return value: -1: Allow and don't modify item count in inventory
  2136. allow_metadata_inventory_take = func(pos, listname, index, stack, player),
  2137. ^ Called when a player wants to take something out of the inventory
  2138. ^ Return value: number of items allowed to take
  2139. ^ Return value: -1: Allow and don't modify item count in inventory
  2140. on_metadata_inventory_move = func(pos, from_list, from_index,
  2141. to_list, to_index, count, player),
  2142. on_metadata_inventory_put = func(pos, listname, index, stack, player),
  2143. on_metadata_inventory_take = func(pos, listname, index, stack, player),
  2144. ^ Called after the actual action has happened, according to what was allowed.
  2145. ^ No return value
  2146. on_blast = func(pos, intensity),
  2147. ^ intensity: 1.0 = mid range of regular TNT
  2148. ^ If defined, called when an explosion touches the node, instead of
  2149. removing the node
  2150. }
  2151. Recipe for register_craft: (shaped)
  2152. {
  2153. output = 'default:pick_stone',
  2154. recipe = {
  2155. {'default:cobble', 'default:cobble', 'default:cobble'},
  2156. {'', 'default:stick', ''},
  2157. {'', 'default:stick', ''}, -- Also groups; eg. 'group:crumbly'
  2158. },
  2159. replacements = <optional list of item pairs,
  2160. replace one input item with another item on crafting>
  2161. }
  2162. Recipe for register_craft (shapeless)
  2163. {
  2164. type = "shapeless",
  2165. output = 'mushrooms:mushroom_stew',
  2166. recipe = {
  2167. "mushrooms:bowl",
  2168. "mushrooms:mushroom_brown",
  2169. "mushrooms:mushroom_red",
  2170. },
  2171. replacements = <optional list of item pairs,
  2172. replace one input item with another item on crafting>
  2173. }
  2174. Recipe for register_craft (tool repair)
  2175. {
  2176. type = "toolrepair",
  2177. additional_wear = -0.02,
  2178. }
  2179. Recipe for register_craft (cooking)
  2180. {
  2181. type = "cooking",
  2182. output = "default:glass",
  2183. recipe = "default:sand",
  2184. cooktime = 3,
  2185. }
  2186. Recipe for register_craft (furnace fuel)
  2187. {
  2188. type = "fuel",
  2189. recipe = "default:leaves",
  2190. burntime = 1,
  2191. }
  2192. Ore definition (register_ore)
  2193. {
  2194. ore_type = "scatter", -- See "Ore types"
  2195. ore = "default:stone_with_coal",
  2196. wherein = "default:stone",
  2197. ^ a list of nodenames is supported too
  2198. clust_scarcity = 8*8*8,
  2199. ^ Ore has a 1 out of clust_scarcity chance of spawning in a node
  2200. ^ This value should be *MUCH* higher than your intuition might tell you!
  2201. clust_num_ores = 8,
  2202. ^ Number of ores in a cluster
  2203. clust_size = 3,
  2204. ^ Size of the bounding box of the cluster
  2205. ^ In this example, there is a 3x3x3 cluster where 8 out of the 27 nodes are coal ore
  2206. height_min = -31000,
  2207. height_max = 64,
  2208. flags = "",
  2209. ^ Attributes for this ore generation
  2210. noise_threshhold = 0.5,
  2211. ^ If noise is above this threshhold, ore is placed. Not needed for a uniform distribution
  2212. noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
  2213. ^ NoiseParams structure describing the perlin noise used for ore distribution.
  2214. ^ Needed for sheet ore_type. Omit from scatter ore_type for a uniform ore distribution
  2215. }
  2216. Decoration definition (register_decoration)
  2217. {
  2218. deco_type = "simple", -- See "Decoration types"
  2219. place_on = "default:dirt_with_grass",
  2220. ^ Node that decoration can be placed on
  2221. sidelen = 8,
  2222. ^ Size of divisions made in the chunk being generated.
  2223. ^ If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size.
  2224. fill_ratio = 0.02,
  2225. ^ Ratio of the area to be uniformly filled by the decoration.
  2226. ^ Used only if noise_params is not specified.
  2227. noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7},
  2228. ^ NoiseParams structure describing the perlin noise used for decoration distribution.
  2229. ^ The result of this is multiplied by the 2d area of the division being decorated.
  2230. biomes = {"Oceanside", "Hills", "Plains"},
  2231. ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
  2232. ^ and ignored if the Mapgen being used does not support biomes.
  2233. ----- Simple-type parameters
  2234. decoration = "default:grass",
  2235. ^ The node name used as the decoration.
  2236. ^ If instead a list of strings, a randomly selected node from the list is placed as the decoration.
  2237. height = 1,
  2238. ^ Number of nodes high the decoration is made.
  2239. ^ If height_max is not 0, this is the lower bound of the randomly selected height.
  2240. height_max = 0,
  2241. ^ Number of nodes the decoration can be at maximum.
  2242. ^ If absent, the parameter 'height' is used as a constant.
  2243. spawn_by = "default:water",
  2244. ^ Node that the decoration only spawns next to, in a 1-node square radius.
  2245. num_spawn_by = 1,
  2246. ^ Number of spawn_by nodes that must be surrounding the decoration position to occur.
  2247. ^ If absent or -1, decorations occur next to any nodes.
  2248. ----- Schematic-type parameters
  2249. schematic = "foobar.mts",
  2250. ^ If schematic is a string, it is the filepath relative to the current working directory of the
  2251. ^ specified Minetest schematic file.
  2252. ^ - OR -, could instead be a table containing two mandatory fields, size and data,
  2253. ^ and an optional table yslice_prob:
  2254. schematic = {
  2255. size = {x=4, y=6, z=4},
  2256. data = {
  2257. {name="cobble", param1=255, param2=0},
  2258. {name="dirt_with_grass", param1=255, param2=0},
  2259. ...
  2260. },
  2261. yslice_prob = {
  2262. {ypos=2, prob=128},
  2263. {ypos=5, prob=64},
  2264. ...
  2265. },
  2266. },
  2267. ^ See 'Schematic specifier' for details.
  2268. replacements = {{"oldname", "convert_to"}, ...},
  2269. flags = "place_center_x, place_center_z",
  2270. ^ Flags for schematic decorations. See 'Schematic attributes'.
  2271. rotation = "90" --rotate schematic 90 degrees on placement
  2272. ^ Rotation can be "0", "90", "180", "270", or "random".
  2273. }
  2274. Chatcommand definition (register_chatcommand)
  2275. {
  2276. params = "<name> <privilege>", -- Short parameter description
  2277. description = "Remove privilege from player", -- Full description
  2278. privs = {privs=true}, -- Require the "privs" privilege to run
  2279. func = function(name, param), -- Called when command is run.
  2280. -- Returns boolean success and text output.
  2281. }
  2282. Detached inventory callbacks
  2283. {
  2284. allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
  2285. ^ Called when a player wants to move items inside the inventory
  2286. ^ Return value: number of items allowed to move
  2287. allow_put = func(inv, listname, index, stack, player),
  2288. ^ Called when a player wants to put something into the inventory
  2289. ^ Return value: number of items allowed to put
  2290. ^ Return value: -1: Allow and don't modify item count in inventory
  2291. allow_take = func(inv, listname, index, stack, player),
  2292. ^ Called when a player wants to take something out of the inventory
  2293. ^ Return value: number of items allowed to take
  2294. ^ Return value: -1: Allow and don't modify item count in inventory
  2295. on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
  2296. on_put = func(inv, listname, index, stack, player),
  2297. on_take = func(inv, listname, index, stack, player),
  2298. ^ Called after the actual action has happened, according to what was allowed.
  2299. ^ No return value
  2300. }
  2301. HUD Definition (hud_add, hud_get)
  2302. {
  2303. hud_elem_type = "image", -- see HUD element types
  2304. ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
  2305. position = {x=0.5, y=0.5},
  2306. ^ Left corner position of element
  2307. name = "<name>",
  2308. scale = {x=2, y=2},
  2309. text = "<text>",
  2310. number = 2,
  2311. item = 3,
  2312. ^ Selected item in inventory. 0 for no item selected.
  2313. direction = 0,
  2314. ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  2315. alignment = {x=0, y=0},
  2316. ^ See "HUD Element Types"
  2317. offset = {x=0, y=0},
  2318. ^ See "HUD Element Types"
  2319. size = { x=100, y=100 },
  2320. ^ Size of element in pixels
  2321. }
  2322. Particle definition (add_particle)
  2323. {
  2324. pos = {x=0, y=0, z=0},
  2325. velocity = {x=0, y=0, z=0},
  2326. acceleration = {x=0, y=0, z=0},
  2327. ^ Spawn particle at pos with velocity and acceleration
  2328. expirationtime = 1,
  2329. ^ Disappears after expirationtime seconds
  2330. size = 1,
  2331. collisiondetection = false,
  2332. ^ collisiondetection: if true collides with physical objects
  2333. vertical = false,
  2334. ^ vertical: if true faces player using y axis only
  2335. texture = "image.png",
  2336. ^ Uses texture (string)
  2337. playername = "singleplayer"
  2338. ^ Playername is optional, if specified spawns particle only on the player's client
  2339. }
  2340. Particlespawner definition (add_particlespawner)
  2341. {
  2342. amount = 1,
  2343. time = 1,
  2344. ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
  2345. minpos = {x=0, y=0, z=0},
  2346. maxpos = {x=0, y=0, z=0},
  2347. minvel = {x=0, y=0, z=0},
  2348. maxvel = {x=0, y=0, z=0},
  2349. minacc = {x=0, y=0, z=0},
  2350. maxacc = {x=0, y=0, z=0},
  2351. minexptime = 1,
  2352. maxexptime = 1,
  2353. minsize = 1,
  2354. maxsize = 1,
  2355. ^ The particle's properties are random values in between the boundings:
  2356. ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
  2357. ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
  2358. collisiondetection = false,
  2359. ^ collisiondetection: if true uses collisiondetection
  2360. vertical = false,
  2361. ^ vertical: if true faces player using y axis only
  2362. texture = "image.png",
  2363. ^ Uses texture (string)
  2364. playername = "singleplayer"
  2365. ^ Playername is optional, if specified spawns particle only on the player's client
  2366. }