lua_api.txt 239 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472
  1. Minetest Lua Modding API Reference
  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 using Lua scripting
  8. in run-time loaded mods.
  9. A mod is a self-contained bunch of scripts, textures and other related
  10. things, which 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, and to document it here.
  15. Programming in Lua
  16. ------------------
  17. If you have any difficulty in understanding this, please read
  18. [Programming in Lua](http://www.lua.org/pil/).
  19. Startup
  20. -------
  21. Mods are loaded during server startup from the mod load paths by running
  22. the `init.lua` scripts in a shared environment.
  23. Paths
  24. -----
  25. * `RUN_IN_PLACE=1` (Windows release, local build)
  26. * `$path_user`:
  27. * Linux: `<build directory>`
  28. * Windows: `<build directory>`
  29. * `$path_share`
  30. * Linux: `<build directory>`
  31. * Windows: `<build directory>`
  32. * `RUN_IN_PLACE=0`: (Linux release)
  33. * `$path_share`
  34. * Linux: `/usr/share/minetest`
  35. * Windows: `<install directory>/minetest-0.4.x`
  36. * `$path_user`:
  37. * Linux: `$HOME/.minetest`
  38. * Windows: `C:/users/<user>/AppData/minetest` (maybe)
  39. Games
  40. -----
  41. Games are looked up from:
  42. * `$path_share/games/gameid/`
  43. * `$path_user/games/gameid/`
  44. Where `gameid` is unique to each game.
  45. The game directory can contain the following files:
  46. * `game.conf`, which contains:
  47. * `name = <Human-readable full name of the game>` e.g. `name = Minetest`
  48. * Optionally, game.conf can also contain
  49. `disallowed_mapgens = <comma-separated mapgens>`
  50. e.g. `disallowed_mapgens = v5,v6,flat`
  51. These mapgens are removed from the list of mapgens for the game.
  52. * `minetest.conf`:
  53. Used to set default settings when running this game.
  54. * `settingtypes.txt`:
  55. In the same format as the one in builtin.
  56. This settingtypes.txt will be parsed by the menu and the settings will be
  57. displayed in the "Games" category in the advanced settings tab.
  58. * If the subgame contains a folder called `textures` the server will load it
  59. as a texturepack, overriding mod textures.
  60. Any server texturepack will override mod textures and the game texturepack.
  61. ### Menu images
  62. Games can provide custom main menu images. They are put inside a `menu`
  63. directory inside the game directory.
  64. The images are named `$identifier.png`, where `$identifier` is one of
  65. `overlay`, `background`, `footer`, `header`.
  66. If you want to specify multiple images for one identifier, add additional
  67. images named like `$identifier.$n.png`, with an ascending number $n starting
  68. with 1, and a random image will be chosen from the provided ones.
  69. Mod load path
  70. -------------
  71. Generic:
  72. * `$path_share/games/gameid/mods/`
  73. * `$path_share/mods/`
  74. * `$path_user/games/gameid/mods/`
  75. * `$path_user/mods/` (User-installed mods)
  76. * `$worldpath/worldmods/`
  77. In a run-in-place version (e.g. the distributed windows version):
  78. * `minetest-0.4.x/games/gameid/mods/`
  79. * `minetest-0.4.x/mods/` (User-installed mods)
  80. * `minetest-0.4.x/worlds/worldname/worldmods/`
  81. On an installed version on Linux:
  82. * `/usr/share/minetest/games/gameid/mods/`
  83. * `$HOME/.minetest/mods/` (User-installed mods)
  84. * `$HOME/.minetest/worlds/worldname/worldmods`
  85. Mod load path for world-specific games
  86. --------------------------------------
  87. It is possible to include a game in a world; in this case, no mods or
  88. games are loaded or checked from anywhere else.
  89. This is useful for e.g. adventure worlds.
  90. This happens if the following directory exists:
  91. $world/game/
  92. Mods should be then be placed in:
  93. $world/game/mods/
  94. Modpack support
  95. ----------------
  96. Mods can be put in a subdirectory, if the parent directory, which otherwise
  97. should be a mod, contains a file named `modpack.txt`. This file shall be
  98. empty, except for lines starting with `#`, which are comments.
  99. Mod directory structure
  100. ------------------------
  101. mods
  102. |-- modname
  103. | |-- depends.txt
  104. | |-- screenshot.png
  105. | |-- description.txt
  106. | |-- settingtypes.txt
  107. | |-- init.lua
  108. | |-- models
  109. | |-- textures
  110. | | |-- modname_stuff.png
  111. | | `-- modname_something_else.png
  112. | |-- sounds
  113. | |-- media
  114. | |-- locale
  115. | `-- <custom data>
  116. `-- another
  117. ### modname
  118. The location of this directory can be fetched by using
  119. `minetest.get_modpath(modname)`.
  120. ### `depends.txt`
  121. List of mods that have to be loaded before loading this mod.
  122. A single line contains a single modname.
  123. Optional dependencies can be defined by appending a question mark
  124. to a single modname. This means that if the specified mod
  125. is missing, it does not prevent this mod from being loaded.
  126. ### `screenshot.png`
  127. A screenshot shown in the mod manager within the main menu. It should
  128. have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
  129. ### `description.txt`
  130. A file containing a description to be shown in the Mods tab of the mainmenu.
  131. ### `settingtypes.txt`
  132. A file in the same format as the one in builtin. It will be parsed by the
  133. settings menu and the settings will be displayed in the "Mods" category.
  134. ### `init.lua`
  135. The main Lua script. Running this script should register everything it
  136. wants to register. Subsequent execution depends on minetest calling the
  137. registered callbacks.
  138. `minetest.settings` can be used to read custom or existing settings at load
  139. time, if necessary. (See `Settings`)
  140. ### `models`
  141. Models for entities or meshnodes.
  142. ### `textures`, `sounds`, `media`
  143. Media files (textures, sounds, whatever) that will be transferred to the
  144. client and will be available for use by the mod.
  145. ### `locale`
  146. Translation files for the clients. (See `Translations`)
  147. Naming convention for registered textual names
  148. ----------------------------------------------
  149. Registered names should generally be in this format:
  150. `modname:<whatever>`
  151. `<whatever>` can have these characters:
  152. a-zA-Z0-9_
  153. This is to prevent conflicting names from corrupting maps and is
  154. enforced by the mod loader.
  155. ### Example
  156. In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
  157. So the name should be `experimental:tnt`.
  158. Enforcement can be overridden by prefixing the name with `:`. This can
  159. be used for overriding the registrations of some other mod.
  160. Example: Any mod can redefine `experimental:tnt` by using the name
  161. :experimental:tnt
  162. when registering it.
  163. (also that mod is required to have `experimental` as a dependency)
  164. The `:` prefix can also be used for maintaining backwards compatibility.
  165. Aliases
  166. -------
  167. Aliases can be added by using `minetest.register_alias(name, convert_to)` or
  168. `minetest.register_alias_force(name, convert_to)`.
  169. This converts anything called `name` to `convert_to`.
  170. The only difference between `minetest.register_alias` and
  171. `minetest.register_alias_force` is that if an item called `name` exists,
  172. `minetest.register_alias` will do nothing while
  173. `minetest.register_alias_force` will unregister it.
  174. This can be used for maintaining backwards compatibility.
  175. This can also set quick access names for things, e.g. if
  176. you have an item called `epiclylongmodname:stuff`, you could do
  177. minetest.register_alias("stuff", "epiclylongmodname:stuff")
  178. and be able to use `/giveme stuff`.
  179. Mapgen aliases
  180. --------------
  181. In a game, a certain number of these must be set to tell core mapgens which
  182. of the game's nodes are to be used by the core mapgens. For example:
  183. minetest.register_alias("mapgen_stone", "default:stone")
  184. ### Aliases needed for all mapgens except Mapgen v6
  185. Base terrain:
  186. "mapgen_stone"
  187. "mapgen_water_source"
  188. "mapgen_river_water_source"
  189. Caves:
  190. "mapgen_lava_source"
  191. Dungeons:
  192. Only needed for registered biomes where 'node_stone' is stone:
  193. "mapgen_cobble"
  194. "mapgen_stair_cobble"
  195. "mapgen_mossycobble"
  196. Only needed for registered biomes where 'node_stone' is desert stone:
  197. "mapgen_desert_stone"
  198. "mapgen_stair_desert_stone"
  199. Only needed for registered biomes where 'node_stone' is sandstone:
  200. "mapgen_sandstone"
  201. "mapgen_sandstonebrick"
  202. "mapgen_stair_sandstone_block"
  203. ### Aliases needed for Mapgen v6
  204. Terrain and biomes:
  205. "mapgen_stone"
  206. "mapgen_water_source"
  207. "mapgen_lava_source"
  208. "mapgen_dirt"
  209. "mapgen_dirt_with_grass"
  210. "mapgen_sand"
  211. "mapgen_gravel"
  212. "mapgen_desert_stone"
  213. "mapgen_desert_sand"
  214. "mapgen_dirt_with_snow"
  215. "mapgen_snowblock"
  216. "mapgen_snow"
  217. "mapgen_ice"
  218. Flora:
  219. "mapgen_tree"
  220. "mapgen_leaves"
  221. "mapgen_apple"
  222. "mapgen_jungletree"
  223. "mapgen_jungleleaves"
  224. "mapgen_junglegrass"
  225. "mapgen_pine_tree"
  226. "mapgen_pine_needles"
  227. Dungeons:
  228. "mapgen_cobble"
  229. "mapgen_stair_cobble"
  230. "mapgen_mossycobble"
  231. "mapgen_stair_desert_stone"
  232. Textures
  233. --------
  234. Mods should generally prefix their textures with `modname_`, e.g. given
  235. the mod name `foomod`, a texture could be called:
  236. foomod_foothing.png
  237. Textures are referred to by their complete name, or alternatively by
  238. stripping out the file extension:
  239. * e.g. `foomod_foothing.png`
  240. * e.g. `foomod_foothing`
  241. Texture modifiers
  242. -----------------
  243. There are various texture modifiers that can be used
  244. to generate textures on-the-fly.
  245. ### Texture overlaying
  246. Textures can be overlaid by putting a `^` between them.
  247. Example:
  248. default_dirt.png^default_grass_side.png
  249. `default_grass_side.png` is overlaid over `default_dirt.png`.
  250. The texture with the lower resolution will be automatically upscaled to
  251. the higher resolution texture.
  252. ### Texture grouping
  253. Textures can be grouped together by enclosing them in `(` and `)`.
  254. Example: `cobble.png^(thing1.png^thing2.png)`
  255. A texture for `thing1.png^thing2.png` is created and the resulting
  256. texture is overlaid on top of `cobble.png`.
  257. ### Escaping
  258. Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
  259. passing complex texture names as arguments. Escaping is done with backslash and
  260. is required for `^` and `:`.
  261. Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
  262. The lower 50 percent of `color.png^[mask:trans.png` are overlaid
  263. on top of `cobble.png`.
  264. ### Advanced texture modifiers
  265. #### Crack
  266. * `[crack:<n>:<p>`
  267. * `[cracko:<n>:<p>`
  268. * `[crack:<t>:<n>:<p>`
  269. * `[cracko:<t>:<n>:<p>`
  270. Parameters:
  271. * `<t>` = tile count (in each direction)
  272. * `<n>` = animation frame count
  273. * `<p>` = current animation frame
  274. Draw a step of the crack animation on the texture.
  275. `crack` draws it normally, while `cracko` lays it over, keeping transparent
  276. pixels intact.
  277. Example:
  278. default_cobble.png^[crack:10:1
  279. #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
  280. * `<w>` = width
  281. * `<h>` = height
  282. * `<x>` = x position
  283. * `<y>` = y position
  284. * `<file>` = texture to combine
  285. Creates a texture of size `<w>` times `<h>` and blits the listed files to their
  286. specified coordinates.
  287. Example:
  288. [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
  289. #### `[resize:<w>x<h>`
  290. Resizes the texture to the given dimensions.
  291. Example:
  292. default_sandstone.png^[resize:16x16
  293. #### `[opacity:<r>`
  294. Makes the base image transparent according to the given ratio.
  295. `r` must be between 0 and 255.
  296. 0 means totally transparent. 255 means totally opaque.
  297. Example:
  298. default_sandstone.png^[opacity:127
  299. #### `[invert:<mode>`
  300. Inverts the given channels of the base image.
  301. Mode may contain the characters "r", "g", "b", "a".
  302. Only the channels that are mentioned in the mode string will be inverted.
  303. Example:
  304. default_apple.png^[invert:rgb
  305. #### `[brighten`
  306. Brightens the texture.
  307. Example:
  308. tnt_tnt_side.png^[brighten
  309. #### `[noalpha`
  310. Makes the texture completely opaque.
  311. Example:
  312. default_leaves.png^[noalpha
  313. #### `[makealpha:<r>,<g>,<b>`
  314. Convert one color to transparency.
  315. Example:
  316. default_cobble.png^[makealpha:128,128,128
  317. #### `[transform<t>`
  318. * `<t>` = transformation(s) to apply
  319. Rotates and/or flips the image.
  320. `<t>` can be a number (between 0 and 7) or a transform name.
  321. Rotations are counter-clockwise.
  322. 0 I identity
  323. 1 R90 rotate by 90 degrees
  324. 2 R180 rotate by 180 degrees
  325. 3 R270 rotate by 270 degrees
  326. 4 FX flip X
  327. 5 FXR90 flip X then rotate by 90 degrees
  328. 6 FY flip Y
  329. 7 FYR90 flip Y then rotate by 90 degrees
  330. Example:
  331. default_stone.png^[transformFXR90
  332. #### `[inventorycube{<top>{<left>{<right>`
  333. Escaping does not apply here and `^` is replaced by `&` in texture names
  334. instead.
  335. Create an inventory cube texture using the side textures.
  336. Example:
  337. [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
  338. Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
  339. `dirt.png^grass_side.png` textures
  340. #### `[lowpart:<percent>:<file>`
  341. Blit the lower `<percent>`% part of `<file>` on the texture.
  342. Example:
  343. base.png^[lowpart:25:overlay.png
  344. #### `[verticalframe:<t>:<n>`
  345. * `<t>` = animation frame count
  346. * `<n>` = current animation frame
  347. Crops the texture to a frame of a vertical animation.
  348. Example:
  349. default_torch_animated.png^[verticalframe:16:8
  350. #### `[mask:<file>`
  351. Apply a mask to the base image.
  352. The mask is applied using binary AND.
  353. #### `[sheet:<w>x<h>:<x>,<y>`
  354. Retrieves a tile at position x,y from the base image
  355. which it assumes to be a tilesheet with dimensions w,h.
  356. #### `[colorize:<color>:<ratio>`
  357. Colorize the textures with the given color.
  358. `<color>` is specified as a `ColorString`.
  359. `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
  360. it is an int, then it specifies how far to interpolate between the
  361. colors where 0 is only the texture color and 255 is only `<color>`. If
  362. omitted, the alpha of `<color>` will be used as the ratio. If it is
  363. the word "`alpha`", then each texture pixel will contain the RGB of
  364. `<color>` and the alpha of `<color>` multiplied by the alpha of the
  365. texture pixel.
  366. #### `[multiply:<color>`
  367. Multiplies texture colors with the given color.
  368. `<color>` is specified as a `ColorString`.
  369. Result is more like what you'd expect if you put a color on top of another
  370. color. Meaning white surfaces get a lot of your new color while black parts
  371. don't change very much.
  372. Hardware coloring
  373. -----------------
  374. The goal of hardware coloring is to simplify the creation of
  375. colorful nodes. If your textures use the same pattern, and they only
  376. differ in their color (like colored wool blocks), you can use hardware
  377. coloring instead of creating and managing many texture files.
  378. All of these methods use color multiplication (so a white-black texture
  379. with red coloring will result in red-black color).
  380. ### Static coloring
  381. This method is useful if you wish to create nodes/items with
  382. the same texture, in different colors, each in a new node/item definition.
  383. #### Global color
  384. When you register an item or node, set its `color` field (which accepts a
  385. `ColorSpec`) to the desired color.
  386. An `ItemStack`s static color can be overwritten by the `color` metadata
  387. field. If you set that field to a `ColorString`, that color will be used.
  388. #### Tile color
  389. Each tile may have an individual static color, which overwrites every
  390. other coloring methods. To disable the coloring of a face,
  391. set its color to white (because multiplying with white does nothing).
  392. You can set the `color` property of the tiles in the node's definition
  393. if the tile is in table format.
  394. ### Palettes
  395. For nodes and items which can have many colors, a palette is more
  396. suitable. A palette is a texture, which can contain up to 256 pixels.
  397. Each pixel is one possible color for the node/item.
  398. You can register one node/item, which can have up to 256 colors.
  399. #### Palette indexing
  400. When using palettes, you always provide a pixel index for the given
  401. node or `ItemStack`. The palette is read from left to right and from
  402. top to bottom. If the palette has less than 256 pixels, then it is
  403. stretched to contain exactly 256 pixels (after arranging the pixels
  404. to one line). The indexing starts from 0.
  405. Examples:
  406. * 16x16 palette, index = 0: the top left corner
  407. * 16x16 palette, index = 4: the fifth pixel in the first row
  408. * 16x16 palette, index = 16: the pixel below the top left corner
  409. * 16x16 palette, index = 255: the bottom right corner
  410. * 2 (width)x4 (height) palette, index=31: the top left corner.
  411. The palette has 8 pixels, so each pixel is stretched to 32 pixels,
  412. to ensure the total 256 pixels.
  413. * 2x4 palette, index=32: the top right corner
  414. * 2x4 palette, index=63: the top right corner
  415. * 2x4 palette, index=64: the pixel below the top left corner
  416. #### Using palettes with items
  417. When registering an item, set the item definition's `palette` field to
  418. a texture. You can also use texture modifiers.
  419. The `ItemStack`'s color depends on the `palette_index` field of the
  420. stack's metadata. `palette_index` is an integer, which specifies the
  421. index of the pixel to use.
  422. #### Linking palettes with nodes
  423. When registering a node, set the item definition's `palette` field to
  424. a texture. You can also use texture modifiers.
  425. The node's color depends on its `param2`, so you also must set an
  426. appropriate `drawtype`:
  427. * `drawtype = "color"` for nodes which use their full `param2` for
  428. palette indexing. These nodes can have 256 different colors.
  429. The palette should contain 256 pixels.
  430. * `drawtype = "colorwallmounted"` for nodes which use the first
  431. five bits (most significant) of `param2` for palette indexing.
  432. The remaining three bits are describing rotation, as in `wallmounted`
  433. draw type. Division by 8 yields the palette index (without stretching the
  434. palette). These nodes can have 32 different colors, and the palette
  435. should contain 32 pixels.
  436. Examples:
  437. * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
  438. pixel will be picked from the palette.
  439. * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
  440. pixel will be picked from the palette.
  441. * `drawtype = "colorfacedir"` for nodes which use the first
  442. three bits of `param2` for palette indexing. The remaining
  443. five bits are describing rotation, as in `facedir` draw type.
  444. Division by 32 yields the palette index (without stretching the
  445. palette). These nodes can have 8 different colors, and the
  446. palette should contain 8 pixels.
  447. Examples:
  448. * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
  449. first (= 0 + 1) pixel will be picked from the palette.
  450. * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
  451. second (= 1 + 1) pixel will be picked from the palette.
  452. To colorize a node on the map, set its `param2` value (according
  453. to the node's draw type).
  454. ### Conversion between nodes in the inventory and the on the map
  455. Static coloring is the same for both cases, there is no need
  456. for conversion.
  457. If the `ItemStack`'s metadata contains the `color` field, it will be
  458. lost on placement, because nodes on the map can only use palettes.
  459. If the `ItemStack`'s metadata contains the `palette_index` field, it is
  460. automatically transferred between node and item forms by the engine,
  461. when a player digs or places a colored node.
  462. You can disable this feature by setting the `drop` field of the node
  463. to itself (without metadata).
  464. To transfer the color to a special drop, you need a drop table.
  465. Example:
  466. minetest.register_node("mod:stone", {
  467. description = "Stone",
  468. tiles = {"default_stone.png"},
  469. paramtype2 = "color",
  470. palette = "palette.png",
  471. drop = {
  472. items = {
  473. -- assume that mod:cobblestone also has the same palette
  474. {items = {"mod:cobblestone"}, inherit_color = true },
  475. }
  476. }
  477. })
  478. ### Colored items in craft recipes
  479. Craft recipes only support item strings, but fortunately item strings
  480. can also contain metadata. Example craft recipe registration:
  481. minetest.register_craft({
  482. output = minetest.itemstring_with_palette("wool:block", 3),
  483. type = "shapeless",
  484. recipe = {
  485. "wool:block",
  486. "dye:red",
  487. },
  488. })
  489. To set the `color` field, you can use `minetest.itemstring_with_color`.
  490. Metadata field filtering in the `recipe` field are not supported yet,
  491. so the craft output is independent of the color of the ingredients.
  492. Soft texture overlay
  493. --------------------
  494. Sometimes hardware coloring is not enough, because it affects the
  495. whole tile. Soft texture overlays were added to Minetest to allow
  496. the dynamic coloring of only specific parts of the node's texture.
  497. For example a grass block may have colored grass, while keeping the
  498. dirt brown.
  499. These overlays are 'soft', because unlike texture modifiers, the layers
  500. are not merged in the memory, but they are simply drawn on top of each
  501. other. This allows different hardware coloring, but also means that
  502. tiles with overlays are drawn slower. Using too much overlays might
  503. cause FPS loss.
  504. For inventory and wield images you can specify overlays which
  505. hardware coloring does not modify. You have to set `inventory_overlay`
  506. and `wield_overlay` fields to an image name.
  507. To define a node overlay, simply set the `overlay_tiles` field of the node
  508. definition. These tiles are defined in the same way as plain tiles:
  509. they can have a texture name, color etc.
  510. To skip one face, set that overlay tile to an empty string.
  511. Example (colored grass block):
  512. minetest.register_node("default:dirt_with_grass", {
  513. description = "Dirt with Grass",
  514. -- Regular tiles, as usual
  515. -- The dirt tile disables palette coloring
  516. tiles = {{name = "default_grass.png"},
  517. {name = "default_dirt.png", color = "white"}},
  518. -- Overlay tiles: define them in the same style
  519. -- The top and bottom tile does not have overlay
  520. overlay_tiles = {"", "",
  521. {name = "default_grass_side.png", tileable_vertical = false}},
  522. -- Global color, used in inventory
  523. color = "green",
  524. -- Palette in the world
  525. paramtype2 = "color",
  526. palette = "default_foilage.png",
  527. })
  528. Sounds
  529. ------
  530. Only Ogg Vorbis files are supported.
  531. For positional playing of sounds, only single-channel (mono) files are
  532. supported. Otherwise OpenAL will play them non-positionally.
  533. Mods should generally prefix their sounds with `modname_`, e.g. given
  534. the mod name "`foomod`", a sound could be called:
  535. foomod_foosound.ogg
  536. Sounds are referred to by their name with a dot, a single digit and the
  537. file extension stripped out. When a sound is played, the actual sound file
  538. is chosen randomly from the matching sounds.
  539. When playing the sound `foomod_foosound`, the sound is chosen randomly
  540. from the available ones of the following files:
  541. * `foomod_foosound.ogg`
  542. * `foomod_foosound.0.ogg`
  543. * `foomod_foosound.1.ogg`
  544. * (...)
  545. * `foomod_foosound.9.ogg`
  546. Examples of sound parameter tables:
  547. -- Play locationless on all clients
  548. {
  549. gain = 1.0, -- default
  550. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  551. pitch = 1.0, -- default
  552. }
  553. -- Play locationless to one player
  554. {
  555. to_player = name,
  556. gain = 1.0, -- default
  557. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  558. pitch = 1.0, -- default
  559. }
  560. -- Play locationless to one player, looped
  561. {
  562. to_player = name,
  563. gain = 1.0, -- default
  564. loop = true,
  565. }
  566. -- Play in a location
  567. {
  568. pos = {x = 1, y = 2, z = 3},
  569. gain = 1.0, -- default
  570. max_hear_distance = 32, -- default, uses an euclidean metric
  571. }
  572. -- Play connected to an object, looped
  573. {
  574. object = <an ObjectRef>,
  575. gain = 1.0, -- default
  576. max_hear_distance = 32, -- default, uses an euclidean metric
  577. loop = true,
  578. }
  579. Looped sounds must either be connected to an object or played locationless to
  580. one player using `to_player = name,`
  581. ### `SimpleSoundSpec`
  582. * e.g. `""`
  583. * e.g. `"default_place_node"`
  584. * e.g. `{}`
  585. * e.g. `{name = "default_place_node"}`
  586. * e.g. `{name = "default_place_node", gain = 1.0}`
  587. * e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}`
  588. Registered definitions of stuff
  589. -------------------------------
  590. Anything added using certain `minetest.register_*` functions get added to
  591. the global `minetest.registered_*` tables.
  592. * `minetest.register_entity(name, prototype table)`
  593. * added to `minetest.registered_entities[name]`
  594. * `minetest.register_node(name, node definition)`
  595. * added to `minetest.registered_items[name]`
  596. * added to `minetest.registered_nodes[name]`
  597. * `minetest.register_tool(name, item definition)`
  598. * added to `minetest.registered_items[name]`
  599. * `minetest.register_craftitem(name, item definition)`
  600. * added to `minetest.registered_items[name]`
  601. * `minetest.unregister_item(name)`
  602. * Unregisters the item name from engine, and deletes the entry with key
  603. * `name` from `minetest.registered_items` and from the associated item
  604. * table according to its nature: `minetest.registered_nodes[]` etc
  605. * `minetest.register_biome(biome definition)`
  606. * returns an integer uniquely identifying the registered biome
  607. * added to `minetest.registered_biome` with the key of `biome.name`
  608. * if `biome.name` is nil, the key is the returned ID
  609. * `minetest.unregister_biome(name)`
  610. * Unregisters the biome name from engine, and deletes the entry with key
  611. * `name` from `minetest.registered_biome`
  612. * `minetest.register_ore(ore definition)`
  613. * returns an integer uniquely identifying the registered ore
  614. * added to `minetest.registered_ores` with the key of `ore.name`
  615. * if `ore.name` is nil, the key is the returned ID
  616. * `minetest.register_decoration(decoration definition)`
  617. * returns an integer uniquely identifying the registered decoration
  618. * added to `minetest.registered_decorations` with the key of
  619. `decoration.name`.
  620. * if `decoration.name` is nil, the key is the returned ID
  621. * `minetest.register_schematic(schematic definition)`
  622. * returns an integer uniquely identifying the registered schematic
  623. * added to `minetest.registered_schematic` with the key of `schematic.name`
  624. * if `schematic.name` is nil, the key is the returned ID
  625. * if the schematic is loaded from a file, schematic.name is set to the
  626. filename.
  627. * if the function is called when loading the mod, and schematic.name is a
  628. relative path, then the current mod path will be prepended to the
  629. schematic filename.
  630. * `minetest.clear_registered_biomes()`
  631. * clears all biomes currently registered
  632. * `minetest.clear_registered_ores()`
  633. * clears all ores currently registered
  634. * `minetest.clear_registered_decorations()`
  635. * clears all decorations currently registered
  636. * `minetest.clear_registered_schematics()`
  637. * clears all schematics currently registered
  638. Note that in some cases you will stumble upon things that are not contained
  639. in these tables (e.g. when a mod has been removed). Always check for
  640. existence before trying to access the fields.
  641. Example: If you want to check the drawtype of a node, you could do:
  642. local function get_nodedef_field(nodename, fieldname)
  643. if not minetest.registered_nodes[nodename] then
  644. return nil
  645. end
  646. return minetest.registered_nodes[nodename][fieldname]
  647. end
  648. local drawtype = get_nodedef_field(nodename, "drawtype")
  649. Example: `minetest.get_item_group(name, group)` has been implemented as:
  650. function minetest.get_item_group(name, group)
  651. if not minetest.registered_items[name] or not
  652. minetest.registered_items[name].groups[group] then
  653. return 0
  654. end
  655. return minetest.registered_items[name].groups[group]
  656. end
  657. Nodes
  658. -----
  659. Nodes are the bulk data of the world: cubes and other things that take the
  660. space of a cube. Huge amounts of them are handled efficiently, but they
  661. are quite static.
  662. The definition of a node is stored and can be accessed by name in
  663. minetest.registered_nodes[node.name]
  664. See "Registered definitions of stuff".
  665. Nodes are passed by value between Lua and the engine.
  666. They are represented by a table:
  667. {name="name", param1=num, param2=num}
  668. `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
  669. them for certain automated functions. If you don't use these functions, you can
  670. use them to store arbitrary values.
  671. The functions of `param1` and `param2` are determined by certain fields in the
  672. node definition:
  673. `param1` is reserved for the engine when `paramtype != "none"`:
  674. paramtype = "light"
  675. ^ The value stores light with and without sun in its upper and lower 4 bits
  676. respectively. Allows light to propagate from or through the node with
  677. light value falling by 1 per node. This is essential for a light source
  678. node to spread its light.
  679. `param2` is reserved for the engine when any of these are used:
  680. liquidtype == "flowing"
  681. ^ The level and some flags of the liquid is stored in param2
  682. drawtype == "flowingliquid"
  683. ^ The drawn liquid level is read from param2
  684. drawtype == "torchlike"
  685. drawtype == "signlike"
  686. paramtype2 == "wallmounted"
  687. ^ The rotation of the node is stored in param2. You can make this value
  688. by using minetest.dir_to_wallmounted().
  689. paramtype2 == "facedir"
  690. ^ The rotation of the node is stored in param2. Furnaces and chests are
  691. rotated this way. Can be made by using minetest.dir_to_facedir().
  692. Values range 0 - 23
  693. facedir / 4 = axis direction:
  694. 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
  695. facedir modulo 4 = rotation around that axis
  696. paramtype2 == "leveled"
  697. ^ Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
  698. Leveled nodebox:
  699. The level of the top face of the nodebox is stored in param2.
  700. The other faces are defined by 'fixed = {}' like 'type = "fixed"'
  701. nodeboxes.
  702. The nodebox height is (param2 / 64) nodes.
  703. The maximum accepted value of param2 is 127.
  704. Rooted plantlike:
  705. The height of the 'plantlike' section is stored in param2.
  706. The height is (param2 / 16) nodes.
  707. paramtype2 == "degrotate"
  708. ^ Only valid for "plantlike". The rotation of the node is stored in param2.
  709. Values range 0 - 179. The value stored in param2 is multiplied by two to
  710. get the actual rotation in degrees of the node.
  711. paramtype2 == "meshoptions"
  712. ^ Only valid for "plantlike". The value of param2 becomes a bitfield which
  713. can be used to change how the client draws plantlike nodes.
  714. Bits 0, 1 and 2 form a mesh selector.
  715. Currently the following meshes are choosable:
  716. 0 = a "x" shaped plant (ordinary plant)
  717. 1 = a "+" shaped plant (just rotated 45 degrees)
  718. 2 = a "*" shaped plant with 3 faces instead of 2
  719. 3 = a "#" shaped plant with 4 faces instead of 2
  720. 4 = a "#" shaped plant with 4 faces that lean outwards
  721. 5-7 are unused and reserved for future meshes.
  722. Bits 3 through 7 are optional flags that can be combined and give these
  723. effects:
  724. bit 3 (0x08) - Makes the plant slightly vary placement horizontally
  725. bit 4 (0x10) - Makes the plant mesh 1.4x larger
  726. bit 5 (0x20) - Moves each face randomly a small bit down (1/8 max)
  727. bits 6-7 are reserved for future use.
  728. paramtype2 == "color"
  729. ^ `param2` tells which color is picked from the palette.
  730. The palette should have 256 pixels.
  731. paramtype2 == "colorfacedir"
  732. ^ Same as `facedir`, but with colors.
  733. The first three bits of `param2` tells which color
  734. is picked from the palette.
  735. The palette should have 8 pixels.
  736. paramtype2 == "colorwallmounted"
  737. ^ Same as `wallmounted`, but with colors.
  738. The first five bits of `param2` tells which color
  739. is picked from the palette.
  740. The palette should have 32 pixels.
  741. paramtype2 == "glasslikeliquidlevel"
  742. ^ Only valid for "glasslike_framed" or "glasslike_framed_optional"
  743. drawtypes.
  744. param2 values 0-63 define 64 levels of internal liquid, 0 being empty and
  745. 63 being full.
  746. Liquid texture is defined using `special_tiles = {"modname_tilename.png"},`
  747. Nodes can also contain extra data. See "Node Metadata".
  748. Node drawtypes
  749. --------------
  750. There are a bunch of different looking node types.
  751. Look for examples in `games/minimal` or `games/minetest_game`.
  752. * `normal`
  753. * `airlike`
  754. * `liquid`
  755. * `flowingliquid`
  756. * `glasslike`
  757. * `glasslike_framed`
  758. * `glasslike_framed_optional`
  759. * `allfaces`
  760. * `allfaces_optional`
  761. * `torchlike`
  762. * `signlike`
  763. * `plantlike`
  764. * `firelike`
  765. * `fencelike`
  766. * `raillike`
  767. * `nodebox` -- See below
  768. * `mesh` -- Use models for nodes, see below
  769. * `plantlike_rooted` -- See below
  770. `*_optional` drawtypes need less rendering time if deactivated
  771. (always client side).
  772. Node boxes
  773. ----------
  774. Node selection boxes are defined using "node boxes"
  775. The `nodebox` node drawtype allows defining nodes consisting of an arbitrary
  776. number of boxes. It allows defining stuff like stairs and slabs.
  777. A nodebox is defined as any of:
  778. {
  779. -- A normal cube; the default in most things
  780. type = "regular"
  781. }
  782. {
  783. -- A fixed box (or boxes) (facedir param2 is used, if applicable)
  784. type = "fixed",
  785. fixed = box OR {box1, box2, ...}
  786. }
  787. {
  788. -- A variable height box (or boxes) with the top face position defined
  789. -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
  790. -- by param2.
  791. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
  792. type = "leveled",
  793. fixed = box OR {box1, box2, ...}
  794. }
  795. {
  796. -- A box like the selection box for torches
  797. -- (wallmounted param2 is used, if applicable)
  798. type = "wallmounted",
  799. wall_top = box,
  800. wall_bottom = box,
  801. wall_side = box
  802. }
  803. {
  804. -- A node that has optional boxes depending on neighbouring nodes'
  805. -- presence and type. See also `connects_to`.
  806. type = "connected",
  807. fixed = box OR {box1, box2, ...}
  808. connect_top = box OR {box1, box2, ...}
  809. connect_bottom = box OR {box1, box2, ...}
  810. connect_front = box OR {box1, box2, ...}
  811. connect_left = box OR {box1, box2, ...}
  812. connect_back = box OR {box1, box2, ...}
  813. connect_right = box OR {box1, box2, ...}
  814. -- The following `disconnected_*` boxes are the opposites of the
  815. -- `connect_*` ones above, i.e. when a node has no suitable neighbour
  816. -- on the respective side, the corresponding disconnected box is drawn.
  817. disconnected_top = box OR {box1, box2, ...}
  818. disconnected_bottom = box OR {box1, box2, ...}
  819. disconnected_front = box OR {box1, box2, ...}
  820. disconnected_left = box OR {box1, box2, ...}
  821. disconnected_back = box OR {box1, box2, ...}
  822. disconnected_right = box OR {box1, box2, ...}
  823. disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
  824. disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
  825. neighbours to the sides
  826. }
  827. A `box` is defined as:
  828. {x1, y1, z1, x2, y2, z2}
  829. A box of a regular node would look like:
  830. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  831. Meshes
  832. ------
  833. If drawtype `mesh` is used, tiles should hold model materials textures.
  834. Only static meshes are implemented.
  835. For supported model formats see Irrlicht engine documentation.
  836. Rooted plantlike drawtype
  837. -------------------------
  838. The `plantlike_rooted` drawtype was developed to enable underwater plants
  839. without air bubbles around the plants.
  840. It consists of a base cube at the co-ordinates of the node (the seabed /
  841. lakebed / riverbed node) plus a 'plantlike' extension above with a height
  842. defined by param2 (maximum height 16 nodes). This extension visually passes
  843. through any nodes above the base cube without affecting them.
  844. The node is dug by digging the base cube.
  845. The base cube texture tiles are defined as normal, the plantlike extension
  846. uses the defined 'special tile', for example:
  847. `special_tiles = {{name = "default_papyrus.png", tileable_vertical = true}},`
  848. Noise Parameters
  849. ----------------
  850. Noise Parameters, or commonly called "`NoiseParams`", define the properties of
  851. perlin noise.
  852. ### `offset`
  853. Offset that the noise is translated by (i.e. added) after calculation.
  854. ### `scale`
  855. Factor that the noise is scaled by (i.e. multiplied) after calculation.
  856. ### `spread`
  857. Vector containing values by which each coordinate is divided by before
  858. calculation.
  859. Higher spread values result in larger noise features.
  860. A value of `{x=250, y=250, z=250}` is common.
  861. ### `seed`
  862. Random seed for the noise. Add the world seed to a seed offset for world-unique
  863. noise. In the case of `minetest.get_perlin()`, this value has the world seed
  864. automatically added.
  865. ### `octaves`
  866. Number of times the noise gradient is accumulated into the noise.
  867. Increase this number to increase the amount of detail in the resulting noise.
  868. A value of `6` is common.
  869. ### `persistence`
  870. Factor by which the effect of the noise gradient function changes with each
  871. successive octave.
  872. Values less than `1` make the details of successive octaves' noise diminish,
  873. while values greater than `1` make successive octaves stronger.
  874. A value of `0.6` is common.
  875. ### `lacunarity`
  876. Factor by which the noise feature sizes change with each successive octave.
  877. A value of `2.0` is common.
  878. ### `flags`
  879. Leave this field unset for no special handling.
  880. Currently supported are `defaults`, `eased` and `absvalue`.
  881. #### `defaults`
  882. Specify this if you would like to keep auto-selection of eased/not-eased while
  883. specifying some other flags.
  884. #### `eased`
  885. Maps noise gradient values onto a quintic S-curve before performing
  886. interpolation. This results in smooth, rolling noise.
  887. Disable this (`noeased`) for sharp-looking noise.
  888. If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
  889. not eased.
  890. #### `absvalue`
  891. Accumulates the absolute value of each noise gradient result.
  892. Noise parameters format example for 2D or 3D perlin noise or perlin noise maps:
  893. np_terrain = {
  894. offset = 0,
  895. scale = 1,
  896. spread = {x=500, y=500, z=500},
  897. seed = 571347,
  898. octaves = 5,
  899. persist = 0.63,
  900. lacunarity = 2.0,
  901. flags = "defaults, absvalue"
  902. }
  903. ^ A single noise parameter table can be used to get 2D or 3D noise,
  904. when getting 2D noise spread.z is ignored.
  905. Ore types
  906. ---------
  907. These tell in what manner the ore is generated.
  908. All default ores are of the uniformly-distributed scatter type.
  909. ### `scatter`
  910. Randomly chooses a location and generates a cluster of ore.
  911. If `noise_params` is specified, the ore will be placed if the 3D perlin noise
  912. at that point is greater than the `noise_threshold`, giving the ability to
  913. create a non-equal distribution of ore.
  914. ### `sheet`
  915. Creates a sheet of ore in a blob shape according to the 2D perlin noise
  916. described by `noise_params` and `noise_threshold`. This is essentially an
  917. improved version of the so-called "stratus" ore seen in some unofficial mods.
  918. This sheet consists of vertical columns of uniform randomly distributed height,
  919. varying between the inclusive range `column_height_min` and `column_height_max`.
  920. If `column_height_min` is not specified, this parameter defaults to 1.
  921. If `column_height_max` is not specified, this parameter defaults to `clust_size`
  922. for reverse compatibility. New code should prefer `column_height_max`.
  923. The `column_midpoint_factor` parameter controls the position of the column at
  924. which ore emanates from.
  925. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
  926. equally starting from each direction.
  927. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
  928. this parameter is not specified, the default is 0.5.
  929. The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
  930. ore type.
  931. ### `puff`
  932. Creates a sheet of ore in a cloud-like puff shape.
  933. As with the `sheet` ore type, the size and shape of puffs are described by
  934. `noise_params` and `noise_threshold` and are placed at random vertical
  935. positions within the currently generated chunk.
  936. The vertical top and bottom displacement of each puff are determined by the
  937. noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
  938. ### `blob`
  939. Creates a deformed sphere of ore according to 3d perlin noise described by
  940. `noise_params`. The maximum size of the blob is `clust_size`, and
  941. `clust_scarcity` has the same meaning as with the `scatter` type.
  942. ### `vein`
  943. Creates veins of ore varying in density by according to the intersection of two
  944. instances of 3d perlin noise with different seeds, both described by
  945. `noise_params`.
  946. `random_factor` varies the influence random chance has on placement of an ore
  947. inside the vein, which is `1` by default. Note that modifying this parameter
  948. may require adjusting `noise_threshold`.
  949. The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
  950. by this ore type.
  951. This ore type is difficult to control since it is sensitive to small changes.
  952. The following is a decent set of parameters to work from:
  953. noise_params = {
  954. offset = 0,
  955. scale = 3,
  956. spread = {x=200, y=200, z=200},
  957. seed = 5390,
  958. octaves = 4,
  959. persist = 0.5,
  960. flags = "eased",
  961. },
  962. noise_threshold = 1.6
  963. **WARNING**: Use this ore type *very* sparingly since it is ~200x more
  964. computationally expensive than any other ore.
  965. ### `stratum`
  966. Creates a single undulating ore stratum that is continuous across mapchunk
  967. borders and horizontally spans the world.
  968. The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
  969. the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
  970. defines the stratum's vertical thickness (in units of nodes). Due to being
  971. continuous across mapchunk borders the stratum's vertical thickness is
  972. unlimited.
  973. If the noise parameter `noise_params` is omitted the ore will occur from y_min
  974. to y_max in a simple horizontal stratum.
  975. A parameter `stratum_thickness` can be provided instead of the noise parameter
  976. `np_stratum_thickness`, to create a constant thickness.
  977. Leaving out one or both noise parameters makes the ore generation less
  978. intensive, useful when adding multiple strata.
  979. `y_min` and `y_max` define the limits of the ore generation and for performance
  980. reasons should be set as close together as possible but without clipping the
  981. stratum's Y variation.
  982. Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
  983. solid-ore stratum would require a `clust_scarcity` of 1.
  984. The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
  985. `random_factor` are ignored by this ore type.
  986. Ore attributes
  987. --------------
  988. See section "Flag Specifier Format".
  989. Currently supported flags:
  990. `puff_cliffs`, `puff_additive_composition`.
  991. ### `puff_cliffs`
  992. If set, puff ore generation will not taper down large differences in
  993. displacement when approaching the edge of a puff. This flag has no effect for
  994. ore types other than `puff`.
  995. ### `puff_additive_composition`
  996. By default, when noise described by `np_puff_top` or `np_puff_bottom` results
  997. in a negative displacement, the sub-column at that point is not generated. With
  998. this attribute set, puff ore generation will instead generate the absolute
  999. difference in noise displacement values. This flag has no effect for ore types
  1000. other than `puff`.
  1001. Decoration types
  1002. ----------------
  1003. The varying types of decorations that can be placed.
  1004. ### `simple`
  1005. Creates a 1 times `H` times 1 column of a specified node (or a random node from
  1006. a list, if a decoration list is specified). Can specify a certain node it must
  1007. spawn next to, such as water or lava, for example. Can also generate a
  1008. decoration of random height between a specified lower and upper bound.
  1009. This type of decoration is intended for placement of grass, flowers, cacti,
  1010. papyri, waterlilies and so on.
  1011. ### `schematic`
  1012. Copies a box of `MapNodes` from a specified schematic file (or raw description).
  1013. Can specify a probability of a node randomly appearing when placed.
  1014. This decoration type is intended to be used for multi-node sized discrete
  1015. structures, such as trees, cave spikes, rocks, and so on.
  1016. Schematic specifier
  1017. --------------------
  1018. A schematic specifier identifies a schematic by either a filename to a
  1019. Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  1020. in the form of a table. This table specifies the following fields:
  1021. * The `size` field is a 3D vector containing the dimensions of the provided
  1022. schematic. (required)
  1023. * The `yslice_prob` field is a table of {ypos, prob} which sets the `ypos`th
  1024. vertical slice of the schematic to have a `prob / 256 * 100` chance of
  1025. occurring. (default: 255)
  1026. * The `data` field is a flat table of MapNode tables making up the schematic,
  1027. in the order of `[z [y [x]]]`. (required)
  1028. Each MapNode table contains:
  1029. * `name`: the name of the map node to place (required)
  1030. * `prob` (alias `param1`): the probability of this node being placed
  1031. (default: 255)
  1032. * `param2`: the raw param2 value of the node being placed onto the map
  1033. (default: 0)
  1034. * `force_place`: boolean representing if the node should forcibly overwrite
  1035. any previous contents (default: false)
  1036. About probability values:
  1037. * A probability value of `0` or `1` means that node will never appear
  1038. (0% chance).
  1039. * A probability value of `254` or `255` means the node will always appear
  1040. (100% chance).
  1041. * If the probability value `p` is greater than `1`, then there is a
  1042. `(p / 256 * 100)` percent chance that node will appear when the schematic is
  1043. placed on the map.
  1044. Schematic attributes
  1045. --------------------
  1046. See section "Flag Specifier Format".
  1047. Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
  1048. `force_placement`.
  1049. * `place_center_x`: Placement of this decoration is centered along the X axis.
  1050. * `place_center_y`: Placement of this decoration is centered along the Y axis.
  1051. * `place_center_z`: Placement of this decoration is centered along the Z axis.
  1052. * `force_placement`: Schematic nodes other than "ignore" will replace existing
  1053. nodes.
  1054. HUD element types
  1055. -----------------
  1056. The position field is used for all element types.
  1057. To account for differing resolutions, the position coordinates are the percentage
  1058. of the screen, ranging in value from `0` to `1`.
  1059. The name field is not yet used, but should contain a description of what the
  1060. HUD element represents. The direction field is the direction in which something
  1061. is drawn.
  1062. `0` draws from left to right, `1` draws from right to left, `2` draws from
  1063. top to bottom, and `3` draws from bottom to top.
  1064. The `alignment` field specifies how the item will be aligned. It ranges from `-1` to `1`,
  1065. with `0` being the center, `-1` is moved to the left/up, and `1` is to the right/down.
  1066. Fractional values can be used.
  1067. The `offset` field specifies a pixel offset from the position. Contrary to position,
  1068. the offset is not scaled to screen size. This allows for some precisely-positioned
  1069. items in the HUD.
  1070. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling factor!
  1071. Below are the specific uses for fields in each type; fields not listed for that type are ignored.
  1072. **Note**: Future revisions to the HUD API may be incompatible; the HUD API is still
  1073. in the experimental stages.
  1074. ### `image`
  1075. Displays an image on the HUD.
  1076. * `scale`: The scale of the image, with 1 being the original texture size.
  1077. Only the X coordinate scale is used (positive values).
  1078. Negative values represent that percentage of the screen it
  1079. should take; e.g. `x=-100` means 100% (width).
  1080. * `text`: The name of the texture that is displayed.
  1081. * `alignment`: The alignment of the image.
  1082. * `offset`: offset in pixels from position.
  1083. ### `text`
  1084. Displays text on the HUD.
  1085. * `scale`: Defines the bounding rectangle of the text.
  1086. A value such as `{x=100, y=100}` should work.
  1087. * `text`: The text to be displayed in the HUD element.
  1088. * `number`: An integer containing the RGB value of the color used to draw the text.
  1089. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
  1090. * `alignment`: The alignment of the text.
  1091. * `offset`: offset in pixels from position.
  1092. ### `statbar`
  1093. Displays a horizontal bar made up of half-images.
  1094. * `text`: The name of the texture that is used.
  1095. * `number`: The number of half-textures that are displayed.
  1096. If odd, will end with a vertically center-split texture.
  1097. * `direction`
  1098. * `offset`: offset in pixels from position.
  1099. * `size`: If used, will force full-image size to this value (override texture pack image size)
  1100. ### `inventory`
  1101. * `text`: The name of the inventory list to be displayed.
  1102. * `number`: Number of items in the inventory to be displayed.
  1103. * `item`: Position of item that is selected.
  1104. * `direction`
  1105. * `offset`: offset in pixels from position.
  1106. ### `waypoint`
  1107. Displays distance to selected world position.
  1108. * `name`: The name of the waypoint.
  1109. * `text`: Distance suffix. Can be blank.
  1110. * `number:` An integer containing the RGB value of the color used to draw the text.
  1111. * `world_pos`: World position of the waypoint.
  1112. Representations of simple things
  1113. --------------------------------
  1114. ### Position/vector
  1115. {x=num, y=num, z=num}
  1116. For helper functions see "Vector helpers".
  1117. ### `pointed_thing`
  1118. * `{type="nothing"}`
  1119. * `{type="node", under=pos, above=pos}`
  1120. * `{type="object", ref=ObjectRef}`
  1121. Flag Specifier Format
  1122. ---------------------
  1123. Flags using the standardized flag specifier format can be specified in either of
  1124. two ways, by string or table.
  1125. The string format is a comma-delimited set of flag names; whitespace and
  1126. unrecognized flag fields are ignored. Specifying a flag in the string sets the
  1127. flag, and specifying a flag prefixed by the string `"no"` explicitly
  1128. clears the flag from whatever the default may be.
  1129. In addition to the standard string flag format, the schematic flags field can
  1130. also be a table of flag names to boolean values representing whether or not the
  1131. flag is set. Additionally, if a field with the flag name prefixed with `"no"`
  1132. is present, mapped to a boolean of any value, the specified flag is unset.
  1133. E.g. A flag field of value
  1134. {place_center_x = true, place_center_y=false, place_center_z=true}
  1135. is equivalent to
  1136. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  1137. which is equivalent to
  1138. "place_center_x, noplace_center_y, place_center_z"
  1139. or even
  1140. "place_center_x, place_center_z"
  1141. since, by default, no schematic attributes are set.
  1142. Items
  1143. -----
  1144. ### Item types
  1145. There are three kinds of items: nodes, tools and craftitems.
  1146. * Node (`register_node`): A node from the world.
  1147. * Tool (`register_tool`): A tool/weapon that can dig and damage
  1148. things according to `tool_capabilities`.
  1149. * Craftitem (`register_craftitem`): A miscellaneous item.
  1150. ### Amount and wear
  1151. All item stacks have an amount between 0 to 65535. It is 1 by
  1152. default. Tool item stacks can not have an amount greater than 1.
  1153. Tools use a wear (=damage) value ranging from 0 to 65535. The
  1154. value 0 is the default and used is for unworn tools. The values
  1155. 1 to 65535 are used for worn tools, where a higher value stands for
  1156. a higher wear. Non-tools always have a wear value of 0.
  1157. ### Item formats
  1158. Items and item stacks can exist in three formats: Serializes, table format
  1159. and `ItemStack`.
  1160. #### Serialized
  1161. This is called "stackstring" or "itemstring". It is a simple string with
  1162. 1-3 components: the full item identifier, an optional amount and an optional
  1163. wear value. Syntax:
  1164. <identifier> [<amount>[ <wear>]]
  1165. Examples:
  1166. * `'default:apple'`: 1 apple
  1167. * `'default:dirt 5'`: 5 dirt
  1168. * `'default:pick_stone'`: a new stone pickaxe
  1169. * `'default:pick_wood 1 21323'`: a wooden pickaxe, ca. 1/3 worn out
  1170. #### Table format
  1171. Examples:
  1172. 5 dirt nodes:
  1173. {name="default:dirt", count=5, wear=0, metadata=""}
  1174. A wooden pick about 1/3 worn out:
  1175. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  1176. An apple:
  1177. {name="default:apple", count=1, wear=0, metadata=""}
  1178. #### `ItemStack`
  1179. A native C++ format with many helper methods. Useful for converting
  1180. between formats. See the Class reference section for details.
  1181. When an item must be passed to a function, it can usually be in any of
  1182. these formats.
  1183. Groups
  1184. ------
  1185. In a number of places, there is a group table. Groups define the
  1186. properties of a thing (item, node, armor of entity, capabilities of
  1187. tool) in such a way that the engine and other mods can can interact with
  1188. the thing without actually knowing what the thing is.
  1189. ### Usage
  1190. Groups are stored in a table, having the group names with keys and the
  1191. group ratings as values. For example:
  1192. groups = {crumbly=3, soil=1}
  1193. -- ^ Default dirt
  1194. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  1195. -- ^ A more special dirt-kind of thing
  1196. Groups always have a rating associated with them. If there is no
  1197. useful meaning for a rating for an enabled group, it shall be `1`.
  1198. When not defined, the rating of a group defaults to `0`. Thus when you
  1199. read groups, you must interpret `nil` and `0` as the same value, `0`.
  1200. You can read the rating of a group for an item or a node by using
  1201. minetest.get_item_group(itemname, groupname)
  1202. ### Groups of items
  1203. Groups of items can define what kind of an item it is (e.g. wool).
  1204. ### Groups of nodes
  1205. In addition to the general item things, groups are used to define whether
  1206. a node is destroyable and how long it takes to destroy by a tool.
  1207. ### Groups of entities
  1208. For entities, groups are, as of now, used only for calculating damage.
  1209. The rating is the percentage of damage caused by tools with this damage group.
  1210. See "Entity damage mechanism".
  1211. object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
  1212. object.set_armor_groups({fleshy=30, cracky=80})
  1213. ### Groups of tools
  1214. Groups in tools define which groups of nodes and entities they are
  1215. effective towards.
  1216. ### Groups in crafting recipes
  1217. An example: Make meat soup from any meat, any water and any bowl:
  1218. {
  1219. output = 'food:meat_soup_raw',
  1220. recipe = {
  1221. {'group:meat'},
  1222. {'group:water'},
  1223. {'group:bowl'},
  1224. },
  1225. -- preserve = {'group:bowl'}, -- Not implemented yet (TODO)
  1226. }
  1227. Another example: Make red wool from white wool and red dye:
  1228. {
  1229. type = 'shapeless',
  1230. output = 'wool:red',
  1231. recipe = {'wool:white', 'group:dye,basecolor_red'},
  1232. }
  1233. ### Special groups
  1234. * `immortal`: Disables the group damage system for an entity
  1235. * `punch_operable`: For entities; disables the regular damage mechanism for
  1236. players punching it by hand or a non-tool item, so that it can do something
  1237. else than take damage.
  1238. * `level`: Can be used to give an additional sense of progression in the game.
  1239. * A larger level will cause e.g. a weapon of a lower level make much less
  1240. damage, and get worn out much faster, or not be able to get drops
  1241. from destroyed nodes.
  1242. * `0` is something that is directly accessible at the start of gameplay
  1243. * There is no upper limit
  1244. * `dig_immediate`: (player can always pick up node without reducing tool wear)
  1245. * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
  1246. * `3`: the node always gets the digging time 0 seconds (torch)
  1247. * `disable_jump`: Player (and possibly other things) cannot jump from node
  1248. * `fall_damage_add_percent`: damage speed = `speed * (1 + value/100)`
  1249. * `bouncy`: value is bounce speed in percent
  1250. * `falling_node`: if there is no walkable block under the node it will fall
  1251. * `attached_node`: if the node under it is not a walkable block the node will be
  1252. dropped as an item. If the node is wallmounted the wallmounted direction is
  1253. checked.
  1254. * `soil`: saplings will grow on nodes in this group
  1255. * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
  1256. connect to each other
  1257. * `slippery`: Players and items will slide on the node.
  1258. Slipperiness rises steadily with `slippery` value, starting at 1.
  1259. ### Known damage and digging time defining groups
  1260. * `crumbly`: dirt, sand
  1261. * `cracky`: tough but crackable stuff like stone.
  1262. * `snappy`: something that can be cut using fine tools; e.g. leaves, small
  1263. plants, wire, sheets of metal
  1264. * `choppy`: something that can be cut using force; e.g. trees, wooden planks
  1265. * `fleshy`: Living things like animals and the player. This could imply
  1266. some blood effects when hitting.
  1267. * `explody`: Especially prone to explosions
  1268. * `oddly_breakable_by_hand`:
  1269. Can be added to nodes that shouldn't logically be breakable by the
  1270. hand but are. Somewhat similar to `dig_immediate`, but times are more
  1271. like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
  1272. speed of a tool if the tool can dig at a faster speed than this
  1273. suggests for the hand.
  1274. ### Examples of custom groups
  1275. Item groups are often used for defining, well, _groups of items_.
  1276. * `meat`: any meat-kind of a thing (rating might define the size or healing
  1277. ability or be irrelevant -- it is not defined as of yet)
  1278. * `eatable`: anything that can be eaten. Rating might define HP gain in half
  1279. hearts.
  1280. * `flammable`: can be set on fire. Rating might define the intensity of the
  1281. fire, affecting e.g. the speed of the spreading of an open fire.
  1282. * `wool`: any wool (any origin, any color)
  1283. * `metal`: any metal
  1284. * `weapon`: any weapon
  1285. * `heavy`: anything considerably heavy
  1286. ### Digging time calculation specifics
  1287. Groups such as `crumbly`, `cracky` and `snappy` are used for this
  1288. purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
  1289. faster digging time.
  1290. The `level` group is used to limit the toughness of nodes a tool can dig
  1291. and to scale the digging times / damage to a greater extent.
  1292. **Please do understand this**, otherwise you cannot use the system to it's
  1293. full potential.
  1294. Tools define their properties by a list of parameters for groups. They
  1295. cannot dig other groups; thus it is important to use a standard bunch of
  1296. groups to enable interaction with tools.
  1297. #### Tools definition
  1298. Tools define:
  1299. * Full punch interval
  1300. * Maximum drop level
  1301. * For an arbitrary list of groups:
  1302. * Uses (until the tool breaks)
  1303. * Maximum level (usually `0`, `1`, `2` or `3`)
  1304. * Digging times
  1305. * Damage groups
  1306. #### Full punch interval
  1307. When used as a weapon, the tool will do full damage if this time is spent
  1308. between punches. If e.g. half the time is spent, the tool will do half
  1309. damage.
  1310. #### Maximum drop level
  1311. Suggests the maximum level of node, when dug with the tool, that will drop
  1312. it's useful item. (e.g. iron ore to drop a lump of iron).
  1313. This is not automated; it is the responsibility of the node definition
  1314. to implement this.
  1315. #### Uses
  1316. Determines how many uses the tool has when it is used for digging a node,
  1317. of this group, of the maximum level. For lower leveled nodes, the use count
  1318. is multiplied by `3^leveldiff`.
  1319. * `uses=10, leveldiff=0`: actual uses: 10
  1320. * `uses=10, leveldiff=1`: actual uses: 30
  1321. * `uses=10, leveldiff=2`: actual uses: 90
  1322. #### Maximum level
  1323. Tells what is the maximum level of a node of this group that the tool will
  1324. be able to dig.
  1325. #### Digging times
  1326. List of digging times for different ratings of the group, for nodes of the
  1327. maximum level.
  1328. For example, as a Lua table, `times={2=2.00, 3=0.70}`. This would
  1329. result in the tool to be able to dig nodes that have a rating of `2` or `3`
  1330. for this group, and unable to dig the rating `1`, which is the toughest.
  1331. Unless there is a matching group that enables digging otherwise.
  1332. If the result digging time is 0, a delay of 0.15 seconds is added between
  1333. digging nodes; If the player releases LMB after digging, this delay is set to 0,
  1334. i.e. players can more quickly click the nodes away instead of holding LMB.
  1335. #### Damage groups
  1336. List of damage for groups of entities. See "Entity damage mechanism".
  1337. #### Example definition of the capabilities of a tool
  1338. tool_capabilities = {
  1339. full_punch_interval=1.5,
  1340. max_drop_level=1,
  1341. groupcaps={
  1342. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  1343. }
  1344. damage_groups = {fleshy=2},
  1345. }
  1346. This makes the tool be able to dig nodes that fulfil both of these:
  1347. * Have the `crumbly` group
  1348. * Have a `level` group less or equal to `2`
  1349. Table of resulting digging times:
  1350. crumbly 0 1 2 3 4 <- level
  1351. -> 0 - - - - -
  1352. 1 0.80 1.60 1.60 - -
  1353. 2 0.60 1.20 1.20 - -
  1354. 3 0.40 0.80 0.80 - -
  1355. level diff: 2 1 0 -1 -2
  1356. Table of resulting tool uses:
  1357. -> 0 - - - - -
  1358. 1 180 60 20 - -
  1359. 2 180 60 20 - -
  1360. 3 180 60 20 - -
  1361. **Notes**:
  1362. * At `crumbly==0`, the node is not diggable.
  1363. * At `crumbly==3`, the level difference digging time divider kicks in and makes
  1364. easy nodes to be quickly breakable.
  1365. * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
  1366. Entity damage mechanism
  1367. -----------------------
  1368. Damage calculation:
  1369. damage = 0
  1370. foreach group in cap.damage_groups:
  1371. damage += cap.damage_groups[group] * limit(actual_interval /
  1372. cap.full_punch_interval, 0.0, 1.0)
  1373. * (object.armor_groups[group] / 100.0)
  1374. -- Where object.armor_groups[group] is 0 for inexistent values
  1375. return damage
  1376. Client predicts damage based on damage groups. Because of this, it is able to
  1377. give an immediate response when an entity is damaged or dies; the response is
  1378. pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
  1379. TODO).
  1380. Currently a smoke puff will appear when an entity dies.
  1381. The group `immortal` completely disables normal damage.
  1382. Entities can define a special armor group, which is `punch_operable`. This
  1383. group disables the regular damage mechanism for players punching it by hand or
  1384. a non-tool item, so that it can do something else than take damage.
  1385. On the Lua side, every punch calls:
  1386. entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage)
  1387. This should never be called directly, because damage is usually not handled by
  1388. the entity itself.
  1389. * `puncher` is the object performing the punch. Can be `nil`. Should never be
  1390. accessed unless absolutely required, to encourage interoperability.
  1391. * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
  1392. * `tool_capabilities` can be `nil`.
  1393. * `direction` is a unit vector, pointing from the source of the punch to
  1394. the punched object.
  1395. * `damage` damage that will be done to entity
  1396. Return value of this function will determine if damage is done by this function
  1397. (retval true) or shall be done by engine (retval false)
  1398. To punch an entity/object in Lua, call:
  1399. object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1400. * Return value is tool wear.
  1401. * Parameters are equal to the above callback.
  1402. * If `direction` equals `nil` and `puncher` does not equal `nil`,
  1403. `direction` will be automatically filled in based on the location of `puncher`.
  1404. Node Metadata
  1405. -------------
  1406. The instance of a node in the world normally only contains the three values
  1407. mentioned in "Nodes". However, it is possible to insert extra data into a
  1408. node. It is called "node metadata"; See `NodeMetaRef`.
  1409. Node metadata contains two things:
  1410. * A key-value store
  1411. * An inventory
  1412. Some of the values in the key-value store are handled specially:
  1413. * `formspec`: Defines a right-click inventory menu. See "Formspec".
  1414. * `infotext`: Text shown on the screen when the node is pointed at
  1415. Example stuff:
  1416. local meta = minetest.get_meta(pos)
  1417. meta:set_string("formspec",
  1418. "size[8,9]"..
  1419. "list[context;main;0,0;8,4;]"..
  1420. "list[current_player;main;0,5;8,4;]")
  1421. meta:set_string("infotext", "Chest");
  1422. local inv = meta:get_inventory()
  1423. inv:set_size("main", 8*4)
  1424. print(dump(meta:to_table()))
  1425. meta:from_table({
  1426. inventory = {
  1427. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
  1428. [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
  1429. [10] = "", [11] = "", [12] = "", [13] = "",
  1430. [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
  1431. [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
  1432. [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
  1433. [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
  1434. [32] = ""}
  1435. },
  1436. fields = {
  1437. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  1438. infotext = "Chest"
  1439. }
  1440. })
  1441. Item Metadata
  1442. -------------
  1443. Item stacks can store metadata too. See `ItemStackMetaRef`.
  1444. Item metadata only contains a key-value store.
  1445. Some of the values in the key-value store are handled specially:
  1446. * `description`: Set the item stack's description. Defaults to `idef.description`
  1447. * `color`: A `ColorString`, which sets the stack's color.
  1448. * `palette_index`: If the item has a palette, this is used to get the
  1449. current color from the palette.
  1450. Example stuff:
  1451. local meta = stack:get_meta()
  1452. meta:set_string("key", "value")
  1453. print(dump(meta:to_table()))
  1454. Formspec
  1455. --------
  1456. Formspec defines a menu. Currently not much else than inventories are
  1457. supported. It is a string, with a somewhat strange format.
  1458. Spaces and newlines can be inserted between the blocks, as is used in the
  1459. examples.
  1460. ### Examples
  1461. #### Chest
  1462. size[8,9]
  1463. list[context;main;0,0;8,4;]
  1464. list[current_player;main;0,5;8,4;]
  1465. #### Furnace
  1466. size[8,9]
  1467. list[context;fuel;2,3;1,1;]
  1468. list[context;src;2,1;1,1;]
  1469. list[context;dst;5,1;2,2;]
  1470. list[current_player;main;0,5;8,4;]
  1471. #### Minecraft-like player inventory
  1472. size[8,7.5]
  1473. image[1,0.6;1,2;player.png]
  1474. list[current_player;main;0,3.5;8,4;]
  1475. list[current_player;craft;3,0;3,3;]
  1476. list[current_player;craftpreview;7,1;1,1;]
  1477. ### Elements
  1478. #### `size[<W>,<H>,<fixed_size>]`
  1479. * Define the size of the menu in inventory slots
  1480. * `fixed_size`: `true`/`false` (optional)
  1481. * deprecated: `invsize[<W>,<H>;]`
  1482. #### `position[<X>,<Y>]`
  1483. * Must be used after `size` element.
  1484. * Defines the position on the game window of the formspec's `anchor` point.
  1485. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window, for example:
  1486. * [0.0, 0.0] sets the position to the top left corner of the game window.
  1487. * [1.0, 1.0] sets the position to the bottom right of the game window.
  1488. * Defaults to the center of the game window [0.5, 0.5].
  1489. #### `anchor[<X>,<Y>]`
  1490. * Must be used after both `size` and `position` (if present) elements.
  1491. * Defines the location of the anchor point within the formspec.
  1492. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec, for example:
  1493. * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
  1494. * [1.0, 0.0] sets the anchor to the top right of the formspec.
  1495. * Defaults to the center of the formspec [0.5, 0.5].
  1496. * `position` and `anchor` elements need suitable values to avoid a formspec
  1497. extending off the game window due to particular game window sizes.
  1498. #### `container[<X>,<Y>]`
  1499. * Start of a container block, moves all physical elements in the container by (X, Y)
  1500. * Must have matching `container_end`
  1501. * Containers can be nested, in which case the offsets are added
  1502. (child containers are relative to parent containers)
  1503. #### `container_end[]`
  1504. * End of a container, following elements are no longer relative to this container
  1505. #### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]`
  1506. * Show an inventory list
  1507. #### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
  1508. * Show an inventory list
  1509. #### `listring[<inventory location>;<list name>]`
  1510. * Allows to create a ring of inventory lists
  1511. * Shift-clicking on items in one element of the ring
  1512. will send them to the next inventory list inside the ring
  1513. * The first occurrence of an element inside the ring will
  1514. determine the inventory where items will be sent to
  1515. #### `listring[]`
  1516. * Shorthand for doing `listring[<inventory location>;<list name>]`
  1517. for the last two inventory lists added by list[...]
  1518. #### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
  1519. * Sets background color of slots as `ColorString`
  1520. * Sets background color of slots on mouse hovering
  1521. #### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
  1522. * Sets background color of slots as `ColorString`
  1523. * Sets background color of slots on mouse hovering
  1524. * Sets color of slots border
  1525. #### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
  1526. * Sets background color of slots as `ColorString`
  1527. * Sets background color of slots on mouse hovering
  1528. * Sets color of slots border
  1529. * Sets default background color of tooltips
  1530. * Sets default font color of tooltips
  1531. #### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1532. * Adds tooltip for an element
  1533. * `<bgcolor>` tooltip background color as `ColorString` (optional)
  1534. * `<fontcolor>` tooltip font color as `ColorString` (optional)
  1535. #### `image[<X>,<Y>;<W>,<H>;<texture name>]`
  1536. * Show an image
  1537. * Position and size units are inventory slots
  1538. #### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
  1539. * Show an inventory image of registered item/node
  1540. * Position and size units are inventory slots
  1541. #### `bgcolor[<color>;<fullscreen>]`
  1542. * Sets background color of formspec as `ColorString`
  1543. * If `true`, the background color is drawn fullscreen (does not effect the size of the formspec)
  1544. #### `background[<X>,<Y>;<W>,<H>;<texture name>]`
  1545. * Use a background. Inventory rectangles are not drawn then.
  1546. * Position and size units are inventory slots
  1547. * Example for formspec 8x4 in 16x resolution: image shall be sized
  1548. 8 times 16px times 4 times 16px.
  1549. #### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
  1550. * Use a background. Inventory rectangles are not drawn then.
  1551. * Position and size units are inventory slots
  1552. * Example for formspec 8x4 in 16x resolution:
  1553. image shall be sized 8 times 16px times 4 times 16px
  1554. * If `true` the background is clipped to formspec size
  1555. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1556. #### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1557. * Textual password style field; will be sent to server when a button is clicked
  1558. * When enter is pressed in field, fields.key_enter_field will be sent with the name
  1559. of this field.
  1560. * `x` and `y` position the field relative to the top left of the menu
  1561. * `w` and `h` are the size of the field
  1562. * Fields are a set height, but will be vertically centred on `h`
  1563. * Position and size units are inventory slots
  1564. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1565. * `label`, if not blank, will be text printed on the top left above the field
  1566. * See field_close_on_enter to stop enter closing the formspec
  1567. #### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1568. * Textual field; will be sent to server when a button is clicked
  1569. * When enter is pressed in field, `fields.key_enter_field` will be sent with the name
  1570. of this field.
  1571. * `x` and `y` position the field relative to the top left of the menu
  1572. * `w` and `h` are the size of the field
  1573. * Fields are a set height, but will be vertically centred on `h`
  1574. * Position and size units are inventory slots
  1575. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1576. * `label`, if not blank, will be text printed on the top left above the field
  1577. * `default` is the default value of the field
  1578. * `default` may contain variable references such as `${text}'` which
  1579. will fill the value from the metadata value `text`
  1580. * **Note**: no extra text or more than a single variable is supported ATM.
  1581. * See `field_close_on_enter` to stop enter closing the formspec
  1582. #### `field[<name>;<label>;<default>]`
  1583. * As above, but without position/size units
  1584. * When enter is pressed in field, `fields.key_enter_field` will be sent with the name
  1585. of this field.
  1586. * Special field for creating simple forms, such as sign text input
  1587. * Must be used without a `size[]` element
  1588. * A "Proceed" button will be added automatically
  1589. * See `field_close_on_enter` to stop enter closing the formspec
  1590. #### `field_close_on_enter[<name>;<close_on_enter>]`
  1591. * <name> is the name of the field
  1592. * if <close_on_enter> is false, pressing enter in the field will submit the form but not close it
  1593. * defaults to true when not specified (ie: no tag for a field)
  1594. #### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1595. * Same as fields above, but with multi-line input
  1596. * if the text overflows a vertical scrollbar is added
  1597. * if the name is empty the textarea is readonly. The label is not displayed then
  1598. #### `label[<X>,<Y>;<label>]`
  1599. * `x` and `y` work as per field
  1600. * `label` is the text on the label
  1601. * Position and size units are inventory slots
  1602. #### `vertlabel[<X>,<Y>;<label>]`
  1603. * Textual label drawn vertically
  1604. * `x` and `y` work as per field
  1605. * `label` is the text on the label
  1606. * Position and size units are inventory slots
  1607. #### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1608. * Clickable button. When clicked, fields will be sent.
  1609. * `x`, `y` and `name` work as per field
  1610. * `w` and `h` are the size of the button
  1611. * Fixed button height. It will be vertically centred on `h`
  1612. * `label` is the text on the button
  1613. * Position and size units are inventory slots
  1614. #### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1615. * `x`, `y`, `w`, `h`, and `name` work as per button
  1616. * `texture name` is the filename of an image
  1617. * Position and size units are inventory slots
  1618. #### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
  1619. * `x`, `y`, `w`, `h`, and `name` work as per button
  1620. * `texture name` is the filename of an image
  1621. * Position and size units are inventory slots
  1622. * `noclip=true` means the image button doesn't need to be within specified formsize
  1623. * `drawborder`: draw button border or not
  1624. * `pressed texture name` is the filename of an image on pressed state
  1625. #### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
  1626. * `x`, `y`, `w`, `h`, `name` and `label` work as per button
  1627. * `item name` is the registered name of an item/node,
  1628. tooltip will be made out of its description
  1629. to override it use tooltip element
  1630. * Position and size units are inventory slots
  1631. #### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1632. * When clicked, fields will be sent and the form will quit.
  1633. #### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1634. * When clicked, fields will be sent and the form will quit.
  1635. #### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
  1636. * Scrollable item list showing arbitrary text elements
  1637. * `x` and `y` position the itemlist relative to the top left of the menu
  1638. * `w` and `h` are the size of the itemlist
  1639. * `name` fieldname sent to server on doubleclick value is current selected element
  1640. * `listelements` can be prepended by #color in hexadecimal format RRGGBB (only),
  1641. * if you want a listelement to start with "#" write "##".
  1642. #### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
  1643. * Scrollable itemlist showing arbitrary text elements
  1644. * `x` and `y` position the item list relative to the top left of the menu
  1645. * `w` and `h` are the size of the item list
  1646. * `name` fieldname sent to server on doubleclick value is current selected element
  1647. * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
  1648. * if you want a listelement to start with "#" write "##"
  1649. * Index to be selected within textlist
  1650. * `true`/`false`: draw transparent background
  1651. * See also `minetest.explode_textlist_event` (main menu: `engine.explode_textlist_event`)
  1652. #### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  1653. * Show a tab**header** at specific position (ignores formsize)
  1654. * `x` and `y` position the itemlist relative to the top left of the menu
  1655. * `name` fieldname data is transferred to Lua
  1656. * `caption 1`...: name shown on top of tab
  1657. * `current_tab`: index of selected tab 1...
  1658. * `transparent` (optional): show transparent
  1659. * `draw_border` (optional): draw border
  1660. #### `box[<X>,<Y>;<W>,<H>;<color>]`
  1661. * Simple colored semitransparent box
  1662. * `x` and `y` position the box relative to the top left of the menu
  1663. * `w` and `h` are the size of box
  1664. * `color` is color specified as a `ColorString`
  1665. #### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]`
  1666. * Show a dropdown field
  1667. * **Important note**: There are two different operation modes:
  1668. 1. handle directly on change (only changed dropdown is submitted)
  1669. 2. read the value on pressing a button (all dropdown values are available)
  1670. * `x` and `y` position of dropdown
  1671. * Width of dropdown
  1672. * Fieldname data is transferred to Lua
  1673. * Items to be shown in dropdown
  1674. * Index of currently selected dropdown item
  1675. #### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
  1676. * Show a checkbox
  1677. * `x` and `y`: position of checkbox
  1678. * `name` fieldname data is transferred to Lua
  1679. * `label` to be shown left of checkbox
  1680. * `selected` (optional): `true`/`false`
  1681. #### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
  1682. * Show a scrollbar
  1683. * There are two ways to use it:
  1684. 1. handle the changed event (only changed scrollbar is available)
  1685. 2. read the value on pressing a button (all scrollbars are available)
  1686. * `x` and `y`: position of trackbar
  1687. * `w` and `h`: width and height
  1688. * `orientation`: `vertical`/`horizontal`
  1689. * Fieldname data is transferred to Lua
  1690. * Value this trackbar is set to (`0`-`1000`)
  1691. * See also `minetest.explode_scrollbar_event` (main menu: `engine.explode_scrollbar_event`)
  1692. #### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
  1693. * Show scrollable table using options defined by the previous `tableoptions[]`
  1694. * Displays cells as defined by the previous `tablecolumns[]`
  1695. * `x` and `y`: position the itemlist relative to the top left of the menu
  1696. * `w` and `h` are the size of the itemlist
  1697. * `name`: fieldname sent to server on row select or doubleclick
  1698. * `cell 1`...`cell n`: cell contents given in row-major order
  1699. * `selected idx`: index of row to be selected within table (first row = `1`)
  1700. * See also `minetest.explode_table_event` (main menu: `engine.explode_table_event`)
  1701. #### `tableoptions[<opt 1>;<opt 2>;...]`
  1702. * Sets options for `table[]`
  1703. * `color=#RRGGBB`
  1704. * default text color (`ColorString`), defaults to `#FFFFFF`
  1705. * `background=#RRGGBB`
  1706. * table background color (`ColorString`), defaults to `#000000`
  1707. * `border=<true/false>`
  1708. * should the table be drawn with a border? (default: `true`)
  1709. * `highlight=#RRGGBB`
  1710. * highlight background color (`ColorString`), defaults to `#466432`
  1711. * `highlight_text=#RRGGBB`
  1712. * highlight text color (`ColorString`), defaults to `#FFFFFF`
  1713. * `opendepth=<value>`
  1714. * all subtrees up to `depth < value` are open (default value = `0`)
  1715. * only useful when there is a column of type "tree"
  1716. #### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
  1717. * Sets columns for `table[]`
  1718. * Types: `text`, `image`, `color`, `indent`, `tree`
  1719. * `text`: show cell contents as text
  1720. * `image`: cell contents are an image index, use column options to define images
  1721. * `color`: cell contents are a ColorString and define color of following cell
  1722. * `indent`: cell contents are a number and define indentation of following cell
  1723. * `tree`: same as indent, but user can open and close subtrees (treeview-like)
  1724. * Column options:
  1725. * `align=<value>`
  1726. * for `text` and `image`: content alignment within cells.
  1727. Available values: `left` (default), `center`, `right`, `inline`
  1728. * `width=<value>`
  1729. * for `text` and `image`: minimum width in em (default: `0`)
  1730. * for `indent` and `tree`: indent width in em (default: `1.5`)
  1731. * `padding=<value>`: padding left of the column, in em (default `0.5`).
  1732. Exception: defaults to 0 for indent columns
  1733. * `tooltip=<value>`: tooltip text (default: empty)
  1734. * `image` column options:
  1735. * `0=<value>` sets image for image index 0
  1736. * `1=<value>` sets image for image index 1
  1737. * `2=<value>` sets image for image index 2
  1738. * and so on; defined indices need not be contiguous empty or
  1739. non-numeric cells are treated as `0`.
  1740. * `color` column options:
  1741. * `span=<value>`: number of following columns to affect (default: infinite)
  1742. **Note**: do _not_ use a element name starting with `key_`; those names are reserved to
  1743. pass key press events to formspec!
  1744. Inventory locations
  1745. -------------------
  1746. * `"context"`: Selected node metadata (deprecated: `"current_name"`)
  1747. * `"current_player"`: Player to whom the menu is shown
  1748. * `"player:<name>"`: Any player
  1749. * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
  1750. * `"detached:<name>"`: A detached inventory
  1751. Player Inventory lists
  1752. ----------------------
  1753. * `main`: list containing the default inventory
  1754. * `craft`: list containing the craft input
  1755. * `craftpreview`: list containing the craft output
  1756. * `hand`: list containing an override for the empty hand
  1757. `ColorString`
  1758. -------------
  1759. `#RGB` defines a color in hexadecimal format.
  1760. `#RGBA` defines a color in hexadecimal format and alpha channel.
  1761. `#RRGGBB` defines a color in hexadecimal format.
  1762. `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
  1763. Named colors are also supported and are equivalent to
  1764. [CSS Color Module Level 4](http://dev.w3.org/csswg/css-color/#named-colors).
  1765. To specify the value of the alpha channel, append `#AA` to the end of the color name
  1766. (e.g. `colorname#08`). For named colors the hexadecimal string representing the alpha
  1767. value must (always) be two hexadecimal digits.
  1768. `ColorSpec`
  1769. -----------
  1770. A ColorSpec specifies a 32-bit color. It can be written in either:
  1771. table form, each element ranging from 0..255 (a, if absent, defaults to 255):
  1772. `colorspec = {a=255, r=0, g=255, b=0}`
  1773. numerical form, the raw integer value of an ARGB8 quad:
  1774. `colorspec = 0xFF00FF00`
  1775. or string form, a ColorString (defined above):
  1776. `colorspec = "green"`
  1777. Escape sequences
  1778. ----------------
  1779. Most text can contain escape sequences, that can for example color the text.
  1780. There are a few exceptions: tab headers, dropdowns and vertical labels can't.
  1781. The following functions provide escape sequences:
  1782. * `minetest.get_color_escape_sequence(color)`:
  1783. * `color` is a ColorString
  1784. * The escape sequence sets the text color to `color`
  1785. * `minetest.colorize(color, message)`:
  1786. * Equivalent to:
  1787. `minetest.get_color_escape_sequence(color) ..
  1788. message ..
  1789. minetest.get_color_escape_sequence("#ffffff")`
  1790. * `minetest.get_background_escape_sequence(color)`
  1791. * `color` is a ColorString
  1792. * The escape sequence sets the background of the whole text element to
  1793. `color`. Only defined for item descriptions and tooltips.
  1794. * `minetest.strip_foreground_colors(str)`
  1795. * Removes foreground colors added by `get_color_escape_sequence`.
  1796. * `minetest.strip_background_colors(str)`
  1797. * Removes background colors added by `get_background_escape_sequence`.
  1798. * `minetest.strip_colors(str)`
  1799. * Removes all color escape sequences.
  1800. Spatial Vectors
  1801. ---------------
  1802. For the following functions, `v`, `v1`, `v2` are vectors, `p1`, `p2` are positions:
  1803. * `vector.new(a[, b, c])`:
  1804. * Returns a vector.
  1805. * A copy of `a` if `a` is a vector.
  1806. * `{x = a, y = b, z = c}`, if all of `a`, `b`, `c` are defined numbers.
  1807. * `vector.direction(p1, p2)`:
  1808. * Returns a vector of length 1 with direction `p1` to `p2`.
  1809. * If `p1` and `p2` are identical, returns `{x = 0, y = 0, z = 0}`.
  1810. * `vector.distance(p1, p2)`:
  1811. * Returns zero or a positive number, the distance between `p1` and `p2`.
  1812. * `vector.length(v)`:
  1813. * Returns zero or a positive number, the length of vector `v`.
  1814. * `vector.normalize(v)`:
  1815. * Returns a vector of length 1 with direction of vector `v`.
  1816. * If `v` has zero length, returns `{x = 0, y = 0, z = 0}`.
  1817. * `vector.floor(v)`:
  1818. * Returns a vector, each dimension rounded down.
  1819. * `vector.round(v)`:
  1820. * Returns a vector, each dimension rounded to nearest integer.
  1821. * `vector.apply(v, func)`:
  1822. * Returns a vector where the function `func` has been applied to each component.
  1823. * `vector.equals(v1, v2)`:
  1824. * Returns a boolean, `true` if the vectors are identical.
  1825. * `vector.sort(v1, v2)`:
  1826. * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
  1827. For the following functions `x` can be either a vector or a number:
  1828. * `vector.add(v, x)`:
  1829. * Returns a vector.
  1830. * `vector.subtract(v, x)`:
  1831. * Returns a vector.
  1832. * `vector.multiply(v, x)`:
  1833. * Returns a scaled vector or Schur product.
  1834. * `vector.divide(v, x)`:
  1835. * Returns a scaled vector or Schur quotient.
  1836. Helper functions
  1837. ----------------
  1838. * `dump2(obj, name, dumped)`: returns a string which makes `obj` human readable,
  1839. handles reference loops
  1840. * `obj`: arbitrary variable
  1841. * `name`: string, default: `"_"`
  1842. * `dumped`: table, default: `{}`
  1843. * `dump(obj, dumped)`: returns a string which makes `obj` human readable
  1844. * `obj`: arbitrary variable
  1845. * `dumped`: table, default: `{}`
  1846. * `math.hypot(x, y)`
  1847. * Get the hypotenuse of a triangle with legs x and y.
  1848. Useful for distance calculation.
  1849. * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
  1850. * Get the sign of a number.
  1851. * tolerance: number, default: `0.0`
  1852. * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
  1853. `0` is returned.
  1854. * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
  1855. * `separator`: string, default: `","`
  1856. * `include_empty`: boolean, default: `false`
  1857. * `max_splits`: number, if it's positive, splits aren't limited,
  1858. default: `-1`
  1859. * `sep_is_pattern`: boolean, it specifies whether separator is a plain
  1860. string or a pattern (regex), default: `false`
  1861. * e.g. `"a,b":split","` returns `{"a","b"}`
  1862. * `string:trim()`: returns the string without whitespace pre- and suffixes
  1863. * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
  1864. * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
  1865. * Adds newlines to the string to keep it within the specified character
  1866. limit
  1867. * Note that the returned lines may be longer than the limit since it only
  1868. splits at word borders.
  1869. * `limit`: number, maximal amount of characters in one line
  1870. * `as_table`: boolean, if set to true, a table of lines instead of a string
  1871. is returned, default: `false`
  1872. * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
  1873. * `pos`: table {x=X, y=Y, z=Z}
  1874. * Converts the position `pos` to a human-readable, printable string
  1875. * `decimal_places`: number, if specified, the x, y and z values of
  1876. the position are rounded to the given decimal place.
  1877. * `minetest.string_to_pos(string)`: returns a position or `nil`
  1878. * Same but in reverse.
  1879. * If the string can't be parsed to a position, nothing is returned.
  1880. * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions
  1881. * Converts a string representing an area box into two positions
  1882. * `minetest.formspec_escape(string)`: returns a string
  1883. * escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs
  1884. * `minetest.is_yes(arg)`
  1885. * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
  1886. * `minetest.get_us_time()`
  1887. * returns time with microsecond precision. May not return wall time.
  1888. * `table.copy(table)`: returns a table
  1889. * returns a deep copy of `table`
  1890. * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a position
  1891. * returns the exact position on the surface of a pointed node
  1892. Translations
  1893. ------------
  1894. Texts can be translated client-side with the help of `minetest.translate` and translation files.
  1895. ### Translating a string
  1896. Two functions are provided to translate strings: `minetest.translate` and `minetest.get_translator`.
  1897. * `minetest.get_translator(textdomain)` is a simple wrapper around `minetest.translate`, and
  1898. `minetest.get_translator(textdomain)(str, ...)` is equivalent to `minetest.translate(textdomain, str, ...)`.
  1899. It is intended to be used in the following way, so that it avoids verbose repetitions of `minetest.translate`:
  1900. local S = minetest.get_translator(textdomain)
  1901. S(str, ...)
  1902. As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
  1903. * `minetest.translate(textdomain, str, ...)` translates the string `str` with the given `textdomain`
  1904. for disambiguation. The textdomain must match the textdomain specified in the translation file in order
  1905. to get the string translated. This can be used so that a string is translated differently in different contexts.
  1906. It is advised to use the name of the mod as textdomain whenever possible, to avoid clashes with other mods.
  1907. This function must be given a number of arguments equal to the number of arguments the translated string expects.
  1908. Arguments are literal strings -- they will not be translated, so if you want them to be, they need to come as
  1909. outputs of `minetest.translate` as well.
  1910. For instance, suppose we want to translate "@1 Wool" with "@1" being replaced by the translation of "Red".
  1911. We can do the following:
  1912. local S = minetest.get_translator()
  1913. S("@1 Wool", S("Red"))
  1914. This will be displayed as "Red Wool" on old clients and on clients that do not have localization enabled.
  1915. However, if we have for instance a translation file named `wool.fr.tr` containing the following:
  1916. @1 Wool=Laine @1
  1917. Red=Rouge
  1918. this will be displayed as "Laine Rouge" on clients with a French locale.
  1919. ### Operations on translated strings
  1920. The output of `minetest.translate` is a string, with escape sequences adding additional information to that string
  1921. so that it can be translated on the different clients. In particular, you can't expect operations like string.length
  1922. to work on them like you would expect them to, or string.gsub to work in the expected manner. However, string
  1923. concatenation will still work as expected (note that you should only use this for things like formspecs; do not
  1924. translate sentences by breaking them into parts; arguments should be used instead), and operations such as
  1925. `minetest.colorize` which are only concatenation under the hood as well.
  1926. ### Translation file format
  1927. A translation file has the suffix `.[lang].tr`, where `[lang]` is the language it corresponds to.
  1928. The file should be a text file, with the following format:
  1929. * Lines beginning with `# textdomain:` (the space is significant) can be used to specify the text
  1930. domain of all following translations in the file.
  1931. * All other empty lines or lines beginning with `#` are ignored.
  1932. * Other lines should be in the format `original=translated`. Both `original` and `translated` can
  1933. contain escape sequences beginning with `@` to insert arguments, literal `@`, `=` or newline
  1934. (See ### Escapes below). There must be no extraneous whitespace around the `=` or at the beginning
  1935. or the end of the line.
  1936. ### Escapes
  1937. Strings that need to be translated can contain several escapes, preceded by `@`.
  1938. * `@@` acts as a literal `@`.
  1939. * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated string that will be inlined
  1940. when translation. Due to how translations are implemented, the original translation string **must** have
  1941. its arguments in increasing order, without gaps or repetitions, starting from 1.
  1942. * `@=` acts as a literal `=`. It is not required in strings given to `minetest.translate`, but is in translation
  1943. files to avoid being confused with the `=` separating the original from the translation.
  1944. * `@\n` (where the `\n` is a literal newline) acts as a literal newline. As with `@=`, this escape is not required
  1945. in strings given to `minetest.translate`, but is in translation files.
  1946. * `@n` acts as a literal newline as well.
  1947. `minetest` namespace reference
  1948. ------------------------------
  1949. ### Utilities
  1950. * `minetest.get_current_modname()`: returns the currently loading mod's name, when we are loading a mod
  1951. * `minetest.get_modpath(modname)`: returns e.g. `"/home/user/.minetest/usermods/modname"`
  1952. * Useful for loading additional `.lua` modules or static data from mod
  1953. * `minetest.get_modnames()`: returns a list of installed mods
  1954. * Return a list of installed mods, sorted alphabetically
  1955. * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
  1956. * Useful for storing custom data
  1957. * `minetest.is_singleplayer()`
  1958. * `minetest.features`: Table containing API feature flags
  1959. {
  1960. glasslike_framed = true,
  1961. nodebox_as_selectionbox = true,
  1962. chat_send_player_param3 = true,
  1963. get_all_craft_recipes_works = true,
  1964. use_texture_alpha = true,
  1965. -- ^ The transparency channel of textures can be used optionally
  1966. no_legacy_abms = true,
  1967. -- ^ Tree and grass ABMs are no longer done from C++
  1968. texture_names_parens = true,
  1969. -- ^ Texture grouping is possible using parentheses
  1970. area_store_custom_ids = true,
  1971. -- ^ Unique Area ID for AreaStore:insert_area
  1972. add_entity_with_staticdata = true,
  1973. -- ^ add_entity supports passing initial staticdata to on_activate
  1974. no_chat_message_prediction = true,
  1975. -- ^ Chat messages are no longer predicted
  1976. }
  1977. * `minetest.has_feature(arg)`: returns `boolean, missing_features`
  1978. * `arg`: string or table in format `{foo=true, bar=true}`
  1979. * `missing_features`: `{foo=true, bar=true}`
  1980. * `minetest.get_player_information(player_name)`:
  1981. * Returns a table containing information about a player. Example return value:
  1982. {
  1983. address = "127.0.0.1", -- IP address of client
  1984. ip_version = 4, -- IPv4 / IPv6
  1985. min_rtt = 0.01, -- minimum round trip time
  1986. max_rtt = 0.2, -- maximum round trip time
  1987. avg_rtt = 0.02, -- average round trip time
  1988. min_jitter = 0.01, -- minimum packet time jitter
  1989. max_jitter = 0.5, -- maximum packet time jitter
  1990. avg_jitter = 0.03, -- average packet time jitter
  1991. connection_uptime = 200, -- seconds since client connected
  1992. protocol_version = 32, -- protocol version used by client
  1993. -- following information is available on debug build only!!!
  1994. -- DO NOT USE IN MODS
  1995. --ser_vers = 26, -- serialization version used by client
  1996. --major = 0, -- major version number
  1997. --minor = 4, -- minor version number
  1998. --patch = 10, -- patch version number
  1999. --vers_string = "0.4.9-git", -- full version string
  2000. --state = "Active" -- current client state
  2001. }
  2002. * `minetest.mkdir(path)`: returns success.
  2003. * Creates a directory specified by `path`, creating parent directories
  2004. if they don't exist.
  2005. * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
  2006. * is_dir is one of:
  2007. * nil: return all entries,
  2008. * true: return only subdirectory names, or
  2009. * false: return only file names.
  2010. * `minetest.safe_file_write(path, content)`: returns boolean indicating success
  2011. * Replaces contents of file at path with new contents in a safe (atomic) way.
  2012. Use this instead of below code when writing e.g. database files:
  2013. `local f = io.open(path, "wb"); f:write(content); f:close()`
  2014. * `minetest.get_version()`: returns a table containing components of the
  2015. engine version. Components:
  2016. * `project`: Name of the project, eg, "Minetest"
  2017. * `string`: Simple version, eg, "1.2.3-dev"
  2018. * `hash`: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty"
  2019. Use this for informational purposes only. The information in the returned
  2020. table does not represent the capabilities of the engine, nor is it
  2021. reliable or verifiable. Compatible forks will have a different name and
  2022. version entirely. To check for the presence of engine features, test
  2023. whether the functions exported by the wanted features exist. For example:
  2024. `if minetest.check_for_falling then ... end`.
  2025. * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
  2026. * `data`: string of data to hash
  2027. * `raw`: return raw bytes instead of hex digits, default: false
  2028. ### Logging
  2029. * `minetest.debug(...)`
  2030. * Equivalent to `minetest.log(table.concat({...}, "\t"))`
  2031. * `minetest.log([level,] text)`
  2032. * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
  2033. `"info"`, or `"verbose"`. Default is `"none"`.
  2034. ### Registration functions
  2035. Call these functions only at load time!
  2036. * `minetest.register_entity(name, prototype table)`
  2037. * `minetest.register_abm(abm definition)`
  2038. * `minetest.register_lbm(lbm definition)`
  2039. * `minetest.register_node(name, node definition)`
  2040. * `minetest.register_tool(name, item definition)`
  2041. * `minetest.register_craftitem(name, item definition)`
  2042. * `minetest.unregister_item(name)`
  2043. * `minetest.register_alias(name, convert_to)`
  2044. * Also use this to set the 'mapgen aliases' needed in a game for the core
  2045. * mapgens. See 'Mapgen aliases' section above.
  2046. * `minetest.register_alias_force(name, convert_to)`
  2047. * `minetest.register_craft(recipe)`
  2048. * Check recipe table syntax for different types below.
  2049. * `minetest.clear_craft(recipe)`
  2050. * Will erase existing craft based either on output item or on input recipe.
  2051. * Specify either output or input only. If you specify both, input will be ignored. For input use the same recipe table
  2052. syntax as for `minetest.register_craft(recipe)`. For output specify only the item, without a quantity.
  2053. * If no erase candidate could be found, Lua exception will be thrown.
  2054. * **Warning**! The type field ("shaped","cooking" or any other) will be ignored if the recipe
  2055. contains output. Erasing is then done independently from the crafting method.
  2056. * `minetest.register_ore(ore definition)`
  2057. * `minetest.register_biome(biome definition)`
  2058. * `minetest.register_decoration(decoration definition)`
  2059. * `minetest.override_item(name, redefinition)`
  2060. * Overrides fields of an item registered with register_node/tool/craftitem.
  2061. * Note: Item must already be defined, (opt)depend on the mod defining it.
  2062. * Example: `minetest.override_item("default:mese", {light_source=LIGHT_MAX})`
  2063. * `minetest.clear_registered_ores()`
  2064. * `minetest.clear_registered_biomes()`
  2065. * `minetest.clear_registered_decorations()`
  2066. ### Global callback registration functions
  2067. Call these functions only at load time!
  2068. * `minetest.register_globalstep(func(dtime))`
  2069. * Called every server step, usually interval of 0.1s
  2070. * `minetest.register_on_shutdown(func())`
  2071. * Called before server shutdown
  2072. * **Warning**: If the server terminates abnormally (i.e. crashes), the registered
  2073. callbacks **will likely not be run**. Data should be saved at
  2074. semi-frequent intervals as well as on server shutdown.
  2075. * `minetest.register_on_placenode(func(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
  2076. * Called when a node has been placed
  2077. * If return `true` no item is taken from `itemstack`
  2078. * `placer` may be any valid ObjectRef or nil.
  2079. * **Not recommended**; use `on_construct` or `after_place_node` in node definition
  2080. whenever possible
  2081. * `minetest.register_on_dignode(func(pos, oldnode, digger))`
  2082. * Called when a node has been dug.
  2083. * **Not recommended**; Use `on_destruct` or `after_dig_node` in node definition
  2084. whenever possible
  2085. * `minetest.register_on_punchnode(func(pos, node, puncher, pointed_thing))`
  2086. * Called when a node is punched
  2087. * `minetest.register_on_generated(func(minp, maxp, blockseed))`
  2088. * Called after generating a piece of world. Modifying nodes inside the area
  2089. is a bit faster than usually.
  2090. * `minetest.register_on_newplayer(func(ObjectRef))`
  2091. * Called after a new player has been created
  2092. * `minetest.register_on_dieplayer(func(ObjectRef))`
  2093. * Called when a player dies
  2094. * `minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
  2095. * Called when a player is punched
  2096. * `player` - ObjectRef - Player that was punched
  2097. * `hitter` - ObjectRef - Player that hit
  2098. * `time_from_last_punch`: Meant for disallowing spamming of clicks (can be nil)
  2099. * `tool_capabilities`: capability table of used tool (can be nil)
  2100. * `dir`: unit vector of direction of punch. Always defined. Points from
  2101. the puncher to the punched.
  2102. * `damage` - number that represents the damage calculated by the engine
  2103. * should return `true` to prevent the default damage mechanism
  2104. * `minetest.register_on_player_hpchange(func(player, hp_change), modifier)`
  2105. * Called when the player gets damaged or healed
  2106. * `player`: ObjectRef of the player
  2107. * `hp_change`: the amount of change. Negative when it is damage.
  2108. * `modifier`: when true, the function should return the actual `hp_change`.
  2109. Note: modifiers only get a temporary hp_change that can be modified by later modifiers.
  2110. modifiers can return true as a second argument to stop the execution of further functions.
  2111. Non-modifiers receive the final hp change calculated by the modifiers.
  2112. * `minetest.register_on_respawnplayer(func(ObjectRef))`
  2113. * Called when player is to be respawned
  2114. * Called _before_ repositioning of player occurs
  2115. * return true in func to disable regular player placement
  2116. * `minetest.register_on_prejoinplayer(func(name, ip))`
  2117. * Called before a player joins the game
  2118. * If it returns a string, the player is disconnected with that string as reason
  2119. * `minetest.register_on_joinplayer(func(ObjectRef))`
  2120. * Called when a player joins the game
  2121. * `minetest.register_on_leaveplayer(func(ObjectRef, timed_out))`
  2122. * Called when a player leaves the game
  2123. * `timed_out`: True for timeout, false for other reasons.
  2124. * `minetest.register_on_auth_fail(func(name, ip))`
  2125. * Called when a client attempts to log into an account but supplies the wrong password.
  2126. * `ip`: The IP address of the client.
  2127. * `name`: The account the client attempted to log into.
  2128. * `minetest.register_on_cheat(func(ObjectRef, cheat))`
  2129. * Called when a player cheats
  2130. * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
  2131. * `moved_too_fast`
  2132. * `interacted_too_far`
  2133. * `interacted_while_dead`
  2134. * `finished_unknown_dig`
  2135. * `dug_unbreakable`
  2136. * `dug_too_fast`
  2137. * `minetest.register_on_chat_message(func(name, message))`
  2138. * Called always when a player says something
  2139. * Return `true` to mark the message as handled, which means that it will not be sent to other players
  2140. * `minetest.register_on_player_receive_fields(func(player, formname, fields))`
  2141. * Called when a button is pressed in player's inventory form
  2142. * Newest functions are called first
  2143. * If function returns `true`, remaining functions are not called
  2144. * `minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))`
  2145. * Called when `player` crafts something
  2146. * `itemstack` is the output
  2147. * `old_craft_grid` contains the recipe (Note: the one in the inventory is cleared)
  2148. * `craft_inv` is the inventory with the crafting grid
  2149. * Return either an `ItemStack`, to replace the output, or `nil`, to not modify it
  2150. * `minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))`
  2151. * The same as before, except that it is called before the player crafts, to make
  2152. craft prediction, and it should not change anything.
  2153. * `minetest.register_on_protection_violation(func(pos, name))`
  2154. * Called by `builtin` and mods when a player violates protection at a position
  2155. (eg, digs a node or punches a protected entity).
  2156. * The registered functions can be called using `minetest.record_protection_violation`
  2157. * The provided function should check that the position is protected by the mod
  2158. calling this function before it prints a message, if it does, to allow for
  2159. multiple protection mods.
  2160. * `minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))`
  2161. * Called when an item is eaten, by `minetest.item_eat`
  2162. * Return `true` or `itemstack` to cancel the default item eat response (i.e.: hp increase)
  2163. * `minetest.register_on_priv_grant(function(name, granter, priv))`
  2164. * Called when `granter` grants the priv `priv` to `name`.
  2165. * Note that the callback will be called twice if it's done by a player, once with granter being the player name,
  2166. and again with granter being nil.
  2167. * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
  2168. * Called when `revoker` revokes the priv `priv` from `name`.
  2169. * Note that the callback will be called twice if it's done by a player, once with revoker being the player name,
  2170. and again with revoker being nil.
  2171. * `minetest.register_can_bypass_userlimit(function(name, ip))`
  2172. * Called when `name` user connects with `ip`.
  2173. * Return `true` to by pass the player limit
  2174. * `minetest.register_on_modchannel_message(func(channel_name, sender, message))`
  2175. * Called when an incoming mod channel message is received
  2176. * You should have joined some channels to receive events.
  2177. * If message comes from a server mod, `sender` field is an empty string.
  2178. ### Other registration functions
  2179. * `minetest.register_chatcommand(cmd, chatcommand definition)`
  2180. * Adds definition to `minetest.registered_chatcommands`
  2181. * `minetest.override_chatcommand(name, redefinition)`
  2182. * Overrides fields of a chatcommand registered with `register_chatcommand`.
  2183. * `minetest.unregister_chatcommand(name)`
  2184. * Unregisters a chatcommands registered with `register_chatcommand`.
  2185. * `minetest.register_privilege(name, definition)`
  2186. * `definition`: `"description text"`
  2187. * `definition`: `{ description = "description text", give_to_singleplayer = boolean}`
  2188. the default of `give_to_singleplayer` is true
  2189. * To allow players with `basic_privs` to grant, see `basic_privs` minetest.conf setting.
  2190. * `on_grant(name, granter_name)`: Called when given to player `name` by `granter_name`.
  2191. `granter_name` will be nil if the priv was granted by a mod.
  2192. * `on_revoke(name, revoker_name)`: Called when taken from player `name` by `revoker_name`.
  2193. `revoker_name` will be nil if the priv was revoked by a mod
  2194. * Note that the above two callbacks will be called twice if a player is responsible -
  2195. once with the player name, and then with a nil player name.
  2196. * Return true in the above callbacks to stop register_on_priv_grant or revoke being called.
  2197. * `minetest.register_authentication_handler(authentication handler definition)`
  2198. * Registers an auth handler that overrides the builtin one
  2199. * This function can be called by a single mod once only.
  2200. ### Setting-related
  2201. * `minetest.settings`: Settings object containing all of the settings from the
  2202. main config file (`minetest.conf`).
  2203. * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
  2204. parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
  2205. ### Authentication
  2206. * `minetest.string_to_privs(str)`: returns `{priv1=true,...}`
  2207. * `minetest.privs_to_string(privs)`: returns `"priv1,priv2,..."`
  2208. * Convert between two privilege representations
  2209. * `minetest.get_player_privs(name) -> {priv1=true,...}`
  2210. * `minetest.check_player_privs(player_or_name, ...)`: returns `bool, missing_privs`
  2211. * A quickhand for checking privileges.
  2212. * `player_or_name`: Either a Player object or the name of a player.
  2213. * `...` is either a list of strings, e.g. `"priva", "privb"` or
  2214. a table, e.g. `{ priva = true, privb = true }`.
  2215. * `minetest.check_password_entry(name, entry, password)`
  2216. * Returns true if the "password entry" for a player with name matches given
  2217. password, false otherwise.
  2218. * The "password entry" is the password representation generated by the engine
  2219. as returned as part of a `get_auth()` call on the auth handler.
  2220. * Only use this function for making it possible to log in via password from
  2221. external protocols such as IRC, other uses are frowned upon.
  2222. * `minetest.get_password_hash(name, raw_password)`
  2223. * Convert a name-password pair to a password hash that Minetest can use.
  2224. * The returned value alone is not a good basis for password checks based
  2225. on comparing the password hash in the database with the password hash
  2226. from the function, with an externally provided password, as the hash
  2227. in the db might use the new SRP verifier format.
  2228. * For this purpose, use `minetest.check_password_entry` instead.
  2229. * `minetest.get_player_ip(name)`: returns an IP address string for the player `name`
  2230. * The player needs to be online for this to be successful.
  2231. * `minetest.get_auth_handler()`: Return the currently active auth handler
  2232. * See the `Authentication handler definition`
  2233. * Use this to e.g. get the authentication data for a player:
  2234. `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  2235. * `minetest.notify_authentication_modified(name)`
  2236. * Must be called by the authentication handler for privilege changes.
  2237. * `name`: string; if omitted, all auth data should be considered modified
  2238. * `minetest.set_player_password(name, password_hash)`: Set password hash of player `name`
  2239. * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player `name`
  2240. * `minetest.auth_reload()`
  2241. * See `reload()` in authentication handler definition
  2242. `minetest.set_player_password`, `minetest_set_player_privs`, `minetest_get_player_privs`
  2243. and `minetest.auth_reload` call the authentication handler.
  2244. ### Chat
  2245. * `minetest.chat_send_all(text)`
  2246. * `minetest.chat_send_player(name, text)`
  2247. ### Environment access
  2248. * `minetest.set_node(pos, node)`
  2249. * `minetest.add_node(pos, node): alias to `minetest.set_node`
  2250. * Set node at position `pos`
  2251. * `node`: table `{name=string, param1=number, param2=number}`
  2252. * If param1 or param2 is omitted, it's set to `0`.
  2253. * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
  2254. * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
  2255. * Set node on all positions set in the first argument.
  2256. * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
  2257. * For node specification or position syntax see `minetest.set_node` call
  2258. * Faster than set_node due to single call, but still considerably slower than
  2259. Voxel Manipulators (LVM) for large numbers of nodes.
  2260. Unlike LVMs, this will call node callbacks. It also allows setting nodes in spread out
  2261. positions which would cause LVMs to waste memory.
  2262. For setting a cube, this is 1.3x faster than set_node whereas LVM is 20x faster.
  2263. * `minetest.swap_node(pos, node)`
  2264. * Set node at position, but don't remove metadata
  2265. * `minetest.remove_node(pos)`
  2266. * By default it does the same as `minetest.set_node(pos, {name="air"})`
  2267. * `minetest.get_node(pos)`
  2268. * Returns the node at the given position as table in the format
  2269. `{name="node_name", param1=0, param2=0}`, returns `{name="ignore", param1=0, param2=0}`
  2270. for unloaded areas.
  2271. * `minetest.get_node_or_nil(pos)`
  2272. * Same as `get_node` but returns `nil` for unloaded areas.
  2273. * `minetest.get_node_light(pos, timeofday)`
  2274. * Gets the light value at the given position. Note that the light value
  2275. "inside" the node at the given position is returned, so you usually want
  2276. to get the light value of a neighbor.
  2277. * `pos`: The position where to measure the light.
  2278. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  2279. * Returns a number between `0` and `15` or `nil`
  2280. * `minetest.place_node(pos, node)`
  2281. * Place node with the same effects that a player would cause
  2282. * `minetest.dig_node(pos)`
  2283. * Dig node with the same effects that a player would cause
  2284. * Returns `true` if successful, `false` on failure (e.g. protected location)
  2285. * `minetest.punch_node(pos)`
  2286. * Punch node with the same effects that a player would cause
  2287. * `minetest.spawn_falling_node(pos)`
  2288. * Change node into falling node
  2289. * Returns `true` if successful, `false` on failure
  2290. * `minetest.find_nodes_with_meta(pos1, pos2)`
  2291. * Get a table of positions of nodes that have metadata within a region {pos1, pos2}
  2292. * `minetest.get_meta(pos)`
  2293. * Get a `NodeMetaRef` at that position
  2294. * `minetest.get_node_timer(pos)`
  2295. * Get `NodeTimerRef`
  2296. * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at position
  2297. * Returns `ObjectRef`, or `nil` if failed
  2298. * `minetest.add_item(pos, item)`: Spawn item
  2299. * Returns `ObjectRef`, or `nil` if failed
  2300. * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
  2301. * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of ObjectRefs
  2302. * `radius`: using an euclidean metric
  2303. * `minetest.set_timeofday(val)`
  2304. * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
  2305. * `minetest.get_timeofday()`
  2306. * `minetest.get_gametime()`: returns the time, in seconds, since the world was created
  2307. * `minetest.get_day_count()`: returns number days elapsed since world was created,
  2308. * accounting for time changes.
  2309. * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns pos or `nil`
  2310. * `radius`: using a maximum metric
  2311. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  2312. * `search_center` is an optional boolean (default: `false`)
  2313. If true `pos` is also checked for the nodes
  2314. * `minetest.find_nodes_in_area(pos1, pos2, nodenames)`: returns a list of positions
  2315. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  2316. * First return value: Table with all node positions
  2317. * Second return value: Table with the count of each node with the node name as index
  2318. * Area volume is limited to 4,096,000 nodes
  2319. * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a list of positions
  2320. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  2321. * Return value: Table with all node positions with a node air above
  2322. * Area volume is limited to 4,096,000 nodes
  2323. * `minetest.get_perlin(noiseparams)`
  2324. * `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
  2325. * Return world-specific perlin noise (`int(worldseed)+seeddiff`)
  2326. * `minetest.get_voxel_manip([pos1, pos2])`
  2327. * Return voxel manipulator object.
  2328. * Loads the manipulator from the map if positions are passed.
  2329. * `minetest.set_gen_notify(flags, {deco_ids})`
  2330. * Set the types of on-generate notifications that should be collected.
  2331. * `flags` is a flag field with the available flags:
  2332. * dungeon
  2333. * temple
  2334. * cave_begin
  2335. * cave_end
  2336. * large_cave_begin
  2337. * large_cave_end
  2338. * decoration
  2339. * The second parameter is a list of IDS of decorations which notification
  2340. is requested for.
  2341. * `minetest.get_gen_notify()`
  2342. * Returns a flagstring and a table with the `deco_id`s.
  2343. * `minetest.get_decoration_id(decoration_name)
  2344. * Returns the decoration ID number for the provided decoration name string,
  2345. or `nil` on failure.
  2346. * `minetest.get_mapgen_object(objectname)`
  2347. * Return requested mapgen object if available (see "Mapgen objects")
  2348. * `minetest.get_heat(pos)`
  2349. * Returns the heat at the position, or `nil` on failure.
  2350. * `minetest.get_humidity(pos)`
  2351. * Returns the humidity at the position, or `nil` on failure.
  2352. * `minetest.get_biome_data(pos)`
  2353. * Returns a table containing:
  2354. * `biome` the biome id of the biome at that position
  2355. * `heat` the heat at the position
  2356. * `humidity` the humidity at the position
  2357. * Or returns `nil` on failure.
  2358. * `minetest.get_biome_id(biome_name)`
  2359. * Returns the biome id, as used in the biomemap Mapgen object and returned
  2360. by `minetest.get_biome_data(pos)`, for a given biome_name string.
  2361. * `minetest.get_mapgen_params()`
  2362. * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
  2363. * Returns a table containing:
  2364. * `mgname`
  2365. * `seed`
  2366. * `chunksize`
  2367. * `water_level`
  2368. * `flags`
  2369. * `minetest.set_mapgen_params(MapgenParams)`
  2370. * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
  2371. instead.
  2372. * Set map generation parameters.
  2373. * Function cannot be called after the registration period; only
  2374. initialization and `on_mapgen_init`.
  2375. * Takes a table as an argument with the fields:
  2376. * `mgname`
  2377. * `seed`
  2378. * `chunksize`
  2379. * `water_level`
  2380. * `flags`
  2381. * Leave field unset to leave that parameter unchanged.
  2382. * `flags` contains a comma-delimited string of flags to set, or if the
  2383. prefix `"no"` is attached, clears instead.
  2384. * `flags` is in the same format and has the same options as `mg_flags` in
  2385. `minetest.conf`.
  2386. * `minetest.get_mapgen_setting(name)`
  2387. * Gets the *active* mapgen setting (or nil if none exists) in string
  2388. format with the following order of precedence:
  2389. 1) Settings loaded from map_meta.txt or overrides set during mod execution
  2390. 2) Settings set by mods without a metafile override
  2391. 3) Settings explicitly set in the user config file, minetest.conf
  2392. 4) Settings set as the user config default
  2393. * `minetest.get_mapgen_setting_noiseparams(name)`
  2394. * Same as above, but returns the value as a NoiseParams table if the
  2395. setting `name` exists and is a valid NoiseParams.
  2396. * `minetest.set_mapgen_setting(name, value, [override_meta])`
  2397. * Sets a mapgen param to `value`, and will take effect if the corresponding
  2398. mapgen setting is not already present in map_meta.txt.
  2399. * `override_meta` is an optional boolean (default: `false`). If this is set
  2400. to true, the setting will become the active setting regardless of the map
  2401. metafile contents.
  2402. * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
  2403. * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
  2404. * Same as above, except value is a NoiseParams table.
  2405. * `minetest.set_noiseparams(name, noiseparams, set_default)`
  2406. * Sets the noiseparams setting of `name` to the noiseparams table specified
  2407. in `noiseparams`.
  2408. * `set_default` is an optional boolean (default: `true`) that specifies
  2409. whether the setting should be applied to the default config or current
  2410. active config.
  2411. * `minetest.get_noiseparams(name)`
  2412. * Returns a table of the noiseparams for name.
  2413. * `minetest.generate_ores(vm, pos1, pos2)`
  2414. * Generate all registered ores within the VoxelManip `vm` and in the area
  2415. from `pos1` to `pos2`.
  2416. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  2417. * `minetest.generate_decorations(vm, pos1, pos2)`
  2418. * Generate all registered decorations within the VoxelManip `vm` and in the
  2419. area from `pos1` to `pos2`.
  2420. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  2421. * `minetest.clear_objects([options])`
  2422. * Clear all objects in the environment
  2423. * Takes an optional table as an argument with the field `mode`.
  2424. * mode = `"full"`: Load and go through every mapblock, clearing objects (default).
  2425. * mode = `"quick"`: Clear objects immediately in loaded mapblocks;
  2426. clear objects in unloaded mapblocks only when the mapblocks are next activated.
  2427. * `minetest.emerge_area(pos1, pos2, [callback], [param])`
  2428. * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be asynchronously
  2429. fetched from memory, loaded from disk, or if inexistent, generates them.
  2430. * If `callback` is a valid Lua function, this will be called for each block emerged.
  2431. * The function signature of callback is:
  2432. * `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
  2433. * `blockpos` is the *block* coordinates of the block that had been emerged
  2434. * `action` could be one of the following constant values:
  2435. * `minetest.EMERGE_CANCELLED`
  2436. * `minetest.EMERGE_ERRORED`
  2437. * `minetest.EMERGE_FROM_MEMORY`
  2438. * `minetest.EMERGE_FROM_DISK`
  2439. * `minetest.EMERGE_GENERATED`
  2440. * `calls_remaining` is the number of callbacks to be expected after this one
  2441. * `param` is the user-defined parameter passed to emerge_area (or nil if the
  2442. parameter was absent)
  2443. * `minetest.delete_area(pos1, pos2)`
  2444. * delete all mapblocks in the area from pos1 to pos2, inclusive
  2445. * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
  2446. * Checks if there is anything other than air between pos1 and pos2.
  2447. * Returns false if something is blocking the sight.
  2448. * Returns the position of the blocking node when `false`
  2449. * `pos1`: First position
  2450. * `pos2`: Second position
  2451. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
  2452. * Creates a `Raycast` object.
  2453. * `pos1`: start of the ray
  2454. * `pos2`: end of the ray
  2455. * `objects` : if false, only nodes will be returned. Default is `true`.
  2456. * `liquids' : if false, liquid nodes won't be returned. Default is `false`.
  2457. * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
  2458. * returns table containing path
  2459. * returns a table of 3D points representing a path from `pos1` to `pos2` or `nil`
  2460. * `pos1`: start position
  2461. * `pos2`: end position
  2462. * `searchdistance`: number of blocks to search in each direction using a maximum metric
  2463. * `max_jump`: maximum height difference to consider walkable
  2464. * `max_drop`: maximum height difference to consider droppable
  2465. * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`
  2466. * `minetest.spawn_tree (pos, {treedef})`
  2467. * spawns L-system tree at given `pos` with definition in `treedef` table
  2468. * `minetest.transforming_liquid_add(pos)`
  2469. * add node to liquid update queue
  2470. * `minetest.get_node_max_level(pos)`
  2471. * get max available level for leveled node
  2472. * `minetest.get_node_level(pos)`
  2473. * get level of leveled node (water, snow)
  2474. * `minetest.set_node_level(pos, level)`
  2475. * set level of leveled node, default `level` equals `1`
  2476. * if `totallevel > maxlevel`, returns rest (`total-max`).
  2477. * `minetest.add_node_level(pos, level)`
  2478. * increase level of leveled node by level, default `level` equals `1`
  2479. * if `totallevel > maxlevel`, returns rest (`total-max`)
  2480. * can be negative for decreasing
  2481. * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
  2482. * resets the light in a cuboid-shaped part of
  2483. the map and removes lighting bugs.
  2484. * Loads the area if it is not loaded.
  2485. * `pos1` is the corner of the cuboid with the least coordinates
  2486. (in node coordinates), inclusive.
  2487. * `pos2` is the opposite corner of the cuboid, inclusive.
  2488. * The actual updated cuboid might be larger than the specified one,
  2489. because only whole map blocks can be updated.
  2490. The actual updated area consists of those map blocks that intersect
  2491. with the given cuboid.
  2492. * However, the neighborhood of the updated area might change
  2493. as well, as light can spread out of the cuboid, also light
  2494. might be removed.
  2495. * returns `false` if the area is not fully generated,
  2496. `true` otherwise
  2497. * `minetest.check_single_for_falling(pos)`
  2498. * causes an unsupported `group:falling_node` node to fall and causes an
  2499. unattached `group:attached_node` node to fall.
  2500. * does not spread these updates to neighbours.
  2501. * `minetest.check_for_falling(pos)`
  2502. * causes an unsupported `group:falling_node` node to fall and causes an
  2503. unattached `group:attached_node` node to fall.
  2504. * spread these updates to neighbours and can cause a cascade
  2505. of nodes to fall.
  2506. ### Mod channels
  2507. You can find mod channels communication scheme in `docs/mod_channels.png`.
  2508. * `minetest.mod_channel_join(channel_name)`
  2509. * Server joins channel `channel_name`, and creates it if necessary. You
  2510. should listen from incoming messages with `minetest.register_on_modchannel_message`
  2511. call to receive incoming messages
  2512. ### Inventory
  2513. `minetest.get_inventory(location)`: returns an `InvRef`
  2514. * `location` = e.g.
  2515. * `{type="player", name="celeron55"}`
  2516. * `{type="node", pos={x=, y=, z=}}`
  2517. * `{type="detached", name="creative"}`
  2518. * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns an `InvRef`
  2519. * callbacks: See "Detached inventory callbacks"
  2520. * `player_name`: Make detached inventory available to one player exclusively,
  2521. by default they will be sent to every player (even if not used).
  2522. Note that this parameter is mostly just a workaround and will be removed in future releases.
  2523. * Creates a detached inventory. If it already exists, it is cleared.
  2524. * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
  2525. returns left over ItemStack
  2526. * See `minetest.item_eat` and `minetest.register_on_item_eat`
  2527. ### Formspec
  2528. * `minetest.show_formspec(playername, formname, formspec)`
  2529. * `playername`: name of player to show formspec
  2530. * `formname`: name passed to `on_player_receive_fields` callbacks.
  2531. It should follow the `"modname:<whatever>"` naming convention
  2532. * `formspec`: formspec to display
  2533. * `minetest.close_formspec(playername, formname)`
  2534. * `playername`: name of player to close formspec
  2535. * `formname`: has to exactly match the one given in `show_formspec`, or the formspec will
  2536. not close.
  2537. * calling `show_formspec(playername, formname, "")` is equal to this expression
  2538. * to close a formspec regardless of the formname, call
  2539. `minetest.close_formspec(playername, "")`. **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  2540. * `minetest.formspec_escape(string)`: returns a string
  2541. * escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs
  2542. * `minetest.explode_table_event(string)`: returns a table
  2543. * returns e.g. `{type="CHG", row=1, column=2}`
  2544. * `type` is one of:
  2545. * `"INV"`: no row selected)
  2546. * `"CHG"`: selected)
  2547. * `"DCL"`: double-click
  2548. * `minetest.explode_textlist_event(string)`: returns a table
  2549. * returns e.g. `{type="CHG", index=1}`
  2550. * `type` is one of:
  2551. * `"INV"`: no row selected)
  2552. * `"CHG"`: selected)
  2553. * `"DCL"`: double-click
  2554. * `minetest.explode_scrollbar_event(string)`: returns a table
  2555. * returns e.g. `{type="CHG", value=500}`
  2556. * `type` is one of:
  2557. * `"INV"`: something failed
  2558. * `"CHG"`: has been changed
  2559. * `"VAL"`: not changed
  2560. ### Item handling
  2561. * `minetest.inventorycube(img1, img2, img3)`
  2562. * Returns a string for making an image of a cube (useful as an item image)
  2563. * `minetest.get_pointed_thing_position(pointed_thing, above)`
  2564. * Get position of a `pointed_thing` (that you can get from somewhere)
  2565. * `minetest.dir_to_facedir(dir, is6d)`
  2566. * Convert a vector to a facedir value, used in `param2` for `paramtype2="facedir"`;
  2567. * passing something non-`nil`/`false` for the optional second parameter causes it to
  2568. take the y component into account
  2569. * `minetest.facedir_to_dir(facedir)`
  2570. * Convert a facedir back into a vector aimed directly out the "back" of a node
  2571. * `minetest.dir_to_wallmounted(dir)`
  2572. * Convert a vector to a wallmounted value, used for `paramtype2="wallmounted"`
  2573. * `minetest.wallmounted_to_dir(wallmounted)`
  2574. * Convert a wallmounted value back into a vector aimed directly out the "back" of a node
  2575. * `minetest.dir_to_yaw(dir)`
  2576. * Convert a vector into a yaw (angle)
  2577. * `minetest.yaw_to_dir(yaw)`
  2578. * Convert yaw (angle) to a vector
  2579. * `minetest.is_colored_paramtype(ptype)`
  2580. * Returns a boolean. Returns `true` if the given `paramtype2` contains color
  2581. information (`color`, `colorwallmounted` or `colorfacedir`).
  2582. * `minetest.strip_param2_color(param2, paramtype2)`
  2583. * Removes everything but the color information from the
  2584. given `param2` value.
  2585. * Returns `nil` if the given `paramtype2` does not contain color information
  2586. * `minetest.get_node_drops(nodename, toolname)`
  2587. * Returns list of item names.
  2588. * **Note**: This will be removed or modified in a future version.
  2589. * `minetest.get_craft_result(input)`: returns `output, decremented_input`
  2590. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  2591. * `input.width` = for example `3`
  2592. * `input.items` = for example
  2593. `{ stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9 }`
  2594. * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
  2595. * `output.time` = a number, if unsuccessful: `0`
  2596. * `output.replacements` = list of `ItemStack`s that couldn't be placed in
  2597. `decremented_input.items`
  2598. * `decremented_input` = like `input`
  2599. * `minetest.get_craft_recipe(output)`: returns input
  2600. * returns last registered recipe for output item (node)
  2601. * `output` is a node or item type such as `"default:torch"`
  2602. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  2603. * `input.width` = for example `3`
  2604. * `input.items` = for example
  2605. `{ stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9 }`
  2606. * `input.items` = `nil` if no recipe found
  2607. * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
  2608. * returns indexed table with all registered recipes for query item (node)
  2609. or `nil` if no recipe was found
  2610. * recipe entry table:
  2611. {
  2612. method = 'normal' or 'cooking' or 'fuel'
  2613. width = 0-3, 0 means shapeless recipe
  2614. items = indexed [1-9] table with recipe items
  2615. output = string with item name and quantity
  2616. }
  2617. * Example query for `"default:gold_ingot"` will return table:
  2618. {
  2619. [1]={method = "cooking", width = 3, output = "default:gold_ingot",
  2620. items = {1 = "default:gold_lump"}},
  2621. [2]={method = "normal", width = 1, output = "default:gold_ingot 9",
  2622. items = {1 = "default:goldblock"}}
  2623. }
  2624. * `minetest.handle_node_drops(pos, drops, digger)`
  2625. * `drops`: list of itemstrings
  2626. * Handles drops from nodes after digging: Default action is to put them into
  2627. digger's inventory
  2628. * Can be overridden to get different functionality (e.g. dropping items on
  2629. ground)
  2630. * `minetest.itemstring_with_palette(item, palette_index)`: returns an item string
  2631. * Creates an item string which contains palette index information
  2632. for hardware colorization. You can use the returned string
  2633. as an output in a craft recipe.
  2634. * `item`: the item stack which becomes colored. Can be in string,
  2635. table and native form.
  2636. * `palette_index`: this index is added to the item stack
  2637. * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
  2638. * Creates an item string which contains static color information
  2639. for hardware colorization. Use this method if you wish to colorize
  2640. an item that does not own a palette. You can use the returned string
  2641. as an output in a craft recipe.
  2642. * `item`: the item stack which becomes colored. Can be in string,
  2643. table and native form.
  2644. * `colorstring`: the new color of the item stack
  2645. ### Rollback
  2646. * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
  2647. returns `{{actor, pos, time, oldnode, newnode}, ...}`
  2648. * Find who has done something to a node, or near a node
  2649. * `actor`: `"player:<name>"`, also `"liquid"`.
  2650. * `minetest.rollback_revert_actions_by(actor, seconds)`: returns `boolean, log_messages`
  2651. * Revert latest actions of someone
  2652. * `actor`: `"player:<name>"`, also `"liquid"`.
  2653. ### Defaults for the `on_*` item definition functions
  2654. These functions return the leftover itemstack.
  2655. * `minetest.item_place_node(itemstack, placer, pointed_thing, param2)`
  2656. * Place item as a node
  2657. * `param2` overrides `facedir` and wallmounted `param2`
  2658. * returns `itemstack, success`
  2659. * `minetest.item_place_object(itemstack, placer, pointed_thing)`
  2660. * Place item as-is
  2661. * `minetest.item_place(itemstack, placer, pointed_thing, param2)`
  2662. * Use one of the above based on what the item is.
  2663. * Calls `on_rightclick` of `pointed_thing.under` if defined instead
  2664. * **Note**: is not called when wielded item overrides `on_place`
  2665. * `param2` overrides `facedir` and wallmounted `param2`
  2666. * returns `itemstack, success`
  2667. * `minetest.item_drop(itemstack, dropper, pos)`
  2668. * Drop the item
  2669. * `minetest.item_eat(hp_change, replace_with_item)`
  2670. * Eat the item.
  2671. * `replace_with_item` is the itemstring which is added to the inventory.
  2672. If the player is eating a stack, then replace_with_item goes to a
  2673. different spot. Can be `nil`
  2674. * See `minetest.do_item_eat`
  2675. ### Defaults for the `on_punch` and `on_dig` node definition callbacks
  2676. * `minetest.node_punch(pos, node, puncher, pointed_thing)`
  2677. * Calls functions registered by `minetest.register_on_punchnode()`
  2678. * `minetest.node_dig(pos, node, digger)`
  2679. * Checks if node can be dug, puts item into inventory, removes node
  2680. * Calls functions registered by `minetest.registered_on_dignodes()`
  2681. ### Sounds
  2682. * `minetest.sound_play(spec, parameters)`: returns a handle
  2683. * `spec` is a `SimpleSoundSpec`
  2684. * `parameters` is a sound parameter table
  2685. * `minetest.sound_stop(handle)`
  2686. * `minetest.sound_fade(handle, step, gain)`
  2687. * `handle` is a handle returned by `minetest.sound_play`
  2688. * `step` determines how fast a sound will fade.
  2689. Negative step will lower the sound volume, positive step will increase the sound volume
  2690. * `gain` the target gain for the fade.
  2691. ### Timing
  2692. * `minetest.after(time, func, ...)`
  2693. * Call the function `func` after `time` seconds, may be fractional
  2694. * Optional: Variable number of arguments that are passed to `func`
  2695. ### Server
  2696. * `minetest.request_shutdown([message],[reconnect],[delay])`: request for server shutdown. Will display `message` to clients.
  2697. * `reconnect` == true displays a reconnect button
  2698. * `delay` adds an optional delay (in seconds) before shutdown.
  2699. Negative delay cancels the current active shutdown.
  2700. Zero delay triggers an immediate shutdown.
  2701. * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
  2702. * `minetest.get_server_status()`: returns server status string
  2703. * `minetest.get_server_uptime()`: returns the server uptime in seconds
  2704. * `minetest.remove_player(name)`: remove player from database (if he is not connected).
  2705. * As auth data is not removed, minetest.player_exists will continue to return true.
  2706. Call the below method as well if you want to remove auth data too.
  2707. * Returns a code (0: successful, 1: no such player, 2: player is connected)
  2708. * `minetest.remove_player_auth(name)`: remove player authentication data
  2709. * Returns boolean indicating success (false if player nonexistant)
  2710. ### Bans
  2711. * `minetest.get_ban_list()`: returns the ban list (same as `minetest.get_ban_description("")`)
  2712. * `minetest.get_ban_description(ip_or_name)`: returns ban description (string)
  2713. * `minetest.ban_player(name)`: ban a player
  2714. * `minetest.unban_player_or_ip(name)`: unban player or IP address
  2715. * `minetest.kick_player(name, [reason])`: disconnect a player with a optional reason
  2716. ### Particles
  2717. * `minetest.add_particle(particle definition)`
  2718. * Deprecated: `minetest.add_particle(pos, velocity, acceleration, expirationtime,
  2719. size, collisiondetection, texture, playername)`
  2720. * `minetest.add_particlespawner(particlespawner definition)`
  2721. * Add a `ParticleSpawner`, an object that spawns an amount of particles over `time` seconds
  2722. * Returns an `id`, and -1 if adding didn't succeed
  2723. * `Deprecated: minetest.add_particlespawner(amount, time,
  2724. minpos, maxpos,
  2725. minvel, maxvel,
  2726. minacc, maxacc,
  2727. minexptime, maxexptime,
  2728. minsize, maxsize,
  2729. collisiondetection, texture, playername)`
  2730. * `minetest.delete_particlespawner(id, player)`
  2731. * Delete `ParticleSpawner` with `id` (return value from `minetest.add_particlespawner`)
  2732. * If playername is specified, only deletes on the player's client, otherwise on all clients
  2733. ### Schematics
  2734. * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
  2735. * Create a schematic from the volume of map specified by the box formed by p1 and p2.
  2736. * Apply the specified probability and per-node force-place to the specified nodes
  2737. according to the `probability_list`.
  2738. * `probability_list` is an array of tables containing two fields, `pos` and `prob`.
  2739. * `pos` is the 3D vector specifying the absolute coordinates of the
  2740. node being modified,
  2741. * `prob` is an integer value from `0` to `255` that encodes probability and
  2742. per-node force-place. Probability has levels 0-127, then 128 is added to
  2743. encode per-node force-place.
  2744. For probability stated as 0-255, divide by 2 and round down to get values
  2745. 0-127, then add 128 to apply per-node force-place.
  2746. * If there are two or more entries with the same pos value, the
  2747. last entry is used.
  2748. * If `pos` is not inside the box formed by `p1` and `p2`, it is ignored.
  2749. * If `probability_list` equals `nil`, no probabilities are applied.
  2750. * Apply the specified probability to the specified horizontal slices according to the
  2751. `slice_prob_list`.
  2752. * `slice_prob_list` is an array of tables containing two fields, `ypos` and `prob`.
  2753. * `ypos` indicates the y position of the slice with a probability applied,
  2754. the lowest slice being `ypos = 0`.
  2755. * If slice probability list equals `nil`, no slice probabilities are applied.
  2756. * Saves schematic in the Minetest Schematic format to filename.
  2757. * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
  2758. * Place the schematic specified by schematic (see: Schematic specifier) at `pos`.
  2759. * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
  2760. * If the `rotation` parameter is omitted, the schematic is not rotated.
  2761. * `replacements` = `{["old_name"] = "convert_to", ...}`
  2762. * `force_placement` is a boolean indicating whether nodes other than `air` and
  2763. `ignore` are replaced by the schematic
  2764. * Returns nil if the schematic could not be loaded.
  2765. * **Warning**: Once you have loaded a schematic from a file, it will be cached. Future calls
  2766. will always use the cached version and the replacement list defined for it,
  2767. regardless of whether the file or the replacement list parameter have changed.
  2768. The only way to load the file anew is to restart the server.
  2769. * `flags` is a flag field with the available flags:
  2770. * place_center_x
  2771. * place_center_y
  2772. * place_center_z
  2773. * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
  2774. * This function is analogous to minetest.place_schematic, but places a schematic onto the
  2775. specified VoxelManip object `vmanip` instead of the whole map.
  2776. * Returns false if any part of the schematic was cut-off due to the VoxelManip not
  2777. containing the full area required, and true if the whole schematic was able to fit.
  2778. * Returns nil if the schematic could not be loaded.
  2779. * After execution, any external copies of the VoxelManip contents are invalidated.
  2780. * `flags` is a flag field with the available flags:
  2781. * place_center_x
  2782. * place_center_y
  2783. * place_center_z
  2784. * `minetest.serialize_schematic(schematic, format, options)`
  2785. * Return the serialized schematic specified by schematic (see: Schematic specifier)
  2786. * in the `format` of either "mts" or "lua".
  2787. * "mts" - a string containing the binary MTS data used in the MTS file format
  2788. * "lua" - a string containing Lua code representing the schematic in table format
  2789. * `options` is a table containing the following optional parameters:
  2790. * If `lua_use_comments` is true and `format` is "lua", the Lua code generated will have (X, Z)
  2791. * position comments for every X row generated in the schematic data for easier reading.
  2792. * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua", the Lua code generated
  2793. * will use that number of spaces as indentation instead of a tab character.
  2794. ### HTTP Requests:
  2795. * `minetest.request_http_api()`:
  2796. * returns `HTTPApiTable` containing http functions if the calling mod has been granted
  2797. access by being listed in the `secure.http_mods` or `secure.trusted_mods` setting,
  2798. otherwise returns `nil`.
  2799. * The returned table contains the functions `fetch`, `fetch_async` and `fetch_async_get`
  2800. described below.
  2801. * Only works at init time and must be called from the mod's main scope (not from a function).
  2802. * Function only exists if minetest server was built with cURL support.
  2803. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
  2804. A LOCAL VARIABLE!**
  2805. * `HTTPApiTable.fetch(HTTPRequest req, callback)`
  2806. * Performs given request asynchronously and calls callback upon completion
  2807. * callback: `function(HTTPRequestResult res)`
  2808. * Use this HTTP function if you are unsure, the others are for advanced use.
  2809. * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
  2810. * Performs given request asynchronously and returns handle for `HTTPApiTable.fetch_async_get`
  2811. * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
  2812. * Return response data for given asynchronous HTTP request
  2813. ### Storage API:
  2814. * `minetest.get_mod_storage()`:
  2815. * returns reference to mod private `StorageRef`
  2816. * must be called during mod load time
  2817. ### Misc.
  2818. * `minetest.get_connected_players()`: returns list of `ObjectRefs`
  2819. * `minetest.is_player(o)`: boolean, whether `o` is a player
  2820. * `minetest.player_exists(name)`: boolean, whether player exists (regardless of online status)
  2821. * `minetest.hud_replace_builtin(name, hud_definition)`
  2822. * Replaces definition of a builtin hud element
  2823. * `name`: `"breath"` or `"health"`
  2824. * `hud_definition`: definition to replace builtin definition
  2825. * `minetest.send_join_message(player_name)`
  2826. * This function can be overridden by mods to change the join message.
  2827. * `minetest.send_leave_message(player_name, timed_out)`
  2828. * This function can be overridden by mods to change the leave message.
  2829. * `minetest.hash_node_position(pos)`: returns an 48-bit integer
  2830. * `pos`: table {x=number, y=number, z=number},
  2831. * Gives a unique hash number for a node position (16+16+16=48bit)
  2832. * `minetest.get_position_from_hash(hash)`: returns a position
  2833. * Inverse transform of `minetest.hash_node_position`
  2834. * `minetest.get_item_group(name, group)`: returns a rating
  2835. * Get rating of a group of an item. (`0` means: not in group)
  2836. * `minetest.get_node_group(name, group)`: returns a rating
  2837. * Deprecated: An alias for the former.
  2838. * `minetest.raillike_group(name)`: returns a rating
  2839. * Returns rating of the connect_to_raillike group corresponding to name
  2840. * If name is not yet the name of a connect_to_raillike group, a new group id
  2841. * is created, with that name
  2842. * `minetest.get_content_id(name)`: returns an integer
  2843. * Gets the internal content ID of `name`
  2844. * `minetest.get_name_from_content_id(content_id)`: returns a string
  2845. * Gets the name of the content with that content ID
  2846. * `minetest.parse_json(string[, nullvalue])`: returns something
  2847. * Convert a string containing JSON data into the Lua equivalent
  2848. * `nullvalue`: returned in place of the JSON null; defaults to `nil`
  2849. * On success returns a table, a string, a number, a boolean or `nullvalue`
  2850. * On failure outputs an error message and returns `nil`
  2851. * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
  2852. * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error message
  2853. * Convert a Lua table into a JSON string
  2854. * styled: Outputs in a human-readable format if this is set, defaults to false
  2855. * Unserializable things like functions and userdata will cause an error.
  2856. * **Warning**: JSON is more strict than the Lua table format.
  2857. 1. You can only use strings and positive integers of at least one as keys.
  2858. 2. You can not mix string and integer keys.
  2859. This is due to the fact that JSON has two distinct array and object values.
  2860. * Example: `write_json({10, {a = false}})`, returns `"[10, {\"a\": false}]"`
  2861. * `minetest.serialize(table)`: returns a string
  2862. * Convert a table containing tables, strings, numbers, booleans and `nil`s
  2863. into string form readable by `minetest.deserialize`
  2864. * Example: `serialize({foo='bar'})`, returns `'return { ["foo"] = "bar" }'`
  2865. * `minetest.deserialize(string)`: returns a table
  2866. * Convert a string returned by `minetest.deserialize` into a table
  2867. * `string` is loaded in an empty sandbox environment.
  2868. * Will load functions, but they cannot access the global environment.
  2869. * Example: `deserialize('return { ["foo"] = "bar" }')`, returns `{foo='bar'}`
  2870. * Example: `deserialize('print("foo")')`, returns `nil` (function call fails)
  2871. * `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
  2872. * `minetest.compress(data, method, ...)`: returns `compressed_data`
  2873. * Compress a string of data.
  2874. * `method` is a string identifying the compression method to be used.
  2875. * Supported compression methods:
  2876. * Deflate (zlib): `"deflate"`
  2877. * `...` indicates method-specific arguments. Currently defined arguments are:
  2878. * Deflate: `level` - Compression level, `0`-`9` or `nil`.
  2879. * `minetest.decompress(compressed_data, method, ...)`: returns data
  2880. * Decompress a string of data (using ZLib).
  2881. * See documentation on `minetest.compress()` for supported compression methods.
  2882. * currently supported.
  2883. * `...` indicates method-specific arguments. Currently, no methods use this.
  2884. * `minetest.rgba(red, green, blue[, alpha])`: returns a string
  2885. * Each argument is a 8 Bit unsigned integer
  2886. * Returns the ColorString from rgb or rgba values
  2887. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
  2888. * `minetest.encode_base64(string)`: returns string encoded in base64
  2889. * Encodes a string in base64.
  2890. * `minetest.decode_base64(string)`: returns string
  2891. * Decodes a string encoded in base64.
  2892. * `minetest.is_protected(pos, name)`: returns boolean
  2893. * Returns true, if player `name` shouldn't be able to dig at `pos` or do other
  2894. actions, definable by mods, due to some mod-defined ownership-like concept.
  2895. Returns false or nil, if the player is allowed to do such actions.
  2896. * `name` will be "" for non-players or unknown players.
  2897. * This function should be overridden by protection mods and should be used to
  2898. check if a player can interact at a position.
  2899. * This function should call the old version of itself if the position is not
  2900. protected by the mod.
  2901. * Example:
  2902. local old_is_protected = minetest.is_protected
  2903. function minetest.is_protected(pos, name)
  2904. if mymod:position_protected_from(pos, name) then
  2905. return true
  2906. end
  2907. return old_is_protected(pos, name)
  2908. end
  2909. * `minetest.record_protection_violation(pos, name)`
  2910. * This function calls functions registered with
  2911. `minetest.register_on_protection_violation`.
  2912. * `minetest.is_area_protected(pos1, pos2, player_name, interval)
  2913. * Returns the position of the first node that `player_name` may not modify in
  2914. the specified cuboid between `pos1` and `pos2`.
  2915. * Returns `false` if no protections were found.
  2916. * Applies `is_protected()` to a 3D lattice of points in the defined volume.
  2917. The points are spaced evenly throughout the volume and have a spacing
  2918. similar to, but no larger than, `interval`.
  2919. * All corners and edges of the defined volume are checked.
  2920. * `interval` defaults to 4.
  2921. * `interval` should be carefully chosen and maximised to avoid an excessive
  2922. number of points being checked.
  2923. * Like `minetest.is_protected`, this function may be extended or overwritten by
  2924. mods to provide a faster implementation to check the cuboid for intersections.
  2925. * `minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orient_flags)`
  2926. * Attempt to predict the desired orientation of the facedir-capable node
  2927. defined by `itemstack`, and place it accordingly (on-wall, on the floor, or
  2928. hanging from the ceiling). Stacks are handled normally if the `infinitestacks`
  2929. field is false or omitted (else, the itemstack is not changed). `orient_flags`
  2930. is an optional table containing extra tweaks to the placement code:
  2931. * `invert_wall`: if `true`, place wall-orientation on the ground and ground-
  2932. orientation on the wall.
  2933. * `force_wall` : if `true`, always place the node in wall orientation.
  2934. * `force_ceiling`: if `true`, always place on the ceiling.
  2935. * `force_floor`: if `true`, always place the node on the floor.
  2936. * `force_facedir`: if `true`, forcefully reset the facedir to north when placing on
  2937. the floor or ceiling
  2938. * The first four options are mutually-exclusive; the last in the list takes
  2939. precedence over the first.
  2940. * `minetest.rotate_node(itemstack, placer, pointed_thing)`
  2941. * calls `rotate_and_place()` with infinitestacks set according to the state of
  2942. the creative mode setting, and checks for "sneak" to set the `invert_wall`
  2943. parameter.
  2944. * `minetest.forceload_block(pos[, transient])`
  2945. * forceloads the position `pos`.
  2946. * returns `true` if area could be forceloaded
  2947. * If `transient` is `false` or absent, the forceload will be persistent
  2948. (saved between server runs). If `true`, the forceload will be transient
  2949. (not saved between server runs).
  2950. * `minetest.forceload_free_block(pos[, transient])`
  2951. * stops forceloading the position `pos`
  2952. * If `transient` is `false` or absent, frees a persistent forceload.
  2953. If `true`, frees a transient forceload.
  2954. * `minetest.request_insecure_environment()`: returns an environment containing
  2955. insecure functions if the calling mod has been listed as trusted in the
  2956. `secure.trusted_mods` setting or security is disabled, otherwise returns `nil`.
  2957. * Only works at init time and must be called from the mod's main scope (not from a function).
  2958. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE IT IN
  2959. A LOCAL VARIABLE!**
  2960. * `minetest.global_exists(name)`
  2961. * Checks if a global variable has been set, without triggering a warning.
  2962. ### Global objects
  2963. * `minetest.env`: `EnvRef` of the server environment and world.
  2964. * Any function in the minetest namespace can be called using the syntax
  2965. `minetest.env:somefunction(somearguments)`
  2966. instead of `minetest.somefunction(somearguments)`
  2967. * Deprecated, but support is not to be dropped soon
  2968. ### Global tables
  2969. * `minetest.registered_items`
  2970. * Map of registered items, indexed by name
  2971. * `minetest.registered_nodes`
  2972. * Map of registered node definitions, indexed by name
  2973. * `minetest.registered_craftitems`
  2974. * Map of registered craft item definitions, indexed by name
  2975. * `minetest.registered_tools`
  2976. * Map of registered tool definitions, indexed by name
  2977. * `minetest.registered_entities`
  2978. * Map of registered entity prototypes, indexed by name
  2979. * `minetest.object_refs`
  2980. * Map of object references, indexed by active object id
  2981. * `minetest.luaentities`
  2982. * Map of Lua entities, indexed by active object id
  2983. * `minetest.registered_chatcommands`
  2984. * Map of registered chat command definitions, indexed by name
  2985. * `minetest.registered_ores`
  2986. * List of registered ore definitions.
  2987. * `minetest.registered_biomes`
  2988. * List of registered biome definitions.
  2989. * `minetest.registered_decorations`
  2990. * List of registered decoration definitions.
  2991. Class reference
  2992. ---------------
  2993. ### ModChannel
  2994. An interface to use mod channels on client and server
  2995. #### Methods
  2996. * `leave()`: leave the mod channel.
  2997. * Server leaves channel `channel_name`.
  2998. * No more incoming or outgoing messages can be sent to this channel from server mods.
  2999. * This invalidate all future object usage
  3000. * Ensure your set mod_channel to nil after that to free Lua resources
  3001. * `is_writeable()`: returns true if channel is writeable and mod can send over it.
  3002. * `send_all(message)`: Send `message` though the mod channel.
  3003. * If mod channel is not writeable or invalid, message will be dropped.
  3004. * Message size is limited to 65535 characters by protocol.
  3005. ### `MetaDataRef`
  3006. See `StorageRef`, `NodeMetaRef` and `ItemStackMetaRef`.
  3007. #### Methods
  3008. * `set_string(name, value)`
  3009. * `get_string(name)`
  3010. * `set_int(name, value)`
  3011. * `get_int(name)`
  3012. * `set_float(name, value)`
  3013. * `get_float(name)`
  3014. * `to_table()`: returns `nil` or a table with keys:
  3015. * `fields`: key-value storage
  3016. * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
  3017. * `from_table(nil or {})`
  3018. * Any non-table value will clear the metadata
  3019. * See "Node Metadata" for an example
  3020. * returns `true` on success
  3021. * `equals(other)`
  3022. * returns `true` if this metadata has the same key-value pairs as `other`
  3023. ### `NodeMetaRef`
  3024. Node metadata: reference extra data and functionality stored in a node.
  3025. Can be obtained via `minetest.get_meta(pos)`.
  3026. #### Methods
  3027. * All methods in MetaDataRef
  3028. * `get_inventory()`: returns `InvRef`
  3029. * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
  3030. This will prevent them from being sent to the client. Note that the "private"
  3031. status will only be remembered if an associated key-value pair exists, meaning
  3032. it's best to call this when initializing all other meta (e.g. `on_construct`).
  3033. ### `ItemStackMetaRef`
  3034. ItemStack metadata: reference extra data and functionality stored in a stack.
  3035. Can be obtained via `item:get_meta()`.
  3036. #### Methods
  3037. * All methods in MetaDataRef
  3038. * `set_tool_capabilities([tool_capabilities])`
  3039. * overrides the item's tool capabilities
  3040. * a nil value will clear the override data and restore the original behavior
  3041. ### `StorageRef`
  3042. Mod metadata: per mod metadata, saved automatically.
  3043. Can be obtained via `minetest.get_mod_storage()` during load time.
  3044. #### Methods
  3045. * All methods in MetaDataRef
  3046. ### `NodeTimerRef`
  3047. Node Timers: a high resolution persistent per-node timer.
  3048. Can be gotten via `minetest.get_node_timer(pos)`.
  3049. #### Methods
  3050. * `set(timeout,elapsed)`
  3051. * set a timer's state
  3052. * `timeout` is in seconds, and supports fractional values (0.1 etc)
  3053. * `elapsed` is in seconds, and supports fractional values (0.1 etc)
  3054. * will trigger the node's `on_timer` function after `(timeout - elapsed)` seconds
  3055. * `start(timeout)`
  3056. * start a timer
  3057. * equivalent to `set(timeout,0)`
  3058. * `stop()`
  3059. * stops the timer
  3060. * `get_timeout()`: returns current timeout in seconds
  3061. * if `timeout` equals `0`, timer is inactive
  3062. * `get_elapsed()`: returns current elapsed time in seconds
  3063. * the node's `on_timer` function will be called after `(timeout - elapsed)` seconds
  3064. * `is_started()`: returns boolean state of timer
  3065. * returns `true` if timer is started, otherwise `false`
  3066. ### `ObjectRef`
  3067. Moving things in the game are generally these.
  3068. This is basically a reference to a C++ `ServerActiveObject`
  3069. #### Methods
  3070. * `remove()`: remove object (after returning from Lua)
  3071. * Note: Doesn't work on players, use `minetest.kick_player` instead
  3072. * `get_pos()`: returns `{x=num, y=num, z=num}`
  3073. * `set_pos(pos)`; `pos`=`{x=num, y=num, z=num}`
  3074. * `move_to(pos, continuous=false)`: interpolated move
  3075. * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
  3076. * `puncher` = another `ObjectRef`,
  3077. * `time_from_last_punch` = time since last punch action of the puncher
  3078. * `direction`: can be `nil`
  3079. * `right_click(clicker)`; `clicker` is another `ObjectRef`
  3080. * `get_hp()`: returns number of hitpoints (2 * number of hearts)
  3081. * `set_hp(hp)`: set number of hitpoints (2 * number of hearts)
  3082. * `get_inventory()`: returns an `InvRef`
  3083. * `get_wield_list()`: returns the name of the inventory list the wielded item is in
  3084. * `get_wield_index()`: returns the index of the wielded item
  3085. * `get_wielded_item()`: returns an `ItemStack`
  3086. * `set_wielded_item(item)`: replaces the wielded item, returns `true` if successful
  3087. * `set_armor_groups({group1=rating, group2=rating, ...})`
  3088. * `get_armor_groups()`: returns a table with the armor group ratings
  3089. * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
  3090. * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
  3091. * `frame_speed`: number, default: `15.0`
  3092. * `frame_blend`: number, default: `0.0`
  3093. * `frame_loop`: boolean, default: `true`
  3094. * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and `frame_loop`
  3095. * `set_animation_frame_speed(frame_speed)`
  3096. * `frame_speed`: number, default: `15.0`
  3097. * `set_attach(parent, bone, position, rotation)`
  3098. * `bone`: string
  3099. * `position`: `{x=num, y=num, z=num}` (relative)
  3100. * `rotation`: `{x=num, y=num, z=num}` = Rotation on each axis, in degrees
  3101. * `get_attach()`: returns parent, bone, position, rotation or nil if it isn't attached
  3102. * `set_detach()`
  3103. * `set_bone_position(bone, position, rotation)`
  3104. * `bone`: string
  3105. * `position`: `{x=num, y=num, z=num}` (relative)
  3106. * `rotation`: `{x=num, y=num, z=num}`
  3107. * `get_bone_position(bone)`: returns position and rotation of the bone
  3108. * `set_properties(object property table)`
  3109. * `get_properties()`: returns object property table
  3110. * `is_player()`: returns true for players, false otherwise
  3111. * `get_nametag_attributes()`
  3112. * returns a table with the attributes of the nametag of an object
  3113. * {
  3114. color = {a=0..255, r=0..255, g=0..255, b=0..255},
  3115. text = "",
  3116. }
  3117. * `set_nametag_attributes(attributes)`
  3118. * sets the attributes of the nametag of an object
  3119. * `attributes`:
  3120. {
  3121. color = ColorSpec,
  3122. text = "My Nametag",
  3123. }
  3124. ##### LuaEntitySAO-only (no-op for other objects)
  3125. * `set_velocity(vel)`
  3126. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  3127. * `get_velocity()`: returns the velocity, a vector
  3128. * `set_acceleration(acc)`
  3129. * `acc` is a vector
  3130. * `get_acceleration()`: returns the acceleration, a vector
  3131. * `set_yaw(radians)`
  3132. * `get_yaw()`: returns number in radians
  3133. * `set_texture_mod(mod)`
  3134. * `get_texture_mod()` returns current texture modifier
  3135. * `set_sprite(p, num_frames, framelength, select_horiz_by_yawpitch)`
  3136. * Select sprite from spritesheet with optional animation and Dungeon Master
  3137. style texture selection based on yaw relative to camera
  3138. * `p`: {x=number, y=number}, the coordinate of the first frame
  3139. (x: column, y: row), default: `{x=0, y=0}`
  3140. * `num_frames`: number, default: `1`
  3141. * `framelength`: number, default: `0.2`
  3142. * `select_horiz_by_yawpitch`: boolean, this was once used for the Dungeon
  3143. Master mob, default: `false`
  3144. * `get_entity_name()` (**Deprecated**: Will be removed in a future version)
  3145. * `get_luaentity()`
  3146. ##### Player-only (no-op for other objects)
  3147. * `get_player_name()`: returns `""` if is not a player
  3148. * `get_player_velocity()`: returns `nil` if is not a player, otherwise a
  3149. table {x, y, z} representing the player's instantaneous velocity in nodes/s
  3150. * `get_look_dir()`: get camera direction as a unit vector
  3151. * `get_look_vertical()`: pitch in radians
  3152. * Angle ranges between -pi/2 and pi/2, which are straight up and down respectively.
  3153. * `get_look_horizontal()`: yaw in radians
  3154. * Angle is counter-clockwise from the +z direction.
  3155. * `set_look_vertical(radians)`: sets look pitch
  3156. * radians - Angle from looking forward, where positive is downwards.
  3157. * `set_look_horizontal(radians)`: sets look yaw
  3158. * radians - Angle from the +z direction, where positive is counter-clockwise.
  3159. * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use `get_look_vertical`.
  3160. * Angle ranges between -pi/2 and pi/2, which are straight down and up respectively.
  3161. * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use `get_look_horizontal`.
  3162. * Angle is counter-clockwise from the +x direction.
  3163. * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use `set_look_vertical`.
  3164. * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use `set_look_horizontal`.
  3165. * `get_breath()`: returns players breath
  3166. * `set_breath(value)`: sets players breath
  3167. * values:
  3168. * `0`: player is drowning
  3169. * max: bubbles bar is not shown
  3170. * See Object Properties for more information
  3171. * `set_attribute(attribute, value)`:
  3172. * Sets an extra attribute with value on player.
  3173. * `value` must be a string, or a number which will be converted to a string.
  3174. * If `value` is `nil`, remove attribute from player.
  3175. * `get_attribute(attribute)`:
  3176. * Returns value (a string) for extra attribute.
  3177. * Returns `nil` if no attribute found.
  3178. * `set_inventory_formspec(formspec)`
  3179. * Redefine player's inventory form
  3180. * Should usually be called in `on_joinplayer`
  3181. * `get_inventory_formspec()`: returns a formspec string
  3182. * `get_player_control()`: returns table with player pressed keys
  3183. * The table consists of fields with boolean value representing the pressed
  3184. keys, the fields are jump, right, left, LMB, RMB, sneak, aux1, down and up
  3185. * example: `{jump=false, right=true, left=false, LMB=false, RMB=false,
  3186. sneak=true, aux1=false, down=false, up=false}`
  3187. * `get_player_control_bits()`: returns integer with bit packed player pressed keys
  3188. * bit nr/meaning: 0/up, 1/down, 2/left, 3/right, 4/jump, 5/aux1, 6/sneak,
  3189. 7/LMB, 8/RMB
  3190. * `set_physics_override(override_table)`
  3191. * `override_table` is a table with the following fields:
  3192. * `speed`: multiplier to default walking speed value (default: `1`)
  3193. * `jump`: multiplier to default jump value (default: `1`)
  3194. * `gravity`: multiplier to default gravity value (default: `1`)
  3195. * `sneak`: whether player can sneak (default: `true`)
  3196. * `sneak_glitch`: whether player can use the new move code replications
  3197. of the old sneak side-effects: sneak ladders and 2 node sneak jump
  3198. (default: `false`)
  3199. * `new_move`: use new move/sneak code. When `false` the exact old code
  3200. is used for the specific old sneak behaviour (default: `true`)
  3201. * `get_physics_override()`: returns the table given to `set_physics_override`
  3202. * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
  3203. number on success
  3204. * `hud_remove(id)`: remove the HUD element of the specified id
  3205. * `hud_change(id, stat, value)`: change a value of a previously added HUD element
  3206. * element `stat` values: `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
  3207. * `hud_get(id)`: gets the HUD element definition structure of the specified ID
  3208. * `hud_set_flags(flags)`: sets specified HUD flags to `true`/`false`
  3209. * `flags`: (is visible) `hotbar`, `healthbar`, `crosshair`, `wielditem`, `breathbar`,
  3210. `minimap`, `minimap_radar`
  3211. * pass a table containing a `true`/`false` value of each flag to be set or unset
  3212. * if a flag equals `nil`, the flag is not modified
  3213. * note that setting `minimap` modifies the client's permission to view the minimap -
  3214. * the client may locally elect to not view the minimap
  3215. * minimap `radar` is only usable when `minimap` is true
  3216. * `hud_get_flags()`: returns a table containing status of hud flags
  3217. * returns `{hotbar=true, healthbar=true, crosshair=true, wielditem=true,
  3218. breathbar=true, minimap=true, minimap_radar=true}`
  3219. * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
  3220. * `count`: number of items, must be between `1` and `23`
  3221. * `hud_get_hotbar_itemcount`: returns number of visible items
  3222. * `hud_set_hotbar_image(texturename)`
  3223. * sets background image for hotbar
  3224. * `hud_get_hotbar_image`: returns texturename
  3225. * `hud_set_hotbar_selected_image(texturename)`
  3226. * sets image for selected item of hotbar
  3227. * `hud_get_hotbar_selected_image`: returns texturename
  3228. * `set_sky(bgcolor, type, {texture names}, clouds)`
  3229. * `bgcolor`: ColorSpec, defaults to white
  3230. * `type`: Available types:
  3231. * `"regular"`: Uses 0 textures, `bgcolor` ignored
  3232. * `"skybox"`: Uses 6 textures, `bgcolor` used
  3233. * `"plain"`: Uses 0 textures, `bgcolor` used
  3234. * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
  3235. `"plain"` custom skyboxes (default: `true`)
  3236. * `get_sky()`: returns bgcolor, type, table of textures, clouds
  3237. * `set_clouds(parameters)`: set cloud parameters
  3238. * `parameters` is a table with the following optional fields:
  3239. * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
  3240. * `color`: basic cloud color with alpha channel, ColorSpec (default `#fff0f0e5`)
  3241. * `ambient`: cloud color lower bound, use for a "glow at night" effect.
  3242. ColorSpec (alpha ignored, default `#000000`)
  3243. * `height`: cloud height, i.e. y of cloud base (default per conf, usually `120`)
  3244. * `thickness`: cloud thickness in nodes (default `16`)
  3245. * `speed`: 2D cloud speed + direction in nodes per second (default `{x=0, z=-2}`)
  3246. * `get_clouds()`: returns a table with the current cloud parameters as in `set_clouds`
  3247. * `override_day_night_ratio(ratio or nil)`
  3248. * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific amount
  3249. * `nil`: Disables override, defaulting to sunlight based on day-night cycle
  3250. * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
  3251. * `set_local_animation(stand/idle, walk, dig, walk+dig, frame_speed=frame_speed)`:
  3252. set animation for player model in third person view
  3253. set_local_animation({x=0, y=79}, -- < stand/idle animation key frames
  3254. {x=168, y=187}, -- < walk animation key frames
  3255. {x=189, y=198}, -- < dig animation key frames
  3256. {x=200, y=219}, -- < walk+dig animation key frames
  3257. frame_speed=30): -- < animation frame speed
  3258. * `get_local_animation()`: returns stand, walk, dig, dig+walk tables and `frame_speed`
  3259. * `set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})`: defines offset value for camera per player
  3260. * in first person view
  3261. * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
  3262. * `get_eye_offset()`: returns `offset_first` and `offset_third`
  3263. ### `InvRef`
  3264. An `InvRef` is a reference to an inventory.
  3265. #### Methods
  3266. * `is_empty(listname)`: return `true` if list is empty
  3267. * `get_size(listname)`: get size of a list
  3268. * `set_size(listname, size)`: set size of a list
  3269. * returns `false` on error (e.g. invalid `listname` or `size`)
  3270. * `get_width(listname)`: get width of a list
  3271. * `set_width(listname, width)`: set width of list; currently used for crafting
  3272. * `get_stack(listname, i)`: get a copy of stack index `i` in list
  3273. * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
  3274. * `get_list(listname)`: return full list
  3275. * `set_list(listname, list)`: set full list (size will not change)
  3276. * `get_lists()`: returns list of inventory lists
  3277. * `set_lists(lists)`: sets inventory lists (size will not change)
  3278. * `add_item(listname, stack)`: add item somewhere in list, returns leftover `ItemStack`
  3279. * `room_for_item(listname, stack):` returns `true` if the stack of items
  3280. can be fully added to the list
  3281. * `contains_item(listname, stack, [match_meta])`: returns `true` if
  3282. the stack of items can be fully taken from the list.
  3283. If `match_meta` is false, only the items' names are compared (default: `false`).
  3284. * `remove_item(listname, stack)`: take as many items as specified from the list,
  3285. returns the items that were actually removed (as an `ItemStack`) -- note that
  3286. any item metadata is ignored, so attempting to remove a specific unique
  3287. item this way will likely remove the wrong one -- to do that use `set_stack`
  3288. with an empty `ItemStack`
  3289. * `get_location()`: returns a location compatible to `minetest.get_inventory(location)`
  3290. * returns `{type="undefined"}` in case location is not known
  3291. ### `AreaStore`
  3292. A fast access data structure to store areas, and find areas near a given position or area.
  3293. Every area has a `data` string attribute to store additional information.
  3294. You can create an empty `AreaStore` by calling `AreaStore()`, or `AreaStore(type_name)`.
  3295. If you chose the parameter-less constructor, a fast implementation will be automatically
  3296. chosen for you.
  3297. #### Methods
  3298. * `get_area(id, include_borders, include_data)`: returns the area with the id `id`.
  3299. (optional) Boolean values `include_borders` and `include_data` control what's copied.
  3300. Returns nil if specified area id does not exist.
  3301. * `get_areas_for_pos(pos, include_borders, include_data)`: returns all areas that contain
  3302. the position `pos`. (optional) Boolean values `include_borders` and `include_data` control
  3303. what's copied.
  3304. * `get_areas_in_area(edge1, edge2, accept_overlap, include_borders, include_data)`:
  3305. returns all areas that contain all nodes inside the area specified by `edge1` and `edge2` (inclusive).
  3306. If `accept_overlap` is true, also areas are returned that have nodes in common with the specified area.
  3307. (optional) Boolean values `include_borders` and `include_data` control what's copied.
  3308. * `insert_area(edge1, edge2, data, [id])`: inserts an area into the store. Returns the new area's ID,
  3309. or nil if the insertion failed. The (inclusive) positions `edge1` and `edge2` describe the area.
  3310. `data` is a string stored with the area. If passed, `id` will be used as the internal area ID,
  3311. it must be a unique number between 0 and 2^32-2. If you use the `id` parameter you must always use it,
  3312. or insertions are likely to fail due to conflicts.
  3313. * `reserve(count)`: reserves resources for at most `count` many contained areas.
  3314. Only needed for efficiency, and only some implementations profit.
  3315. * `remove_area(id)`: removes the area with the given id from the store, returns success.
  3316. * `set_cache_params(params)`: sets params for the included prefiltering cache.
  3317. Calling invalidates the cache, so that its elements have to be newly generated.
  3318. * `params`:
  3319. {
  3320. enabled = boolean, -- whether to enable, default true
  3321. block_radius = number, -- the radius (in nodes) of the areas the cache generates
  3322. prefiltered lists for, minimum 16, default 64
  3323. limit = number, -- the cache's size, minimum 20, default 1000
  3324. }
  3325. * `to_string()`: Experimental. Returns area store serialized as a (binary) string.
  3326. * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to a file.
  3327. * `from_string(str)`: Experimental. Deserializes string and loads it into the AreaStore.
  3328. Returns success and, optionally, an error message.
  3329. * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data from a file.
  3330. ### `ItemStack`
  3331. An `ItemStack` is a stack of items.
  3332. It can be created via `ItemStack(x)`, where x is an `ItemStack`,
  3333. an itemstring, a table or `nil`.
  3334. #### Methods
  3335. * `is_empty()`: returns `true` if stack is empty.
  3336. * `get_name()`: returns item name (e.g. `"default:stone"`).
  3337. * `set_name(item_name)`: returns a boolean indicating whether the item was cleared
  3338. * `get_count()`: Returns number of items on the stack.
  3339. * `set_count(count)`: returns a boolean indicating whether the item was cleared
  3340. * `count`: number, unsigned 16 bit integer
  3341. * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
  3342. * `set_wear(wear)`: returns boolean indicating whether item was cleared
  3343. * `wear`: number, unsigned 16 bit integer
  3344. * `get_meta()`: returns ItemStackMetaRef. See section for more details
  3345. * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item stack).
  3346. * `set_metadata(metadata)`: (DEPRECATED) Returns true.
  3347. * `clear()`: removes all items from the stack, making it empty.
  3348. * `replace(item)`: replace the contents of this stack.
  3349. * `item` can also be an itemstring or table.
  3350. * `to_string()`: returns the stack in itemstring form.
  3351. * `to_table()`: returns the stack in Lua table form.
  3352. * `get_stack_max()`: returns the maximum size of the stack (depends on the item).
  3353. * `get_free_space()`: returns `get_stack_max() - get_count()`.
  3354. * `is_known()`: returns `true` if the item name refers to a defined item type.
  3355. * `get_definition()`: returns the item definition table.
  3356. * `get_tool_capabilities()`: returns the digging properties of the item,
  3357. or those of the hand if none are defined for this item type
  3358. * `add_wear(amount)`
  3359. * Increases wear by `amount` if the item is a tool
  3360. * `amount`: number, integer
  3361. * `add_item(item)`: returns leftover `ItemStack`
  3362. * Put some item or stack onto this stack
  3363. * `item_fits(item)`: returns `true` if item or stack can be fully added to
  3364. this one.
  3365. * `take_item(n)`: returns taken `ItemStack`
  3366. * Take (and remove) up to `n` items from this stack
  3367. * `n`: number, default: `1`
  3368. * `peek_item(n)`: returns taken `ItemStack`
  3369. * Copy (don't remove) up to `n` items from this stack
  3370. * `n`: number, default: `1`
  3371. ### `PseudoRandom`
  3372. A 16-bit pseudorandom number generator.
  3373. Uses a well-known LCG algorithm introduced by K&R.
  3374. It can be created via `PseudoRandom(seed)`.
  3375. #### Methods
  3376. * `next()`: return next integer random number [`0`...`32767`]
  3377. * `next(min, max)`: return next integer random number [`min`...`max`]
  3378. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
  3379. due to the simple implementation making bad distribution otherwise.
  3380. ### `PcgRandom`
  3381. A 32-bit pseudorandom number generator.
  3382. Uses PCG32, an algorithm of the permuted congruential generator family, offering very strong randomness.
  3383. It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
  3384. #### Methods
  3385. * `next()`: return next integer random number [`-2147483648`...`2147483647`]
  3386. * `next(min, max)`: return next integer random number [`min`...`max`]
  3387. * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed random number [`min`...`max`]
  3388. * This is only a rough approximation of a normal distribution with:
  3389. * `mean = (max - min) / 2`, and
  3390. * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
  3391. * Increasing `num_trials` improves accuracy of the approximation
  3392. ### `SecureRandom`
  3393. Interface for the operating system's crypto-secure PRNG.
  3394. It can be created via `SecureRandom()`. The constructor returns nil if a secure random device cannot be
  3395. be found on the system.
  3396. #### Methods
  3397. * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many random bytes, as a string.
  3398. ### `PerlinNoise`
  3399. A perlin noise generator.
  3400. It can be created via `PerlinNoise(seed, octaves, persistence, scale)`
  3401. or `PerlinNoise(noiseparams)`.
  3402. Alternatively with `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
  3403. or `minetest.get_perlin(noiseparams)`.
  3404. #### Methods
  3405. * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
  3406. * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
  3407. ### `PerlinNoiseMap`
  3408. A fast, bulk perlin noise generator.
  3409. It can be created via `PerlinNoiseMap(noiseparams, size)` or
  3410. `minetest.get_perlin_map(noiseparams, size)`.
  3411. Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
  3412. for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
  3413. `nil` is returned).
  3414. For each of the functions with an optional `buffer` parameter: If `buffer` is not
  3415. nil, this table will be used to store the result instead of creating a new table.
  3416. #### Methods
  3417. * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
  3418. with values starting at `pos={x=,y=}`
  3419. * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>` 3D array
  3420. of 3D noise with values starting at `pos={x=,y=,z=}`
  3421. * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element array of 2D noise
  3422. with values starting at `pos={x=,y=}`
  3423. * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
  3424. * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result is stored internally.
  3425. * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result is stored internally.
  3426. * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array, returns a slice of the
  3427. most recently computed noise results. The result slice begins at coordinates `slice_offset` and
  3428. takes a chunk of `slice_size`.
  3429. E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer offset y = 20:
  3430. `noisevals = noise:get_map_slice({y=20}, {y=2})`
  3431. It is important to note that `slice_offset` offset coordinates begin at 1, and are relative to
  3432. the starting position of the most recently calculated noise.
  3433. To grab a single vertical column of noise starting at map coordinates x = 1023, y=1000, z = 1000:
  3434. `noise:calc_3d_map({x=1000, y=1000, z=1000})`
  3435. `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
  3436. ### `VoxelManip`
  3437. #### About VoxelManip
  3438. VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator' facility. The purpose of
  3439. this object is for fast, low-level, bulk access to reading and writing Map content. As such, setting
  3440. map nodes through VoxelManip will lack many of the higher level features and concepts you may be used
  3441. to with other methods of setting nodes. For example, nodes will not have their construction and
  3442. destruction callbacks run, and no rollback information is logged.
  3443. It is important to note that VoxelManip is designed for speed, and *not* ease of use or flexibility.
  3444. If your mod requires a map manipulation facility that will handle 100% of all edge cases, or the use
  3445. of high level node placement features, perhaps `minetest.set_node()` is better suited for the job.
  3446. In addition, VoxelManip might not be faster, or could even be slower, for your specific use case.
  3447. VoxelManip is most effective when setting very large areas of map at once - for example, if only
  3448. setting a 5x5x5 node area, a `minetest.set_node()` loop may be more optimal. Always profile code
  3449. using both methods of map manipulation to determine which is most appropriate for your usage.
  3450. #### Using VoxelManip
  3451. A VoxelManip object can be created any time using either:
  3452. `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
  3453. If the optional position parameters are present for either of these routines, the specified region
  3454. will be pre-loaded into the VoxelManip object on creation. Otherwise, the area of map you wish to
  3455. manipulate must first be loaded into the VoxelManip object using `VoxelManip:read_from_map()`.
  3456. Note that `VoxelManip:read_from_map()` returns two position vectors. The region formed by these
  3457. positions indicate the minimum and maximum (respectively) positions of the area actually loaded in
  3458. the VoxelManip, which may be larger than the area requested. For convenience, the loaded area
  3459. coordinates can also be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
  3460. Now that the VoxelManip object is populated with map data, your mod can fetch a copy of this data
  3461. using either of two methods. `VoxelManip:get_node_at()`, which retrieves an individual node in a
  3462. MapNode formatted table at the position requested is the simplest method to use, but also the slowest.
  3463. Nodes in a VoxelManip object may also be read in bulk to a flat array table using:
  3464. `VoxelManip:get_data()` for node content (in Content ID form, see section 'Content IDs'),
  3465. `VoxelManip:get_light_data()` for node light levels, and
  3466. `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
  3467. See section 'Flat array format' for more details.
  3468. It is very important to understand that the tables returned by any of the above three functions
  3469. represent a snapshot of the VoxelManip's internal state at the time of the call. This copy of the
  3470. data will *not* magically update itself if another function modifies the internal VoxelManip state.
  3471. Any functions that modify a VoxelManip's contents work on the VoxelManip's internal state unless
  3472. otherwise explicitly stated.
  3473. Once the bulk data has been edited to your liking, the internal VoxelManip state can be set using:
  3474. `VoxelManip:set_data()` for node content (in Content ID form, see section 'Content IDs'),
  3475. `VoxelManip:set_light_data()` for node light levels, and
  3476. `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
  3477. The parameter to each of the above three functions can use any table at all in the same flat array
  3478. format as produced by `get_data()` et al. and is *not required* to be a table retrieved from `get_data()`.
  3479. Once the internal VoxelManip state has been modified to your liking, the changes can be committed back
  3480. to the map by calling `VoxelManip:write_to_map()`.
  3481. ##### Flat array format
  3482. Let
  3483. `Nx = p2.X - p1.X + 1`,
  3484. `Ny = p2.Y - p1.Y + 1`, and
  3485. `Nz = p2.Z - p1.Z + 1`.
  3486. Then, for a loaded region of p1..p2, this array ranges from `1` up to and including the value of
  3487. the expression `Nx * Ny * Nz`.
  3488. Positions offset from p1 are present in the array with the format of:
  3489. ```
  3490. [
  3491. (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
  3492. (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
  3493. ...
  3494. (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
  3495. (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
  3496. ...
  3497. (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
  3498. ...
  3499. (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
  3500. ]
  3501. ```
  3502. and the array index for a position p contained completely in p1..p2 is:
  3503. `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
  3504. Note that this is the same "flat 3D array" format as `PerlinNoiseMap:get3dMap_flat()`.
  3505. VoxelArea objects (see section 'VoxelArea') can be used to simplify calculation of the index
  3506. for a single point in a flat VoxelManip array.
  3507. ##### Content IDs
  3508. A Content ID is a unique integer identifier for a specific node type. These IDs are used by VoxelManip
  3509. in place of the node name string for `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
  3510. `minetest.get_content_id()` to look up the Content ID for the specified node name, and
  3511. `minetest.get_name_from_content_id()` to look up the node name string for a given Content ID.
  3512. After registration of a node, its Content ID will remain the same throughout execution of the mod.
  3513. Note that the node being queried needs to have already been been registered.
  3514. The following builtin node types have their Content IDs defined as constants:
  3515. * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
  3516. * `minetest.CONTENT_AIR`: ID for "air" nodes
  3517. * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
  3518. ##### Mapgen VoxelManip objects
  3519. Inside of `on_generated()` callbacks, it is possible to retrieve the same VoxelManip object used by the
  3520. core's Map Generator (commonly abbreviated Mapgen). Most of the rules previously described still apply
  3521. but with a few differences:
  3522. * The Mapgen VoxelManip object is retrieved using: `minetest.get_mapgen_object("voxelmanip")`
  3523. * This VoxelManip object already has the region of map just generated loaded into it; it's not necessary
  3524. to call `VoxelManip:read_from_map()` before using a Mapgen VoxelManip.
  3525. * The `on_generated()` callbacks of some mods may place individual nodes in the generated area using
  3526. non-VoxelManip map modification methods. Because the same Mapgen VoxelManip object is passed through
  3527. each `on_generated()` callback, it becomes necessary for the Mapgen VoxelManip object to maintain
  3528. consistency with the current map state. For this reason, calling any of the following functions:
  3529. `minetest.add_node()`, `minetest.set_node()`, or `minetest.swap_node()`
  3530. will also update the Mapgen VoxelManip object's internal state active on the current thread.
  3531. * After modifying the Mapgen VoxelManip object's internal buffer, it may be necessary to update lighting
  3532. information using either: `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
  3533. ##### Other API functions operating on a VoxelManip
  3534. If any VoxelManip contents were set to a liquid node, `VoxelManip:update_liquids()` must be called
  3535. for these liquid nodes to begin flowing. It is recommended to call this function only after having
  3536. written all buffered data back to the VoxelManip object, save for special situations where the modder
  3537. desires to only have certain liquid nodes begin flowing.
  3538. The functions `minetest.generate_ores()` and `minetest.generate_decorations()` will generate all
  3539. registered decorations and ores throughout the full area inside of the specified VoxelManip object.
  3540. `minetest.place_schematic_on_vmanip()` is otherwise identical to `minetest.place_schematic()`,
  3541. except instead of placing the specified schematic directly on the map at the specified position, it
  3542. will place the schematic inside of the VoxelManip.
  3543. ##### Notes
  3544. * Attempting to read data from a VoxelManip object before map is read will result in a zero-length
  3545. array table for `VoxelManip:get_data()`, and an "ignore" node at any position for
  3546. `VoxelManip:get_node_at()`.
  3547. * If either a region of map has not yet been generated or is out-of-bounds of the map, that region is
  3548. filled with "ignore" nodes.
  3549. * Other mods, or the core itself, could possibly modify the area of map currently loaded into a VoxelManip
  3550. object. With the exception of Mapgen VoxelManips (see above section), the internal buffers are not
  3551. updated. For this reason, it is strongly encouraged to complete the usage of a particular VoxelManip
  3552. object in the same callback it had been created.
  3553. * If a VoxelManip object will be used often, such as in an `on_generated()` callback, consider passing
  3554. a file-scoped table as the optional parameter to `VoxelManip:get_data()`, which serves as a static
  3555. buffer the function can use to write map data to instead of returning a new table each call. This
  3556. greatly enhances performance by avoiding unnecessary memory allocations.
  3557. #### Methods
  3558. * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object containing
  3559. the region formed by `p1` and `p2`.
  3560. * returns actual emerged `pmin`, actual emerged `pmax`
  3561. * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to the map.
  3562. * **important**: data must be set using `VoxelManip:set_data()` before calling this
  3563. * if `light` is true, then lighting is automatically recalculated.
  3564. The default value is true.
  3565. If `light` is false, no light calculations happen, and you should correct
  3566. all modified blocks with `minetest.fix_light()` as soon as possible.
  3567. Keep in mind that modifying the map where light is incorrect can cause
  3568. more lighting bugs.
  3569. * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
  3570. the `VoxelManip` at that position
  3571. * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at that position
  3572. * `get_data([buffer])`: Retrieves the node content data loaded into the `VoxelManip` object
  3573. * returns raw node data in the form of an array of node content IDs
  3574. * if the param `buffer` is present, this table will be used to store the result instead
  3575. * `set_data(data)`: Sets the data contents of the `VoxelManip` object
  3576. * `update_map()`: Does nothing, kept for compatibility.
  3577. * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to a uniform value
  3578. * `light` is a table, `{day=<0...15>, night=<0...15>}`
  3579. * To be used only by a `VoxelManip` object from `minetest.get_mapgen_object`
  3580. * (`p1`, `p2`) is the area in which lighting is set;
  3581. defaults to the whole area if left out
  3582. * `get_light_data()`: Gets the light data read into the `VoxelManip` object
  3583. * Returns an array (indices 1 to volume) of integers ranging from `0` to `255`
  3584. * Each value is the bitwise combination of day and night light values (`0` to `15` each)
  3585. * `light = day + (night * 16)`
  3586. * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
  3587. in the `VoxelManip`
  3588. * expects lighting data in the same format that `get_light_data()` returns
  3589. * `get_param2_data([buffer])`: Gets the raw `param2` data read into the `VoxelManip` object
  3590. * Returns an array (indices 1 to volume) of integers ranging from `0` to `255`
  3591. * If the param `buffer` is present, this table will be used to store the result instead
  3592. * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in the `VoxelManip`
  3593. * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the `VoxelManip`
  3594. * To be used only by a `VoxelManip` object from `minetest.get_mapgen_object`
  3595. * (`p1`, `p2`) is the area in which lighting is set; defaults to the whole area
  3596. if left out or nil
  3597. * `propagate_shadow` is an optional boolean deciding whether shadows in a generated
  3598. mapchunk above are propagated down into the mapchunk; defaults to `true` if left out
  3599. * `update_liquids()`: Update liquid flow
  3600. * `was_modified()`: Returns `true` or `false` if the data in the voxel manipulator
  3601. had been modified since the last read from map, due to a call to
  3602. `minetest.set_data()` on the loaded area elsewhere
  3603. * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
  3604. ### `VoxelArea`
  3605. A helper class for voxel areas.
  3606. It can be created via `VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}`.
  3607. The coordinates are *inclusive*, like most other things in Minetest.
  3608. #### Methods
  3609. * `getExtent()`: returns a 3D vector containing the size of the area formed by
  3610. `MinEdge` and `MaxEdge`
  3611. * `getVolume()`: returns the volume of the area formed by `MinEdge` and `MaxEdge`
  3612. * `index(x, y, z)`: returns the index of an absolute position in a flat array starting at `1`
  3613. * useful for things like `VoxelManip`, raw Schematic specifiers,
  3614. `PerlinNoiseMap:get2d`/`3dMap`, and so on
  3615. * `indexp(p)`: same as above, except takes a vector
  3616. * `position(i)`: returns the absolute position vector corresponding to index `i`
  3617. * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by `MinEdge` and `MaxEdge`
  3618. * `containsp(p)`: same as above, except takes a vector
  3619. * `containsi(i)`: same as above, except takes an index `i`
  3620. * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns indices
  3621. * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of `[z [y [x]]]`
  3622. * `iterp(minp, maxp)`: same as above, except takes a vector
  3623. ### `Settings`
  3624. An interface to read config files in the format of `minetest.conf`.
  3625. It can be created via `Settings(filename)`.
  3626. #### Methods
  3627. * `get(key)`: returns a value
  3628. * `get_bool(key, [default])`: returns a boolean
  3629. * `default` is the value returned if `key` is not found.
  3630. * Returns `nil` if `key` is not found and `default` not specified.
  3631. * `get_np_group(key)`: returns a NoiseParams table
  3632. * `set(key, value)`
  3633. * Setting names can't contain whitespace or any of `="{}#`.
  3634. * Setting values can't contain the sequence `\n"""`.
  3635. * Setting names starting with "secure." can't be set on the main settings object (`minetest.settings`).
  3636. * `set_bool(key, value)`
  3637. * See documentation for set() above.
  3638. * `set_np_group(key, value)`
  3639. * `value` is a NoiseParams table.
  3640. * Also, see documentation for set() above.
  3641. * `remove(key)`: returns a boolean (`true` for success)
  3642. * `get_names()`: returns `{key1,...}`
  3643. * `write()`: returns a boolean (`true` for success)
  3644. * Writes changes to file.
  3645. * `to_table()`: returns `{[key1]=value1,...}`
  3646. ### `Raycast`
  3647. A raycast on the map. It works with selection boxes.
  3648. Can be used as an iterator in a for loop.
  3649. The map is loaded as the ray advances. If the
  3650. map is modified after the `Raycast` is created,
  3651. the changes may or may not have an effect on
  3652. the object.
  3653. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  3654. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  3655. * `pos1`: start of the ray
  3656. * `pos2`: end of the ray
  3657. * `objects` : if false, only nodes will be returned. Default is true.
  3658. * `liquids' : if false, liquid nodes won't be returned. Default is false.
  3659. #### Methods
  3660. * `next()`: returns a `pointed_thing`
  3661. * Returns the next thing pointed by the ray or nil.
  3662. Mapgen objects
  3663. --------------
  3664. A mapgen object is a construct used in map generation. Mapgen objects can be used
  3665. by an `on_generate` callback to speed up operations by avoiding unnecessary
  3666. recalculations; these can be retrieved using the `minetest.get_mapgen_object()`
  3667. function. If the requested Mapgen object is unavailable, or `get_mapgen_object()`
  3668. was called outside of an `on_generate()` callback, `nil` is returned.
  3669. The following Mapgen objects are currently available:
  3670. ### `voxelmanip`
  3671. This returns three values; the `VoxelManip` object to be used, minimum and maximum
  3672. emerged position, in that order. All mapgens support this object.
  3673. ### `heightmap`
  3674. Returns an array containing the y coordinates of the ground levels of nodes in
  3675. the most recently generated chunk by the current mapgen.
  3676. ### `biomemap`
  3677. Returns an array containing the biome IDs of nodes in the most recently
  3678. generated chunk by the current mapgen.
  3679. ### `heatmap`
  3680. Returns an array containing the temperature values of nodes in the most
  3681. recently generated chunk by the current mapgen.
  3682. ### `humiditymap`
  3683. Returns an array containing the humidity values of nodes in the most recently
  3684. generated chunk by the current mapgen.
  3685. ### `gennotify`
  3686. Returns a table mapping requested generation notification types to arrays of
  3687. positions at which the corresponding generated structures are located within
  3688. the current chunk. To set the capture of positions of interest to be recorded
  3689. on generate, use `minetest.set_gen_notify()`.
  3690. For decorations, the returned positions are the ground surface 'place_on' nodes,
  3691. not the decorations themselves. A 'simple' type decoration is often 1 node above
  3692. the returned position and possibly displaced by 'place_offset_y'.
  3693. Possible fields of the table returned are:
  3694. * `dungeon`
  3695. * `temple`
  3696. * `cave_begin`
  3697. * `cave_end`
  3698. * `large_cave_begin`
  3699. * `large_cave_end`
  3700. * `decoration`
  3701. Decorations have a key in the format of `"decoration#id"`, where `id` is the
  3702. numeric unique decoration ID.
  3703. Registered entities
  3704. -------------------
  3705. * Functions receive a "luaentity" as `self`:
  3706. * It has the member `.name`, which is the registered name `("mod:thing")`
  3707. * It has the member `.object`, which is an `ObjectRef` pointing to the object
  3708. * The original prototype stuff is visible directly via a metatable
  3709. * Callbacks:
  3710. * `on_activate(self, staticdata, dtime_s)`
  3711. * Called when the object is instantiated.
  3712. * `dtime_s` is the time passed since the object was unloaded, which can
  3713. be used for updating the entity state.
  3714. * `on_step(self, dtime)`
  3715. * Called on every server tick, after movement and collision processing.
  3716. `dtime` is usually 0.1 seconds, as per the `dedicated_server_step` setting
  3717. `in minetest.conf`.
  3718. * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)`
  3719. * Called when somebody punches the object.
  3720. * Note that you probably want to handle most punches using the
  3721. automatic armor group system.
  3722. * `puncher`: an `ObjectRef` (can be `nil`)
  3723. * `time_from_last_punch`: Meant for disallowing spamming of clicks (can be `nil`)
  3724. * `tool_capabilities`: capability table of used tool (can be `nil`)
  3725. * `dir`: unit vector of direction of punch. Always defined. Points from
  3726. the puncher to the punched.
  3727. * `on_death(self, killer)`
  3728. * Called when the object dies.
  3729. * `killer`: an `ObjectRef` (can be `nil`)
  3730. * `on_rightclick(self, clicker)`
  3731. * `get_staticdata(self)`
  3732. * Should return a string that will be passed to `on_activate` when
  3733. the object is instantiated the next time.
  3734. L-system trees
  3735. --------------
  3736. **Warning**
  3737. L-system generation currently creates lighting bugs in the form of mapblock-sized shadows.
  3738. Often these bugs appear as subtle shadows in water.
  3739. ### Tree definition
  3740. treedef={
  3741. axiom, --string initial tree axiom
  3742. rules_a, --string rules set A
  3743. rules_b, --string rules set B
  3744. rules_c, --string rules set C
  3745. rules_d, --string rules set D
  3746. trunk, --string trunk node name
  3747. leaves, --string leaves node name
  3748. leaves2, --string secondary leaves node name
  3749. leaves2_chance,--num chance (0-100) to replace leaves with leaves2
  3750. angle, --num angle in deg
  3751. iterations, --num max # of iterations, usually 2 -5
  3752. random_level, --num factor to lower nr of iterations, usually 0 - 3
  3753. trunk_type, --string single/double/crossed) type of trunk: 1 node,
  3754. -- 2x2 nodes or 3x3 in cross shape
  3755. thin_branches, --boolean true -> use thin (1 node) branches
  3756. fruit, --string fruit node name
  3757. fruit_chance, --num chance (0-100) to replace leaves with fruit node
  3758. seed, --num random seed; if no seed is provided, the engine will create one
  3759. }
  3760. ### Key for Special L-System Symbols used in Axioms
  3761. * `G`: move forward one unit with the pen up
  3762. * `F`: move forward one unit with the pen down drawing trunks and branches
  3763. * `f`: move forward one unit with the pen down drawing leaves (100% chance)
  3764. * `T`: move forward one unit with the pen down drawing trunks only
  3765. * `R`: move forward one unit with the pen down placing fruit
  3766. * `A`: replace with rules set A
  3767. * `B`: replace with rules set B
  3768. * `C`: replace with rules set C
  3769. * `D`: replace with rules set D
  3770. * `a`: replace with rules set A, chance 90%
  3771. * `b`: replace with rules set B, chance 80%
  3772. * `c`: replace with rules set C, chance 70%
  3773. * `d`: replace with rules set D, chance 60%
  3774. * `+`: yaw the turtle right by `angle` parameter
  3775. * `-`: yaw the turtle left by `angle` parameter
  3776. * `&`: pitch the turtle down by `angle` parameter
  3777. * `^`: pitch the turtle up by `angle` parameter
  3778. * `/`: roll the turtle to the right by `angle` parameter
  3779. * `*`: roll the turtle to the left by `angle` parameter
  3780. * `[`: save in stack current state info
  3781. * `]`: recover from stack state info
  3782. ### Example
  3783. Spawn a small apple tree:
  3784. pos = {x=230,y=20,z=4}
  3785. apple_tree={
  3786. axiom="FFFFFAFFBF",
  3787. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  3788. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  3789. trunk="default:tree",
  3790. leaves="default:leaves",
  3791. angle=30,
  3792. iterations=2,
  3793. random_level=0,
  3794. trunk_type="single",
  3795. thin_branches=true,
  3796. fruit_chance=10,
  3797. fruit="default:apple"
  3798. }
  3799. minetest.spawn_tree(pos,apple_tree)
  3800. Definition tables
  3801. -----------------
  3802. ### Object Properties
  3803. {
  3804. hp_max = 1,
  3805. -- ^ For players: Defaults to `minetest.PLAYER_MAX_HP_DEFAULT`
  3806. breath_max = 0,
  3807. -- ^ For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`
  3808. zoom_fov = 0.0,
  3809. -- ^ For players only. Zoom FOV in degrees.
  3810. -- Note that zoom loads and/or generates world beyond the server's maximum
  3811. -- send and generate distances, so acts like a telescope.
  3812. -- Smaller zoomFOV values increase the distance loaded and/or generated.
  3813. -- Defaults to 15 in creative mode, 0 in survival mode.
  3814. -- zoom_fov = 0 disables zooming for the player.
  3815. eye_height = 1.625,
  3816. -- ^ For players only. Camera height above feet position in nodes. Defaults to 1.625
  3817. physical = true,
  3818. collide_with_objects = true, -- collide with other objects if physical = true
  3819. weight = 5,
  3820. collisionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
  3821. selectionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
  3822. -- ^ Default, uses collision box dimensions when not set.
  3823. -- ^ For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
  3824. -- object position.
  3825. pointable = true, -- overrides selection box when false
  3826. visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem",
  3827. -- ^ "cube" is a node-sized cube.
  3828. -- ^ "sprite" is a flat texture always facing the player.
  3829. -- ^ "upright_sprite" is a vertical flat texture.
  3830. -- ^ "mesh" uses the defined mesh model.
  3831. -- ^ "wielditem" is used for dropped items (see builtin/game/item_entity.lua).
  3832. -- For this use 'textures = {itemname}'.
  3833. -- If the item has a 'wield_image' the object will be an extrusion of that,
  3834. -- otherwise:
  3835. -- If 'itemname' is a cubic node or nodebox the object will appear identical
  3836. -- to 'itemname'.
  3837. -- If 'itemname' is a plantlike node the object will be an extrusion of its
  3838. -- texture.
  3839. -- Otherwise for non-node items, the object will be an extrusion of
  3840. -- 'inventory_image'.
  3841. visual_size = {x = 1, y = 1},
  3842. -- ^ `x` multiplies horizontal (X and Z) visual size.
  3843. -- ^ `y` multiplies vertical (Y) visual size.
  3844. mesh = "model",
  3845. textures = {}, -- number of required textures depends on visual
  3846. -- ^ "cube" uses 6 textures in the way a node does.
  3847. -- ^ "sprite" uses 1 texture.
  3848. -- ^ "upright_sprite" uses 2 textures: {front, back}.
  3849. -- ^ "wielditem" expects 'textures = {itemname}' (see 'visual' above).
  3850. colors = {}, -- number of required colors depends on visual
  3851. spritediv = {x = 1, y = 1},
  3852. -- ^ Used with spritesheet textures for animation and/or frame selection according
  3853. -- to position relative to player.
  3854. -- ^ Defines the number of columns and rows in the spritesheet: {columns, rows}.
  3855. initial_sprite_basepos = {x = 0, y = 0},
  3856. -- ^ Used with spritesheet textures.
  3857. -- ^ Defines the {column, row} position of the initially used frame in the
  3858. -- spritesheet.
  3859. is_visible = true,
  3860. makes_footstep_sound = false,
  3861. automatic_rotate = 0,
  3862. -- ^ Set constant rotation in radians per second, positive or negative.
  3863. -- ^ Set to 0 to disable constant rotation.
  3864. stepheight = 0,
  3865. automatic_face_movement_dir = 0.0,
  3866. -- ^ Automatically set yaw to movement direction, offset in degrees,
  3867. -- 'false' to disable.
  3868. automatic_face_movement_max_rotation_per_sec = -1,
  3869. -- ^ Limit automatic rotation to this value in degrees per second,
  3870. -- value < 0 no limit.
  3871. backface_culling = true, -- false to disable backface_culling for model
  3872. glow = 0,
  3873. -- ^ Add this much extra lighting when calculating texture color.
  3874. -- Value < 0 disables light's effect on texture color.
  3875. -- For faking self-lighting, UI style entities, or programmatic coloring in mods.
  3876. nametag = "", -- by default empty, for players their name is shown if empty
  3877. nametag_color = <color>, -- sets color of nametag as ColorSpec
  3878. infotext = "", -- by default empty, text to be shown when pointed at object
  3879. static_save = true,
  3880. -- ^ If false, never save this object statically. It will simply be deleted when the
  3881. -- block gets unloaded.
  3882. -- The get_staticdata() callback is never called then.
  3883. -- Defaults to 'true'
  3884. }
  3885. ### Entity definition (`register_entity`)
  3886. {
  3887. -- Deprecated: Everything in object properties is read directly from here
  3888. initial_properties = --[[<initial object properties>]],
  3889. on_activate = function(self, staticdata, dtime_s),
  3890. on_step = function(self, dtime),
  3891. on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir),
  3892. on_rightclick = function(self, clicker),
  3893. get_staticdata = function(self),
  3894. -- ^ Called sometimes; the string returned is passed to on_activate when
  3895. -- the entity is re-activated from static state
  3896. -- Also you can define arbitrary member variables here (see item definition for
  3897. -- more info)
  3898. _custom_field = whatever,
  3899. }
  3900. ### ABM (ActiveBlockModifier) definition (`register_abm`)
  3901. {
  3902. label = "Lava cooling",
  3903. ^ Descriptive label for profiling purposes (optional).
  3904. Definitions with identical labels will be listed as one.
  3905. nodenames = {"default:lava_source"},
  3906. ^ Apply `action` function to these nodes.
  3907. ^ `group:groupname` can also be used here.
  3908. neighbors = {"default:water_source", "default:water_flowing"},
  3909. ^ Only apply `action` to nodes that have one of, or any
  3910. combination of, these neighbors.
  3911. ^ If left out or empty, any neighbor will do.
  3912. ^ `group:groupname` can also be used here.
  3913. interval = 1.0,
  3914. ^ Operation interval in seconds.
  3915. chance = 1,
  3916. ^ Chance of triggering `action` per-node per-interval is 1.0 / this value.
  3917. catch_up = true,
  3918. ^ If true, catch-up behaviour is enabled: The `chance` value is temporarily
  3919. reduced when returning to an area to simulate time lost by the area being
  3920. unattended. Note that the `chance` value can often be reduced to 1.
  3921. action = function(pos, node, active_object_count, active_object_count_wider),
  3922. ^ Function triggered for each qualifying node.
  3923. ^ `active_object_count` is number of active objects in the node's mapblock.
  3924. ^ `active_object_count_wider` is number of active objects in the node's
  3925. mapblock plus all 26 neighboring mapblocks. If any neighboring mapblocks
  3926. are unloaded an estmate is calculated for them based on loaded mapblocks.
  3927. }
  3928. ### LBM (LoadingBlockModifier) definition (`register_lbm`)
  3929. {
  3930. label = "Upgrade legacy doors",
  3931. -- ^ Descriptive label for profiling purposes (optional).
  3932. -- Definitions with identical labels will be listed as one.
  3933. name = "modname:replace_legacy_door",
  3934. nodenames = {"default:lava_source"},
  3935. -- ^ List of node names to trigger the LBM on.
  3936. -- Also non-registered nodes will work.
  3937. -- Groups (as of group:groupname) will work as well.
  3938. run_at_every_load = false,
  3939. -- ^ Whether to run the LBM's action every time a block gets loaded,
  3940. -- and not just for blocks that were saved last time before LBMs were
  3941. -- introduced to the world.
  3942. action = func(pos, node),
  3943. }
  3944. ### Item definition (`register_node`, `register_craftitem`, `register_tool`)
  3945. {
  3946. description = "Steel Axe",
  3947. groups = {}, -- key = name, value = rating; rating = 1..3.
  3948. if rating not applicable, use 1.
  3949. e.g. {wool = 1, fluffy = 3}
  3950. {soil = 2, outerspace = 1, crumbly = 1}
  3951. {bendy = 2, snappy = 1},
  3952. {hard = 1, metal = 1, spikes = 1}
  3953. inventory_image = "default_tool_steelaxe.png",
  3954. inventory_overlay = "overlay.png", -- an overlay which does not get colorized
  3955. wield_image = "",
  3956. wield_overlay = "",
  3957. palette = "",
  3958. --[[
  3959. ^ An image file containing the palette of a node.
  3960. ^ You can set the currently used color as the
  3961. ^ "palette_index" field of the item stack metadata.
  3962. ^ The palette is always stretched to fit indices
  3963. ^ between 0 and 255, to ensure compatibility with
  3964. ^ "colorfacedir" and "colorwallmounted" nodes.
  3965. ]]
  3966. color = "0xFFFFFFFF",
  3967. --[[
  3968. ^ The color of the item. The palette overrides this.
  3969. ]]
  3970. wield_scale = {x = 1, y = 1, z = 1},
  3971. stack_max = 99,
  3972. range = 4.0,
  3973. liquids_pointable = false,
  3974. tool_capabilities = {
  3975. full_punch_interval = 1.0,
  3976. max_drop_level = 0,
  3977. groupcaps = {
  3978. -- For example:
  3979. choppy = {times = {[1] = 2.50, [2] = 1.40, [3] = 1.00}, uses = 20, maxlevel = 2},
  3980. },
  3981. damage_groups = {groupname = damage},
  3982. },
  3983. node_placement_prediction = nil,
  3984. --[[
  3985. ^ If nil and item is node, prediction is made automatically
  3986. ^ If nil and item is not a node, no prediction is made
  3987. ^ If "" and item is anything, no prediction is made
  3988. ^ Otherwise should be name of node which the client immediately places
  3989. on ground when the player places the item. Server will always update
  3990. actual result to client in a short moment.
  3991. ]]
  3992. node_dig_prediction = "air",
  3993. --[[
  3994. ^ if "", no prediction is made
  3995. ^ if "air", node is removed
  3996. ^ Otherwise should be name of node which the client immediately places
  3997. upon digging. Server will always update actual result shortly.
  3998. ]]
  3999. sound = {
  4000. breaks = "default_tool_break", -- tools only
  4001. place = --[[<SimpleSoundSpec>]],
  4002. },
  4003. on_place = func(itemstack, placer, pointed_thing),
  4004. --[[
  4005. ^ Shall place item and return the leftover itemstack
  4006. ^ The placer may be any ObjectRef or nil.
  4007. ^ default: minetest.item_place ]]
  4008. on_secondary_use = func(itemstack, user, pointed_thing),
  4009. --[[
  4010. ^ Same as on_place but called when pointing at nothing.
  4011. ^ The user may be any ObjectRef or nil.
  4012. ^ pointed_thing : always { type = "nothing" }
  4013. ]]
  4014. on_drop = func(itemstack, dropper, pos),
  4015. --[[
  4016. ^ Shall drop item and return the leftover itemstack
  4017. ^ The dropper may be any ObjectRef or nil.
  4018. ^ default: minetest.item_drop ]]
  4019. on_use = func(itemstack, user, pointed_thing),
  4020. --[[
  4021. ^ default: nil
  4022. ^ Function must return either nil if no item shall be removed from
  4023. inventory, or an itemstack to replace the original itemstack.
  4024. e.g. itemstack:take_item(); return itemstack
  4025. ^ Otherwise, the function is free to do what it wants.
  4026. ^ The user may be any ObjectRef or nil.
  4027. ^ The default functions handle regular use cases.
  4028. ]]
  4029. after_use = func(itemstack, user, node, digparams),
  4030. --[[
  4031. ^ default: nil
  4032. ^ If defined, should return an itemstack and will be called instead of
  4033. wearing out the tool. If returns nil, does nothing.
  4034. If after_use doesn't exist, it is the same as:
  4035. function(itemstack, user, node, digparams)
  4036. itemstack:add_wear(digparams.wear)
  4037. return itemstack
  4038. end
  4039. ^ The user may be any ObjectRef or nil.
  4040. ]]
  4041. _custom_field = whatever,
  4042. --[[
  4043. ^ Add your own custom fields. By convention, all custom field names
  4044. should start with `_` to avoid naming collisions with future engine
  4045. usage.
  4046. ]]
  4047. }
  4048. ### Tile definition
  4049. * `"image.png"`
  4050. * `{name="image.png", animation={Tile Animation definition}}`
  4051. * `{name="image.png", backface_culling=bool, tileable_vertical=bool,
  4052. tileable_horizontal=bool, align_style="node"/"world"/"user", scale=int}`
  4053. * backface culling enabled by default for most nodes
  4054. * tileable flags are info for shaders, how they should treat texture
  4055. when displacement mapping is used
  4056. Directions are from the point of view of the tile texture,
  4057. not the node it's on
  4058. * align style determines whether the texture will be rotated with the node
  4059. or kept aligned with its surroundings. "user" means that client
  4060. setting will be used, similar to `glasslike_framed_optional`.
  4061. Note: supported by solid nodes and nodeboxes only.
  4062. * scale is used to make texture span several (exactly `scale`) nodes,
  4063. instead of just one, in each direction. Works for world-aligned
  4064. textures only.
  4065. Note that as the effect is applied on per-mapblock basis, `16` should
  4066. be equally divisible by `scale` or you may get wrong results.
  4067. * `{name="image.png", color=ColorSpec}`
  4068. * the texture's color will be multiplied with this color.
  4069. * the tile's color overrides the owning node's color in all cases.
  4070. * deprecated, yet still supported field names:
  4071. * `image` (name)
  4072. ### Tile animation definition
  4073. {
  4074. type = "vertical_frames",
  4075. aspect_w = 16,
  4076. -- ^ specify width of a frame in pixels
  4077. aspect_h = 16,
  4078. -- ^ specify height of a frame in pixels
  4079. length = 3.0,
  4080. -- ^ specify full loop length
  4081. }
  4082. {
  4083. type = "sheet_2d",
  4084. frames_w = 5,
  4085. -- ^ specify width in number of frames
  4086. frames_h = 3,
  4087. -- ^ specify height in number of frames
  4088. frame_length = 0.5,
  4089. -- ^ specify length of a single frame
  4090. }
  4091. ### Node definition (`register_node`)
  4092. {
  4093. -- <all fields allowed in item definitions>,
  4094. drawtype = "normal", -- See "Node drawtypes"
  4095. visual_scale = 1.0, --[[
  4096. ^ Supported for drawtypes "plantlike", "signlike", "torchlike",
  4097. ^ "firelike", "mesh".
  4098. ^ For plantlike and firelike, the image will start at the bottom of the
  4099. ^ node, for the other drawtypes the image will be centered on the node.
  4100. ^ Note that positioning for "torchlike" may still change. ]]
  4101. tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[
  4102. ^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
  4103. ^ List can be shortened to needed length ]]
  4104. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[
  4105. ^ Same as `tiles`, but these textures are drawn on top of the
  4106. ^ base tiles. You can use this to colorize only specific parts of
  4107. ^ your texture. If the texture name is an empty string, that
  4108. ^ overlay is not drawn. Since such tiles are drawn twice, it
  4109. ^ is not recommended to use overlays on very common nodes. ]]
  4110. special_tiles = {tile definition 1, Tile definition 2}, --[[
  4111. ^ Special textures of node; used rarely (old field name: special_materials)
  4112. ^ List can be shortened to needed length ]]
  4113. color = ColorSpec, --[[
  4114. ^ The node's original color will be multiplied with this color.
  4115. ^ If the node has a palette, then this setting only has an effect
  4116. ^ in the inventory and on the wield item. ]]
  4117. use_texture_alpha = false, -- Use texture's alpha channel
  4118. palette = "palette.png", --[[
  4119. ^ The node's `param2` is used to select a pixel from the image
  4120. ^ (pixels are arranged from left to right and from top to bottom).
  4121. ^ The node's color will be multiplied with the selected pixel's
  4122. ^ color. Tiles can override this behavior.
  4123. ^ Only when `paramtype2` supports palettes. ]]
  4124. post_effect_color = "green#0F", -- If player is inside node, see "ColorSpec"
  4125. paramtype = "none", -- See "Nodes" --[[
  4126. ^ paramtype = "light" allows light to propagate from or through the node with light value
  4127. ^ falling by 1 per node. This line is essential for a light source node to spread its light. ]]
  4128. paramtype2 = "none", -- See "Nodes"
  4129. place_param2 = nil, -- Force value for param2 when player places node
  4130. is_ground_content = true, -- If false, the cave generator will not carve through this
  4131. sunlight_propagates = false, -- If true, sunlight will go infinitely through this
  4132. walkable = true, -- If true, objects collide with node
  4133. pointable = true, -- If true, can be pointed at
  4134. diggable = true, -- If false, can never be dug
  4135. climbable = false, -- If true, can be climbed on (ladder)
  4136. buildable_to = false, -- If true, placed nodes can replace this node
  4137. floodable = false, --[[
  4138. ^ If true, liquids flow into and replace this node.
  4139. ^ Warning: making a liquid node 'floodable' does not work and may cause problems. ]]
  4140. liquidtype = "none", -- "none"/"source"/"flowing"
  4141. liquid_alternative_flowing = "", -- Flowing version of source liquid
  4142. liquid_alternative_source = "", -- Source version of flowing liquid
  4143. liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
  4144. liquid_renewable = true, --[[
  4145. ^ If true, a new liquid source can be created by placing two or more sources nearby ]]
  4146. leveled = 16, --[[
  4147. ^ Only valid for "nodebox" drawtype with 'type = "leveled"'.
  4148. ^ Allows defining the nodebox height without using param2.
  4149. ^ The nodebox height is 'leveled' / 64 nodes.
  4150. ^ The maximum value of 'leveled' is 127. ]]
  4151. liquid_range = 8, -- number of flowing nodes around source (max. 8)
  4152. drowning = 0, -- Player will take this amount of damage if no bubbles are left
  4153. light_source = 0, --[[
  4154. ^ Amount of light emitted by node.
  4155. ^ To set the maximum (currently 14), use the value 'minetest.LIGHT_MAX'.
  4156. ^ A value outside the range 0 to minetest.LIGHT_MAX causes undefined behavior.]]
  4157. damage_per_second = 0, -- If player is inside node, this damage is caused
  4158. node_box = {type="regular"}, -- See "Node boxes"
  4159. connects_to = nodenames, --[[
  4160. * Used for nodebox nodes with the type == "connected"
  4161. * Specifies to what neighboring nodes connections will be drawn
  4162. * e.g. `{"group:fence", "default:wood"}` or `"default:stone"` ]]
  4163. connect_sides = { "top", "bottom", "front", "left", "back", "right" }, --[[
  4164. ^ Tells connected nodebox nodes to connect only to these sides of this node. ]]
  4165. mesh = "model",
  4166. selection_box = {type="regular"}, -- See "Node boxes" --[[
  4167. ^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used. ]]
  4168. legacy_facedir_simple = false, -- Support maps made in and before January 2012
  4169. legacy_wallmounted = false, -- Support maps made in and before January 2012
  4170. waving = 0, --[[ valid for mesh, nodebox, plantlike, allfaces_optional nodes
  4171. ^ 1 - wave node like plants (top of node moves, bottom is fixed)
  4172. ^ 2 - wave node like leaves (whole node moves side-to-side synchronously)
  4173. ^ caveats: not all models will properly wave
  4174. ^ plantlike drawtype nodes can only wave like plants
  4175. ^ allfaces_optional drawtype nodes can only wave like leaves --]]
  4176. sounds = {
  4177. footstep = <SimpleSoundSpec>,
  4178. dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
  4179. dug = <SimpleSoundSpec>,
  4180. place = <SimpleSoundSpec>,
  4181. place_failed = <SimpleSoundSpec>,
  4182. },
  4183. drop = "", -- Name of dropped node when dug. Default is the node itself.
  4184. -- Alternatively:
  4185. drop = {
  4186. max_items = 1, -- Maximum number of items to drop.
  4187. items = { -- Choose max_items randomly from this list.
  4188. {
  4189. items = {"foo:bar", "baz:frob"}, -- Items to drop.
  4190. rarity = 1, -- Probability of dropping is 1 / rarity.
  4191. inherit_color = true, -- To inherit palette color from the node
  4192. },
  4193. },
  4194. },
  4195. on_construct = func(pos), --[[
  4196. ^ Node constructor; called after adding node
  4197. ^ Can set up metadata and stuff like that
  4198. ^ Not called for bulk node placement (i.e. schematics and VoxelManip)
  4199. ^ default: nil ]]
  4200. on_destruct = func(pos), --[[
  4201. ^ Node destructor; called before removing node
  4202. ^ Not called for bulk node placement (i.e. schematics and VoxelManip)
  4203. ^ default: nil ]]
  4204. after_destruct = func(pos, oldnode), --[[
  4205. ^ Node destructor; called after removing node
  4206. ^ Not called for bulk node placement (i.e. schematics and VoxelManip)
  4207. ^ default: nil ]]
  4208. on_flood = func(pos, oldnode, newnode), --[[
  4209. ^ Called when a liquid (newnode) is about to flood oldnode, if
  4210. ^ it has `floodable = true` in the nodedef. Not called for bulk
  4211. ^ node placement (i.e. schematics and VoxelManip) or air nodes. If
  4212. ^ return true the node is not flooded, but on_flood callback will
  4213. ^ most likely be called over and over again every liquid update
  4214. ^ interval. Default: nil.
  4215. ^ Warning: making a liquid node 'floodable' does not work and may cause problems. ]]
  4216. preserve_metadata = func(pos, oldnode, oldmeta, drops) --[[
  4217. ^ Called when oldnode is about be converted to an item, but before the
  4218. node is deleted from the world or the drops are added. This is generally
  4219. the result of either the node being dug or an attached node becoming detached.
  4220. ^ drops is a table of ItemStacks, so any metadata to be preserved can be
  4221. added directly to one or more of the dropped items. See "ItemStackMetaRef".
  4222. ^ default: nil ]]
  4223. after_place_node = func(pos, placer, itemstack, pointed_thing) --[[
  4224. ^ Called after constructing node when node was placed using
  4225. minetest.item_place_node / minetest.place_node
  4226. ^ If return true no item is taken from itemstack
  4227. ^ `placer` may be any valid ObjectRef or nil
  4228. ^ default: nil ]]
  4229. after_dig_node = func(pos, oldnode, oldmetadata, digger), --[[
  4230. ^ oldmetadata is in table format
  4231. ^ Called after destructing node when node was dug using
  4232. minetest.node_dig / minetest.dig_node
  4233. ^ default: nil ]]
  4234. can_dig = function(pos, [player]) --[[
  4235. ^ returns true if node can be dug, or false if not
  4236. ^ default: nil ]]
  4237. on_punch = func(pos, node, puncher, pointed_thing), --[[
  4238. ^ default: minetest.node_punch
  4239. ^ By default: Calls minetest.register_on_punchnode callbacks ]]
  4240. on_rightclick = func(pos, node, clicker, itemstack, pointed_thing), --[[
  4241. ^ default: nil
  4242. ^ itemstack will hold clicker's wielded item
  4243. ^ Shall return the leftover itemstack
  4244. ^ Note: pointed_thing can be nil, if a mod calls this function
  4245. This function does not get triggered by clients <=0.4.16 if the
  4246. "formspec" node metadata field is set ]]
  4247. on_dig = func(pos, node, digger), --[[
  4248. ^ default: minetest.node_dig
  4249. ^ By default: checks privileges, wears out tool and removes node ]]
  4250. on_timer = function(pos,elapsed), --[[
  4251. ^ default: nil
  4252. ^ called by NodeTimers, see minetest.get_node_timer and NodeTimerRef
  4253. ^ elapsed is the total time passed since the timer was started
  4254. ^ return true to run the timer for another cycle with the same timeout value ]]
  4255. on_receive_fields = func(pos, formname, fields, sender), --[[
  4256. ^ fields = {name1 = value1, name2 = value2, ...}
  4257. ^ Called when an UI form (e.g. sign text input) returns data
  4258. ^ default: nil ]]
  4259. allow_metadata_inventory_move = func(pos, from_list, from_index,
  4260. to_list, to_index, count, player), --[[
  4261. ^ Called when a player wants to move items inside the inventory
  4262. ^ Return value: number of items allowed to move ]]
  4263. allow_metadata_inventory_put = func(pos, listname, index, stack, player), --[[
  4264. ^ Called when a player wants to put something into the inventory
  4265. ^ Return value: number of items allowed to put
  4266. ^ Return value: -1: Allow and don't modify item count in inventory ]]
  4267. allow_metadata_inventory_take = func(pos, listname, index, stack, player), --[[
  4268. ^ Called when a player wants to take something out of the inventory
  4269. ^ Return value: number of items allowed to take
  4270. ^ Return value: -1: Allow and don't modify item count in inventory ]]
  4271. on_metadata_inventory_move = func(pos, from_list, from_index,
  4272. to_list, to_index, count, player),
  4273. on_metadata_inventory_put = func(pos, listname, index, stack, player),
  4274. on_metadata_inventory_take = func(pos, listname, index, stack, player), --[[
  4275. ^ Called after the actual action has happened, according to what was allowed.
  4276. ^ No return value ]]
  4277. on_blast = func(pos, intensity), --[[
  4278. ^ intensity: 1.0 = mid range of regular TNT
  4279. ^ If defined, called when an explosion touches the node, instead of
  4280. removing the node ]]
  4281. }
  4282. ### Recipe for `register_craft` (shaped)
  4283. {
  4284. output = 'default:pick_stone',
  4285. recipe = {
  4286. {'default:cobble', 'default:cobble', 'default:cobble'},
  4287. {'', 'default:stick', ''},
  4288. {'', 'default:stick', ''}, -- Also groups; e.g. 'group:crumbly'
  4289. },
  4290. replacements = --[[<optional list of item pairs,
  4291. replace one input item with another item on crafting>]]
  4292. }
  4293. ### Recipe for `register_craft` (shapeless)
  4294. {
  4295. type = "shapeless",
  4296. output = 'mushrooms:mushroom_stew',
  4297. recipe = {
  4298. "mushrooms:bowl",
  4299. "mushrooms:mushroom_brown",
  4300. "mushrooms:mushroom_red",
  4301. },
  4302. replacements = --[[<optional list of item pairs,
  4303. replace one input item with another item on crafting>]]
  4304. }
  4305. ### Recipe for `register_craft` (tool repair)
  4306. {
  4307. type = "toolrepair",
  4308. additional_wear = -0.02,
  4309. }
  4310. ### Recipe for `register_craft` (cooking)
  4311. {
  4312. type = "cooking",
  4313. output = "default:glass",
  4314. recipe = "default:sand",
  4315. cooktime = 3,
  4316. }
  4317. ### Recipe for `register_craft` (furnace fuel)
  4318. {
  4319. type = "fuel",
  4320. recipe = "default:leaves",
  4321. burntime = 1,
  4322. }
  4323. ### Ore definition (`register_ore`)
  4324. See 'Ore types' section above for essential information.
  4325. {
  4326. ore_type = "scatter",
  4327. ore = "default:stone_with_coal",
  4328. ore_param2 = 3,
  4329. -- ^ Facedir rotation. Default is 0 (unchanged rotation)
  4330. wherein = "default:stone",
  4331. -- ^ a list of nodenames is supported too
  4332. clust_scarcity = 8 * 8 * 8,
  4333. -- ^ Ore has a 1 out of clust_scarcity chance of spawning in a node
  4334. -- ^ If the desired average distance between ores is 'd', set this to d * d * d.
  4335. clust_num_ores = 8,
  4336. -- ^ Number of ores in a cluster
  4337. clust_size = 3,
  4338. -- ^ Size of the bounding box of the cluster
  4339. -- ^ In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27 nodes
  4340. -- ^ are coal ore.
  4341. y_min = -31000,
  4342. y_max = 64,
  4343. -- ^ Lower and upper limits for ore.
  4344. flags = "",
  4345. -- ^ Attributes for this ore generation, see 'Ore attributes' section above.
  4346. noise_threshold = 0.5,
  4347. -- ^ If noise is above this threshold, ore is placed. Not needed for a
  4348. -- ^ uniform distribution.
  4349. noise_params = {
  4350. offset = 0,
  4351. scale = 1,
  4352. spread = {x = 100, y = 100, z = 100},
  4353. seed = 23,
  4354. octaves = 3,
  4355. persist = 0.7
  4356. },
  4357. -- ^ NoiseParams structure describing one of the perlin noises used for ore
  4358. -- ^ distribution.
  4359. -- ^ Needed by "sheet", "puff", "blob" and "vein" ores.
  4360. -- ^ Omit from "scatter" ore for a uniform ore distribution.
  4361. -- ^ Omit from "stratum ore for a simple horizontal strata from y_min to y_max.
  4362. biomes = {"desert", "rainforest"}
  4363. -- ^ List of biomes in which this decoration occurs.
  4364. -- ^ Occurs in all biomes if this is omitted, and ignored if the Mapgen being
  4365. -- ^ used does not support biomes.
  4366. -- ^ Can be a list of (or a single) biome names, IDs, or definitions.
  4367. column_height_min = 1,
  4368. column_height_max = 16,
  4369. column_midpoint_factor = 0.5,
  4370. -- ^ See 'Ore types' section above.
  4371. -- ^ The above 3 parameters are only valid for "sheet" ore.
  4372. np_puff_top = {
  4373. offset = 4,
  4374. scale = 2,
  4375. spread = {x = 100, y = 100, z = 100},
  4376. seed = 47,
  4377. octaves = 3,
  4378. persist = 0.7
  4379. },
  4380. np_puff_bottom = {
  4381. offset = 4,
  4382. scale = 2,
  4383. spread = {x = 100, y = 100, z = 100},
  4384. seed = 11,
  4385. octaves = 3,
  4386. persist = 0.7
  4387. },
  4388. -- ^ See 'Ore types' section above.
  4389. -- ^ The above 2 parameters are only valid for "puff" ore.
  4390. random_factor = 1.0,
  4391. -- ^ See 'Ore types' section above.
  4392. -- ^ Only valid for "vein" ore.
  4393. np_stratum_thickness = {
  4394. offset = 8,
  4395. scale = 4,
  4396. spread = {x = 100, y = 100, z = 100},
  4397. seed = 17,
  4398. octaves = 3,
  4399. persist = 0.7
  4400. },
  4401. stratum_thickness = 8,
  4402. -- ^ See 'Ore types' section above.
  4403. -- ^ The above 2 parameters are only valid for "stratum" ore.
  4404. }
  4405. ### Biome definition (`register_biome`)
  4406. {
  4407. name = "tundra",
  4408. node_dust = "default:snow",
  4409. -- ^ Node dropped onto upper surface after all else is generated.
  4410. node_top = "default:dirt_with_snow",
  4411. depth_top = 1,
  4412. -- ^ Node forming surface layer of biome and thickness of this layer.
  4413. node_filler = "default:permafrost",
  4414. depth_filler = 3,
  4415. -- ^ Node forming lower layer of biome and thickness of this layer.
  4416. node_stone = "default:bluestone",
  4417. -- ^ Node that replaces all stone nodes between roughly y_min and y_max.
  4418. node_water_top = "default:ice",
  4419. depth_water_top = 10,
  4420. -- ^ Node forming a surface layer in seawater with the defined thickness.
  4421. node_water = "",
  4422. -- ^ Node that replaces all seawater nodes not in the defined surface layer.
  4423. node_river_water = "default:ice",
  4424. -- ^ Node that replaces river water in mapgens that use default:river_water.
  4425. node_riverbed = "default:gravel",
  4426. depth_riverbed = 2,
  4427. -- ^ Node placed under river water and thickness of this layer.
  4428. y_max = 31000,
  4429. y_min = 1,
  4430. -- ^ Upper and lower limits for biome.
  4431. -- ^ Alternatively you can use xyz limits as shown below.
  4432. max_pos = {x = 31000, y = 128, z = 31000},
  4433. min_pos = {x = -31000, y = 9, z = -31000},
  4434. -- ^ xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
  4435. -- ^ Biome is limited to a cuboid defined by these positions.
  4436. -- ^ Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
  4437. -- ^ 31000 in 'max_pos'.
  4438. vertical_blend = 8,
  4439. -- ^ Vertical distance in nodes above 'y_max' over which the biome will
  4440. -- ^ blend with the biome above.
  4441. -- ^ Set to 0 for no vertical blend. Defaults to 0.
  4442. heat_point = 0,
  4443. humidity_point = 50,
  4444. -- ^ Characteristic temperature and humidity for the biome.
  4445. -- ^ These values create 'biome points' on a voronoi diagram with heat and
  4446. -- ^ humidity as axes. The resulting voronoi cells determine the
  4447. -- ^ distribution of the biomes.
  4448. -- ^ Heat and humidity have average values of 50, vary mostly between
  4449. -- ^ 0 and 100 but can exceed these values.
  4450. }
  4451. ### Decoration definition (`register_decoration`)
  4452. {
  4453. deco_type = "simple", -- See "Decoration types"
  4454. place_on = "default:dirt_with_grass",
  4455. -- ^ Node (or list of nodes) that the decoration can be placed on
  4456. sidelen = 8,
  4457. -- ^ Size of divisions made in the chunk being generated.
  4458. -- ^ If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size.
  4459. fill_ratio = 0.02,
  4460. -- ^ Ratio of the area to be uniformly filled by the decoration.
  4461. -- ^ Used only if noise_params is not specified.
  4462. noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7},
  4463. -- ^ NoiseParams structure describing the perlin noise used for decoration distribution.
  4464. -- ^ The result of this is multiplied by the 2d area of the division being decorated.
  4465. biomes = {"Oceanside", "Hills", "Plains"},
  4466. -- ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
  4467. -- ^ and ignored if the Mapgen being used does not support biomes.
  4468. -- ^ Can be a list of (or a single) biome names, IDs, or definitions.
  4469. y_min = -31000
  4470. y_max = 31000
  4471. -- ^ Lower and upper limits for decoration.
  4472. -- ^ These parameters refer to the Y co-ordinate of the 'place_on' node.
  4473. spawn_by = "default:water",
  4474. -- ^ Node (or list of nodes) that the decoration only spawns next to.
  4475. -- ^ Checks two horizontal planes of neighbouring nodes (including diagonal neighbours),
  4476. -- ^ one plane level with the 'place_on' node and a plane one node above that.
  4477. num_spawn_by = 1,
  4478. -- ^ Number of spawn_by nodes that must be surrounding the decoration position to occur.
  4479. -- ^ If absent or -1, decorations occur next to any nodes.
  4480. flags = "liquid_surface, force_placement, all_floors, all_ceilings",
  4481. -- ^ Flags for all decoration types.
  4482. -- ^ "liquid_surface": Instead of placement on the highest solid surface
  4483. -- ^ in a mapchunk column, placement is on the highest liquid surface.
  4484. -- ^ Placement is disabled if solid nodes are found above the liquid
  4485. -- ^ surface.
  4486. -- ^ "force_placement": Nodes other than "air" and "ignore" are replaced
  4487. -- ^ by the decoration.
  4488. -- ^ "all_floors", "all_ceilings": Instead of placement on the highest
  4489. -- ^ surface in a mapchunk the decoration is placed on all floor and/or
  4490. -- ^ ceiling surfaces, for example in caves.
  4491. -- ^ Ceiling decorations act as an inversion of floor decorations so the
  4492. -- ^ effect of 'place_offset_y' is inverted.
  4493. -- ^ If a single decoration registration has both flags the floor and
  4494. -- ^ ceiling decorations will be aligned vertically and may sometimes
  4495. -- ^ meet to form a column.
  4496. ----- Simple-type parameters
  4497. decoration = "default:grass",
  4498. -- ^ The node name used as the decoration.
  4499. -- ^ If instead a list of strings, a randomly selected node from the list is placed as the decoration.
  4500. height = 1,
  4501. -- ^ Decoration height in nodes.
  4502. -- ^ If height_max is not 0, this is the lower limit of a randomly selected height.
  4503. height_max = 0,
  4504. -- ^ Upper limit of the randomly selected height.
  4505. -- ^ If absent, the parameter 'height' is used as a constant.
  4506. param2 = 0,
  4507. -- ^ Param2 value of decoration nodes.
  4508. -- ^ If param2_max is not 0, this is the lower limit of a randomly selected param2.
  4509. param2_max = 0,
  4510. -- ^ Upper limit of the randomly selected param2.
  4511. -- ^ If absent, the parameter 'param2' is used as a constant.
  4512. place_offset_y = 0,
  4513. -- ^ Y offset of the decoration base node relative to the standard base
  4514. -- ^ node position.
  4515. -- ^ Can be positive or negative. Default is 0.
  4516. -- ^ Effect is inverted for "all_ceilings" decorations.
  4517. -- ^ Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  4518. -- ^ to the 'place_on' node.
  4519. ----- Schematic-type parameters
  4520. schematic = "foobar.mts",
  4521. -- ^ If schematic is a string, it is the filepath relative to the current working directory of the
  4522. -- ^ specified Minetest schematic file.
  4523. -- ^ - OR -, could be the ID of a previously registered schematic
  4524. -- ^ - OR -, could instead be a table containing two mandatory fields, size and data,
  4525. -- ^ and an optional table yslice_prob:
  4526. schematic = {
  4527. size = {x=4, y=6, z=4},
  4528. data = {
  4529. {name="default:cobble", param1=255, param2=0},
  4530. {name="default:dirt_with_grass", param1=255, param2=0},
  4531. {name="ignore", param1=255, param2=0},
  4532. {name="air", param1=255, param2=0},
  4533. ...
  4534. },
  4535. yslice_prob = {
  4536. {ypos=2, prob=128},
  4537. {ypos=5, prob=64},
  4538. ...
  4539. },
  4540. },
  4541. -- ^ See 'Schematic specifier' for details.
  4542. replacements = {["oldname"] = "convert_to", ...},
  4543. flags = "place_center_x, place_center_y, place_center_z",
  4544. -- ^ Flags for schematic decorations. See 'Schematic attributes'.
  4545. rotation = "90" -- rotate schematic 90 degrees on placement
  4546. -- ^ Rotation can be "0", "90", "180", "270", or "random".
  4547. place_offset_y = 0,
  4548. -- ^ If the flag 'place_center_y' is set this parameter is ignored.
  4549. -- ^ Y offset of the schematic base node layer relative to the 'place_on'
  4550. -- ^ node.
  4551. -- ^ Can be positive or negative. Default is 0.
  4552. -- ^ Effect is inverted for "all_ceilings" decorations.
  4553. -- ^ Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  4554. -- ^ to the 'place_on' node.
  4555. }
  4556. ### Chat command definition (`register_chatcommand`)
  4557. {
  4558. params = "<name> <privilege>", -- Short parameter description
  4559. description = "Remove privilege from player", -- Full description
  4560. privs = {privs=true}, -- Require the "privs" privilege to run
  4561. func = function(name, param), -- Called when command is run.
  4562. -- Returns boolean success and text output.
  4563. }
  4564. Note that in params, use of symbols is as follows:
  4565. * `<>` signifies a placeholder to be replaced when the command is used. For example,
  4566. when a player name is needed: `<name>`
  4567. * `[]` signifies param is optional and not required when the command is used. For
  4568. example, if you require param1 but param2 is optional: `<param1> [<param2>]`
  4569. * `|` signifies exclusive or. The command requires one param from the options
  4570. provided. For example: `<param1> | <param2>`
  4571. * `()` signifies grouping. For example, when param1 and param2 are both required,
  4572. or only param3 is required: `(<param1> <param2>) | <param3>`
  4573. ### Detached inventory callbacks
  4574. {
  4575. allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
  4576. -- ^ Called when a player wants to move items inside the inventory
  4577. -- ^ Return value: number of items allowed to move
  4578. allow_put = func(inv, listname, index, stack, player),
  4579. -- ^ Called when a player wants to put something into the inventory
  4580. -- ^ Return value: number of items allowed to put
  4581. -- ^ Return value: -1: Allow and don't modify item count in inventory
  4582. allow_take = func(inv, listname, index, stack, player),
  4583. -- ^ Called when a player wants to take something out of the inventory
  4584. -- ^ Return value: number of items allowed to take
  4585. -- ^ Return value: -1: Allow and don't modify item count in inventory
  4586. on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
  4587. on_put = func(inv, listname, index, stack, player),
  4588. on_take = func(inv, listname, index, stack, player),
  4589. -- ^ Called after the actual action has happened, according to what was allowed.
  4590. -- ^ No return value
  4591. }
  4592. ### HUD Definition (`hud_add`, `hud_get`)
  4593. {
  4594. hud_elem_type = "image", -- see HUD element types
  4595. -- ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
  4596. position = {x=0.5, y=0.5},
  4597. -- ^ Left corner position of element
  4598. name = "<name>",
  4599. scale = {x=2, y=2},
  4600. text = "<text>",
  4601. number = 2,
  4602. item = 3,
  4603. -- ^ Selected item in inventory. 0 for no item selected.
  4604. direction = 0,
  4605. -- ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  4606. alignment = {x=0, y=0},
  4607. -- ^ See "HUD Element Types"
  4608. offset = {x=0, y=0},
  4609. -- ^ See "HUD Element Types"
  4610. size = { x=100, y=100 },
  4611. -- ^ Size of element in pixels
  4612. }
  4613. ### Particle definition (`add_particle`)
  4614. {
  4615. pos = {x=0, y=0, z=0},
  4616. velocity = {x=0, y=0, z=0},
  4617. acceleration = {x=0, y=0, z=0},
  4618. -- ^ Spawn particle at pos with velocity and acceleration
  4619. expirationtime = 1,
  4620. -- ^ Disappears after expirationtime seconds
  4621. size = 1,
  4622. collisiondetection = false,
  4623. -- ^ collisiondetection: if true collides with physical objects
  4624. collision_removal = false,
  4625. -- ^ collision_removal: if true then particle is removed when it collides,
  4626. -- ^ requires collisiondetection = true to have any effect
  4627. vertical = false,
  4628. -- ^ vertical: if true faces player using y axis only
  4629. texture = "image.png",
  4630. -- ^ Uses texture (string)
  4631. playername = "singleplayer",
  4632. -- ^ optional, if specified spawns particle only on the player's client
  4633. animation = {Tile Animation definition},
  4634. -- ^ optional, specifies how to animate the particle texture
  4635. glow = 0
  4636. -- ^ optional, specify particle self-luminescence in darkness
  4637. }
  4638. ### `ParticleSpawner` definition (`add_particlespawner`)
  4639. {
  4640. amount = 1,
  4641. time = 1,
  4642. -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
  4643. minpos = {x=0, y=0, z=0},
  4644. maxpos = {x=0, y=0, z=0},
  4645. minvel = {x=0, y=0, z=0},
  4646. maxvel = {x=0, y=0, z=0},
  4647. minacc = {x=0, y=0, z=0},
  4648. maxacc = {x=0, y=0, z=0},
  4649. minexptime = 1,
  4650. maxexptime = 1,
  4651. minsize = 1,
  4652. maxsize = 1,
  4653. -- ^ The particle's properties are random values in between the bounds:
  4654. -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
  4655. -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
  4656. collisiondetection = false,
  4657. -- ^ collisiondetection: if true uses collision detection
  4658. collision_removal = false,
  4659. -- ^ collision_removal: if true then particle is removed when it collides,
  4660. -- ^ requires collisiondetection = true to have any effect
  4661. attached = ObjectRef,
  4662. -- ^ attached: if defined, particle positions, velocities and accelerations
  4663. -- ^ are relative to this object's position and yaw.
  4664. vertical = false,
  4665. -- ^ vertical: if true faces player using y axis only
  4666. texture = "image.png",
  4667. -- ^ Uses texture (string)
  4668. playername = "singleplayer"
  4669. -- ^ Playername is optional, if specified spawns particle only on the player's client
  4670. animation = {Tile Animation definition},
  4671. -- ^ optional, specifies how to animate the particle texture
  4672. glow = 0
  4673. -- ^ optional, specify particle self-luminescence in darkness
  4674. }
  4675. ### `HTTPRequest` definition (`HTTPApiTable.fetch_async`, `HTTPApiTable.fetch_async`)
  4676. {
  4677. url = "http://example.org",
  4678. timeout = 10,
  4679. -- ^ Timeout for connection in seconds. Default is 3 seconds.
  4680. post_data = "Raw POST request data string" OR { field1 = "data1", field2 = "data2" },
  4681. -- ^ Optional, if specified a POST request with post_data is performed.
  4682. -- ^ Accepts both a string and a table. If a table is specified, encodes table
  4683. -- ^ as x-www-form-urlencoded key-value pairs.
  4684. -- ^ If post_data ist not specified, a GET request is performed instead.
  4685. user_agent = "ExampleUserAgent",
  4686. -- ^ Optional, if specified replaces the default minetest user agent with given string
  4687. extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
  4688. -- ^ Optional, if specified adds additional headers to the HTTP request. You must make sure
  4689. -- ^ that the header strings follow HTTP specification ("Key: Value").
  4690. multipart = boolean
  4691. -- ^ Optional, if true performs a multipart HTTP request. Default is false.
  4692. }
  4693. ### `HTTPRequestResult` definition (`HTTPApiTable.fetch` callback, `HTTPApiTable.fetch_async_get`)
  4694. {
  4695. completed = true,
  4696. -- ^ If true, the request has finished (either succeeded, failed or timed out)
  4697. succeeded = true,
  4698. -- ^ If true, the request was successful
  4699. timeout = false,
  4700. -- ^ If true, the request timed out
  4701. code = 200,
  4702. -- ^ HTTP status code
  4703. data = "response"
  4704. }
  4705. ### Authentication handler definition
  4706. {
  4707. get_auth = func(name),
  4708. -- ^ Get authentication data for existing player `name` (`nil` if player doesn't exist)
  4709. -- ^ returns following structure `{password=<string>, privileges=<table>, last_login=<number or nil>}`
  4710. create_auth = func(name, password),
  4711. -- ^ Create new auth data for player `name`
  4712. -- ^ Note that `password` is not plain-text but an arbitrary representation decided by the engine
  4713. delete_auth = func(name),
  4714. -- ^ Delete auth data of player `name`, returns boolean indicating success (false if player nonexistant)
  4715. set_password = func(name, password),
  4716. -- ^ Set password of player `name` to `password`
  4717. Auth data should be created if not present
  4718. set_privileges = func(name, privileges),
  4719. -- ^ Set privileges of player `name`
  4720. -- ^ `privileges` is in table form, auth data should be created if not present
  4721. reload = func(),
  4722. -- ^ Reload authentication data from the storage location
  4723. -- ^ Returns boolean indicating success
  4724. record_login = func(name),
  4725. -- ^ Called when player joins, used for keeping track of last_login
  4726. iterate = func(),
  4727. -- ^ Returns an iterator (use with `for` loops) for all player names currently in the auth database
  4728. }