lua_api.txt 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639
  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 background color of tooltips
  780. ^ Sets font color of tooltips
  781. image[<X>,<Y>;<W>,<H>;<texture name>]
  782. ^ Show an image
  783. ^ Position and size units are inventory slots
  784. item_image[<X>,<Y>;<W>,<H>;<item name>]
  785. ^ Show an inventory image of registered item/node
  786. ^ Position and size units are inventory slots
  787. bgcolor[<color>;<fullscreen>]
  788. ^ Sets background color of formspec in HEX-Color format
  789. ^ If true the background color is drawn fullscreen (does not effect the size of the formspec)
  790. background[<X>,<Y>;<W>,<H>;<texture name>]
  791. ^ Use a background. Inventory rectangles are not drawn then.
  792. ^ Position and size units are inventory slots
  793. ^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px
  794. background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]
  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. ^ If true the background is clipped to formspec size (x and y are used as offset values, w and h are ignored)
  799. pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]
  800. ^ Textual password style field; will be sent to server when a button is clicked
  801. ^ x and y position the field relative to the top left of the menu
  802. ^ w and h are the size of the field
  803. ^ fields are a set height, but will be vertically centred on h
  804. ^ Position and size units are inventory slots
  805. ^ name is the name of the field as returned in fields to on_receive_fields
  806. ^ label, if not blank, will be text printed on the top left above the field
  807. field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
  808. ^ Textual field; will be sent to server when a button is clicked
  809. ^ x and y position the field relative to the top left of the menu
  810. ^ w and h are the size of the field
  811. ^ fields are a set height, but will be vertically centred on h
  812. ^ Position and size units are inventory slots
  813. ^ name is the name of the field as returned in fields to on_receive_fields
  814. ^ label, if not blank, will be text printed on the top left above the field
  815. ^ default is the default value of the field
  816. ^ default may contain variable references such as '${text}' which
  817. will fill the value from the metadata value 'text'
  818. ^ Note: no extra text or more than a single variable is supported ATM.
  819. field[<name>;<label>;<default>]
  820. ^ as above but without position/size units
  821. ^ special field for creating simple forms, such as sign text input
  822. ^ must be used without a size[] element
  823. ^ a 'Proceed' button will be added automatically
  824. textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
  825. ^ same as fields above, but with multi-line input
  826. label[<X>,<Y>;<label>]
  827. ^ x and y work as per field
  828. ^ label is the text on the label
  829. ^ Position and size units are inventory slots
  830. vertlabel[<X>,<Y>;<label>]
  831. ^ Textual label drawn verticaly
  832. ^ x and y work as per field
  833. ^ label is the text on the label
  834. ^ Position and size units are inventory slots
  835. button[<X>,<Y>;<W>,<H>;<name>;<label>]
  836. ^ Clickable button. When clicked, fields will be sent.
  837. ^ x, y and name work as per field
  838. ^ w and h are the size of the button
  839. ^ label is the text on the button
  840. ^ Position and size units are inventory slots
  841. image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
  842. ^ x, y, w, h, and name work as per button
  843. ^ texture name is the filename of an image
  844. ^ Position and size units are inventory slots
  845. image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>]
  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. ^ noclip true meand imagebutton doesn't need to be within specified formsize
  850. ^ drawborder draw button bodrer or not
  851. image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]
  852. ^ x, y, w, h, and name work as per button
  853. ^ texture name is the filename of an image
  854. ^ Position and size units are inventory slots
  855. ^ noclip true meand imagebutton doesn't need to be within specified formsize
  856. ^ drawborder draw button bodrer or not
  857. ^ pressed texture name is the filename of an image on pressed state
  858. item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]
  859. ^ x, y, w, h, name and label work as per button
  860. ^ item name is the registered name of an item/node,
  861. tooltip will be made out of its descritption
  862. ^ Position and size units are inventory slots
  863. button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]
  864. ^ When clicked, fields will be sent and the form will quit.
  865. image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
  866. ^ When clicked, fields will be sent and the form will quit.
  867. textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]
  868. ^Scrollabel itemlist showing arbitrary text elements
  869. ^ x and y position the itemlist relative to the top left of the menu
  870. ^ w and h are the size of the itemlist
  871. ^ name fieldname sent to server on doubleclick value is current selected element
  872. ^ listelements can be prepended by #color in hexadecimal format RRGGBB (only),
  873. ^ if you want a listelement to start with # write ##
  874. textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]
  875. ^Scrollabel itemlist showing arbitrary text elements
  876. ^ x and y position the itemlist relative to the top left of the menu
  877. ^ w and h are the size of the itemlist
  878. ^ name fieldname sent to server on doubleclick value is current selected element
  879. ^ listelements can be prepended by #RRGGBB (only) in hexadecimal format
  880. ^ if you want a listelement to start with # write ##
  881. ^ index to be selected within textlist
  882. ^ true/false draw transparent background
  883. ^ see also minetest.explode_textlist_event (main menu: engine.explode_textlist_event)
  884. tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]
  885. ^ show a tabHEADER at specific position (ignores formsize)
  886. ^ x and y position the itemlist relative to the top left of the menu
  887. ^ name fieldname data is transfered to lua
  888. ^ caption 1... name shown on top of tab
  889. ^ current_tab index of selected tab 1...
  890. ^ transparent (optional) show transparent
  891. ^ draw_border (optional) draw border
  892. box[<X>,<Y>;<W>,<H>;<color>]
  893. ^ simple colored semitransparent box
  894. ^ x and y position the box relative to the top left of the menu
  895. ^ w and h are the size of box
  896. ^ color in HEX-Color format
  897. dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]
  898. ^ show a dropdown field
  899. ^ x and y position of dropdown
  900. ^ width of dropdown
  901. ^ fieldname data is transfered to lua
  902. ^ items to be shown in dropdown
  903. ^ index of currently selected dropdown item
  904. ^ color in hexadecimal format RRGGBB (only)
  905. checkbox[<X>,<Y>;<name>;<label>;<selected>]
  906. ^ show a checkbox
  907. ^ x and y position of checkbox
  908. ^ name fieldname data is transfered to lua
  909. ^ label to be shown left of checkbox
  910. ^ selected (optional) true/false
  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. Other registration functions:
  1137. minetest.register_chatcommand(cmd, chatcommand definition)
  1138. minetest.register_privilege(name, definition)
  1139. ^ definition: "description text"
  1140. ^ definition: {
  1141. description = "description text",
  1142. give_to_singleplayer = boolean, -- default: true
  1143. }
  1144. minetest.register_authentication_handler(handler)
  1145. ^ See minetest.builtin_auth_handler in builtin.lua for reference
  1146. Setting-related:
  1147. minetest.setting_set(name, value)
  1148. minetest.setting_get(name) -> string or nil
  1149. minetest.setting_setbool(name, value)
  1150. minetest.setting_getbool(name) -> boolean value or nil
  1151. minetest.setting_get_pos(name) -> position or nil
  1152. minetest.setting_save() -> nil, save all settings to config file
  1153. Authentication:
  1154. minetest.notify_authentication_modified(name)
  1155. ^ Should be called by the authentication handler if privileges change.
  1156. ^ To report everybody, set name=nil.
  1157. minetest.get_password_hash(name, raw_password)
  1158. ^ Convert a name-password pair to a password hash that minetest can use
  1159. minetest.string_to_privs(str) -> {priv1=true,...}
  1160. minetest.privs_to_string(privs) -> "priv1,priv2,..."
  1161. ^ Convert between two privilege representations
  1162. minetest.set_player_password(name, password_hash)
  1163. minetest.set_player_privs(name, {priv1=true,...})
  1164. minetest.get_player_privs(name) -> {priv1=true,...}
  1165. minetest.auth_reload()
  1166. ^ These call the authentication handler
  1167. minetest.check_player_privs(name, {priv1=true,...}) -> bool, missing_privs
  1168. ^ A quickhand for checking privileges
  1169. minetest.get_player_ip(name) -> IP address string
  1170. Chat:
  1171. minetest.chat_send_all(text)
  1172. minetest.chat_send_player(name, text)
  1173. Environment access:
  1174. minetest.set_node(pos, node)
  1175. minetest.add_node(pos, node): alias set_node(pos, node)
  1176. ^ Set node at position (node = {name="foo", param1=0, param2=0})
  1177. minetest.swap_node(pos, node)
  1178. ^ Set node at position, but don't remove metadata
  1179. minetest.remove_node(pos)
  1180. ^ Equivalent to set_node(pos, "air")
  1181. minetest.get_node(pos)
  1182. ^ Returns {name="ignore", ...} for unloaded area
  1183. minetest.get_node_or_nil(pos)
  1184. ^ Returns nil for unloaded area
  1185. minetest.get_node_light(pos, timeofday) -> 0...15 or nil
  1186. ^ timeofday: nil = current time, 0 = night, 0.5 = day
  1187. minetest.place_node(pos, node)
  1188. ^ Place node with the same effects that a player would cause
  1189. minetest.dig_node(pos)
  1190. ^ Dig node with the same effects that a player would cause
  1191. minetest.punch_node(pos)
  1192. ^ Punch node with the same effects that a player would cause
  1193. minetest.get_meta(pos) -- Get a NodeMetaRef at that position
  1194. minetest.get_node_timer(pos) -- Get NodeTimerRef
  1195. minetest.add_entity(pos, name): Spawn Lua-defined entity at position
  1196. ^ Returns ObjectRef, or nil if failed
  1197. minetest.add_item(pos, item): Spawn item
  1198. ^ Returns ObjectRef, or nil if failed
  1199. minetest.get_player_by_name(name) -- Get an ObjectRef to a player
  1200. minetest.get_objects_inside_radius(pos, radius)
  1201. minetest.set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
  1202. minetest.get_timeofday()
  1203. minetest.get_gametime(): returns the time, in seconds, since the world was created
  1204. minetest.find_node_near(pos, radius, nodenames) -> pos or nil
  1205. ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
  1206. minetest.find_nodes_in_area(minp, maxp, nodenames) -> list of positions
  1207. ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
  1208. minetest.get_perlin(seeddiff, octaves, persistence, scale)
  1209. ^ Return world-specific perlin noise (int(worldseed)+seeddiff)
  1210. minetest.get_voxel_manip()
  1211. ^ Return voxel manipulator object
  1212. minetest.set_gen_notify(flags)
  1213. ^ Set the types of on-generate notifications that should be collected
  1214. ^ flags is a comma-delimited combination of:
  1215. ^ dungeon, temple, cave_begin, cave_end, large_cave_begin, large_cave_end
  1216. minetest.get_mapgen_object(objectname)
  1217. ^ Return requested mapgen object if available (see Mapgen objects)
  1218. minetest.set_mapgen_params(MapgenParams)
  1219. ^ Set map generation parameters
  1220. ^ Function cannot be called after the registration period; only initialization and on_mapgen_init
  1221. ^ Takes a table as an argument with the fields mgname, seed, water_level, and flags.
  1222. ^ Leave field unset to leave that parameter unchanged
  1223. ^ flags contains a comma-delimited string of flags to set, or if the prefix "no" is attached, clears instead.
  1224. ^ flags is in the same format and has the same options as 'mg_flags' in minetest.conf
  1225. minetest.set_noiseparam_defaults({np1=NoiseParams, np2= NoiseParams, ...})
  1226. ^ Sets the default value of a noiseparam setting
  1227. ^ Takes a table as an argument that maps one or more setting names to NoiseParams structures
  1228. ^ Possible setting names consist of any NoiseParams setting exposed through the global settings
  1229. minetest.clear_objects()
  1230. ^ clear all objects in the environments
  1231. minetest.line_of_sight(pos1, pos2, stepsize) -> true/false, pos
  1232. ^ Check if there is a direct line of sight between pos1 and pos2
  1233. ^ Returns the position of the blocking node when false
  1234. ^ pos1 First position
  1235. ^ pos2 Second position
  1236. ^ stepsize smaller gives more accurate results but requires more computing
  1237. time. Default is 1.
  1238. minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)
  1239. ^ -> table containing path
  1240. ^ returns a table of 3d points representing a path from pos1 to pos2 or nil
  1241. ^ pos1: start position
  1242. ^ pos2: end position
  1243. ^ searchdistance: number of blocks to search in each direction
  1244. ^ max_jump: maximum height difference to consider walkable
  1245. ^ max_drop: maximum height difference to consider droppable
  1246. ^ algorithm: A*_noprefetch(default), A*, Dijkstra
  1247. minetest.spawn_tree (pos, {treedef})
  1248. ^ spawns L-System tree at given pos with definition in treedef table
  1249. minetest.transforming_liquid_add(pos)
  1250. ^ add node to liquid update queue
  1251. minetest.get_node_max_level(pos)
  1252. ^ get max available level for leveled node
  1253. minetest.get_node_level(pos)
  1254. ^ get level of leveled node (water, snow)
  1255. minetest.set_node_level(pos, level)
  1256. ^ set level of leveled node, default level = 1, if totallevel > maxlevel returns rest (total-max).
  1257. minetest.add_node_level(pos, level)
  1258. ^ increase level of leveled node by level, default level = 1, if totallevel > maxlevel returns rest (total-max). can be negative for decreasing
  1259. Inventory:
  1260. minetest.get_inventory(location) -> InvRef
  1261. ^ location = eg. {type="player", name="celeron55"}
  1262. {type="node", pos={x=, y=, z=}}
  1263. {type="detached", name="creative"}
  1264. minetest.create_detached_inventory(name, callbacks) -> InvRef
  1265. ^ callbacks: See "Detached inventory callbacks"
  1266. ^ Creates a detached inventory. If it already exists, it is cleared.
  1267. Formspec:
  1268. minetest.show_formspec(playername, formname, formspec)
  1269. ^ playername: name of player to show formspec
  1270. ^ formname: name passed to on_player_receive_fields callbacks
  1271. ^ should follow "modname:<whatever>" naming convention
  1272. ^ formspec: formspec to display
  1273. minetest.formspec_escape(string) -> string
  1274. ^ escapes characters [ ] \ , ; that can not be used in formspecs
  1275. minetest.explode_table_event(string) -> table
  1276. ^ returns e.g. {type="CHG", row=1, column=2}
  1277. ^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
  1278. minetest.explode_textlist_event(string) -> table
  1279. ^ returns e.g. {type="CHG", index=1}
  1280. ^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
  1281. Item handling:
  1282. minetest.inventorycube(img1, img2, img3)
  1283. ^ Returns a string for making an image of a cube (useful as an item image)
  1284. minetest.get_pointed_thing_position(pointed_thing, above)
  1285. ^ Get position of a pointed_thing (that you can get from somewhere)
  1286. minetest.dir_to_facedir(dir, is6d)
  1287. ^ 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
  1288. minetest.facedir_to_dir(facedir)
  1289. ^ Convert a facedir back into a vector aimed directly out the "back" of a node
  1290. minetest.dir_to_wallmounted(dir)
  1291. ^ Convert a vector to a wallmounted value, used for paramtype2="wallmounted"
  1292. minetest.get_node_drops(nodename, toolname)
  1293. ^ Returns list of item names.
  1294. ^ Note: This will be removed or modified in a future version.
  1295. minetest.get_craft_result(input) -> output, decremented_input
  1296. ^ input.method = 'normal' or 'cooking' or 'fuel'
  1297. ^ input.width = for example 3
  1298. ^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
  1299. stack 5, stack 6, stack 7, stack 8, stack 9 }
  1300. ^ output.item = ItemStack, if unsuccessful: empty ItemStack
  1301. ^ output.time = number, if unsuccessful: 0
  1302. ^ decremented_input = like input
  1303. minetest.get_craft_recipe(output) -> input
  1304. ^ returns last registered recipe for output item (node)
  1305. ^ output is a node or item type such as 'default:torch'
  1306. ^ input.method = 'normal' or 'cooking' or 'fuel'
  1307. ^ input.width = for example 3
  1308. ^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
  1309. stack 5, stack 6, stack 7, stack 8, stack 9 }
  1310. ^ input.items = nil if no recipe found
  1311. minetest.get_all_craft_recipes(query item) -> table or nil
  1312. ^ returns indexed table with all registered recipes for query item (node)
  1313. or nil if no recipe was found
  1314. recipe entry table:
  1315. {
  1316. method = 'normal' or 'cooking' or 'fuel'
  1317. width = 0-3, 0 means shapeless recipe
  1318. items = indexed [1-9] table with recipe items
  1319. output = string with item name and quantity
  1320. }
  1321. Example query for default:gold_ingot will return table:
  1322. {
  1323. 1={type = "cooking", width = 3, output = "default:gold_ingot",
  1324. items = {1 = "default:gold_lump"}},
  1325. 2={type = "normal", width = 1, output = "default:gold_ingot 9",
  1326. items = {1 = "default:goldblock"}}
  1327. }
  1328. minetest.handle_node_drops(pos, drops, digger)
  1329. ^ drops: list of itemstrings
  1330. ^ Handles drops from nodes after digging: Default action is to put them into
  1331. digger's inventory
  1332. ^ Can be overridden to get different functionality (eg. dropping items on
  1333. ground)
  1334. Rollback:
  1335. minetest.rollback_get_node_actions(pos, range, seconds, limit) -> {{actor, pos, time, oldnode, newnode}, ...}
  1336. ^ Find who has done something to a node, or near a node
  1337. ^ actor: "player:<name>", also "liquid".
  1338. minetest.rollback_revert_actions_by(actor, seconds) -> bool, log messages
  1339. ^ Revert latest actions of someone
  1340. ^ actor: "player:<name>", also "liquid".
  1341. Defaults for the on_* item definition functions:
  1342. (These return the leftover itemstack)
  1343. minetest.item_place_node(itemstack, placer, pointed_thing, param2)
  1344. ^ Place item as a node
  1345. ^ param2 overrides facedir and wallmounted param2
  1346. ^ returns itemstack, success
  1347. minetest.item_place_object(itemstack, placer, pointed_thing)
  1348. ^ Place item as-is
  1349. minetest.item_place(itemstack, placer, pointed_thing, param2)
  1350. ^ Use one of the above based on what the item is.
  1351. ^ Calls on_rightclick of pointed_thing.under if defined instead
  1352. ^ Note: is not called when wielded item overrides on_place
  1353. ^ param2 overrides facedir and wallmounted param2
  1354. ^ returns itemstack, success
  1355. minetest.item_drop(itemstack, dropper, pos)
  1356. ^ Drop the item
  1357. minetest.item_eat(hp_change, replace_with_item)
  1358. ^ Eat the item. replace_with_item can be nil.
  1359. Defaults for the on_punch and on_dig node definition callbacks:
  1360. minetest.node_punch(pos, node, puncher, pointed_thing)
  1361. ^ Calls functions registered by minetest.register_on_punchnode()
  1362. minetest.node_dig(pos, node, digger)
  1363. ^ Checks if node can be dug, puts item into inventory, removes node
  1364. ^ Calls functions registered by minetest.registered_on_dignodes()
  1365. Sounds:
  1366. minetest.sound_play(spec, parameters) -> handle
  1367. ^ spec = SimpleSoundSpec
  1368. ^ parameters = sound parameter table
  1369. minetest.sound_stop(handle)
  1370. Timing:
  1371. minetest.after(time, func, ...)
  1372. ^ Call function after time seconds
  1373. ^ Optional: Variable number of arguments that are passed to func
  1374. Server:
  1375. minetest.request_shutdown() -> request for server shutdown
  1376. minetest.get_server_status() -> server status string
  1377. Bans:
  1378. minetest.get_ban_list() -> ban list (same as minetest.get_ban_description(""))
  1379. minetest.get_ban_description(ip_or_name) -> ban description (string)
  1380. minetest.ban_player(name) -> ban a player
  1381. minetest.unban_player_or_ip(name) -> unban player or IP address
  1382. minetest.kick_player(name, [reason]) -> disconnect a player with a optional reason
  1383. Particles:
  1384. minetest.add_particle(particle definition)
  1385. ^ Deprecated: minetest.add_particle(pos, velocity, acceleration, expirationtime,
  1386. size, collisiondetection, texture, playername)
  1387. minetest.add_particlespawner(particlespawner definition)
  1388. ^ Add a particlespawner, an object that spawns an amount of particles over time seconds
  1389. ^ Returns an id
  1390. ^ Deprecated: minetest.add_particlespawner(amount, time,
  1391. minpos, maxpos,
  1392. minvel, maxvel,
  1393. minacc, maxacc,
  1394. minexptime, maxexptime,
  1395. minsize, maxsize,
  1396. collisiondetection, texture, playername)
  1397. minetest.delete_particlespawner(id, player)
  1398. ^ Delete ParticleSpawner with id (return value from add_particlespawner)
  1399. ^ If playername is specified, only deletes on the player's client,
  1400. ^ otherwise on all clients
  1401. Schematics:
  1402. minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)
  1403. ^ Create a schematic from the volume of map specified by the box formed by p1 and p2.
  1404. ^ Apply the specified probability values to the specified nodes in probability_list.
  1405. ^ probability_list is an array of tables containing two fields, pos and prob.
  1406. ^ pos is the 3d vector specifying the absolute coordinates of the node being modified,
  1407. ^ and prob is the integer value from 0 to 255 of the probability (see: Schematic specifier).
  1408. ^ If there are two or more entries with the same pos value, the last occuring in the array is used.
  1409. ^ If pos is not inside the box formed by p1 and p2, it is ignored.
  1410. ^ If probability_list is nil, no probabilities are applied.
  1411. ^ Slice probability works in the same manner, except takes a field called ypos instead which indicates
  1412. ^ the y position of the slice with a probability applied.
  1413. ^ If slice probability list is nil, no slice probabilities are applied.
  1414. ^ Saves schematic in the Minetest Schematic format to filename.
  1415. minetest.place_schematic(pos, schematic, rotation, replacements, force_placement)
  1416. ^ Place the schematic specified by schematic (see: Schematic specifier) at pos.
  1417. ^ Rotation can be "0", "90", "180", "270", or "random".
  1418. ^ If the rotation parameter is omitted, the schematic is not rotated.
  1419. ^ replacements = {{"oldname", "convert_to"}, ...}
  1420. ^ force_placement is a boolean indicating whether nodes other than air and
  1421. ^ ignore are replaced by the schematic
  1422. Random:
  1423. minetest.get_connected_players() -> list of ObjectRefs
  1424. minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
  1425. ^ Gives a unique hash number for a node position (16+16+16=48bit)
  1426. minetest.get_position_from_hash(hash) -> postion
  1427. ^ Inverse transform of minetest.hash_node_postion
  1428. minetest.get_item_group(name, group) -> rating
  1429. ^ Get rating of a group of an item. (0 = not in group)
  1430. minetest.get_node_group(name, group) -> rating
  1431. ^ Deprecated: An alias for the former.
  1432. minetest.get_content_id(name) -> integer
  1433. ^ Gets the internal content ID of name
  1434. minetest.get_name_from_content_id(content_id) -> string
  1435. ^ Gets the name of the content with that content ID
  1436. minetest.parse_json(string[, nullvalue]) -> something
  1437. ^ Convert a string containing JSON data into the Lua equivalent
  1438. ^ nullvalue: returned in place of the JSON null; defaults to nil
  1439. ^ On success returns a table, a string, a number, a boolean or nullvalue
  1440. ^ On failure outputs an error message and returns nil
  1441. ^ Example: parse_json("[10, {\"a\":false}]") -> {10, {a = false}}
  1442. minetest.write_json(data[, styled]) -> string or nil and error message
  1443. ^ Convert a Lua table into a JSON string
  1444. ^ styled: Outputs in a human-readable format if this is set, defaults to false
  1445. ^ Un-serializable things like functions and userdata are saved as null.
  1446. ^ Warning: JSON is more strict than the Lua table format.
  1447. 1. You can only use strings and positive integers of at least one as keys.
  1448. 2. You can not mix string and integer keys.
  1449. This is due to the fact that Javascript has two distinct array and object values.
  1450. ^ Example: write_json({10, {a = false}}) -> "[10, {\"a\": false}]"
  1451. minetest.serialize(table) -> string
  1452. ^ Convert a table containing tables, strings, numbers, booleans and nils
  1453. into string form readable by minetest.deserialize
  1454. ^ Example: serialize({foo='bar'}) -> 'return { ["foo"] = "bar" }'
  1455. minetest.deserialize(string) -> table
  1456. ^ Convert a string returned by minetest.deserialize into a table
  1457. ^ String is loaded in an empty sandbox environment.
  1458. ^ Will load functions, but they cannot access the global environment.
  1459. ^ Example: deserialize('return { ["foo"] = "bar" }') -> {foo='bar'}
  1460. ^ Example: deserialize('print("foo")') -> nil (function call fails)
  1461. ^ error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)
  1462. minetest.is_protected(pos, name) -> bool
  1463. ^ This function should be overriden by protection mods and should be used to
  1464. check if a player can interact at a position.
  1465. ^ This function should call the old version of itself if the position is not
  1466. protected by the mod.
  1467. ^ Example:
  1468. local old_is_protected = minetest.is_protected
  1469. function minetest.is_protected(pos, name)
  1470. if mymod:position_protected_from(pos, name) then
  1471. return true
  1472. end
  1473. return old_is_protected(pos, name)
  1474. end
  1475. minetest.record_protection_violation(pos, name)
  1476. ^ This function calls functions registered with
  1477. minetest.register_on_protection_violation.
  1478. minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orient_flags)
  1479. ^ Attempt to predict the desired orientation of the facedir-capable node
  1480. defined by itemstack, and place it accordingly (on-wall, on the floor, or
  1481. hanging from the ceiling). Stacks are handled normally if the infinitestacks
  1482. field is false or omitted (else, the itemstack is not changed). orient_flags
  1483. is an optional table containing extra tweaks to the placement code:
  1484. invert_wall: if true, place wall-orientation on the ground and ground-
  1485. orientation on the wall.
  1486. force_wall: if true, always place the node in wall orientation.
  1487. force_ceiling: if true, always place on the ceiling.
  1488. force_floor: if true, always place the node on the floor.
  1489. The above four options are mutually-exclusive; the last in the list takes
  1490. precedence over the first.
  1491. force_facedir: if true, forcably reset the facedir to north when placing on
  1492. the floor or ceiling
  1493. minetest.rotate_node(itemstack, placer, pointed_thing)
  1494. ^ calls rotate_and_place() with infinitestacks set according to the state of
  1495. the creative mode setting, and checks for "sneak" to set the invert_wall
  1496. parameter.
  1497. minetest.forceload_block(pos)
  1498. ^ forceloads the position pos.
  1499. ^ returns true if area could be forceloaded
  1500. minetest.forceload_free_block(pos)
  1501. ^ stops forceloading the position pos.
  1502. Please note that forceloaded areas are saved when the server restarts.
  1503. Global objects:
  1504. minetest.env - EnvRef of the server environment and world.
  1505. ^ Any function in the minetest namespace can be called using the syntax
  1506. minetest.env:somefunction(somearguments)
  1507. instead of
  1508. minetest.somefunction(somearguments)
  1509. ^ Deprecated, but support is not to be dropped soon
  1510. Global tables:
  1511. minetest.registered_items
  1512. ^ List of registered items, indexed by name
  1513. minetest.registered_nodes
  1514. ^ List of registered node definitions, indexed by name
  1515. minetest.registered_craftitems
  1516. ^ List of registered craft item definitions, indexed by name
  1517. minetest.registered_tools
  1518. ^ List of registered tool definitions, indexed by name
  1519. minetest.registered_entities
  1520. ^ List of registered entity prototypes, indexed by name
  1521. minetest.object_refs
  1522. ^ List of object references, indexed by active object id
  1523. minetest.luaentities
  1524. ^ List of lua entities, indexed by active object id
  1525. Class reference
  1526. ----------------
  1527. NodeMetaRef: Node metadata - reference extra data and functionality stored
  1528. in a node
  1529. - Can be gotten via minetest.get_nodemeta(pos)
  1530. methods:
  1531. - set_string(name, value)
  1532. - get_string(name)
  1533. - set_int(name, value)
  1534. - get_int(name)
  1535. - set_float(name, value)
  1536. - get_float(name)
  1537. - get_inventory() -> InvRef
  1538. - to_table() -> nil or {fields = {...}, inventory = {list1 = {}, ...}}
  1539. - from_table(nil or {})
  1540. ^ See "Node Metadata"
  1541. NodeTimerRef: Node Timers - a high resolution persistent per-node timer
  1542. - Can be gotten via minetest.get_node_timer(pos)
  1543. methods:
  1544. - set(timeout,elapsed)
  1545. ^ set a timer's state
  1546. ^ timeout is in seconds, and supports fractional values (0.1 etc)
  1547. ^ elapsed is in seconds, and supports fractional values (0.1 etc)
  1548. ^ will trigger the node's on_timer function after timeout-elapsed seconds
  1549. - start(timeout)
  1550. ^ start a timer
  1551. ^ equivelent to set(timeout,0)
  1552. - stop()
  1553. ^ stops the timer
  1554. - get_timeout() -> current timeout in seconds
  1555. ^ if timeout is 0, timer is inactive
  1556. - get_elapsed() -> current elapsed time in seconds
  1557. ^ the node's on_timer function will be called after timeout-elapsed seconds
  1558. - is_started() -> boolean state of timer
  1559. ^ returns true if timer is started, otherwise false
  1560. ObjectRef: Moving things in the game are generally these
  1561. (basically reference to a C++ ServerActiveObject)
  1562. methods:
  1563. - remove(): remove object (after returning from Lua)
  1564. - getpos() -> {x=num, y=num, z=num}
  1565. - setpos(pos); pos={x=num, y=num, z=num}
  1566. - moveto(pos, continuous=false): interpolated move
  1567. - punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1568. ^ puncher = an another ObjectRef,
  1569. ^ time_from_last_punch = time since last punch action of the puncher
  1570. ^ direction: can be nil
  1571. - right_click(clicker); clicker = an another ObjectRef
  1572. - get_hp(): returns number of hitpoints (2 * number of hearts)
  1573. - set_hp(hp): set number of hitpoints (2 * number of hearts)
  1574. - get_inventory() -> InvRef
  1575. - get_wield_list(): returns the name of the inventory list the wielded item is in
  1576. - get_wield_index(): returns the index of the wielded item
  1577. - get_wielded_item() -> ItemStack
  1578. - set_wielded_item(item): replaces the wielded item, returns true if successful
  1579. - set_armor_groups({group1=rating, group2=rating, ...})
  1580. - set_animation({x=1,y=1}, frame_speed=15, frame_blend=0)
  1581. - set_attach(parent, bone, position, rotation)
  1582. ^ bone = string
  1583. ^ position = {x=num, y=num, z=num} (relative)
  1584. ^ rotation = {x=num, y=num, z=num}
  1585. - set_detach()
  1586. - set_bone_position(bone, position, rotation)
  1587. ^ bone = string
  1588. ^ position = {x=num, y=num, z=num} (relative)
  1589. ^ rotation = {x=num, y=num, z=num}
  1590. - set_properties(object property table)
  1591. LuaEntitySAO-only: (no-op for other objects)
  1592. - setvelocity({x=num, y=num, z=num})
  1593. - getvelocity() -> {x=num, y=num, z=num}
  1594. - setacceleration({x=num, y=num, z=num})
  1595. - getacceleration() -> {x=num, y=num, z=num}
  1596. - setyaw(radians)
  1597. - getyaw() -> radians
  1598. - settexturemod(mod)
  1599. - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
  1600. - select_horiz_by_yawpitch=false)
  1601. ^ Select sprite from spritesheet with optional animation and DM-style
  1602. texture selection based on yaw relative to camera
  1603. - get_entity_name() (DEPRECATED: Will be removed in a future version)
  1604. - get_luaentity()
  1605. Player-only: (no-op for other objects)
  1606. - is_player(): true for players, false for others
  1607. - get_player_name(): returns "" if is not a player
  1608. - get_look_dir(): get camera direction as a unit vector
  1609. - get_look_pitch(): pitch in radians
  1610. - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
  1611. - set_look_pitch(radians): sets look pitch
  1612. - set_look_yaw(radians): sets look yaw
  1613. - get_breath() : returns players breath
  1614. - set_breath(value) : sets players breath
  1615. values: 0 player is drowning,
  1616. 1-10 number of bubbles remain,
  1617. 11 bubbles bar is not shown
  1618. - set_inventory_formspec(formspec)
  1619. ^ Redefine player's inventory form
  1620. ^ Should usually be called in on_joinplayer
  1621. - get_inventory_formspec() -> formspec string
  1622. - get_player_control(): returns table with player pressed keys
  1623. {jump=bool,right=bool,left=bool,LMB=bool,RMB=bool,sneak=bool,aux1=bool,down=bool,up=bool}
  1624. - get_player_control_bits(): returns integer with bit packed player pressed keys
  1625. bit nr/meaning: 0/up ,1/down ,2/left ,3/right ,4/jump ,5/aux1 ,6/sneak ,7/LMB ,8/RMB
  1626. - set_physics_override({
  1627. speed = 1.0, -- multiplier to default value
  1628. jump = 1.0, -- multiplier to default value
  1629. gravity = 1.0, -- multiplier to default value
  1630. sneak = true, -- whether player can sneak
  1631. sneak_glitch = true, -- whether player can use the sneak glitch
  1632. })
  1633. - hud_add(hud definition): add a HUD element described by HUD def, returns ID number on success
  1634. - hud_remove(id): remove the HUD element of the specified id
  1635. - hud_change(id, stat, value): change a value of a previously added HUD element
  1636. ^ element stat values: position, name, scale, text, number, item, dir
  1637. - hud_get(id): gets the HUD element definition structure of the specified ID
  1638. - hud_set_flags(flags): sets specified HUD flags to true/false
  1639. ^ flags: (is visible) hotbar, healthbar, crosshair, wielditem
  1640. ^ pass a table containing a true/false value of each flag to be set or unset
  1641. ^ if a flag is nil, the flag is not modified
  1642. - hud_get_flags(): returns a table containing status of hud flags
  1643. ^ returns { hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true }
  1644. - hud_set_hotbar_itemcount(count): sets number of items in builtin hotbar
  1645. ^ count: number of items, must be between 1 and 23
  1646. - hud_set_hotbar_image(texturename)
  1647. ^ sets background image for hotbar
  1648. - hud_set_hotbar_selected_image(texturename)
  1649. ^ sets image for selected item of hotbar
  1650. - hud_replace_builtin(name, hud definition)
  1651. ^ replace definition of a builtin hud element
  1652. ^ name: "breath" or "health"
  1653. ^ hud definition: definition to replace builtin definition
  1654. - set_sky(bgcolor, type, {texture names})
  1655. ^ bgcolor: {r=0...255, g=0...255, b=0...255} or nil, defaults to white
  1656. ^ Available types:
  1657. - "regular": Uses 0 textures, bgcolor ignored
  1658. - "skybox": Uses 6 textures, bgcolor used
  1659. - "plain": Uses 0 textures, bgcolor used
  1660. ^ Note: currently does not work directly in on_joinplayer; use
  1661. minetest.after(0) in there.
  1662. - override_day_night_ratio(ratio or nil)
  1663. ^ 0...1: Overrides day-night ratio, controlling sunlight to a specific amount
  1664. ^ nil: Disables override, defaulting to sunlight based on day-night cycle
  1665. - 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
  1666. ^ stand/idle animation key frames
  1667. ^ walk animation key frames
  1668. ^ dig animation key frames
  1669. ^ walk+dig animation key frames
  1670. ^ animation frame speed
  1671. - set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0}): defines offset value for camera per player
  1672. ^ in first person view
  1673. ^ in third person view (max. values {x=-10/10,y=-10,15,z=-5/5})
  1674. InvRef: Reference to an inventory
  1675. methods:
  1676. - is_empty(listname): return true if list is empty
  1677. - get_size(listname): get size of a list
  1678. - set_size(listname, size): set size of a list
  1679. ^ returns false on error (e.g. invalid listname or listsize)
  1680. - get_width(listname): get width of a list
  1681. - set_width(listname, width): set width of list; currently used for crafting
  1682. - get_stack(listname, i): get a copy of stack index i in list
  1683. - set_stack(listname, i, stack): copy stack to index i in list
  1684. - get_list(listname): return full list
  1685. - set_list(listname, list): set full list (size will not change)
  1686. - get_lists(): returns list of inventory lists
  1687. - set_lists(lists): sets inventory lists (size will not change)
  1688. - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
  1689. - room_for_item(listname, stack): returns true if the stack of items
  1690. can be fully added to the list
  1691. - contains_item(listname, stack): returns true if the stack of items
  1692. can be fully taken from the list
  1693. remove_item(listname, stack): take as many items as specified from the list,
  1694. returns the items that were actually removed (as an ItemStack)
  1695. - get_location() -> location compatible to minetest.get_inventory(location)
  1696. -> {type="undefined"} in case location is not known
  1697. ItemStack: A stack of items.
  1698. - Can be created via ItemStack(itemstack or itemstring or table or nil)
  1699. methods:
  1700. - is_empty(): return true if stack is empty
  1701. - get_name(): returns item name (e.g. "default:stone")
  1702. - set_name(itemname)
  1703. - get_count(): returns number of items on the stack
  1704. - set_count(count)
  1705. - get_wear(): returns tool wear (0-65535), 0 for non-tools
  1706. - set_wear(wear)
  1707. - get_metadata(): returns metadata (a string attached to an item stack)
  1708. - set_metadata(metadata)
  1709. - clear(): removes all items from the stack, making it empty
  1710. - replace(item): replace the contents of this stack (item can also
  1711. be an itemstring or table)
  1712. - to_string(): returns the stack in itemstring form
  1713. - to_table(): returns the stack in Lua table form
  1714. - get_stack_max(): returns the maximum size of the stack (depends on the item)
  1715. - get_free_space(): returns get_stack_max() - get_count()
  1716. - is_known(): returns true if the item name refers to a defined item type
  1717. - get_definition(): returns the item definition table
  1718. - get_tool_capabilities(): returns the digging properties of the item,
  1719. ^ or those of the hand if none are defined for this item type
  1720. - add_wear(amount): increases wear by amount if the item is a tool
  1721. - add_item(item): put some item or stack onto this stack,
  1722. ^ returns leftover ItemStack
  1723. - item_fits(item): returns true if item or stack can be fully added to this one
  1724. - take_item(n): take (and remove) up to n items from this stack
  1725. ^ returns taken ItemStack
  1726. ^ if n is omitted, n=1 is used
  1727. - peek_item(n): copy (don't remove) up to n items from this stack
  1728. ^ returns copied ItemStack
  1729. ^ if n is omitted, n=1 is used
  1730. PseudoRandom: A pseudorandom number generator
  1731. - Can be created via PseudoRandom(seed)
  1732. methods:
  1733. - next(): return next integer random number [0...32767]
  1734. - next(min, max): return next integer random number [min...max]
  1735. (max - min) must be 32767 or <= 6553 due to the simple
  1736. implementation making bad distribution otherwise.
  1737. PerlinNoise: A perlin noise generator
  1738. - Can be created via PerlinNoise(seed, octaves, persistence, scale)
  1739. - Also minetest.get_perlin(seeddiff, octaves, persistence, scale)
  1740. methods:
  1741. - get2d(pos) -> 2d noise value at pos={x=,y=}
  1742. - get3d(pos) -> 3d noise value at pos={x=,y=,z=}
  1743. PerlinNoiseMap: A fast, bulk perlin noise generator
  1744. - Can be created via PerlinNoiseMap(noiseparams, size)
  1745. - Also minetest.get_perlin_map(noiseparams, size)
  1746. methods:
  1747. - get2dMap(pos) -> <size.x>X<size.y> 2d array of 2d noise values starting at pos={x=,y=}
  1748. - get3dMap(pos) -> <size.x>X<size.y>X<size.z> 3d array of 3d noise values starting at pos={x=,y=,z=}
  1749. - get2dMap_flat(pos) -> Flat <size.x * size.y> element array of 2d noise values starting at pos={x=,y=}
  1750. - get3dMap_flat(pos) -> Same as get2dMap_flat, but 3d noise
  1751. VoxelManip: An interface to the MapVoxelManipulator for Lua
  1752. - Can be created via VoxelManip()
  1753. - Also minetest.get_voxel_manip()
  1754. methods:
  1755. - read_from_map(p1, p2): Reads a chunk of map from the map containing the region formed by p1 and p2.
  1756. ^ returns actual emerged pmin, actual emerged pmax
  1757. - write_to_map(): Writes the data loaded from the VoxelManip back to the map.
  1758. ^ important: data must be set using VoxelManip:set_data before calling this
  1759. - get_data(): Gets the data read into the VoxelManip object
  1760. ^ returns raw node data is in the form of an array of node content ids
  1761. - set_data(data): Sets the data contents of the VoxelManip object
  1762. - update_map(): Update map after writing chunk back to map.
  1763. ^ To be used only by VoxelManip objects created by the mod itself; not a VoxelManip that was
  1764. ^ retrieved from minetest.get_mapgen_object
  1765. - set_lighting(light, p1, p2): Set the lighting within the VoxelManip to a uniform value
  1766. ^ light is a table, {day=<0...15>, night=<0...15>}
  1767. ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
  1768. ^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
  1769. - get_light_data(): Gets the light data read into the VoxelManip object
  1770. ^ Returns an array (indicies 1 to volume) of integers ranging from 0 to 255
  1771. ^ Each value is the bitwise combination of day and night light values (0..15 each)
  1772. ^ light = day + (night * 16)
  1773. - set_light_data(light_data): Sets the param1 (light) contents of each node in the VoxelManip
  1774. ^ expects lighting data in the same format that get_light_data() returns
  1775. - get_param2_data(): Gets the raw param2 data read into the VoxelManip object
  1776. - set_param2_data(param2_data): Sets the param2 contents of each node in the VoxelManip
  1777. - calc_lighting(p1, p2): Calculate lighting within the VoxelManip
  1778. ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
  1779. ^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
  1780. - update_liquids(): Update liquid flow
  1781. VoxelArea: A helper class for voxel areas
  1782. - Can be created via VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}
  1783. - Coordinates are *inclusive*, like most other things in Minetest
  1784. methods:
  1785. - getExtent(): returns a 3d vector containing the size of the area formed by MinEdge and MaxEdge
  1786. - getVolume(): returns the volume of the area formed by MinEdge and MaxEdge
  1787. - index(x, y, z): returns the index of an absolute position in a flat array starting at 1
  1788. ^ useful for things like VoxelManip, raw Schematic specifiers, PerlinNoiseMap:get2d/3dMap, and so on
  1789. - indexp(p): same as above, except takes a vector
  1790. - position(i): returns the absolute position vector corresponding to index i
  1791. - contains(x, y, z): check if (x,y,z) is inside area formed by MinEdge and MaxEdge
  1792. - containsp(p): same as above, except takes a vector
  1793. - containsi(i): same as above, except takes an index
  1794. - iter(minx, miny, minz, maxx, maxy, maxz): returns an iterator that returns indices
  1795. ^ from (minx,miny,minz) to (maxx,maxy,maxz) in the order of [z [y [x]]]
  1796. - iterp(minp, maxp): same as above, except takes a vector
  1797. Settings: An interface to read config files in the format of minetest.conf
  1798. - Can be created via Settings(filename)
  1799. methods:
  1800. - get(key) -> value
  1801. - get_bool(key) -> boolean
  1802. - set(key, value)
  1803. - remove(key) -> success
  1804. - get_names() -> {key1,...}
  1805. - write() -> success
  1806. ^ write changes to file
  1807. - to_table() -> {[key1]=value1,...}
  1808. Mapgen objects
  1809. ---------------
  1810. A mapgen object is a construct used in map generation. Mapgen objects can be used by an on_generate
  1811. callback to speed up operations by avoiding unnecessary recalculations; these can be retrieved using the
  1812. minetest.get_mapgen_object() function. If the requested Mapgen object is unavailable, or
  1813. get_mapgen_object() was called outside of an on_generate() callback, nil is returned.
  1814. The following Mapgen objects are currently available:
  1815. - voxelmanip
  1816. This returns three values; the VoxelManip object to be used, minimum and maximum emerged position, in that
  1817. order. All mapgens support this object.
  1818. - heightmap
  1819. Returns an array containing the y coordinates of the ground levels of nodes in the most recently
  1820. generated chunk by the current mapgen.
  1821. - biomemap
  1822. Returns an array containing the biome IDs of nodes in the most recently generated chunk by the
  1823. current mapgen.
  1824. - heatmap
  1825. Returns an array containing the temperature values of nodes in the most recently generated chunk by
  1826. the current mapgen.
  1827. - humiditymap
  1828. Returns an array containing the humidity values of nodes in the most recently generated chunk by the
  1829. current mapgen.
  1830. - gennotify
  1831. Returns a table mapping requested generation notification types to arrays of positions at which the
  1832. corresponding generated structures are located at within the current chunk. To set the capture of positions
  1833. of interest to be recorded on generate, use minetest.set_gen_notify().
  1834. Possible fields of the table returned are: dungeon, temple, cave_begin, cave_end, large_cave_begin, large_cave_end
  1835. Registered entities
  1836. --------------------
  1837. - Functions receive a "luaentity" as self:
  1838. - It has the member .name, which is the registered name ("mod:thing")
  1839. - It has the member .object, which is an ObjectRef pointing to the object
  1840. - The original prototype stuff is visible directly via a metatable
  1841. - Callbacks:
  1842. - on_activate(self, staticdata)
  1843. ^ Called when the object is instantiated.
  1844. - on_step(self, dtime)
  1845. ^ Called on every server tick (dtime is usually 0.1 seconds)
  1846. - on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
  1847. ^ Called when somebody punches the object.
  1848. ^ Note that you probably want to handle most punches using the
  1849. automatic armor group system.
  1850. ^ puncher: ObjectRef (can be nil)
  1851. ^ time_from_last_punch: Meant for disallowing spamming of clicks (can be nil)
  1852. ^ tool_capabilities: capability table of used tool (can be nil)
  1853. ^ dir: unit vector of direction of punch. Always defined. Points from
  1854. the puncher to the punched.
  1855. - on_rightclick(self, clicker)
  1856. - get_staticdata(self)
  1857. ^ Should return a string that will be passed to on_activate when
  1858. the object is instantiated the next time.
  1859. L-system trees
  1860. ---------------
  1861. treedef={
  1862. axiom, - string initial tree axiom
  1863. rules_a, - string rules set A
  1864. rules_b, - string rules set B
  1865. rules_c, - string rules set C
  1866. rules_d, - string rules set D
  1867. trunk, - string trunk node name
  1868. leaves, - string leaves node name
  1869. leaves2, - string secondary leaves node name
  1870. leaves2_chance,- num chance (0-100) to replace leaves with leaves2
  1871. angle, - num angle in deg
  1872. iterations, - num max # of iterations, usually 2 -5
  1873. random_level, - num factor to lower nr of iterations, usually 0 - 3
  1874. trunk_type, - string single/double/crossed) type of trunk: 1 node, 2x2 nodes or 3x3 in cross shape
  1875. thin_branches, - boolean true -> use thin (1 node) branches
  1876. fruit, - string fruit node name
  1877. fruit_chance, - num chance (0-100) to replace leaves with fruit node
  1878. seed, - num random seed
  1879. }
  1880. Key for Special L-System Symbols used in Axioms
  1881. G - move forward one unit with the pen up
  1882. F - move forward one unit with the pen down drawing trunks and branches
  1883. f - move forward one unit with the pen down drawing leaves (100% chance)
  1884. T - move forward one unit with the pen down drawing trunks only
  1885. R - move forward one unit with the pen down placing fruit
  1886. A - replace with rules set A
  1887. B - replace with rules set B
  1888. C - replace with rules set C
  1889. D - replace with rules set D
  1890. a - replace with rules set A, chance 90%
  1891. b - replace with rules set B, chance 80%
  1892. c - replace with rules set C, chance 70%
  1893. d - replace with rules set D, chance 60%
  1894. + - yaw the turtle right by angle parameter
  1895. - - yaw the turtle left by angle parameter
  1896. & - pitch the turtle down by angle parameter
  1897. ^ - pitch the turtle up by angle parameter
  1898. / - roll the turtle to the right by angle parameter
  1899. * - roll the turtle to the left by angle parameter
  1900. [ - save in stack current state info
  1901. ] - recover from stack state info
  1902. Example usage: spawn small apple tree
  1903. apple_tree={
  1904. axiom="FFFFFAFFBF",
  1905. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  1906. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  1907. trunk="default:tree",
  1908. leaves="default:leaves",
  1909. angle=30,
  1910. iterations=2,
  1911. random_level=0,
  1912. trunk_type="single",
  1913. thin_branches=true,
  1914. fruit_chance=10,
  1915. fruit="default:apple"
  1916. }
  1917. minetest.spawn_tree(pos,apple_tree)
  1918. Definition tables
  1919. ------------------
  1920. Object Properties
  1921. {
  1922. hp_max = 1,
  1923. physical = true,
  1924. collide_with_objects = true, -- collide with other objects if physical=true
  1925. weight = 5,
  1926. collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
  1927. visual = "cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem",
  1928. visual_size = {x=1, y=1},
  1929. mesh = "model",
  1930. textures = {}, -- number of required textures depends on visual
  1931. colors = {}, -- number of required colors depends on visual
  1932. spritediv = {x=1, y=1},
  1933. initial_sprite_basepos = {x=0, y=0},
  1934. is_visible = true,
  1935. makes_footstep_sound = false,
  1936. automatic_rotate = false,
  1937. stepheight = 0,
  1938. automatic_face_movement_dir = 0.0,
  1939. ^ automatically set yaw to movement direction; offset in degrees; false to disable
  1940. }
  1941. Entity definition (register_entity)
  1942. {
  1943. (Deprecated: Everything in object properties is read directly from here)
  1944. initial_properties = <initial object properties>,
  1945. on_activate = function(self, staticdata, dtime_s),
  1946. on_step = function(self, dtime),
  1947. on_punch = function(self, hitter),
  1948. on_rightclick = function(self, clicker),
  1949. get_staticdata = function(self),
  1950. ^ Called sometimes; the string returned is passed to on_activate when
  1951. the entity is re-activated from static state
  1952. # Also you can define arbitrary member variables here
  1953. myvariable = whatever,
  1954. }
  1955. ABM (ActiveBlockModifier) definition (register_abm)
  1956. {
  1957. -- In the following two fields, also group:groupname will work.
  1958. nodenames = {"default:lava_source"},
  1959. neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
  1960. ^ If left out or empty, any neighbor will do
  1961. interval = 1.0, -- (operation interval)
  1962. chance = 1, -- (chance of trigger is 1.0/this)
  1963. action = func(pos, node, active_object_count, active_object_count_wider),
  1964. }
  1965. Item definition (register_node, register_craftitem, register_tool)
  1966. {
  1967. description = "Steel Axe",
  1968. groups = {}, -- key=name, value=rating; rating=1..3.
  1969. if rating not applicable, use 1.
  1970. eg. {wool=1, fluffy=3}
  1971. {soil=2, outerspace=1, crumbly=1}
  1972. {bendy=2, snappy=1},
  1973. {hard=1, metal=1, spikes=1}
  1974. inventory_image = "default_tool_steelaxe.png",
  1975. wield_image = "",
  1976. wield_scale = {x=1,y=1,z=1},
  1977. stack_max = 99,
  1978. range = 4.0,
  1979. liquids_pointable = false,
  1980. tool_capabilities = {
  1981. full_punch_interval = 1.0,
  1982. max_drop_level=0,
  1983. groupcaps={
  1984. -- For example:
  1985. snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
  1986. choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
  1987. },
  1988. damage_groups = {groupname=damage},
  1989. }
  1990. node_placement_prediction = nil,
  1991. ^ If nil and item is node, prediction is made automatically
  1992. ^ If nil and item is not a node, no prediction is made
  1993. ^ If "" and item is anything, no prediction is made
  1994. ^ Otherwise should be name of node which the client immediately places
  1995. on ground when the player places the item. Server will always update
  1996. actual result to client in a short moment.
  1997. sound = {
  1998. place = <SimpleSoundSpec>,
  1999. }
  2000. on_place = func(itemstack, placer, pointed_thing),
  2001. ^ Shall place item and return the leftover itemstack
  2002. ^ default: minetest.item_place
  2003. on_drop = func(itemstack, dropper, pos),
  2004. ^ Shall drop item and return the leftover itemstack
  2005. ^ default: minetest.item_drop
  2006. on_use = func(itemstack, user, pointed_thing),
  2007. ^ default: nil
  2008. ^ Function must return either nil if no item shall be removed from
  2009. inventory, or an itemstack to replace the original itemstack.
  2010. eg. itemstack:take_item(); return itemstack
  2011. ^ Otherwise, the function is free to do what it wants.
  2012. ^ The default functions handle regular use cases.
  2013. after_use = func(itemstack, user, node, digparams),
  2014. ^ default: nil
  2015. ^ If defined, should return an itemstack and will be called instead of
  2016. wearing out the tool. If returns nil, does nothing.
  2017. If after_use doesn't exist, it is the same as:
  2018. function(itemstack, user, node, digparams)
  2019. itemstack:add_wear(digparams.wear)
  2020. return itemstack
  2021. end
  2022. }
  2023. Tile definition:
  2024. - "image.png"
  2025. - {name="image.png", animation={Tile Animation definition}}
  2026. - {name="image.png", backface_culling=bool}
  2027. ^ backface culling only supported in special tiles
  2028. - deprecated still supported field names:
  2029. - image -> name
  2030. Tile animation definition:
  2031. - {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}
  2032. Node definition (register_node)
  2033. {
  2034. <all fields allowed in item definitions>,
  2035. drawtype = "normal", -- See "Node drawtypes"
  2036. visual_scale = 1.0,
  2037. ^ Supported for drawtypes "plantlike", "signlike", "torchlike".
  2038. ^ For plantlike, the image will start at the bottom of the node; for the
  2039. ^ other drawtypes, the image will be centered on the node.
  2040. ^ Note that positioning for "torchlike" may still change.
  2041. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  2042. ^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
  2043. ^ List can be shortened to needed length
  2044. special_tiles = {tile definition 1, Tile definition 2},
  2045. ^ Special textures of node; used rarely (old field name: special_materials)
  2046. ^ List can be shortened to needed length
  2047. alpha = 255,
  2048. use_texture_alpha = false, -- Use texture's alpha channel
  2049. post_effect_color = {a=0, r=0, g=0, b=0}, -- If player is inside node
  2050. paramtype = "none", -- See "Nodes"
  2051. paramtype2 = "none", -- See "Nodes"
  2052. is_ground_content = true, -- If false, cavegen will not carve through this
  2053. sunlight_propagates = false, -- If true, sunlight will go infinitely through this
  2054. walkable = true, -- If true, objects collide with node
  2055. pointable = true, -- If true, can be pointed at
  2056. diggable = true, -- If false, can never be dug
  2057. climbable = false, -- If true, can be climbed on (ladder)
  2058. buildable_to = false, -- If true, placed nodes can replace this node
  2059. drop = "", -- alternatively drop = { max_items = ..., items = { ... } }
  2060. liquidtype = "none", -- "none"/"source"/"flowing"
  2061. liquid_alternative_flowing = "", -- Flowing version of source liquid
  2062. liquid_alternative_source = "", -- Source version of flowing liquid
  2063. liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
  2064. liquid_renewable = true, -- Can new liquid source be created by placing two or more sources nearby?
  2065. freezemelt = "", -- water for snow/ice, ice/snow for water
  2066. leveled = 0, -- Block contain level in param2. value - default level, used for snow. Dont forget use "leveled" type nodebox
  2067. liquid_range = 8, -- number of flowing nodes arround source (max. 8)
  2068. drowning = 0, -- Player will take this amount of damage if no bubbles are left
  2069. light_source = 0, -- Amount of light emitted by node
  2070. damage_per_second = 0, -- If player is inside node, this damage is caused
  2071. node_box = {type="regular"}, -- See "Node boxes"
  2072. selection_box = {type="regular"}, -- See "Node boxes"
  2073. ^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used
  2074. legacy_facedir_simple = false, -- Support maps made in and before January 2012
  2075. legacy_wallmounted = false, -- Support maps made in and before January 2012
  2076. sounds = {
  2077. footstep = <SimpleSoundSpec>,
  2078. dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
  2079. dug = <SimpleSoundSpec>,
  2080. place = <SimpleSoundSpec>,
  2081. },
  2082. on_construct = func(pos),
  2083. ^ Node constructor; always called after adding node
  2084. ^ Can set up metadata and stuff like that
  2085. ^ default: nil
  2086. on_destruct = func(pos),
  2087. ^ Node destructor; always called before removing node
  2088. ^ default: nil
  2089. after_destruct = func(pos, oldnode),
  2090. ^ Node destructor; always called after removing node
  2091. ^ default: nil
  2092. after_place_node = func(pos, placer, itemstack, pointed_thing),
  2093. ^ Called after constructing node when node was placed using
  2094. minetest.item_place_node / minetest.place_node
  2095. ^ If return true no item is taken from itemstack
  2096. ^ default: nil
  2097. after_dig_node = func(pos, oldnode, oldmetadata, digger),
  2098. ^ oldmetadata is in table format
  2099. ^ Called after destructing node when node was dug using
  2100. minetest.node_dig / minetest.dig_node
  2101. ^ default: nil
  2102. can_dig = function(pos,player)
  2103. ^ returns true if node can be dug, or false if not
  2104. ^ default: nil
  2105. on_punch = func(pos, node, puncher, pointed_thing),
  2106. ^ default: minetest.node_punch
  2107. ^ By default: Calls minetest.register_on_punchnode callbacks
  2108. on_rightclick = func(pos, node, clicker, itemstack, pointed_thing),
  2109. ^ default: nil
  2110. ^ if defined, itemstack will hold clicker's wielded item
  2111. ^ Shall return the leftover itemstack
  2112. ^ Note: pointed_thing can be nil, if a mod calls this function
  2113. on_dig = func(pos, node, digger),
  2114. ^ default: minetest.node_dig
  2115. ^ By default: checks privileges, wears out tool and removes node
  2116. on_timer = function(pos,elapsed),
  2117. ^ default: nil
  2118. ^ called by NodeTimers, see minetest.get_node_timer and NodeTimerRef
  2119. ^ elapsed is the total time passed since the timer was started
  2120. ^ return true to run the timer for another cycle with the same timeout value
  2121. on_receive_fields = func(pos, formname, fields, sender),
  2122. ^ fields = {name1 = value1, name2 = value2, ...}
  2123. ^ Called when an UI form (eg. sign text input) returns data
  2124. ^ default: nil
  2125. allow_metadata_inventory_move = func(pos, from_list, from_index,
  2126. to_list, to_index, count, player),
  2127. ^ Called when a player wants to move items inside the inventory
  2128. ^ Return value: number of items allowed to move
  2129. allow_metadata_inventory_put = func(pos, listname, index, stack, player),
  2130. ^ Called when a player wants to put something into the inventory
  2131. ^ Return value: number of items allowed to put
  2132. ^ Return value: -1: Allow and don't modify item count in inventory
  2133. allow_metadata_inventory_take = func(pos, listname, index, stack, player),
  2134. ^ Called when a player wants to take something out of the inventory
  2135. ^ Return value: number of items allowed to take
  2136. ^ Return value: -1: Allow and don't modify item count in inventory
  2137. on_metadata_inventory_move = func(pos, from_list, from_index,
  2138. to_list, to_index, count, player),
  2139. on_metadata_inventory_put = func(pos, listname, index, stack, player),
  2140. on_metadata_inventory_take = func(pos, listname, index, stack, player),
  2141. ^ Called after the actual action has happened, according to what was allowed.
  2142. ^ No return value
  2143. on_blast = func(pos, intensity),
  2144. ^ intensity: 1.0 = mid range of regular TNT
  2145. ^ If defined, called when an explosion touches the node, instead of
  2146. removing the node
  2147. }
  2148. Recipe for register_craft: (shaped)
  2149. {
  2150. output = 'default:pick_stone',
  2151. recipe = {
  2152. {'default:cobble', 'default:cobble', 'default:cobble'},
  2153. {'', 'default:stick', ''},
  2154. {'', 'default:stick', ''}, -- Also groups; eg. 'group:crumbly'
  2155. },
  2156. replacements = <optional list of item pairs,
  2157. replace one input item with another item on crafting>
  2158. }
  2159. Recipe for register_craft (shapeless)
  2160. {
  2161. type = "shapeless",
  2162. output = 'mushrooms:mushroom_stew',
  2163. recipe = {
  2164. "mushrooms:bowl",
  2165. "mushrooms:mushroom_brown",
  2166. "mushrooms:mushroom_red",
  2167. },
  2168. replacements = <optional list of item pairs,
  2169. replace one input item with another item on crafting>
  2170. }
  2171. Recipe for register_craft (tool repair)
  2172. {
  2173. type = "toolrepair",
  2174. additional_wear = -0.02,
  2175. }
  2176. Recipe for register_craft (cooking)
  2177. {
  2178. type = "cooking",
  2179. output = "default:glass",
  2180. recipe = "default:sand",
  2181. cooktime = 3,
  2182. }
  2183. Recipe for register_craft (furnace fuel)
  2184. {
  2185. type = "fuel",
  2186. recipe = "default:leaves",
  2187. burntime = 1,
  2188. }
  2189. Ore definition (register_ore)
  2190. {
  2191. ore_type = "scatter", -- See "Ore types"
  2192. ore = "default:stone_with_coal",
  2193. wherein = "default:stone",
  2194. ^ a list of nodenames is supported too
  2195. clust_scarcity = 8*8*8,
  2196. ^ Ore has a 1 out of clust_scarcity chance of spawning in a node
  2197. ^ This value should be *MUCH* higher than your intuition might tell you!
  2198. clust_num_ores = 8,
  2199. ^ Number of ores in a cluster
  2200. clust_size = 3,
  2201. ^ Size of the bounding box of the cluster
  2202. ^ In this example, there is a 3x3x3 cluster where 8 out of the 27 nodes are coal ore
  2203. height_min = -31000,
  2204. height_max = 64,
  2205. flags = "",
  2206. ^ Attributes for this ore generation
  2207. noise_threshhold = 0.5,
  2208. ^ If noise is above this threshhold, ore is placed. Not needed for a uniform distribution
  2209. noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
  2210. ^ NoiseParams structure describing the perlin noise used for ore distribution.
  2211. ^ Needed for sheet ore_type. Omit from scatter ore_type for a uniform ore distribution
  2212. }
  2213. Decoration definition (register_decoration)
  2214. {
  2215. deco_type = "simple", -- See "Decoration types"
  2216. place_on = "default:dirt_with_grass",
  2217. ^ Node that decoration can be placed on
  2218. sidelen = 8,
  2219. ^ Size of divisions made in the chunk being generated.
  2220. ^ If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size.
  2221. fill_ratio = 0.02,
  2222. ^ Ratio of the area to be uniformly filled by the decoration.
  2223. ^ Used only if noise_params is not specified.
  2224. noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7},
  2225. ^ NoiseParams structure describing the perlin noise used for decoration distribution.
  2226. ^ The result of this is multiplied by the 2d area of the division being decorated.
  2227. biomes = {"Oceanside", "Hills", "Plains"},
  2228. ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
  2229. ^ and ignored if the Mapgen being used does not support biomes.
  2230. ----- Simple-type parameters
  2231. decoration = "default:grass",
  2232. ^ The node name used as the decoration.
  2233. ^ If instead a list of strings, a randomly selected node from the list is placed as the decoration.
  2234. height = 1,
  2235. ^ Number of nodes high the decoration is made.
  2236. ^ If height_max is not 0, this is the lower bound of the randomly selected height.
  2237. height_max = 0,
  2238. ^ Number of nodes the decoration can be at maximum.
  2239. ^ If absent, the parameter 'height' is used as a constant.
  2240. spawn_by = "default:water",
  2241. ^ Node that the decoration only spawns next to, in a 1-node square radius.
  2242. num_spawn_by = 1,
  2243. ^ Number of spawn_by nodes that must be surrounding the decoration position to occur.
  2244. ^ If absent or -1, decorations occur next to any nodes.
  2245. ----- Schematic-type parameters
  2246. schematic = "foobar.mts",
  2247. ^ If schematic is a string, it is the filepath relative to the current working directory of the
  2248. ^ specified Minetest schematic file.
  2249. ^ - OR -, could instead be a table containing two mandatory fields, size and data,
  2250. ^ and an optional table yslice_prob:
  2251. schematic = {
  2252. size = {x=4, y=6, z=4},
  2253. data = {
  2254. {name="cobble", param1=255, param2=0},
  2255. {name="dirt_with_grass", param1=255, param2=0},
  2256. ...
  2257. },
  2258. yslice_prob = {
  2259. {ypos=2, prob=128},
  2260. {ypos=5, prob=64},
  2261. ...
  2262. },
  2263. },
  2264. ^ See 'Schematic specifier' for details.
  2265. replacements = {{"oldname", "convert_to"}, ...},
  2266. flags = "place_center_x, place_center_z",
  2267. ^ Flags for schematic decorations. See 'Schematic attributes'.
  2268. rotation = "90" --rotate schematic 90 degrees on placement
  2269. ^ Rotation can be "0", "90", "180", "270", or "random".
  2270. }
  2271. Chatcommand definition (register_chatcommand)
  2272. {
  2273. params = "<name> <privilege>", -- short parameter description
  2274. description = "Remove privilege from player", -- full description
  2275. privs = {privs=true}, -- require the "privs" privilege to run
  2276. func = function(name, param), -- called when command is run
  2277. }
  2278. Detached inventory callbacks
  2279. {
  2280. allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
  2281. ^ Called when a player wants to move items inside the inventory
  2282. ^ Return value: number of items allowed to move
  2283. allow_put = func(inv, listname, index, stack, player),
  2284. ^ Called when a player wants to put something into the inventory
  2285. ^ Return value: number of items allowed to put
  2286. ^ Return value: -1: Allow and don't modify item count in inventory
  2287. allow_take = func(inv, listname, index, stack, player),
  2288. ^ Called when a player wants to take something out of the inventory
  2289. ^ Return value: number of items allowed to take
  2290. ^ Return value: -1: Allow and don't modify item count in inventory
  2291. on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
  2292. on_put = func(inv, listname, index, stack, player),
  2293. on_take = func(inv, listname, index, stack, player),
  2294. ^ Called after the actual action has happened, according to what was allowed.
  2295. ^ No return value
  2296. }
  2297. HUD Definition (hud_add, hud_get)
  2298. {
  2299. hud_elem_type = "image", -- see HUD element types
  2300. ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
  2301. position = {x=0.5, y=0.5},
  2302. ^ Left corner position of element
  2303. name = "<name>",
  2304. scale = {x=2, y=2},
  2305. text = "<text>",
  2306. number = 2,
  2307. item = 3,
  2308. ^ Selected item in inventory. 0 for no item selected.
  2309. direction = 0,
  2310. ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  2311. alignment = {x=0, y=0},
  2312. ^ See "HUD Element Types"
  2313. offset = {x=0, y=0},
  2314. ^ See "HUD Element Types"
  2315. size = { x=100, y=100 },
  2316. ^ Size of element in pixels
  2317. }
  2318. Particle definition (add_particle)
  2319. {
  2320. pos = {x=0, y=0, z=0},
  2321. velocity = {x=0, y=0, z=0},
  2322. acceleration = {x=0, y=0, z=0},
  2323. ^ Spawn particle at pos with velocity and acceleration
  2324. expirationtime = 1,
  2325. ^ Disappears after expirationtime seconds
  2326. size = 1,
  2327. collisiondetection = false,
  2328. ^ collisiondetection: if true collides with physical objects
  2329. vertical = false,
  2330. ^ vertical: if true faces player using y axis only
  2331. texture = "image.png",
  2332. ^ Uses texture (string)
  2333. playername = "singleplayer"
  2334. ^ Playername is optional, if specified spawns particle only on the player's client
  2335. }
  2336. Particlespawner definition (add_particlespawner)
  2337. {
  2338. amount = 1,
  2339. time = 1,
  2340. ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
  2341. minpos = {x=0, y=0, z=0},
  2342. maxpos = {x=0, y=0, z=0},
  2343. minvel = {x=0, y=0, z=0},
  2344. maxvel = {x=0, y=0, z=0},
  2345. minacc = {x=0, y=0, z=0},
  2346. maxacc = {x=0, y=0, z=0},
  2347. minexptime = 1,
  2348. maxexptime = 1,
  2349. minsize = 1,
  2350. maxsize = 1,
  2351. ^ The particle's properties are random values in between the boundings:
  2352. ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
  2353. ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
  2354. collisiondetection = false,
  2355. ^ collisiondetection: if true uses collisiondetection
  2356. vertical = false,
  2357. ^ vertical: if true faces player using y axis only
  2358. texture = "image.png",
  2359. ^ Uses texture (string)
  2360. playername = "singleplayer"
  2361. ^ Playername is optional, if specified spawns particle only on the player's client
  2362. }