lua_api.txt 283 KB

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