lua_api.txt 118 KB

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