lua_api.txt 409 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915
  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. Minetest keeps and looks for files mostly in two paths. `path_share` or `path_user`.
  27. `path_share` contains possibly read-only content for the engine (incl. games and mods).
  28. `path_user` contains mods or games installed by the user but also the users
  29. worlds or settings.
  30. With a local build (`RUN_IN_PLACE=1`) `path_share` and `path_user` both point to
  31. the build directory. For system-wide builds on Linux the share path is usually at
  32. `/usr/share/minetest` while the user path resides in `.minetest` in the home directory.
  33. Paths on other operating systems will differ.
  34. Games
  35. =====
  36. Games are looked up from:
  37. * `$path_share/games/<gameid>/`
  38. * `$path_user/games/<gameid>/`
  39. Where `<gameid>` is unique to each game.
  40. The game directory can contain the following files:
  41. * `game.conf`, with the following keys:
  42. * `title`: Required, a human-readable title to address the game, e.g. `title = Minetest Game`.
  43. * `name`: (Deprecated) same as title.
  44. * `description`: Short description to be shown in the content tab
  45. * `allowed_mapgens = <comma-separated mapgens>`
  46. e.g. `allowed_mapgens = v5,v6,flat`
  47. Mapgens not in this list are removed from the list of mapgens for the
  48. game.
  49. If not specified, all mapgens are allowed.
  50. * `disallowed_mapgens = <comma-separated mapgens>`
  51. e.g. `disallowed_mapgens = v5,v6,flat`
  52. These mapgens are removed from the list of mapgens for the game.
  53. When both `allowed_mapgens` and `disallowed_mapgens` are
  54. specified, `allowed_mapgens` is applied before
  55. `disallowed_mapgens`.
  56. * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
  57. e.g. `disallowed_mapgen_settings = mgv5_spflags`
  58. These mapgen settings are hidden for this game in the world creation
  59. dialog and game start menu. Add `seed` to hide the seed input field.
  60. * `disabled_settings = <comma-separated settings>`
  61. e.g. `disabled_settings = enable_damage, creative_mode`
  62. These settings are hidden for this game in the "Start game" tab
  63. and will be initialized as `false` when the game is started.
  64. Prepend a setting name with an exclamation mark to initialize it to `true`
  65. (this does not work for `enable_server`).
  66. Only these settings are supported:
  67. `enable_damage`, `creative_mode`, `enable_server`.
  68. * `author`: The author of the game. It only appears when downloaded from
  69. ContentDB.
  70. * `release`: Ignore this: Should only ever be set by ContentDB, as it is
  71. an internal ID used to track versions.
  72. * `minetest.conf`:
  73. Used to set default settings when running this game.
  74. * `settingtypes.txt`:
  75. In the same format as the one in builtin.
  76. This settingtypes.txt will be parsed by the menu and the settings will be
  77. displayed in the "Games" category in the advanced settings tab.
  78. * If the game contains a folder called `textures` the server will load it as a
  79. texturepack, overriding mod textures.
  80. Any server texturepack will override mod textures and the game texturepack.
  81. Menu images
  82. -----------
  83. Games can provide custom main menu images. They are put inside a `menu`
  84. directory inside the game directory.
  85. The images are named `$identifier.png`, where `$identifier` is one of
  86. `overlay`, `background`, `footer`, `header`.
  87. If you want to specify multiple images for one identifier, add additional
  88. images named like `$identifier.$n.png`, with an ascending number $n starting
  89. with 1, and a random image will be chosen from the provided ones.
  90. Menu music
  91. -----------
  92. Games can provide custom main menu music. They are put inside a `menu`
  93. directory inside the game directory.
  94. The music files are named `theme.ogg`.
  95. If you want to specify multiple music files for one game, add additional
  96. images named like `theme.$n.ogg`, with an ascending number $n starting
  97. with 1 (max 10), and a random music file will be chosen from the provided ones.
  98. Mods
  99. ====
  100. Mod load path
  101. -------------
  102. Paths are relative to the directories listed in the [Paths] section above.
  103. * `games/<gameid>/mods/`
  104. * `mods/`
  105. * `worlds/<worldname>/worldmods/`
  106. World-specific games
  107. --------------------
  108. It is possible to include a game in a world; in this case, no mods or
  109. games are loaded or checked from anywhere else.
  110. This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
  111. directory exists.
  112. Mods should then be placed in `<worldname>/game/mods/`.
  113. Modpacks
  114. --------
  115. Mods can be put in a subdirectory, if the parent directory, which otherwise
  116. should be a mod, contains a file named `modpack.conf`.
  117. The file is a key-value store of modpack details.
  118. * `name`: The modpack name. Allows Minetest to determine the modpack name even
  119. if the folder is wrongly named.
  120. * `description`: Description of mod to be shown in the Mods tab of the main
  121. menu.
  122. * `author`: The author of the modpack. It only appears when downloaded from
  123. ContentDB.
  124. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  125. internal ID used to track versions.
  126. * `title`: A human-readable title to address the modpack.
  127. Note: to support 0.4.x, please also create an empty modpack.txt file.
  128. Mod directory structure
  129. -----------------------
  130. mods
  131. ├── modname
  132. │   ├── mod.conf
  133. │   ├── screenshot.png
  134. │   ├── settingtypes.txt
  135. │   ├── init.lua
  136. │   ├── models
  137. │   ├── textures
  138. │   │   ├── modname_stuff.png
  139. │   │   ├── modname_stuff_normal.png
  140. │   │   ├── modname_something_else.png
  141. │   │   ├── subfolder_foo
  142. │   │   │ ├── modname_more_stuff.png
  143. │   │   │ └── another_subfolder
  144. │   │   └── bar_subfolder
  145. │   ├── sounds
  146. │   ├── media
  147. │   ├── locale
  148. │   └── <custom data>
  149. └── another
  150. ### modname
  151. The location of this directory can be fetched by using
  152. `minetest.get_modpath(modname)`.
  153. ### mod.conf
  154. A `Settings` file that provides meta information about the mod.
  155. * `name`: The mod name. Allows Minetest to determine the mod name even if the
  156. folder is wrongly named.
  157. * `description`: Description of mod to be shown in the Mods tab of the main
  158. menu.
  159. * `depends`: A comma separated list of dependencies. These are mods that must be
  160. loaded before this mod.
  161. * `optional_depends`: A comma separated list of optional dependencies.
  162. Like a dependency, but no error if the mod doesn't exist.
  163. * `author`: The author of the mod. It only appears when downloaded from
  164. ContentDB.
  165. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  166. internal ID used to track versions.
  167. * `title`: A human-readable title to address the mod.
  168. ### `screenshot.png`
  169. A screenshot shown in the mod manager within the main menu. It should
  170. have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
  171. ### `depends.txt`
  172. **Deprecated:** you should use mod.conf instead.
  173. This file is used if there are no dependencies in mod.conf.
  174. List of mods that have to be loaded before loading this mod.
  175. A single line contains a single modname.
  176. Optional dependencies can be defined by appending a question mark
  177. to a single modname. This means that if the specified mod
  178. is missing, it does not prevent this mod from being loaded.
  179. ### `description.txt`
  180. **Deprecated:** you should use mod.conf instead.
  181. This file is used if there is no description in mod.conf.
  182. A file containing a description to be shown in the Mods tab of the main menu.
  183. ### `settingtypes.txt`
  184. The format is documented in `builtin/settingtypes.txt`.
  185. It is parsed by the main menu settings dialogue to list mod-specific
  186. settings in the "Mods" category.
  187. ### `init.lua`
  188. The main Lua script. Running this script should register everything it
  189. wants to register. Subsequent execution depends on minetest calling the
  190. registered callbacks.
  191. `minetest.settings` can be used to read custom or existing settings at load
  192. time, if necessary. (See [`Settings`])
  193. ### `textures`, `sounds`, `media`, `models`, `locale`
  194. Media files (textures, sounds, whatever) that will be transferred to the
  195. client and will be available for use by the mod and translation files for
  196. the clients (see [Translations]).
  197. It is suggested to use the folders for the purpose they are thought for,
  198. eg. put textures into `textures`, translation files into `locale`,
  199. models for entities or meshnodes into `models` et cetera.
  200. These folders and subfolders can contain subfolders.
  201. Subfolders with names starting with `_` or `.` are ignored.
  202. If a subfolder contains a media file with the same name as a media file
  203. in one of its parents, the parent's file is used.
  204. Although it is discouraged, a mod can overwrite a media file of any mod that it
  205. depends on by supplying a file with an equal name.
  206. Naming conventions
  207. ------------------
  208. Registered names should generally be in this format:
  209. modname:<whatever>
  210. `<whatever>` can have these characters:
  211. a-zA-Z0-9_
  212. This is to prevent conflicting names from corrupting maps and is
  213. enforced by the mod loader.
  214. Registered names can be overridden by prefixing the name with `:`. This can
  215. be used for overriding the registrations of some other mod.
  216. The `:` prefix can also be used for maintaining backwards compatibility.
  217. ### Example
  218. In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
  219. So the name should be `experimental:tnt`.
  220. Any mod can redefine `experimental:tnt` by using the name
  221. :experimental:tnt
  222. when registering it. For this to work correctly, that mod must have
  223. `experimental` as a dependency.
  224. Aliases
  225. =======
  226. Aliases of itemnames can be added by using
  227. `minetest.register_alias(alias, original_name)` or
  228. `minetest.register_alias_force(alias, original_name)`.
  229. This adds an alias `alias` for the item called `original_name`.
  230. From now on, you can use `alias` to refer to the item `original_name`.
  231. The only difference between `minetest.register_alias` and
  232. `minetest.register_alias_force` is that if an item named `alias` already exists,
  233. `minetest.register_alias` will do nothing while
  234. `minetest.register_alias_force` will unregister it.
  235. This can be used for maintaining backwards compatibility.
  236. This can also set quick access names for things, e.g. if
  237. you have an item called `epiclylongmodname:stuff`, you could do
  238. minetest.register_alias("stuff", "epiclylongmodname:stuff")
  239. and be able to use `/giveme stuff`.
  240. Mapgen aliases
  241. --------------
  242. In a game, a certain number of these must be set to tell core mapgens which
  243. of the game's nodes are to be used for core mapgen generation. For example:
  244. minetest.register_alias("mapgen_stone", "default:stone")
  245. ### Aliases for non-V6 mapgens
  246. #### Essential aliases
  247. * `mapgen_stone`
  248. * `mapgen_water_source`
  249. * `mapgen_river_water_source`
  250. `mapgen_river_water_source` is required for mapgens with sloping rivers where
  251. it is necessary to have a river liquid node with a short `liquid_range` and
  252. `liquid_renewable = false` to avoid flooding.
  253. #### Optional aliases
  254. * `mapgen_lava_source`
  255. Fallback lava node used if cave liquids are not defined in biome definitions.
  256. Deprecated, define cave liquids in biome definitions instead.
  257. * `mapgen_cobble`
  258. Fallback node used if dungeon nodes are not defined in biome definitions.
  259. Deprecated, define dungeon nodes in biome definitions instead.
  260. ### Aliases for Mapgen V6
  261. #### Essential
  262. * `mapgen_stone`
  263. * `mapgen_water_source`
  264. * `mapgen_lava_source`
  265. * `mapgen_dirt`
  266. * `mapgen_dirt_with_grass`
  267. * `mapgen_sand`
  268. * `mapgen_tree`
  269. * `mapgen_leaves`
  270. * `mapgen_apple`
  271. * `mapgen_cobble`
  272. #### Optional
  273. * `mapgen_gravel` (falls back to stone)
  274. * `mapgen_desert_stone` (falls back to stone)
  275. * `mapgen_desert_sand` (falls back to sand)
  276. * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
  277. * `mapgen_snowblock` (falls back to dirt_with_grass)
  278. * `mapgen_snow` (not placed if missing)
  279. * `mapgen_ice` (falls back to water_source)
  280. * `mapgen_jungletree` (falls back to tree)
  281. * `mapgen_jungleleaves` (falls back to leaves)
  282. * `mapgen_junglegrass` (not placed if missing)
  283. * `mapgen_pine_tree` (falls back to tree)
  284. * `mapgen_pine_needles` (falls back to leaves)
  285. * `mapgen_stair_cobble` (falls back to cobble)
  286. * `mapgen_mossycobble` (falls back to cobble)
  287. * `mapgen_stair_desert_stone` (falls back to desert_stone)
  288. ### Setting the node used in Mapgen Singlenode
  289. By default the world is filled with air nodes. To set a different node use e.g.:
  290. minetest.register_alias("mapgen_singlenode", "default:stone")
  291. Textures
  292. ========
  293. Mods should generally prefix their textures with `modname_`, e.g. given
  294. the mod name `foomod`, a texture could be called:
  295. foomod_foothing.png
  296. Textures are referred to by their complete name, or alternatively by
  297. stripping out the file extension:
  298. * e.g. `foomod_foothing.png`
  299. * e.g. `foomod_foothing`
  300. Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
  301. and Targa (`.tga`).
  302. Since better alternatives exist, the latter two may be removed in the future.
  303. Texture modifiers
  304. -----------------
  305. There are various texture modifiers that can be used
  306. to let the client generate textures on-the-fly.
  307. The modifiers are applied directly in sRGB colorspace,
  308. i.e. without gamma-correction.
  309. ### Texture overlaying
  310. Textures can be overlaid by putting a `^` between them.
  311. Example:
  312. default_dirt.png^default_grass_side.png
  313. `default_grass_side.png` is overlaid over `default_dirt.png`.
  314. The texture with the lower resolution will be automatically upscaled to
  315. the higher resolution texture.
  316. ### Texture grouping
  317. Textures can be grouped together by enclosing them in `(` and `)`.
  318. Example: `cobble.png^(thing1.png^thing2.png)`
  319. A texture for `thing1.png^thing2.png` is created and the resulting
  320. texture is overlaid on top of `cobble.png`.
  321. ### Escaping
  322. Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
  323. passing complex texture names as arguments. Escaping is done with backslash and
  324. is required for `^` and `:`.
  325. Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
  326. The lower 50 percent of `color.png^[mask:trans.png` are overlaid
  327. on top of `cobble.png`.
  328. ### Advanced texture modifiers
  329. #### Crack
  330. * `[crack:<n>:<p>`
  331. * `[cracko:<n>:<p>`
  332. * `[crack:<t>:<n>:<p>`
  333. * `[cracko:<t>:<n>:<p>`
  334. Parameters:
  335. * `<t>`: tile count (in each direction)
  336. * `<n>`: animation frame count
  337. * `<p>`: current animation frame
  338. Draw a step of the crack animation on the texture.
  339. `crack` draws it normally, while `cracko` lays it over, keeping transparent
  340. pixels intact.
  341. Example:
  342. default_cobble.png^[crack:10:1
  343. #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
  344. * `<w>`: width
  345. * `<h>`: height
  346. * `<x>`: x position
  347. * `<y>`: y position
  348. * `<file>`: texture to combine
  349. Creates a texture of size `<w>` times `<h>` and blits the listed files to their
  350. specified coordinates.
  351. Example:
  352. [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
  353. #### `[resize:<w>x<h>`
  354. Resizes the texture to the given dimensions.
  355. Example:
  356. default_sandstone.png^[resize:16x16
  357. #### `[opacity:<r>`
  358. Makes the base image transparent according to the given ratio.
  359. `r` must be between 0 (transparent) and 255 (opaque).
  360. Example:
  361. default_sandstone.png^[opacity:127
  362. #### `[invert:<mode>`
  363. Inverts the given channels of the base image.
  364. Mode may contain the characters "r", "g", "b", "a".
  365. Only the channels that are mentioned in the mode string will be inverted.
  366. Example:
  367. default_apple.png^[invert:rgb
  368. #### `[brighten`
  369. Brightens the texture.
  370. Example:
  371. tnt_tnt_side.png^[brighten
  372. #### `[noalpha`
  373. Makes the texture completely opaque.
  374. Example:
  375. default_leaves.png^[noalpha
  376. #### `[makealpha:<r>,<g>,<b>`
  377. Convert one color to transparency.
  378. Example:
  379. default_cobble.png^[makealpha:128,128,128
  380. #### `[transform<t>`
  381. * `<t>`: transformation(s) to apply
  382. Rotates and/or flips the image.
  383. `<t>` can be a number (between 0 and 7) or a transform name.
  384. Rotations are counter-clockwise.
  385. 0 I identity
  386. 1 R90 rotate by 90 degrees
  387. 2 R180 rotate by 180 degrees
  388. 3 R270 rotate by 270 degrees
  389. 4 FX flip X
  390. 5 FXR90 flip X then rotate by 90 degrees
  391. 6 FY flip Y
  392. 7 FYR90 flip Y then rotate by 90 degrees
  393. Example:
  394. default_stone.png^[transformFXR90
  395. #### `[inventorycube{<top>{<left>{<right>`
  396. Escaping does not apply here and `^` is replaced by `&` in texture names
  397. instead.
  398. Create an inventory cube texture using the side textures.
  399. Example:
  400. [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
  401. Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
  402. `dirt.png^grass_side.png` textures
  403. #### `[lowpart:<percent>:<file>`
  404. Blit the lower `<percent>`% part of `<file>` on the texture.
  405. Example:
  406. base.png^[lowpart:25:overlay.png
  407. #### `[verticalframe:<t>:<n>`
  408. * `<t>`: animation frame count
  409. * `<n>`: current animation frame
  410. Crops the texture to a frame of a vertical animation.
  411. Example:
  412. default_torch_animated.png^[verticalframe:16:8
  413. #### `[mask:<file>`
  414. Apply a mask to the base image.
  415. The mask is applied using binary AND.
  416. #### `[sheet:<w>x<h>:<x>,<y>`
  417. Retrieves a tile at position x,y from the base image
  418. which it assumes to be a tilesheet with dimensions w,h.
  419. #### `[colorize:<color>:<ratio>`
  420. Colorize the textures with the given color.
  421. `<color>` is specified as a `ColorString`.
  422. `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
  423. it is an int, then it specifies how far to interpolate between the
  424. colors where 0 is only the texture color and 255 is only `<color>`. If
  425. omitted, the alpha of `<color>` will be used as the ratio. If it is
  426. the word "`alpha`", then each texture pixel will contain the RGB of
  427. `<color>` and the alpha of `<color>` multiplied by the alpha of the
  428. texture pixel.
  429. #### `[multiply:<color>`
  430. Multiplies texture colors with the given color.
  431. `<color>` is specified as a `ColorString`.
  432. Result is more like what you'd expect if you put a color on top of another
  433. color, meaning white surfaces get a lot of your new color while black parts
  434. don't change very much.
  435. #### `[png:<base64>`
  436. Embed a base64 encoded PNG image in the texture string.
  437. You can produce a valid string for this by calling
  438. `minetest.encode_base64(minetest.encode_png(tex))`,
  439. refer to the documentation of these functions for details.
  440. You can use this to send disposable images such as captchas
  441. to individual clients, or render things that would be too
  442. expensive to compose with `[combine:`.
  443. IMPORTANT: Avoid sending large images this way.
  444. This is not a replacement for asset files, do not use it to do anything
  445. that you could instead achieve by just using a file.
  446. In particular consider `minetest.dynamic_add_media` and test whether
  447. using other texture modifiers could result in a shorter string than
  448. embedding a whole image, this may vary by use case.
  449. Hardware coloring
  450. -----------------
  451. The goal of hardware coloring is to simplify the creation of
  452. colorful nodes. If your textures use the same pattern, and they only
  453. differ in their color (like colored wool blocks), you can use hardware
  454. coloring instead of creating and managing many texture files.
  455. All of these methods use color multiplication (so a white-black texture
  456. with red coloring will result in red-black color).
  457. ### Static coloring
  458. This method is useful if you wish to create nodes/items with
  459. the same texture, in different colors, each in a new node/item definition.
  460. #### Global color
  461. When you register an item or node, set its `color` field (which accepts a
  462. `ColorSpec`) to the desired color.
  463. An `ItemStack`'s static color can be overwritten by the `color` metadata
  464. field. If you set that field to a `ColorString`, that color will be used.
  465. #### Tile color
  466. Each tile may have an individual static color, which overwrites every
  467. other coloring method. To disable the coloring of a face,
  468. set its color to white (because multiplying with white does nothing).
  469. You can set the `color` property of the tiles in the node's definition
  470. if the tile is in table format.
  471. ### Palettes
  472. For nodes and items which can have many colors, a palette is more
  473. suitable. A palette is a texture, which can contain up to 256 pixels.
  474. Each pixel is one possible color for the node/item.
  475. You can register one node/item, which can have up to 256 colors.
  476. #### Palette indexing
  477. When using palettes, you always provide a pixel index for the given
  478. node or `ItemStack`. The palette is read from left to right and from
  479. top to bottom. If the palette has less than 256 pixels, then it is
  480. stretched to contain exactly 256 pixels (after arranging the pixels
  481. to one line). The indexing starts from 0.
  482. Examples:
  483. * 16x16 palette, index = 0: the top left corner
  484. * 16x16 palette, index = 4: the fifth pixel in the first row
  485. * 16x16 palette, index = 16: the pixel below the top left corner
  486. * 16x16 palette, index = 255: the bottom right corner
  487. * 2 (width) x 4 (height) palette, index = 31: the top left corner.
  488. The palette has 8 pixels, so each pixel is stretched to 32 pixels,
  489. to ensure the total 256 pixels.
  490. * 2x4 palette, index = 32: the top right corner
  491. * 2x4 palette, index = 63: the top right corner
  492. * 2x4 palette, index = 64: the pixel below the top left corner
  493. #### Using palettes with items
  494. When registering an item, set the item definition's `palette` field to
  495. a texture. You can also use texture modifiers.
  496. The `ItemStack`'s color depends on the `palette_index` field of the
  497. stack's metadata. `palette_index` is an integer, which specifies the
  498. index of the pixel to use.
  499. #### Linking palettes with nodes
  500. When registering a node, set the item definition's `palette` field to
  501. a texture. You can also use texture modifiers.
  502. The node's color depends on its `param2`, so you also must set an
  503. appropriate `paramtype2`:
  504. * `paramtype2 = "color"` for nodes which use their full `param2` for
  505. palette indexing. These nodes can have 256 different colors.
  506. The palette should contain 256 pixels.
  507. * `paramtype2 = "colorwallmounted"` for nodes which use the first
  508. five bits (most significant) of `param2` for palette indexing.
  509. The remaining three bits are describing rotation, as in `wallmounted`
  510. paramtype2. Division by 8 yields the palette index (without stretching the
  511. palette). These nodes can have 32 different colors, and the palette
  512. should contain 32 pixels.
  513. Examples:
  514. * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
  515. pixel will be picked from the palette.
  516. * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
  517. pixel will be picked from the palette.
  518. * `paramtype2 = "colorfacedir"` for nodes which use the first
  519. three bits of `param2` for palette indexing. The remaining
  520. five bits are describing rotation, as in `facedir` paramtype2.
  521. Division by 32 yields the palette index (without stretching the
  522. palette). These nodes can have 8 different colors, and the
  523. palette should contain 8 pixels.
  524. Examples:
  525. * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
  526. first (= 0 + 1) pixel will be picked from the palette.
  527. * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
  528. second (= 1 + 1) pixel will be picked from the palette.
  529. * `paramtype2 = "color4dir"` for nodes which use the first
  530. six bits of `param2` for palette indexing. The remaining
  531. two bits are describing rotation, as in `4dir` paramtype2.
  532. Division by 4 yields the palette index (without stretching the
  533. palette). These nodes can have 64 different colors, and the
  534. palette should contain 64 pixels.
  535. Examples:
  536. * `param2 = 17` is 4 * 4 + 1, so the rotation is 1 and the
  537. fifth (= 4 + 1) pixel will be picked from the palette.
  538. * `param2 = 35` is 8 * 4 + 3, so the rotation is 3 and the
  539. ninth (= 8 + 1) pixel will be picked from the palette.
  540. To colorize a node on the map, set its `param2` value (according
  541. to the node's paramtype2).
  542. ### Conversion between nodes in the inventory and on the map
  543. Static coloring is the same for both cases, there is no need
  544. for conversion.
  545. If the `ItemStack`'s metadata contains the `color` field, it will be
  546. lost on placement, because nodes on the map can only use palettes.
  547. If the `ItemStack`'s metadata contains the `palette_index` field, it is
  548. automatically transferred between node and item forms by the engine,
  549. when a player digs or places a colored node.
  550. You can disable this feature by setting the `drop` field of the node
  551. to itself (without metadata).
  552. To transfer the color to a special drop, you need a drop table.
  553. Example:
  554. minetest.register_node("mod:stone", {
  555. description = "Stone",
  556. tiles = {"default_stone.png"},
  557. paramtype2 = "color",
  558. palette = "palette.png",
  559. drop = {
  560. items = {
  561. -- assume that mod:cobblestone also has the same palette
  562. {items = {"mod:cobblestone"}, inherit_color = true },
  563. }
  564. }
  565. })
  566. ### Colored items in craft recipes
  567. Craft recipes only support item strings, but fortunately item strings
  568. can also contain metadata. Example craft recipe registration:
  569. minetest.register_craft({
  570. output = minetest.itemstring_with_palette("wool:block", 3),
  571. type = "shapeless",
  572. recipe = {
  573. "wool:block",
  574. "dye:red",
  575. },
  576. })
  577. To set the `color` field, you can use `minetest.itemstring_with_color`.
  578. Metadata field filtering in the `recipe` field are not supported yet,
  579. so the craft output is independent of the color of the ingredients.
  580. Soft texture overlay
  581. --------------------
  582. Sometimes hardware coloring is not enough, because it affects the
  583. whole tile. Soft texture overlays were added to Minetest to allow
  584. the dynamic coloring of only specific parts of the node's texture.
  585. For example a grass block may have colored grass, while keeping the
  586. dirt brown.
  587. These overlays are 'soft', because unlike texture modifiers, the layers
  588. are not merged in the memory, but they are simply drawn on top of each
  589. other. This allows different hardware coloring, but also means that
  590. tiles with overlays are drawn slower. Using too much overlays might
  591. cause FPS loss.
  592. For inventory and wield images you can specify overlays which
  593. hardware coloring does not modify. You have to set `inventory_overlay`
  594. and `wield_overlay` fields to an image name.
  595. To define a node overlay, simply set the `overlay_tiles` field of the node
  596. definition. These tiles are defined in the same way as plain tiles:
  597. they can have a texture name, color etc.
  598. To skip one face, set that overlay tile to an empty string.
  599. Example (colored grass block):
  600. minetest.register_node("default:dirt_with_grass", {
  601. description = "Dirt with Grass",
  602. -- Regular tiles, as usual
  603. -- The dirt tile disables palette coloring
  604. tiles = {{name = "default_grass.png"},
  605. {name = "default_dirt.png", color = "white"}},
  606. -- Overlay tiles: define them in the same style
  607. -- The top and bottom tile does not have overlay
  608. overlay_tiles = {"", "",
  609. {name = "default_grass_side.png"}},
  610. -- Global color, used in inventory
  611. color = "green",
  612. -- Palette in the world
  613. paramtype2 = "color",
  614. palette = "default_foilage.png",
  615. })
  616. Sounds
  617. ======
  618. Only Ogg Vorbis files are supported.
  619. For positional playing of sounds, only single-channel (mono) files are
  620. supported. Otherwise OpenAL will play them non-positionally.
  621. Mods should generally prefix their sounds with `modname_`, e.g. given
  622. the mod name "`foomod`", a sound could be called:
  623. foomod_foosound.ogg
  624. Sounds are referred to by their name with a dot, a single digit and the
  625. file extension stripped out. When a sound is played, the actual sound file
  626. is chosen randomly from the matching sounds.
  627. When playing the sound `foomod_foosound`, the sound is chosen randomly
  628. from the available ones of the following files:
  629. * `foomod_foosound.ogg`
  630. * `foomod_foosound.0.ogg`
  631. * `foomod_foosound.1.ogg`
  632. * (...)
  633. * `foomod_foosound.9.ogg`
  634. Examples of sound parameter tables:
  635. -- Play locationless on all clients
  636. {
  637. gain = 1.0, -- default
  638. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  639. pitch = 1.0, -- default
  640. }
  641. -- Play locationless to one player
  642. {
  643. to_player = name,
  644. gain = 1.0, -- default
  645. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  646. pitch = 1.0, -- default
  647. }
  648. -- Play locationless to one player, looped
  649. {
  650. to_player = name,
  651. gain = 1.0, -- default
  652. loop = true,
  653. }
  654. -- Play at a location
  655. {
  656. pos = {x = 1, y = 2, z = 3},
  657. gain = 1.0, -- default
  658. max_hear_distance = 32, -- default, uses a Euclidean metric
  659. }
  660. -- Play connected to an object, looped
  661. {
  662. object = <an ObjectRef>,
  663. gain = 1.0, -- default
  664. max_hear_distance = 32, -- default, uses a Euclidean metric
  665. loop = true,
  666. }
  667. -- Play at a location, heard by anyone *but* the given player
  668. {
  669. pos = {x = 32, y = 0, z = 100},
  670. max_hear_distance = 40,
  671. exclude_player = name,
  672. }
  673. Looped sounds must either be connected to an object or played locationless to
  674. one player using `to_player = name`.
  675. A positional sound will only be heard by players that are within
  676. `max_hear_distance` of the sound position, at the start of the sound.
  677. `exclude_player = name` can be applied to locationless, positional and object-
  678. bound sounds to exclude a single player from hearing them.
  679. `SimpleSoundSpec`
  680. -----------------
  681. Specifies a sound name, gain (=volume) and pitch.
  682. This is either a string or a table.
  683. In string form, you just specify the sound name or
  684. the empty string for no sound.
  685. Table form has the following fields:
  686. * `name`: Sound name
  687. * `gain`: Volume (`1.0` = 100%)
  688. * `pitch`: Pitch (`1.0` = 100%)
  689. `gain` and `pitch` are optional and default to `1.0`.
  690. Examples:
  691. * `""`: No sound
  692. * `{}`: No sound
  693. * `"default_place_node"`: Play e.g. `default_place_node.ogg`
  694. * `{name = "default_place_node"}`: Same as above
  695. * `{name = "default_place_node", gain = 0.5}`: 50% volume
  696. * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
  697. Special sound files
  698. -------------------
  699. These sound files are played back by the engine if provided.
  700. * `player_damage`: Played when the local player takes damage (gain = 0.5)
  701. * `player_falling_damage`: Played when the local player takes
  702. damage by falling (gain = 0.5)
  703. * `player_jump`: Played when the local player jumps
  704. * `default_dig_<groupname>`: Default node digging sound
  705. (see node sound definition for details)
  706. Registered definitions
  707. ======================
  708. Anything added using certain [Registration functions] gets added to one or more
  709. of the global [Registered definition tables].
  710. Note that in some cases you will stumble upon things that are not contained
  711. in these tables (e.g. when a mod has been removed). Always check for
  712. existence before trying to access the fields.
  713. Example:
  714. All nodes registered with `minetest.register_node` get added to the table
  715. `minetest.registered_nodes`.
  716. If you want to check the drawtype of a node, you could do it like this:
  717. local def = minetest.registered_nodes[nodename]
  718. local drawtype = def and def.drawtype
  719. Nodes
  720. =====
  721. Nodes are the bulk data of the world: cubes and other things that take the
  722. space of a cube. Huge amounts of them are handled efficiently, but they
  723. are quite static.
  724. The definition of a node is stored and can be accessed by using
  725. minetest.registered_nodes[node.name]
  726. See [Registered definitions].
  727. Nodes are passed by value between Lua and the engine.
  728. They are represented by a table:
  729. {name="name", param1=num, param2=num}
  730. `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
  731. them for certain automated functions. If you don't use these functions, you can
  732. use them to store arbitrary values.
  733. Node paramtypes
  734. ---------------
  735. The functions of `param1` and `param2` are determined by certain fields in the
  736. node definition.
  737. The function of `param1` is determined by `paramtype` in node definition.
  738. `param1` is reserved for the engine when `paramtype != "none"`.
  739. * `paramtype = "light"`
  740. * The value stores light with and without sun in its lower and upper 4 bits
  741. respectively.
  742. * Required by a light source node to enable spreading its light.
  743. * Required by the following drawtypes as they determine their visual
  744. brightness from their internal light value:
  745. * torchlike
  746. * signlike
  747. * firelike
  748. * fencelike
  749. * raillike
  750. * nodebox
  751. * mesh
  752. * plantlike
  753. * plantlike_rooted
  754. * `paramtype = "none"`
  755. * `param1` will not be used by the engine and can be used to store
  756. an arbitrary value
  757. The function of `param2` is determined by `paramtype2` in node definition.
  758. `param2` is reserved for the engine when `paramtype2 != "none"`.
  759. * `paramtype2 = "flowingliquid"`
  760. * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
  761. * The liquid level and a flag of the liquid are stored in `param2`
  762. * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
  763. see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
  764. to access/manipulate the content of this field
  765. * Bit 3: If set, liquid is flowing downwards (no graphical effect)
  766. * `paramtype2 = "wallmounted"`
  767. * Supported drawtypes: "torchlike", "signlike", "plantlike",
  768. "plantlike_rooted", "normal", "nodebox", "mesh"
  769. * The rotation of the node is stored in `param2`
  770. * Node is 'mounted'/facing towards one of 6 directions
  771. * You can make this value by using `minetest.dir_to_wallmounted()`
  772. * Values range 0 - 5
  773. * The value denotes at which direction the node is "mounted":
  774. 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z-
  775. * By default, on placement the param2 is automatically set to the
  776. appropriate rotation, depending on which side was pointed at
  777. * `paramtype2 = "facedir"`
  778. * Supported drawtypes: "normal", "nodebox", "mesh"
  779. * The rotation of the node is stored in `param2`.
  780. * Node is rotated around face and axis; 24 rotations in total.
  781. * Can be made by using `minetest.dir_to_facedir()`.
  782. * Chests and furnaces can be rotated that way, and also 'flipped'
  783. * Values range 0 - 23
  784. * facedir / 4 = axis direction:
  785. 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y-
  786. * The node is rotated 90 degrees around the X or Z axis so that its top face
  787. points in the desired direction. For the y- direction, it's rotated 180
  788. degrees around the Z axis.
  789. * facedir modulo 4 = left-handed rotation around the specified axis, in 90° steps.
  790. * By default, on placement the param2 is automatically set to the
  791. horizontal direction the player was looking at (values 0-3)
  792. * Special case: If the node is a connected nodebox, the nodebox
  793. will NOT rotate, only the textures will.
  794. * `paramtype2 = "4dir"`
  795. * Supported drawtypes: "normal", "nodebox", "mesh"
  796. * The rotation of the node is stored in `param2`.
  797. * Allows node to be rotated horizontally, 4 rotations in total
  798. * Can be made by using `minetest.dir_to_fourdir()`.
  799. * Chests and furnaces can be rotated that way, but not flipped
  800. * Values range 0 - 3
  801. * 4dir modulo 4 = rotation
  802. * Otherwise, behavior is identical to facedir
  803. * `paramtype2 = "leveled"`
  804. * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
  805. * Leveled nodebox:
  806. * The level of the top face of the nodebox is stored in `param2`.
  807. * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
  808. nodeboxes.
  809. * The nodebox height is (`param2` / 64) nodes.
  810. * The maximum accepted value of `param2` is 127.
  811. * Rooted plantlike:
  812. * The height of the 'plantlike' section is stored in `param2`.
  813. * The height is (`param2` / 16) nodes.
  814. * `paramtype2 = "degrotate"`
  815. * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
  816. stored in `param2`.
  817. * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
  818. get the actual rotation in degrees of the node.
  819. * `paramtype2 = "meshoptions"`
  820. * Only valid for "plantlike" drawtype. `param2` encodes the shape and
  821. optional modifiers of the "plant". `param2` is a bitfield.
  822. * Bits 0 to 2 select the shape.
  823. Use only one of the values below:
  824. * 0 = an "x" shaped plant (ordinary plant)
  825. * 1 = a "+" shaped plant (just rotated 45 degrees)
  826. * 2 = a "*" shaped plant with 3 faces instead of 2
  827. * 3 = a "#" shaped plant with 4 faces instead of 2
  828. * 4 = a "#" shaped plant with 4 faces that lean outwards
  829. * 5-7 are unused and reserved for future meshes.
  830. * Bits 3 to 7 are used to enable any number of optional modifiers.
  831. Just add the corresponding value(s) below to `param2`:
  832. * 8 - Makes the plant slightly vary placement horizontally
  833. * 16 - Makes the plant mesh 1.4x larger
  834. * 32 - Moves each face randomly a small bit down (1/8 max)
  835. * values 64 and 128 (bits 6-7) are reserved for future use.
  836. * Example: `param2 = 0` selects a normal "x" shaped plant
  837. * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
  838. * `paramtype2 = "color"`
  839. * `param2` tells which color is picked from the palette.
  840. The palette should have 256 pixels.
  841. * `paramtype2 = "colorfacedir"`
  842. * Same as `facedir`, but with colors.
  843. * The first three bits of `param2` tells which color is picked from the
  844. palette. The palette should have 8 pixels.
  845. * `paramtype2 = "color4dir"`
  846. * Same as `facedir`, but with colors.
  847. * The first six bits of `param2` tells which color is picked from the
  848. palette. The palette should have 64 pixels.
  849. * `paramtype2 = "colorwallmounted"`
  850. * Same as `wallmounted`, but with colors.
  851. * The first five bits of `param2` tells which color is picked from the
  852. palette. The palette should have 32 pixels.
  853. * `paramtype2 = "glasslikeliquidlevel"`
  854. * Only valid for "glasslike_framed" or "glasslike_framed_optional"
  855. drawtypes. "glasslike_framed_optional" nodes are only affected if the
  856. "Connected Glass" setting is enabled.
  857. * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
  858. full.
  859. * Bits 6 and 7 modify the appearance of the frame and node faces. One or
  860. both of these values may be added to `param2`:
  861. * 64 - Makes the node not connect with neighbors above or below it.
  862. * 128 - Makes the node not connect with neighbors to its sides.
  863. * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
  864. * `paramtype2 = "colordegrotate"`
  865. * Same as `degrotate`, but with colors.
  866. * The first (most-significant) three bits of `param2` tells which color
  867. is picked from the palette. The palette should have 8 pixels.
  868. * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
  869. * `paramtype2 = "none"`
  870. * `param2` will not be used by the engine and can be used to store
  871. an arbitrary value
  872. Nodes can also contain extra data. See [Node Metadata].
  873. Node drawtypes
  874. --------------
  875. There are a bunch of different looking node types.
  876. Look for examples in `games/devtest` or `games/minetest_game`.
  877. * `normal`
  878. * A node-sized cube.
  879. * `airlike`
  880. * Invisible, uses no texture.
  881. * `liquid`
  882. * The cubic source node for a liquid.
  883. * Faces bordering to the same node are never rendered.
  884. * Connects to node specified in `liquid_alternative_flowing`.
  885. * You *must* set `liquid_alternative_source` to the node's own name.
  886. * Use `backface_culling = false` for the tiles you want to make
  887. visible when inside the node.
  888. * `flowingliquid`
  889. * The flowing version of a liquid, appears with various heights and slopes.
  890. * Faces bordering to the same node are never rendered.
  891. * Connects to node specified in `liquid_alternative_source`.
  892. * You *must* set `liquid_alternative_flowing` to the node's own name.
  893. * Node textures are defined with `special_tiles` where the first tile
  894. is for the top and bottom faces and the second tile is for the side
  895. faces.
  896. * `tiles` is used for the item/inventory/wield image rendering.
  897. * Use `backface_culling = false` for the special tiles you want to make
  898. visible when inside the node
  899. * `glasslike`
  900. * Often used for partially-transparent nodes.
  901. * Only external sides of textures are visible.
  902. * `glasslike_framed`
  903. * All face-connected nodes are drawn as one volume within a surrounding
  904. frame.
  905. * The frame appearance is generated from the edges of the first texture
  906. specified in `tiles`. The width of the edges used are 1/16th of texture
  907. size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
  908. * The glass 'shine' (or other desired detail) on each node face is supplied
  909. by the second texture specified in `tiles`.
  910. * `glasslike_framed_optional`
  911. * This switches between the above 2 drawtypes according to the menu setting
  912. 'Connected Glass'.
  913. * `allfaces`
  914. * Often used for partially-transparent nodes.
  915. * External and internal sides of textures are visible.
  916. * `allfaces_optional`
  917. * Often used for leaves nodes.
  918. * This switches between `normal`, `glasslike` and `allfaces` according to
  919. the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
  920. * With 'Simple Leaves' selected, the texture specified in `special_tiles`
  921. is used instead, if present. This allows a visually thicker texture to be
  922. used to compensate for how `glasslike` reduces visual thickness.
  923. * `torchlike`
  924. * A single vertical texture.
  925. * If `paramtype2="[color]wallmounted"`:
  926. * If placed on top of a node, uses the first texture specified in `tiles`.
  927. * If placed against the underside of a node, uses the second texture
  928. specified in `tiles`.
  929. * If placed on the side of a node, uses the third texture specified in
  930. `tiles` and is perpendicular to that node.
  931. * If `paramtype2="none"`:
  932. * Will be rendered as if placed on top of a node (see
  933. above) and only the first texture is used.
  934. * `signlike`
  935. * A single texture parallel to, and mounted against, the top, underside or
  936. side of a node.
  937. * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
  938. * If `paramtype2="none"`, it will always be on the floor.
  939. * `plantlike`
  940. * Two vertical and diagonal textures at right-angles to each other.
  941. * See `paramtype2 = "meshoptions"` above for other options.
  942. * `firelike`
  943. * When above a flat surface, appears as 6 textures, the central 2 as
  944. `plantlike` plus 4 more surrounding those.
  945. * If not above a surface the central 2 do not appear, but the texture
  946. appears against the faces of surrounding nodes if they are present.
  947. * `fencelike`
  948. * A 3D model suitable for a wooden fence.
  949. * One placed node appears as a single vertical post.
  950. * Adjacently-placed nodes cause horizontal bars to appear between them.
  951. * `raillike`
  952. * Often used for tracks for mining carts.
  953. * Requires 4 textures to be specified in `tiles`, in order: Straight,
  954. curved, t-junction, crossing.
  955. * Each placed node automatically switches to a suitable rotated texture
  956. determined by the adjacent `raillike` nodes, in order to create a
  957. continuous track network.
  958. * Becomes a sloping node if placed against stepped nodes.
  959. * `nodebox`
  960. * Often used for stairs and slabs.
  961. * Allows defining nodes consisting of an arbitrary number of boxes.
  962. * See [Node boxes] below for more information.
  963. * `mesh`
  964. * Uses models for nodes.
  965. * Tiles should hold model materials textures.
  966. * Only static meshes are implemented.
  967. * For supported model formats see Irrlicht engine documentation.
  968. * `plantlike_rooted`
  969. * Enables underwater `plantlike` without air bubbles around the nodes.
  970. * Consists of a base cube at the co-ordinates of the node plus a
  971. `plantlike` extension above
  972. * If `paramtype2="leveled", the `plantlike` extension has a height
  973. of `param2 / 16` nodes, otherwise it's the height of 1 node
  974. * If `paramtype2="wallmounted"`, the `plantlike` extension
  975. will be at one of the corresponding 6 sides of the base cube.
  976. Also, the base cube rotates like a `normal` cube would
  977. * The `plantlike` extension visually passes through any nodes above the
  978. base cube without affecting them.
  979. * The base cube texture tiles are defined as normal, the `plantlike`
  980. extension uses the defined special tile, for example:
  981. `special_tiles = {{name = "default_papyrus.png"}},`
  982. `*_optional` drawtypes need less rendering time if deactivated
  983. (always client-side).
  984. Node boxes
  985. ----------
  986. Node selection boxes are defined using "node boxes".
  987. A nodebox is defined as any of:
  988. {
  989. -- A normal cube; the default in most things
  990. type = "regular"
  991. }
  992. {
  993. -- A fixed box (or boxes) (facedir param2 is used, if applicable)
  994. type = "fixed",
  995. fixed = box OR {box1, box2, ...}
  996. }
  997. {
  998. -- A variable height box (or boxes) with the top face position defined
  999. -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
  1000. -- by param2.
  1001. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
  1002. type = "leveled",
  1003. fixed = box OR {box1, box2, ...}
  1004. }
  1005. {
  1006. -- A box like the selection box for torches
  1007. -- (wallmounted param2 is used, if applicable)
  1008. type = "wallmounted",
  1009. wall_top = box,
  1010. wall_bottom = box,
  1011. wall_side = box
  1012. }
  1013. {
  1014. -- A node that has optional boxes depending on neighboring nodes'
  1015. -- presence and type. See also `connects_to`.
  1016. type = "connected",
  1017. fixed = box OR {box1, box2, ...}
  1018. connect_top = box OR {box1, box2, ...}
  1019. connect_bottom = box OR {box1, box2, ...}
  1020. connect_front = box OR {box1, box2, ...}
  1021. connect_left = box OR {box1, box2, ...}
  1022. connect_back = box OR {box1, box2, ...}
  1023. connect_right = box OR {box1, box2, ...}
  1024. -- The following `disconnected_*` boxes are the opposites of the
  1025. -- `connect_*` ones above, i.e. when a node has no suitable neighbor
  1026. -- on the respective side, the corresponding disconnected box is drawn.
  1027. disconnected_top = box OR {box1, box2, ...}
  1028. disconnected_bottom = box OR {box1, box2, ...}
  1029. disconnected_front = box OR {box1, box2, ...}
  1030. disconnected_left = box OR {box1, box2, ...}
  1031. disconnected_back = box OR {box1, box2, ...}
  1032. disconnected_right = box OR {box1, box2, ...}
  1033. disconnected = box OR {box1, box2, ...} -- when there is *no* neighbor
  1034. disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
  1035. -- neighbors to the sides
  1036. }
  1037. A `box` is defined as:
  1038. {x1, y1, z1, x2, y2, z2}
  1039. A box of a regular node would look like:
  1040. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  1041. To avoid collision issues, keep each value within the range of +/- 1.45.
  1042. This also applies to leveled nodeboxes, where the final height shall not
  1043. exceed this soft limit.
  1044. Map terminology and coordinates
  1045. ===============================
  1046. Nodes, mapblocks, mapchunks
  1047. ---------------------------
  1048. A 'node' is the fundamental cubic unit of a world and appears to a player as
  1049. roughly 1x1x1 meters in size.
  1050. A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
  1051. fundamental region of a world that is stored in the world database, sent to
  1052. clients and handled by many parts of the engine.
  1053. 'mapblock' is preferred terminology to 'block' to help avoid confusion with
  1054. 'node', however 'block' often appears in the API.
  1055. A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
  1056. (80x80x80 nodes) and is the volume of world generated in one operation by
  1057. the map generator.
  1058. The size in mapblocks has been chosen to optimize map generation.
  1059. Coordinates
  1060. -----------
  1061. ### Orientation of axes
  1062. For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
  1063. ### Node coordinates
  1064. Almost all positions used in the API use node coordinates.
  1065. ### Mapblock coordinates
  1066. Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
  1067. specify a particular mapblock.
  1068. For example blockpos (0,0,0) specifies the mapblock that extends from
  1069. node position (0,0,0) to node position (15,15,15).
  1070. #### Converting node position to the containing blockpos
  1071. To calculate the blockpos of the mapblock that contains the node at 'nodepos',
  1072. for each axis:
  1073. * blockpos = math.floor(nodepos / 16)
  1074. #### Converting blockpos to min/max node positions
  1075. To calculate the min/max node positions contained in the mapblock at 'blockpos',
  1076. for each axis:
  1077. * Minimum:
  1078. nodepos = blockpos * 16
  1079. * Maximum:
  1080. nodepos = blockpos * 16 + 15
  1081. HUD
  1082. ===
  1083. HUD element types
  1084. -----------------
  1085. The position field is used for all element types.
  1086. To account for differing resolutions, the position coordinates are the
  1087. percentage of the screen, ranging in value from `0` to `1`.
  1088. The `name` field is not yet used, but should contain a description of what the
  1089. HUD element represents.
  1090. The `direction` field is the direction in which something is drawn.
  1091. `0` draws from left to right, `1` draws from right to left, `2` draws from
  1092. top to bottom, and `3` draws from bottom to top.
  1093. The `alignment` field specifies how the item will be aligned. It is a table
  1094. where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
  1095. moved to the left/up, and `1` is to the right/down. Fractional values can be
  1096. used.
  1097. The `offset` field specifies a pixel offset from the position. Contrary to
  1098. position, the offset is not scaled to screen size. This allows for some
  1099. precisely positioned items in the HUD.
  1100. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
  1101. factor!
  1102. The `z_index` field specifies the order of HUD elements from back to front.
  1103. Lower z-index elements are displayed behind higher z-index elements. Elements
  1104. with same z-index are displayed in an arbitrary order. Default 0.
  1105. Supports negative values. By convention, the following values are recommended:
  1106. * -400: Graphical effects, such as vignette
  1107. * -300: Name tags, waypoints
  1108. * -200: Wieldhand
  1109. * -100: Things that block the player's view, e.g. masks
  1110. * 0: Default. For standard in-game HUD elements like crosshair, hotbar,
  1111. minimap, builtin statbars, etc.
  1112. * 100: Temporary text messages or notification icons
  1113. * 1000: Full-screen effects such as full-black screen or credits.
  1114. This includes effects that cover the entire screen
  1115. If your HUD element doesn't fit into any category, pick a number
  1116. between the suggested values
  1117. Below are the specific uses for fields in each type; fields not listed for that
  1118. type are ignored.
  1119. ### `image`
  1120. Displays an image on the HUD.
  1121. * `scale`: The scale of the image, with 1 being the original texture size.
  1122. Only the X coordinate scale is used (positive values).
  1123. Negative values represent that percentage of the screen it
  1124. should take; e.g. `x=-100` means 100% (width).
  1125. * `text`: The name of the texture that is displayed.
  1126. * `alignment`: The alignment of the image.
  1127. * `offset`: offset in pixels from position.
  1128. ### `text`
  1129. Displays text on the HUD.
  1130. * `scale`: Defines the bounding rectangle of the text.
  1131. A value such as `{x=100, y=100}` should work.
  1132. * `text`: The text to be displayed in the HUD element.
  1133. * `number`: An integer containing the RGB value of the color used to draw the
  1134. text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
  1135. * `alignment`: The alignment of the text.
  1136. * `offset`: offset in pixels from position.
  1137. * `size`: size of the text.
  1138. The player-set font size is multiplied by size.x (y value isn't used).
  1139. * `style`: determines font style
  1140. Bitfield with 1 = bold, 2 = italic, 4 = monospace
  1141. ### `statbar`
  1142. Displays a horizontal bar made up of half-images with an optional background.
  1143. * `text`: The name of the texture to use.
  1144. * `text2`: Optional texture name to enable a background / "off state"
  1145. texture (useful to visualize the maximal value). Both textures
  1146. must have the same size.
  1147. * `number`: The number of half-textures that are displayed.
  1148. If odd, will end with a vertically center-split texture.
  1149. * `item`: Same as `number` but for the "off state" texture
  1150. * `direction`: To which direction the images will extend to
  1151. * `offset`: offset in pixels from position.
  1152. * `size`: If used, will force full-image size to this value (override texture
  1153. pack image size)
  1154. ### `inventory`
  1155. * `text`: The name of the inventory list to be displayed.
  1156. * `number`: Number of items in the inventory to be displayed.
  1157. * `item`: Position of item that is selected.
  1158. * `direction`: Direction the list will be displayed in
  1159. * `offset`: offset in pixels from position.
  1160. ### `waypoint`
  1161. Displays distance to selected world position.
  1162. * `name`: The name of the waypoint.
  1163. * `text`: Distance suffix. Can be blank.
  1164. * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
  1165. If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
  1166. When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
  1167. `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
  1168. `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
  1169. `precision = n` will show multiples of `1/n`
  1170. * `number:` An integer containing the RGB value of the color used to draw the
  1171. text.
  1172. * `world_pos`: World position of the waypoint.
  1173. * `offset`: offset in pixels from position.
  1174. * `alignment`: The alignment of the waypoint.
  1175. ### `image_waypoint`
  1176. Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
  1177. * `scale`: The scale of the image, with 1 being the original texture size.
  1178. Only the X coordinate scale is used (positive values).
  1179. Negative values represent that percentage of the screen it
  1180. should take; e.g. `x=-100` means 100% (width).
  1181. * `text`: The name of the texture that is displayed.
  1182. * `alignment`: The alignment of the image.
  1183. * `world_pos`: World position of the waypoint.
  1184. * `offset`: offset in pixels from position.
  1185. ### `compass`
  1186. Displays an image oriented or translated according to current heading direction.
  1187. * `size`: The size of this element. Negative values represent percentage
  1188. of the screen; e.g. `x=-100` means 100% (width).
  1189. * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
  1190. * `text`: The name of the texture to use.
  1191. * `alignment`: The alignment of the image.
  1192. * `offset`: Offset in pixels from position.
  1193. * `direction`: How the image is rotated/translated:
  1194. * 0 - Rotate as heading direction
  1195. * 1 - Rotate in reverse direction
  1196. * 2 - Translate as landscape direction
  1197. * 3 - Translate in reverse direction
  1198. If translation is chosen, texture is repeated horizontally to fill the whole element.
  1199. ### `minimap`
  1200. Displays a minimap on the HUD.
  1201. * `size`: Size of the minimap to display. Minimap should be a square to avoid
  1202. distortion.
  1203. * `alignment`: The alignment of the minimap.
  1204. * `offset`: offset in pixels from position.
  1205. Representations of simple things
  1206. ================================
  1207. Vector (ie. a position)
  1208. -----------------------
  1209. vector.new(x, y, z)
  1210. See [Spatial Vectors] for details.
  1211. `pointed_thing`
  1212. ---------------
  1213. * `{type="nothing"}`
  1214. * `{type="node", under=pos, above=pos}`
  1215. * Indicates a pointed node selection box.
  1216. * `under` refers to the node position behind the pointed face.
  1217. * `above` refers to the node position in front of the pointed face.
  1218. * `{type="object", ref=ObjectRef}`
  1219. Exact pointing location (currently only `Raycast` supports these fields):
  1220. * `pointed_thing.intersection_point`: The absolute world coordinates of the
  1221. point on the selection box which is pointed at. May be in the selection box
  1222. if the pointer is in the box too.
  1223. * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
  1224. from 1).
  1225. * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
  1226. selected selection box. This specifies which face is pointed at.
  1227. Is a null vector `vector.zero()` when the pointer is inside the selection box.
  1228. For entities with rotated selection boxes, this will be rotated properly
  1229. by the entity's rotation - it will always be in absolute world space.
  1230. Flag Specifier Format
  1231. =====================
  1232. Flags using the standardized flag specifier format can be specified in either
  1233. of two ways, by string or table.
  1234. The string format is a comma-delimited set of flag names; whitespace and
  1235. unrecognized flag fields are ignored. Specifying a flag in the string sets the
  1236. flag, and specifying a flag prefixed by the string `"no"` explicitly
  1237. clears the flag from whatever the default may be.
  1238. In addition to the standard string flag format, the schematic flags field can
  1239. also be a table of flag names to boolean values representing whether or not the
  1240. flag is set. Additionally, if a field with the flag name prefixed with `"no"`
  1241. is present, mapped to a boolean of any value, the specified flag is unset.
  1242. E.g. A flag field of value
  1243. {place_center_x = true, place_center_y=false, place_center_z=true}
  1244. is equivalent to
  1245. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  1246. which is equivalent to
  1247. "place_center_x, noplace_center_y, place_center_z"
  1248. or even
  1249. "place_center_x, place_center_z"
  1250. since, by default, no schematic attributes are set.
  1251. Items
  1252. =====
  1253. Items are things that can be held by players, dropped in the map and
  1254. stored in inventories.
  1255. Items come in the form of item stacks, which are collections of equal
  1256. items that occupy a single inventory slot.
  1257. Item types
  1258. ----------
  1259. There are three kinds of items: nodes, tools and craftitems.
  1260. * Node: Placeable item form of a node in the world's voxel grid
  1261. * Tool: Has a changeable wear property but cannot be stacked
  1262. * Craftitem: Has no special properties
  1263. Every registered node (the voxel in the world) has a corresponding
  1264. item form (the thing in your inventory) that comes along with it.
  1265. This item form can be placed which will create a node in the
  1266. world (by default).
  1267. Both the 'actual' node and its item form share the same identifier.
  1268. For all practical purposes, you can treat the node and its item form
  1269. interchangeably. We usually just say 'node' to the item form of
  1270. the node as well.
  1271. Note the definition of tools is purely technical. The only really
  1272. unique thing about tools is their wear, and that's basically it.
  1273. Beyond that, you can't make any gameplay-relevant assumptions
  1274. about tools or non-tools. It is perfectly valid to register something
  1275. that acts as tool in a gameplay sense as a craftitem, and vice-versa.
  1276. Craftitems can be used for items that neither need to be a node
  1277. nor a tool.
  1278. Amount and wear
  1279. ---------------
  1280. All item stacks have an amount between 0 and 65535. It is 1 by
  1281. default. Tool item stacks cannot have an amount greater than 1.
  1282. Tools use a wear (damage) value ranging from 0 to 65535. The
  1283. value 0 is the default and is used for unworn tools. The values
  1284. 1 to 65535 are used for worn tools, where a higher value stands for
  1285. a higher wear. Non-tools technically also have a wear property,
  1286. but it is always 0. There is also a special 'toolrepair' crafting
  1287. recipe that is only available to tools.
  1288. Item formats
  1289. ------------
  1290. Items and item stacks can exist in three formats: Serializes, table format
  1291. and `ItemStack`.
  1292. When an item must be passed to a function, it can usually be in any of
  1293. these formats.
  1294. ### Serialized
  1295. This is called "stackstring" or "itemstring". It is a simple string with
  1296. 1-4 components:
  1297. 1. Full item identifier ("item name")
  1298. 2. Optional amount
  1299. 3. Optional wear value
  1300. 4. Optional item metadata
  1301. Syntax:
  1302. <identifier> [<amount>[ <wear>[ <metadata>]]]
  1303. Examples:
  1304. * `"default:apple"`: 1 apple
  1305. * `"default:dirt 5"`: 5 dirt
  1306. * `"default:pick_stone"`: a new stone pickaxe
  1307. * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
  1308. * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
  1309. * a wooden pickaxe from the `default` mod,
  1310. * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
  1311. * with the `description` field set to `"My worn out pick"` in its metadata
  1312. * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
  1313. * analogous to the above example
  1314. * note how the wear is set to `0` as dirt is not a tool
  1315. You should ideally use the `ItemStack` format to build complex item strings
  1316. (especially if they use item metadata)
  1317. without relying on the serialization format. Example:
  1318. local stack = ItemStack("default:pick_wood")
  1319. stack:set_wear(21323)
  1320. stack:get_meta():set_string("description", "My worn out pick")
  1321. local itemstring = stack:to_string()
  1322. Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
  1323. and `minetest.itemstring_with_color(item, colorstring)` may be used to create
  1324. item strings encoding color information in their metadata.
  1325. ### Table format
  1326. Examples:
  1327. 5 dirt nodes:
  1328. {name="default:dirt", count=5, wear=0, metadata=""}
  1329. A wooden pick about 1/3 worn out:
  1330. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  1331. An apple:
  1332. {name="default:apple", count=1, wear=0, metadata=""}
  1333. ### `ItemStack`
  1334. A native C++ format with many helper methods. Useful for converting
  1335. between formats. See the [Class reference] section for details.
  1336. Groups
  1337. ======
  1338. In a number of places, there is a group table. Groups define the
  1339. properties of a thing (item, node, armor of entity, tool capabilities)
  1340. in such a way that the engine and other mods can can interact with
  1341. the thing without actually knowing what the thing is.
  1342. Usage
  1343. -----
  1344. Groups are stored in a table, having the group names with keys and the
  1345. group ratings as values. Group ratings are integer values within the
  1346. range [-32767, 32767]. For example:
  1347. -- Default dirt
  1348. groups = {crumbly=3, soil=1}
  1349. -- A more special dirt-kind of thing
  1350. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  1351. Groups always have a rating associated with them. If there is no
  1352. useful meaning for a rating for an enabled group, it shall be `1`.
  1353. When not defined, the rating of a group defaults to `0`. Thus when you
  1354. read groups, you must interpret `nil` and `0` as the same value, `0`.
  1355. You can read the rating of a group for an item or a node by using
  1356. minetest.get_item_group(itemname, groupname)
  1357. Groups of items
  1358. ---------------
  1359. Groups of items can define what kind of an item it is (e.g. wool).
  1360. Groups of nodes
  1361. ---------------
  1362. In addition to the general item things, groups are used to define whether
  1363. a node is destroyable and how long it takes to destroy by a tool.
  1364. Groups of entities
  1365. ------------------
  1366. For entities, groups are, as of now, used only for calculating damage.
  1367. The rating is the percentage of damage caused by items with this damage group.
  1368. See [Entity damage mechanism].
  1369. object:get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
  1370. object:set_armor_groups({fleshy=30, cracky=80})
  1371. Groups of tool capabilities
  1372. ---------------------------
  1373. Groups in tool capabilities define which groups of nodes and entities they
  1374. are effective towards.
  1375. Groups in crafting recipes
  1376. --------------------------
  1377. In crafting recipes, you can specify a group as an input item.
  1378. This means that any item in that group will be accepted as input.
  1379. The basic syntax is:
  1380. "group:<group_name>"
  1381. For example, `"group:meat"` will accept any item in the `meat` group.
  1382. It is also possible to require an input item to be in
  1383. multiple groups at once. The syntax for that is:
  1384. "group:<group_name_1>,<group_name_2>,(...),<group_name_n>"
  1385. For example, `"group:leaves,birch,trimmed"` accepts any item which is member
  1386. of *all* the groups `leaves` *and* `birch` *and* `trimmed`.
  1387. An example recipe: Craft a raw meat soup from any meat, any water and any bowl:
  1388. {
  1389. output = "food:meat_soup_raw",
  1390. recipe = {
  1391. {"group:meat"},
  1392. {"group:water"},
  1393. {"group:bowl"},
  1394. },
  1395. }
  1396. Another example: Craft red wool from white wool and red dye
  1397. (here, "red dye" is defined as any item which is member of
  1398. *both* the groups `dye` and `basecolor_red`).
  1399. {
  1400. type = "shapeless",
  1401. output = "wool:red",
  1402. recipe = {"wool:white", "group:dye,basecolor_red"},
  1403. }
  1404. Special groups
  1405. --------------
  1406. The asterisk `(*)` after a group name describes that there is no engine
  1407. functionality bound to it, and implementation is left up as a suggestion
  1408. to games.
  1409. ### Node and item groups
  1410. * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
  1411. that the item should be hidden in item lists.
  1412. ### Node-only groups
  1413. * `attached_node`: if the node under it is not a walkable block the node will be
  1414. dropped as an item. If the node is wallmounted the wallmounted direction is
  1415. checked.
  1416. * `bouncy`: value is bounce speed in percent.
  1417. If positive, jump/sneak on floor impact will increase/decrease bounce height.
  1418. Negative value is the same bounciness, but non-controllable.
  1419. * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
  1420. connect to each other
  1421. * `dig_immediate`: Player can always pick up node without reducing tool wear
  1422. * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
  1423. * `3`: the node always gets the digging time 0 seconds (torch)
  1424. * `disable_jump`: Player (and possibly other things) cannot jump from node
  1425. or if their feet are in the node. Note: not supported for `new_move = false`
  1426. * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
  1427. the top of this node. There's also an armor group with the same name.
  1428. The final player damage is determined by the following formula:
  1429. damage =
  1430. collision speed
  1431. * ((node_fall_damage_add_percent + 100) / 100) -- node group
  1432. * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
  1433. - (14) -- constant tolerance
  1434. Negative damage values are discarded as no damage.
  1435. * `falling_node`: if there is no walkable block under the node it will fall
  1436. * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
  1437. * `level`: Can be used to give an additional sense of progression in the game.
  1438. * A larger level will cause e.g. a weapon of a lower level make much less
  1439. damage, and get worn out much faster, or not be able to get drops
  1440. from destroyed nodes.
  1441. * `0` is something that is directly accessible at the start of gameplay
  1442. * There is no upper limit
  1443. * See also: `leveldiff` in [Tool Capabilities]
  1444. * `slippery`: Players and items will slide on the node.
  1445. Slipperiness rises steadily with `slippery` value, starting at 1.
  1446. ### Tool-only groups
  1447. * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
  1448. `"toolrepair"` crafting recipe
  1449. ### `ObjectRef` armor groups
  1450. * `immortal`: Skips all damage and breath handling for an object. This group
  1451. will also hide the integrated HUD status bars for players. It is
  1452. automatically set to all players when damage is disabled on the server and
  1453. cannot be reset (subject to change).
  1454. * `fall_damage_add_percent`: Modifies the fall damage suffered by players
  1455. when they hit the ground. It is analog to the node group with the same
  1456. name. See the node group above for the exact calculation.
  1457. * `punch_operable`: For entities; disables the regular damage mechanism for
  1458. players punching it by hand or a non-tool item, so that it can do something
  1459. else than take damage.
  1460. Known damage and digging time defining groups
  1461. ---------------------------------------------
  1462. * `crumbly`: dirt, sand
  1463. * `cracky`: tough but crackable stuff like stone.
  1464. * `snappy`: something that can be cut using things like scissors, shears,
  1465. bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
  1466. * `choppy`: something that can be cut using force; e.g. trees, wooden planks
  1467. * `fleshy`: Living things like animals and the player. This could imply
  1468. some blood effects when hitting.
  1469. * `explody`: Especially prone to explosions
  1470. * `oddly_breakable_by_hand`:
  1471. Can be added to nodes that shouldn't logically be breakable by the
  1472. hand but are. Somewhat similar to `dig_immediate`, but times are more
  1473. like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
  1474. digging speed of an item if it can dig at a faster speed than this
  1475. suggests for the hand.
  1476. Examples of custom groups
  1477. -------------------------
  1478. Item groups are often used for defining, well, _groups of items_.
  1479. * `meat`: any meat-kind of a thing (rating might define the size or healing
  1480. ability or be irrelevant -- it is not defined as of yet)
  1481. * `eatable`: anything that can be eaten. Rating might define HP gain in half
  1482. hearts.
  1483. * `flammable`: can be set on fire. Rating might define the intensity of the
  1484. fire, affecting e.g. the speed of the spreading of an open fire.
  1485. * `wool`: any wool (any origin, any color)
  1486. * `metal`: any metal
  1487. * `weapon`: any weapon
  1488. * `heavy`: anything considerably heavy
  1489. Digging time calculation specifics
  1490. ----------------------------------
  1491. Groups such as `crumbly`, `cracky` and `snappy` are used for this
  1492. purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
  1493. faster digging time.
  1494. The `level` group is used to limit the toughness of nodes an item capable
  1495. of digging can dig and to scale the digging times / damage to a greater extent.
  1496. **Please do understand this**, otherwise you cannot use the system to it's
  1497. full potential.
  1498. Items define their properties by a list of parameters for groups. They
  1499. cannot dig other groups; thus it is important to use a standard bunch of
  1500. groups to enable interaction with items.
  1501. Tool Capabilities
  1502. =================
  1503. 'Tool capabilities' is a property of items that defines two things:
  1504. 1) Which nodes it can dig and how fast
  1505. 2) Which objects it can hurt by punching and by how much
  1506. Tool capabilities are available for all items, not just tools.
  1507. But only tools can receive wear from digging and punching.
  1508. Missing or incomplete tool capabilities will default to the
  1509. player's hand.
  1510. Tool capabilities definition
  1511. ----------------------------
  1512. Tool capabilities define:
  1513. * Full punch interval
  1514. * Maximum drop level
  1515. * For an arbitrary list of node groups:
  1516. * Uses (until the tool breaks)
  1517. * Maximum level (usually `0`, `1`, `2` or `3`)
  1518. * Digging times
  1519. * Damage groups
  1520. * Punch attack uses (until the tool breaks)
  1521. ### Full punch interval `full_punch_interval`
  1522. When used as a weapon, the item will do full damage if this time is spent
  1523. between punches. If e.g. half the time is spent, the item will do half
  1524. damage.
  1525. ### Maximum drop level `max_drop_level`
  1526. Suggests the maximum level of node, when dug with the item, that will drop
  1527. its useful item. (e.g. iron ore to drop a lump of iron).
  1528. This value is not used in the engine; it is the responsibility of the game/mod
  1529. code to implement this.
  1530. ### Uses `uses` (tools only)
  1531. Determines how many uses the tool has when it is used for digging a node,
  1532. of this group, of the maximum level. The maximum supported number of
  1533. uses is 65535. The special number 0 is used for infinite uses.
  1534. For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
  1535. `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
  1536. node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
  1537. * `uses=10, leveldiff=0`: actual uses: 10
  1538. * `uses=10, leveldiff=1`: actual uses: 30
  1539. * `uses=10, leveldiff=2`: actual uses: 90
  1540. For non-tools, this has no effect.
  1541. ### Maximum level `maxlevel`
  1542. Tells what is the maximum level of a node of this group that the item will
  1543. be able to dig.
  1544. ### Digging times `times`
  1545. List of digging times for different ratings of the group, for nodes of the
  1546. maximum level.
  1547. For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
  1548. result in the item to be able to dig nodes that have a rating of `2` or `3`
  1549. for this group, and unable to dig the rating `1`, which is the toughest.
  1550. Unless there is a matching group that enables digging otherwise.
  1551. If the result digging time is 0, a delay of 0.15 seconds is added between
  1552. digging nodes; If the player releases LMB after digging, this delay is set to 0,
  1553. i.e. players can more quickly click the nodes away instead of holding LMB.
  1554. ### Damage groups
  1555. List of damage for groups of entities. See [Entity damage mechanism].
  1556. ### Punch attack uses (tools only)
  1557. Determines how many uses (before breaking) the tool has when dealing damage
  1558. to an object, when the full punch interval (see above) was always
  1559. waited out fully.
  1560. Wear received by the tool is proportional to the time spent, scaled by
  1561. the full punch interval.
  1562. For non-tools, this has no effect.
  1563. Example definition of the capabilities of an item
  1564. -------------------------------------------------
  1565. tool_capabilities = {
  1566. groupcaps={
  1567. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  1568. },
  1569. }
  1570. This makes the item capable of digging nodes that fulfill both of these:
  1571. * Have the `crumbly` group
  1572. * Have a `level` group less or equal to `2`
  1573. Table of resulting digging times:
  1574. crumbly 0 1 2 3 4 <- level
  1575. -> 0 - - - - -
  1576. 1 0.80 1.60 1.60 - -
  1577. 2 0.60 1.20 1.20 - -
  1578. 3 0.40 0.80 0.80 - -
  1579. level diff: 2 1 0 -1 -2
  1580. Table of resulting tool uses:
  1581. -> 0 - - - - -
  1582. 1 180 60 20 - -
  1583. 2 180 60 20 - -
  1584. 3 180 60 20 - -
  1585. **Notes**:
  1586. * At `crumbly==0`, the node is not diggable.
  1587. * At `crumbly==3`, the level difference digging time divider kicks in and makes
  1588. easy nodes to be quickly breakable.
  1589. * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
  1590. Entity damage mechanism
  1591. =======================
  1592. Damage calculation:
  1593. damage = 0
  1594. foreach group in cap.damage_groups:
  1595. damage += cap.damage_groups[group]
  1596. * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
  1597. * (object.armor_groups[group] / 100.0)
  1598. -- Where object.armor_groups[group] is 0 for inexistent values
  1599. return damage
  1600. Client predicts damage based on damage groups. Because of this, it is able to
  1601. give an immediate response when an entity is damaged or dies; the response is
  1602. pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
  1603. TODO).
  1604. Currently a smoke puff will appear when an entity dies.
  1605. The group `immortal` completely disables normal damage.
  1606. Entities can define a special armor group, which is `punch_operable`. This
  1607. group disables the regular damage mechanism for players punching it by hand or
  1608. a non-tool item, so that it can do something else than take damage.
  1609. On the Lua side, every punch calls:
  1610. entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
  1611. damage)
  1612. This should never be called directly, because damage is usually not handled by
  1613. the entity itself.
  1614. * `puncher` is the object performing the punch. Can be `nil`. Should never be
  1615. accessed unless absolutely required, to encourage interoperability.
  1616. * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
  1617. * `tool_capabilities` can be `nil`.
  1618. * `direction` is a unit vector, pointing from the source of the punch to
  1619. the punched object.
  1620. * `damage` damage that will be done to entity
  1621. Return value of this function will determine if damage is done by this function
  1622. (retval true) or shall be done by engine (retval false)
  1623. To punch an entity/object in Lua, call:
  1624. object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1625. * Return value is tool wear.
  1626. * Parameters are equal to the above callback.
  1627. * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
  1628. will be automatically filled in based on the location of `puncher`.
  1629. Metadata
  1630. ========
  1631. Node Metadata
  1632. -------------
  1633. The instance of a node in the world normally only contains the three values
  1634. mentioned in [Nodes]. However, it is possible to insert extra data into a node.
  1635. It is called "node metadata"; See `NodeMetaRef`.
  1636. Node metadata contains two things:
  1637. * A key-value store
  1638. * An inventory
  1639. Some of the values in the key-value store are handled specially:
  1640. * `formspec`: Defines an inventory menu that is opened with the
  1641. 'place/use' key. Only works if no `on_rightclick` was
  1642. defined for the node. See also [Formspec].
  1643. * `infotext`: Text shown on the screen when the node is pointed at.
  1644. Line-breaks will be applied automatically.
  1645. If the infotext is very long, it will be truncated.
  1646. Example:
  1647. local meta = minetest.get_meta(pos)
  1648. meta:set_string("formspec",
  1649. "size[8,9]"..
  1650. "list[context;main;0,0;8,4;]"..
  1651. "list[current_player;main;0,5;8,4;]")
  1652. meta:set_string("infotext", "Chest");
  1653. local inv = meta:get_inventory()
  1654. inv:set_size("main", 8*4)
  1655. print(dump(meta:to_table()))
  1656. meta:from_table({
  1657. inventory = {
  1658. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
  1659. [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
  1660. [10] = "", [11] = "", [12] = "", [13] = "",
  1661. [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
  1662. [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
  1663. [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
  1664. [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
  1665. [32] = ""}
  1666. },
  1667. fields = {
  1668. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  1669. infotext = "Chest"
  1670. }
  1671. })
  1672. Item Metadata
  1673. -------------
  1674. Item stacks can store metadata too. See [`ItemStackMetaRef`].
  1675. Item metadata only contains a key-value store.
  1676. Some of the values in the key-value store are handled specially:
  1677. * `description`: Set the item stack's description.
  1678. See also: `get_description` in [`ItemStack`]
  1679. * `short_description`: Set the item stack's short description.
  1680. See also: `get_short_description` in [`ItemStack`]
  1681. * `color`: A `ColorString`, which sets the stack's color.
  1682. * `palette_index`: If the item has a palette, this is used to get the
  1683. current color from the palette.
  1684. * `count_meta`: Replace the displayed count with any string.
  1685. * `count_alignment`: Set the alignment of the displayed count value. This is an
  1686. int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
  1687. 4th bit specify the alignment in y-direction:
  1688. 0 = default, 1 = left / up, 2 = middle, 3 = right / down
  1689. The default currently is the same as right/down.
  1690. Example: 6 = 2 + 1*4 = middle,up
  1691. Example:
  1692. local meta = stack:get_meta()
  1693. meta:set_string("key", "value")
  1694. print(dump(meta:to_table()))
  1695. Example manipulations of "description" and expected output behaviors:
  1696. print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
  1697. print(ItemStack("foobar"):get_description()) --> Unknown Item
  1698. local stack = ItemStack("default:stone")
  1699. stack:get_meta():set_string("description", "Custom description\nAnother line")
  1700. print(stack:get_description()) --> Custom description\nAnother line
  1701. print(stack:get_short_description()) --> Custom description
  1702. stack:get_meta():set_string("short_description", "Short")
  1703. print(stack:get_description()) --> Custom description\nAnother line
  1704. print(stack:get_short_description()) --> Short
  1705. print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
  1706. Formspec
  1707. ========
  1708. Formspec defines a menu. This supports inventories and some of the
  1709. typical widgets like buttons, checkboxes, text input fields, etc.
  1710. It is a string, with a somewhat strange format.
  1711. A formspec is made out of formspec elements, which includes widgets
  1712. like buttons but also can be used to set stuff like background color.
  1713. Many formspec elements have a `name`, which is a unique identifier which
  1714. is used when the server receives user input. You must not use the name
  1715. "quit" for formspec elements.
  1716. Spaces and newlines can be inserted between the blocks, as is used in the
  1717. examples.
  1718. Position and size units are inventory slots unless the new coordinate system
  1719. is enabled. `X` and `Y` position the formspec element relative to the top left
  1720. of the menu or container. `W` and `H` are its width and height values.
  1721. If the new system is enabled, all elements have unified coordinates for all
  1722. elements with no padding or spacing in between. This is highly recommended
  1723. for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
  1724. Coordinates`.
  1725. Inventories with a `player:<name>` inventory location are only sent to the
  1726. player named `<name>`.
  1727. When displaying text which can contain formspec code, e.g. text set by a player,
  1728. use `minetest.formspec_escape`.
  1729. For colored text you can use `minetest.colorize`.
  1730. Since formspec version 3, elements drawn in the order they are defined. All
  1731. background elements are drawn before all other elements.
  1732. **WARNING**: do _not_ use an element name starting with `key_`; those names are
  1733. reserved to pass key press events to formspec!
  1734. **WARNING**: Minetest allows you to add elements to every single formspec instance
  1735. using `player:set_formspec_prepend()`, which may be the reason backgrounds are
  1736. appearing when you don't expect them to, or why things are styled differently
  1737. to normal. See [`no_prepend[]`] and [Styling Formspecs].
  1738. Examples
  1739. --------
  1740. ### Chest
  1741. size[8,9]
  1742. list[context;main;0,0;8,4;]
  1743. list[current_player;main;0,5;8,4;]
  1744. ### Furnace
  1745. size[8,9]
  1746. list[context;fuel;2,3;1,1;]
  1747. list[context;src;2,1;1,1;]
  1748. list[context;dst;5,1;2,2;]
  1749. list[current_player;main;0,5;8,4;]
  1750. ### Minecraft-like player inventory
  1751. size[8,7.5]
  1752. image[1,0.6;1,2;player.png]
  1753. list[current_player;main;0,3.5;8,4;]
  1754. list[current_player;craft;3,0;3,3;]
  1755. list[current_player;craftpreview;7,1;1,1;]
  1756. Version History
  1757. ---------------
  1758. * Formspec version 1 (pre-5.1.0):
  1759. * (too much)
  1760. * Formspec version 2 (5.1.0):
  1761. * Forced real coordinates
  1762. * background9[]: 9-slice scaling parameters
  1763. * Formspec version 3 (5.2.0):
  1764. * Formspec elements are drawn in the order of definition
  1765. * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
  1766. * box[] and image[] elements enable clipping by default
  1767. * new element: scroll_container[]
  1768. * Formspec version 4 (5.4.0):
  1769. * Allow dropdown indexing events
  1770. * Formspec version 5 (5.5.0):
  1771. * Added padding[] element
  1772. * Formspec version 6 (5.6.0):
  1773. * Add nine-slice images, animated_image, and fgimg_middle
  1774. Elements
  1775. --------
  1776. ### `formspec_version[<version>]`
  1777. * Set the formspec version to a certain number. If not specified,
  1778. version 1 is assumed.
  1779. * Must be specified before `size` element.
  1780. * Clients older than this version can neither show newer elements nor display
  1781. elements with new arguments correctly.
  1782. * Available since feature `formspec_version_element`.
  1783. * See also: [Version History]
  1784. ### `size[<W>,<H>,<fixed_size>]`
  1785. * Define the size of the menu in inventory slots
  1786. * `fixed_size`: `true`/`false` (optional)
  1787. * deprecated: `invsize[<W>,<H>;]`
  1788. ### `position[<X>,<Y>]`
  1789. * Must be used after `size` element.
  1790. * Defines the position on the game window of the formspec's `anchor` point.
  1791. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
  1792. for example:
  1793. * [0.0, 0.0] sets the position to the top left corner of the game window.
  1794. * [1.0, 1.0] sets the position to the bottom right of the game window.
  1795. * Defaults to the center of the game window [0.5, 0.5].
  1796. ### `anchor[<X>,<Y>]`
  1797. * Must be used after both `size` and `position` (if present) elements.
  1798. * Defines the location of the anchor point within the formspec.
  1799. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
  1800. for example:
  1801. * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
  1802. * [1.0, 0.0] sets the anchor to the top right of the formspec.
  1803. * Defaults to the center of the formspec [0.5, 0.5].
  1804. * `position` and `anchor` elements need suitable values to avoid a formspec
  1805. extending off the game window due to particular game window sizes.
  1806. ### `padding[<X>,<Y>]`
  1807. * Must be used after the `size`, `position`, and `anchor` elements (if present).
  1808. * Defines how much space is padded around the formspec if the formspec tries to
  1809. increase past the size of the screen and coordinates have to be shrunk.
  1810. * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
  1811. screen), and 0.5 represents half the screen (which forces the coordinate size
  1812. to 0). If negative, the formspec can extend off the edge of the screen.
  1813. * Defaults to [0.05, 0.05].
  1814. ### `no_prepend[]`
  1815. * Must be used after the `size`, `position`, `anchor`, and `padding` elements
  1816. (if present).
  1817. * Disables player:set_formspec_prepend() from applying to this formspec.
  1818. ### `real_coordinates[<bool>]`
  1819. * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
  1820. * When set to true, all following formspec elements will use the new coordinate system.
  1821. * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
  1822. (if present), the form size will use the new coordinate system.
  1823. * **Note**: Formspec prepends are not affected by the coordinates in the main form.
  1824. They must enable it explicitly.
  1825. * For information on converting forms to the new coordinate system, see `Migrating
  1826. to Real Coordinates`.
  1827. ### `container[<X>,<Y>]`
  1828. * Start of a container block, moves all physical elements in the container by
  1829. (X, Y).
  1830. * Must have matching `container_end`
  1831. * Containers can be nested, in which case the offsets are added
  1832. (child containers are relative to parent containers)
  1833. ### `container_end[]`
  1834. * End of a container, following elements are no longer relative to this
  1835. container.
  1836. ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
  1837. * Start of a scroll_container block. All contained elements will ...
  1838. * take the scroll_container coordinate as position origin,
  1839. * be additionally moved by the current value of the scrollbar with the name
  1840. `scrollbar name` times `scroll factor` along the orientation `orientation` and
  1841. * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
  1842. * `orientation`: possible values are `vertical` and `horizontal`.
  1843. * `scroll factor`: optional, defaults to `0.1`.
  1844. * Nesting is possible.
  1845. * Some elements might work a little different if they are in a scroll_container.
  1846. * Note: If you want the scroll_container to actually work, you also need to add a
  1847. scrollbar element with the specified name. Furthermore, it is highly recommended
  1848. to use a scrollbaroptions element on this scrollbar.
  1849. ### `scroll_container_end[]`
  1850. * End of a scroll_container, following elements are no longer bound to this
  1851. container.
  1852. ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
  1853. * Show an inventory list if it has been sent to the client.
  1854. * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
  1855. are moved) while the formspec is open, the formspec element may (but is not guaranteed
  1856. to) adapt to the new inventory list.
  1857. * Item slots are drawn in a grid from left to right, then up to down, ordered
  1858. according to the slot index.
  1859. * `W` and `H` are in inventory slots, not in coordinates.
  1860. * `starting item index` (Optional): The index of the first (upper-left) item to draw.
  1861. Indices start at `0`. Default is `0`.
  1862. * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
  1863. `starting item index`.
  1864. * **Note**: With the new coordinate system, the spacing between inventory
  1865. slots is one-fourth the size of an inventory slot by default. Also see
  1866. [Styling Formspecs] for changing the size of slots and spacing.
  1867. ### `listring[<inventory location>;<list name>]`
  1868. * Appends to an internal ring of inventory lists.
  1869. * Shift-clicking on items in one element of the ring
  1870. will send them to the next inventory list inside the ring
  1871. * The first occurrence of an element inside the ring will
  1872. determine the inventory where items will be sent to
  1873. ### `listring[]`
  1874. * Shorthand for doing `listring[<inventory location>;<list name>]`
  1875. for the last two inventory lists added by list[...]
  1876. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
  1877. * Sets background color of slots as `ColorString`
  1878. * Sets background color of slots on mouse hovering
  1879. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
  1880. * Sets background color of slots as `ColorString`
  1881. * Sets background color of slots on mouse hovering
  1882. * Sets color of slots border
  1883. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
  1884. * Sets background color of slots as `ColorString`
  1885. * Sets background color of slots on mouse hovering
  1886. * Sets color of slots border
  1887. * Sets default background color of tooltips
  1888. * Sets default font color of tooltips
  1889. ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1890. * Adds tooltip for an element
  1891. * `bgcolor` tooltip background color as `ColorString` (optional)
  1892. * `fontcolor` tooltip font color as `ColorString` (optional)
  1893. ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1894. * Adds tooltip for an area. Other tooltips will take priority when present.
  1895. * `bgcolor` tooltip background color as `ColorString` (optional)
  1896. * `fontcolor` tooltip font color as `ColorString` (optional)
  1897. ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
  1898. * Show an image.
  1899. * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
  1900. * Requires formspec version >= 6.
  1901. * See `background9[]` documentation for more information.
  1902. ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
  1903. * Show an animated image. The image is drawn like a "vertical_frames" tile
  1904. animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
  1905. * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
  1906. * `texture name`: The image to use.
  1907. * `frame count`: The number of frames animating the image.
  1908. * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
  1909. * `frame start` (optional): The index of the frame to start on. Default `1`.
  1910. * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
  1911. * Requires formspec version >= 6.
  1912. * See `background9[]` documentation for more information.
  1913. ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
  1914. * Show a mesh model.
  1915. * `name`: Element name that can be used for styling
  1916. * `mesh`: The mesh model to use.
  1917. * `textures`: The mesh textures to use according to the mesh materials.
  1918. Texture names must be separated by commas.
  1919. * `rotation {X,Y}` (Optional): Initial rotation of the camera.
  1920. The axes are euler angles in degrees.
  1921. * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
  1922. * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
  1923. * `frame loop range` (Optional): Range of the animation frames.
  1924. * Defaults to the full range of all available frames.
  1925. * Syntax: `<begin>,<end>`
  1926. * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
  1927. ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
  1928. * Show an inventory image of registered item/node
  1929. ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
  1930. * Sets background color of formspec.
  1931. * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
  1932. of the non-fullscreen and the fullscreen background.
  1933. * `fullscreen` (optional) can be one of the following:
  1934. * `false`: Only the non-fullscreen background color is drawn. (default)
  1935. * `true`: Only the fullscreen background color is drawn.
  1936. * `both`: The non-fullscreen and the fullscreen background color are drawn.
  1937. * `neither`: No background color is drawn.
  1938. * Note: Leave a parameter empty to not modify the value.
  1939. * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
  1940. are not bools are only available since formspec version 3.
  1941. ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
  1942. * Example for formspec 8x4 in 16x resolution: image shall be sized
  1943. 8 times 16px times 4 times 16px.
  1944. ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
  1945. * Example for formspec 8x4 in 16x resolution:
  1946. image shall be sized 8 times 16px times 4 times 16px
  1947. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1948. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1949. ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
  1950. * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
  1951. * Middle is a rect which defines the middle of the 9-slice.
  1952. * `x` - The middle will be x pixels from all sides.
  1953. * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
  1954. * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
  1955. will be added to the width and height of the texture, allowing it to be used as the
  1956. distance from the far end.
  1957. * All numbers in middle are integers.
  1958. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1959. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1960. * Available since formspec version 2
  1961. ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1962. * Textual password style field; will be sent to server when a button is clicked
  1963. * When enter is pressed in field, fields.key_enter_field will be sent with the
  1964. name of this field.
  1965. * With the old coordinate system, fields are a set height, but will be vertically
  1966. centered on `H`. With the new coordinate system, `H` will modify the height.
  1967. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1968. * `label`, if not blank, will be text printed on the top left above the field
  1969. * See `field_close_on_enter` to stop enter closing the formspec
  1970. ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1971. * Textual field; will be sent to server when a button is clicked
  1972. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1973. the name of this field.
  1974. * With the old coordinate system, fields are a set height, but will be vertically
  1975. centered on `H`. With the new coordinate system, `H` will modify the height.
  1976. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1977. * `label`, if not blank, will be text printed on the top left above the field
  1978. * `default` is the default value of the field
  1979. * `default` may contain variable references such as `${text}` which
  1980. will fill the value from the metadata value `text`
  1981. * **Note**: no extra text or more than a single variable is supported ATM.
  1982. * See `field_close_on_enter` to stop enter closing the formspec
  1983. ### `field[<name>;<label>;<default>]`
  1984. * As above, but without position/size units
  1985. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1986. the name of this field.
  1987. * Special field for creating simple forms, such as sign text input
  1988. * Must be used without a `size[]` element
  1989. * A "Proceed" button will be added automatically
  1990. * See `field_close_on_enter` to stop enter closing the formspec
  1991. ### `field_close_on_enter[<name>;<close_on_enter>]`
  1992. * <name> is the name of the field
  1993. * if <close_on_enter> is false, pressing enter in the field will submit the
  1994. form but not close it.
  1995. * defaults to true when not specified (ie: no tag for a field)
  1996. ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1997. * Same as fields above, but with multi-line input
  1998. * If the text overflows, a vertical scrollbar is added.
  1999. * If the name is empty, the textarea is read-only and
  2000. the background is not shown, which corresponds to a multi-line label.
  2001. ### `label[<X>,<Y>;<label>]`
  2002. * The label formspec element displays the text set in `label`
  2003. at the specified position.
  2004. * **Note**: If the new coordinate system is enabled, labels are
  2005. positioned from the center of the text, not the top.
  2006. * The text is displayed directly without automatic line breaking,
  2007. so label should not be used for big text chunks. Newlines can be
  2008. used to make labels multiline.
  2009. * **Note**: With the new coordinate system, newlines are spaced with
  2010. half a coordinate. With the old system, newlines are spaced 2/5 of
  2011. an inventory slot.
  2012. ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
  2013. * Displays a static formatted text with hyperlinks.
  2014. * **Note**: This element is currently unstable and subject to change.
  2015. * `x`, `y`, `w` and `h` work as per field
  2016. * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
  2017. * `text` is the formatted text using `Markup Language` described below.
  2018. ### `vertlabel[<X>,<Y>;<label>]`
  2019. * Textual label drawn vertically
  2020. * `label` is the text on the label
  2021. * **Note**: If the new coordinate system is enabled, vertlabels are
  2022. positioned from the center of the text, not the left.
  2023. ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
  2024. * Clickable button. When clicked, fields will be sent.
  2025. * With the old coordinate system, buttons are a set height, but will be vertically
  2026. centered on `H`. With the new coordinate system, `H` will modify the height.
  2027. * `label` is the text on the button
  2028. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  2029. * `texture name` is the filename of an image
  2030. * **Note**: Height is supported on both the old and new coordinate systems
  2031. for image_buttons.
  2032. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
  2033. * `texture name` is the filename of an image
  2034. * `noclip=true` means the image button doesn't need to be within specified
  2035. formsize.
  2036. * `drawborder`: draw button border or not
  2037. * `pressed texture name` is the filename of an image on pressed state
  2038. ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
  2039. * `item name` is the registered name of an item/node
  2040. * The item description will be used as the tooltip. This can be overridden with
  2041. a tooltip element.
  2042. ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
  2043. * When clicked, fields will be sent and the form will quit.
  2044. * Same as `button` in all other respects.
  2045. ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  2046. * When clicked, fields will be sent and the form will quit.
  2047. * Same as `image_button` in all other respects.
  2048. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
  2049. * Scrollable item list showing arbitrary text elements
  2050. * `name` fieldname sent to server on doubleclick value is current selected
  2051. element.
  2052. * `listelements` can be prepended by #color in hexadecimal format RRGGBB
  2053. (only).
  2054. * if you want a listelement to start with "#" write "##".
  2055. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
  2056. * Scrollable itemlist showing arbitrary text elements
  2057. * `name` fieldname sent to server on doubleclick value is current selected
  2058. element.
  2059. * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
  2060. * if you want a listelement to start with "#" write "##"
  2061. * Index to be selected within textlist
  2062. * `true`/`false`: draw transparent background
  2063. * See also `minetest.explode_textlist_event`
  2064. (main menu: `core.explode_textlist_event`).
  2065. ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2066. * Show a tab**header** at specific position (ignores formsize)
  2067. * `X` and `Y`: position of the tabheader
  2068. * *Note*: Width and height are automatically chosen with this syntax
  2069. * `name` fieldname data is transferred to Lua
  2070. * `caption 1`...: name shown on top of tab
  2071. * `current_tab`: index of selected tab 1...
  2072. * `transparent` (optional): if true, tabs are semi-transparent
  2073. * `draw_border` (optional): if true, draw a thin line at tab base
  2074. ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2075. * Show a tab**header** at specific position (ignores formsize)
  2076. * **Important note**: This syntax for tabheaders can only be used with the
  2077. new coordinate system.
  2078. * `X` and `Y`: position of the tabheader
  2079. * `H`: height of the tabheader. Width is automatically determined with this syntax.
  2080. * `name` fieldname data is transferred to Lua
  2081. * `caption 1`...: name shown on top of tab
  2082. * `current_tab`: index of selected tab 1...
  2083. * `transparent` (optional): show transparent
  2084. * `draw_border` (optional): draw border
  2085. ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2086. * Show a tab**header** at specific position (ignores formsize)
  2087. * **Important note**: This syntax for tabheaders can only be used with the
  2088. new coordinate system.
  2089. * `X` and `Y`: position of the tabheader
  2090. * `W` and `H`: width and height of the tabheader
  2091. * `name` fieldname data is transferred to Lua
  2092. * `caption 1`...: name shown on top of tab
  2093. * `current_tab`: index of selected tab 1...
  2094. * `transparent` (optional): show transparent
  2095. * `draw_border` (optional): draw border
  2096. ### `box[<X>,<Y>;<W>,<H>;<color>]`
  2097. * Simple colored box
  2098. * `color` is color specified as a `ColorString`.
  2099. If the alpha component is left blank, the box will be semitransparent.
  2100. If the color is not specified, the box will use the options specified by
  2101. its style. If the color is specified, all styling options will be ignored.
  2102. ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2103. * Show a dropdown field
  2104. * **Important note**: There are two different operation modes:
  2105. 1. handle directly on change (only changed dropdown is submitted)
  2106. 2. read the value on pressing a button (all dropdown values are available)
  2107. * `X` and `Y`: position of the dropdown
  2108. * `W`: width of the dropdown. Height is automatically chosen with this syntax.
  2109. * Fieldname data is transferred to Lua
  2110. * Items to be shown in dropdown
  2111. * Index of currently selected dropdown item
  2112. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2113. event field value for selected items.
  2114. * `true`: Selected item index
  2115. * `false` (default): Selected item value
  2116. ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2117. * Show a dropdown field
  2118. * **Important note**: This syntax for dropdowns can only be used with the
  2119. new coordinate system.
  2120. * **Important note**: There are two different operation modes:
  2121. 1. handle directly on change (only changed dropdown is submitted)
  2122. 2. read the value on pressing a button (all dropdown values are available)
  2123. * `X` and `Y`: position of the dropdown
  2124. * `W` and `H`: width and height of the dropdown
  2125. * Fieldname data is transferred to Lua
  2126. * Items to be shown in dropdown
  2127. * Index of currently selected dropdown item
  2128. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2129. event field value for selected items.
  2130. * `true`: Selected item index
  2131. * `false` (default): Selected item value
  2132. ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
  2133. * Show a checkbox
  2134. * `name` fieldname data is transferred to Lua
  2135. * `label` to be shown left of checkbox
  2136. * `selected` (optional): `true`/`false`
  2137. * **Note**: If the new coordinate system is enabled, checkboxes are
  2138. positioned from the center of the checkbox, not the top.
  2139. ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
  2140. * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
  2141. * There are two ways to use it:
  2142. 1. handle the changed event (only changed scrollbar is available)
  2143. 2. read the value on pressing a button (all scrollbars are available)
  2144. * `orientation`: `vertical`/`horizontal`. Default horizontal.
  2145. * Fieldname data is transferred to Lua
  2146. * Value of this trackbar is set to (`0`-`1000`) by default
  2147. * See also `minetest.explode_scrollbar_event`
  2148. (main menu: `core.explode_scrollbar_event`).
  2149. ### `scrollbaroptions[opt1;opt2;...]`
  2150. * Sets options for all following `scrollbar[]` elements
  2151. * `min=<int>`
  2152. * Sets scrollbar minimum value, defaults to `0`.
  2153. * `max=<int>`
  2154. * Sets scrollbar maximum value, defaults to `1000`.
  2155. If the max is equal to the min, the scrollbar will be disabled.
  2156. * `smallstep=<int>`
  2157. * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
  2158. scrolled.
  2159. * If this is set to a negative number, the value will be reset to `10`.
  2160. * `largestep=<int>`
  2161. * Sets scrollbar step value used by page up and page down.
  2162. * If this is set to a negative number, the value will be reset to `100`.
  2163. * `thumbsize=<int>`
  2164. * Sets size of the thumb on the scrollbar. Size is calculated in the number of
  2165. units the thumb spans out of the range of the scrollbar values.
  2166. * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
  2167. would span a tenth of the scrollbar space.
  2168. * If this is set to zero or less, the value will be reset to `1`.
  2169. * `arrows=<show/hide/default>`
  2170. * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
  2171. when the scrollbar gets too small, but shows them otherwise.
  2172. ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
  2173. * Show scrollable table using options defined by the previous `tableoptions[]`
  2174. * Displays cells as defined by the previous `tablecolumns[]`
  2175. * `name`: fieldname sent to server on row select or doubleclick
  2176. * `cell 1`...`cell n`: cell contents given in row-major order
  2177. * `selected idx`: index of row to be selected within table (first row = `1`)
  2178. * See also `minetest.explode_table_event`
  2179. (main menu: `core.explode_table_event`).
  2180. ### `tableoptions[<opt 1>;<opt 2>;...]`
  2181. * Sets options for `table[]`
  2182. * `color=#RRGGBB`
  2183. * default text color (`ColorString`), defaults to `#FFFFFF`
  2184. * `background=#RRGGBB`
  2185. * table background color (`ColorString`), defaults to `#000000`
  2186. * `border=<true/false>`
  2187. * should the table be drawn with a border? (default: `true`)
  2188. * `highlight=#RRGGBB`
  2189. * highlight background color (`ColorString`), defaults to `#466432`
  2190. * `highlight_text=#RRGGBB`
  2191. * highlight text color (`ColorString`), defaults to `#FFFFFF`
  2192. * `opendepth=<value>`
  2193. * all subtrees up to `depth < value` are open (default value = `0`)
  2194. * only useful when there is a column of type "tree"
  2195. ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
  2196. * Sets columns for `table[]`
  2197. * Types: `text`, `image`, `color`, `indent`, `tree`
  2198. * `text`: show cell contents as text
  2199. * `image`: cell contents are an image index, use column options to define
  2200. images.
  2201. * `color`: cell contents are a ColorString and define color of following
  2202. cell.
  2203. * `indent`: cell contents are a number and define indentation of following
  2204. cell.
  2205. * `tree`: same as indent, but user can open and close subtrees
  2206. (treeview-like).
  2207. * Column options:
  2208. * `align=<value>`
  2209. * for `text` and `image`: content alignment within cells.
  2210. Available values: `left` (default), `center`, `right`, `inline`
  2211. * `width=<value>`
  2212. * for `text` and `image`: minimum width in em (default: `0`)
  2213. * for `indent` and `tree`: indent width in em (default: `1.5`)
  2214. * `padding=<value>`: padding left of the column, in em (default `0.5`).
  2215. Exception: defaults to 0 for indent columns
  2216. * `tooltip=<value>`: tooltip text (default: empty)
  2217. * `image` column options:
  2218. * `0=<value>` sets image for image index 0
  2219. * `1=<value>` sets image for image index 1
  2220. * `2=<value>` sets image for image index 2
  2221. * and so on; defined indices need not be contiguous empty or
  2222. non-numeric cells are treated as `0`.
  2223. * `color` column options:
  2224. * `span=<value>`: number of following columns to affect
  2225. (default: infinite).
  2226. ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2227. * Set the style for the element(s) matching `selector` by name.
  2228. * `selector` can be one of:
  2229. * `<name>` - An element name. Includes `*`, which represents every element.
  2230. * `<name>:<state>` - An element name, a colon, and one or more states.
  2231. * `state` is a list of states separated by the `+` character.
  2232. * If a state is provided, the style will only take effect when the element is in that state.
  2233. * All provided states must be active for the style to apply.
  2234. * Note: this **must** be before the element is defined.
  2235. * See [Styling Formspecs].
  2236. ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2237. * Set the style for the element(s) matching `selector` by type.
  2238. * `selector` can be one of:
  2239. * `<type>` - An element type. Includes `*`, which represents every element.
  2240. * `<type>:<state>` - An element type, a colon, and one or more states.
  2241. * `state` is a list of states separated by the `+` character.
  2242. * If a state is provided, the style will only take effect when the element is in that state.
  2243. * All provided states must be active for the style to apply.
  2244. * See [Styling Formspecs].
  2245. ### `set_focus[<name>;<force>]`
  2246. * Sets the focus to the element with the same `name` parameter.
  2247. * **Note**: This element must be placed before the element it focuses.
  2248. * `force` (optional, default `false`): By default, focus is not applied for
  2249. re-sent formspecs with the same name so that player-set focus is kept.
  2250. `true` sets the focus to the specified element for every sent formspec.
  2251. * The following elements have the ability to be focused:
  2252. * checkbox
  2253. * button
  2254. * button_exit
  2255. * image_button
  2256. * image_button_exit
  2257. * item_image_button
  2258. * table
  2259. * textlist
  2260. * dropdown
  2261. * field
  2262. * pwdfield
  2263. * textarea
  2264. * scrollbar
  2265. Migrating to Real Coordinates
  2266. -----------------------------
  2267. In the old system, positions included padding and spacing. Padding is a gap between
  2268. the formspec window edges and content, and spacing is the gaps between items. For
  2269. example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
  2270. and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
  2271. in the new coordinate system from scratch.
  2272. To recreate an old layout with padding, you'll need to pass the positions and sizes
  2273. through the following formula to re-introduce padding:
  2274. ```
  2275. pos = (oldpos + 1)*spacing + padding
  2276. where
  2277. padding = 3/8
  2278. spacing = 5/4
  2279. ```
  2280. You'll need to change the `size[]` tag like this:
  2281. ```
  2282. size = (oldsize-1)*spacing + padding*2 + 1
  2283. ```
  2284. A few elements had random offsets in the old system. Here is a table which shows these
  2285. offsets when migrating:
  2286. | Element | Position | Size | Notes
  2287. |---------|------------|---------|-------
  2288. | box | +0.3, +0.1 | 0, -0.4 |
  2289. | button | | | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
  2290. | list | | | Spacing is now 0.25 for both directions, meaning lists will be taller in height
  2291. | label | 0, +0.3 | | The first line of text is now positioned centered exactly at the position specified
  2292. Styling Formspecs
  2293. -----------------
  2294. Formspec elements can be themed using the style elements:
  2295. style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
  2296. style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
  2297. style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
  2298. style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
  2299. Where a prop is:
  2300. property_name=property_value
  2301. For example:
  2302. style_type[button;bgcolor=#006699]
  2303. style[world_delete;bgcolor=red;textcolor=yellow]
  2304. button[4,3.95;2.6,1;world_delete;Delete]
  2305. A name/type can optionally be a comma separated list of names/types, like so:
  2306. world_delete,world_create,world_configure
  2307. button,image_button
  2308. A `*` type can be used to select every element in the formspec.
  2309. Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
  2310. world_delete:hovered+pressed
  2311. button:pressed
  2312. States allow you to apply styles in response to changes in the element, instead of applying at all times.
  2313. Setting a property to nothing will reset it to the default value. For example:
  2314. style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
  2315. style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
  2316. ### Supported Element Types
  2317. Some types may inherit styles from parent types.
  2318. * animated_image, inherits from image
  2319. * box
  2320. * button
  2321. * button_exit, inherits from button
  2322. * checkbox
  2323. * dropdown
  2324. * field
  2325. * image
  2326. * image_button
  2327. * item_image_button
  2328. * label
  2329. * list
  2330. * model
  2331. * pwdfield, inherits from field
  2332. * scrollbar
  2333. * tabheader
  2334. * table
  2335. * textarea
  2336. * textlist
  2337. * vertlabel, inherits from label
  2338. ### Valid Properties
  2339. * animated_image
  2340. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2341. * box
  2342. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2343. * Defaults to false in formspec_version version 3 or higher
  2344. * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
  2345. * Single value (e.g. `#FF0`): All corners/borders.
  2346. * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
  2347. top and bottom,left and right.
  2348. * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
  2349. * These work similarly to CSS borders.
  2350. * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
  2351. * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
  2352. * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
  2353. negative, the border will extend inside the box, whereas positive extends outside
  2354. the box. A width of zero results in no border; this is default.
  2355. * button, button_exit, image_button, item_image_button
  2356. * alpha - boolean, whether to draw alpha in bgimg. Default true.
  2357. * bgcolor - color, sets button tint.
  2358. * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
  2359. * This is deprecated, use states instead.
  2360. * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
  2361. * This is deprecated, use states instead.
  2362. * bgimg - standard background image. Defaults to none.
  2363. * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
  2364. * This is deprecated, use states instead.
  2365. * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
  2366. See background9[] documentation for more details. This property also pads the
  2367. button's content when set.
  2368. * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
  2369. * This is deprecated, use states instead.
  2370. * font - Sets font type. This is a comma separated list of options. Valid options:
  2371. * Main font type options. These cannot be combined with each other:
  2372. * `normal`: Default font
  2373. * `mono`: Monospaced font
  2374. * Font modification options. If used without a main font type, `normal` is used:
  2375. * `bold`: Makes font bold.
  2376. * `italic`: Makes font italic.
  2377. Default `normal`.
  2378. * font_size - Sets font size. Default is user-set. Can have multiple values:
  2379. * `<number>`: Sets absolute font size to `number`.
  2380. * `+<number>`/`-<number>`: Offsets default font size by `number` points.
  2381. * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
  2382. * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
  2383. * content_offset - 2d vector, shifts the position of the button's content without resizing it.
  2384. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2385. * padding - rect, adds space between the edges of the button and the content. This value is
  2386. relative to bgimg_middle.
  2387. * sound - a sound to be played when triggered.
  2388. * textcolor - color, default white.
  2389. * checkbox
  2390. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2391. * sound - a sound to be played when triggered.
  2392. * dropdown
  2393. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2394. * sound - a sound to be played when the entry is changed.
  2395. * field, pwdfield, textarea
  2396. * border - set to false to hide the textbox background and border. Default true.
  2397. * font - Sets font type. See button `font` property for more information.
  2398. * font_size - Sets font size. See button `font_size` property for more information.
  2399. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2400. * textcolor - color. Default white.
  2401. * model
  2402. * bgcolor - color, sets background color.
  2403. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2404. * Default to false in formspec_version version 3 or higher
  2405. * image
  2406. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2407. * Default to false in formspec_version version 3 or higher
  2408. * item_image
  2409. * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
  2410. * label, vertlabel
  2411. * font - Sets font type. See button `font` property for more information.
  2412. * font_size - Sets font size. See button `font_size` property for more information.
  2413. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2414. * list
  2415. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2416. * size - 2d vector, sets the size of inventory slots in coordinates.
  2417. * spacing - 2d vector, sets the space between inventory slots in coordinates.
  2418. * image_button (additional properties)
  2419. * fgimg - standard image. Defaults to none.
  2420. * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
  2421. * This is deprecated, use states instead.
  2422. * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
  2423. * This is deprecated, use states instead.
  2424. * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
  2425. See background9[] documentation for more details.
  2426. * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
  2427. * sound - a sound to be played when triggered.
  2428. * scrollbar
  2429. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2430. * tabheader
  2431. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2432. * sound - a sound to be played when a different tab is selected.
  2433. * textcolor - color. Default white.
  2434. * table, textlist
  2435. * font - Sets font type. See button `font` property for more information.
  2436. * font_size - Sets font size. See button `font_size` property for more information.
  2437. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2438. ### Valid States
  2439. * *all elements*
  2440. * default - Equivalent to providing no states
  2441. * button, button_exit, image_button, item_image_button
  2442. * hovered - Active when the mouse is hovering over the element
  2443. * pressed - Active when the button is pressed
  2444. Markup Language
  2445. ---------------
  2446. Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
  2447. The markup language is currently unstable and subject to change. Use with caution.
  2448. Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
  2449. Tags can have attributes, in that case, attributes are in the opening tag in
  2450. form of a key/value separated with equal signs. Attribute values should not be quoted.
  2451. If you want to insert a literal greater-than sign or a backslash into the text,
  2452. you must escape it by preceding it with a backslash.
  2453. These are the technically basic tags but see below for usual tags. Base tags are:
  2454. `<style color=... font=... size=...>...</style>`
  2455. Changes the style of the text.
  2456. * `color`: Text color. Given color is a `colorspec`.
  2457. * `size`: Text size.
  2458. * `font`: Text font (`mono` or `normal`).
  2459. `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
  2460. Sets global style.
  2461. Global only styles:
  2462. * `background`: Text background, a `colorspec` or `none`.
  2463. * `margin`: Page margins in pixel.
  2464. * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
  2465. Inheriting styles (affects child elements):
  2466. * `color`: Default text color. Given color is a `colorspec`.
  2467. * `hovercolor`: Color of <action> tags when mouse is over.
  2468. * `size`: Default text size.
  2469. * `font`: Default text font (`mono` or `normal`).
  2470. * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
  2471. This tag needs to be placed only once as it changes the global settings of the
  2472. text. Anyway, if several tags are placed, each changed will be made in the order
  2473. tags appear.
  2474. `<tag name=... color=... hovercolor=... font=... size=...>`
  2475. Defines or redefines tag style. This can be used to define new tags.
  2476. * `name`: Name of the tag to define or change.
  2477. * `color`: Text color. Given color is a `colorspec`.
  2478. * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
  2479. * `size`: Text size.
  2480. * `font`: Text font (`mono` or `normal`).
  2481. Following tags are the usual tags for text layout. They are defined by default.
  2482. Other tags can be added using `<tag ...>` tag.
  2483. `<normal>...</normal>`: Normal size text
  2484. `<big>...</big>`: Big text
  2485. `<bigger>...</bigger>`: Bigger text
  2486. `<center>...</center>`: Centered text
  2487. `<left>...</left>`: Left-aligned text
  2488. `<right>...</right>`: Right-aligned text
  2489. `<justify>...</justify>`: Justified text
  2490. `<mono>...</mono>`: Monospaced font
  2491. `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
  2492. `<action name=...>...</action>`
  2493. Make that text a clickable text triggering an action.
  2494. * `name`: Name of the action (mandatory).
  2495. When clicked, the formspec is send to the server. The value of the text field
  2496. sent to `on_player_receive_fields` will be "action:" concatenated to the action
  2497. name.
  2498. `<img name=... float=... width=... height=...>`
  2499. Draws an image which is present in the client media cache.
  2500. * `name`: Name of the texture (mandatory).
  2501. * `float`: If present, makes the image floating (`left` or `right`).
  2502. * `width`: Force image width instead of taking texture width.
  2503. * `height`: Force image height instead of taking texture height.
  2504. If only width or height given, texture aspect is kept.
  2505. `<item name=... float=... width=... height=... rotate=...>`
  2506. Draws an item image.
  2507. * `name`: Item string of the item to draw (mandatory).
  2508. * `float`: If present, makes the image floating (`left` or `right`).
  2509. * `width`: Item image width.
  2510. * `height`: Item image height.
  2511. * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
  2512. rotation speeds in percent of standard speed (-1000 to 1000). Works only if
  2513. `inventory_items_animations` is set to true.
  2514. * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
  2515. X, Y and Z being angles around each three axes. Works only if
  2516. `inventory_items_animations` is set to true.
  2517. Inventory
  2518. =========
  2519. Inventory locations
  2520. -------------------
  2521. * `"context"`: Selected node metadata (deprecated: `"current_name"`)
  2522. * `"current_player"`: Player to whom the menu is shown
  2523. * `"player:<name>"`: Any player
  2524. * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
  2525. * `"detached:<name>"`: A detached inventory
  2526. Player Inventory lists
  2527. ----------------------
  2528. * `main`: list containing the default inventory
  2529. * `craft`: list containing the craft input
  2530. * `craftpreview`: list containing the craft prediction
  2531. * `craftresult`: list containing the crafted output
  2532. * `hand`: list containing an override for the empty hand
  2533. * Is not created automatically, use `InvRef:set_size`
  2534. * Is only used to enhance the empty hand's tool capabilities
  2535. Colors
  2536. ======
  2537. `ColorString`
  2538. -------------
  2539. `#RGB` defines a color in hexadecimal format.
  2540. `#RGBA` defines a color in hexadecimal format and alpha channel.
  2541. `#RRGGBB` defines a color in hexadecimal format.
  2542. `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
  2543. Named colors are also supported and are equivalent to
  2544. [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
  2545. To specify the value of the alpha channel, append `#A` or `#AA` to the end of
  2546. the color name (e.g. `colorname#08`).
  2547. `ColorSpec`
  2548. -----------
  2549. A ColorSpec specifies a 32-bit color. It can be written in any of the following
  2550. forms:
  2551. * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
  2552. * `colorspec = {a=255, r=0, g=255, b=0}`
  2553. * numerical form: The raw integer value of an ARGB8 quad:
  2554. * `colorspec = 0xFF00FF00`
  2555. * string form: A ColorString (defined above):
  2556. * `colorspec = "green"`
  2557. Escape sequences
  2558. ================
  2559. Most text can contain escape sequences, that can for example color the text.
  2560. There are a few exceptions: tab headers, dropdowns and vertical labels can't.
  2561. The following functions provide escape sequences:
  2562. * `minetest.get_color_escape_sequence(color)`:
  2563. * `color` is a ColorString
  2564. * The escape sequence sets the text color to `color`
  2565. * `minetest.colorize(color, message)`:
  2566. * Equivalent to:
  2567. `minetest.get_color_escape_sequence(color) ..
  2568. message ..
  2569. minetest.get_color_escape_sequence("#ffffff")`
  2570. * `minetest.get_background_escape_sequence(color)`
  2571. * `color` is a ColorString
  2572. * The escape sequence sets the background of the whole text element to
  2573. `color`. Only defined for item descriptions and tooltips.
  2574. * `minetest.strip_foreground_colors(str)`
  2575. * Removes foreground colors added by `get_color_escape_sequence`.
  2576. * `minetest.strip_background_colors(str)`
  2577. * Removes background colors added by `get_background_escape_sequence`.
  2578. * `minetest.strip_colors(str)`
  2579. * Removes all color escape sequences.
  2580. Spatial Vectors
  2581. ===============
  2582. Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
  2583. and has a class to represent them (`vector.*`), which this chapter is about.
  2584. For details on what a spatial vectors is, please refer to Wikipedia:
  2585. https://en.wikipedia.org/wiki/Euclidean_vector.
  2586. Spatial vectors are used for various things, including, but not limited to:
  2587. * any 3D spatial vector (x/y/z-directions)
  2588. * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
  2589. meaning here. Therefore, most vector operations make no sense in this use case.)
  2590. Note that they are *not* used for:
  2591. * n-dimensional vectors where n is not 3 (ie. n=2)
  2592. * arrays of the form `{num, num, num}`
  2593. The API documentation may refer to spatial vectors, as produced by `vector.new`,
  2594. by any of the following notations:
  2595. * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
  2596. * `vector.new(x, y, z)`
  2597. * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
  2598. Compatibility notes
  2599. -------------------
  2600. Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
  2601. Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
  2602. Note: Those old-style vectors can still be found in old mod code. Hence, mod and
  2603. engine APIs still need to be able to cope with them in many places.
  2604. Manually constructed tables are deprecated and highly discouraged. This interface
  2605. should be used to ensure seamless compatibility between mods and the Minetest API.
  2606. This is especially important to callback function parameters and functions overwritten
  2607. by mods.
  2608. Also, though not likely, the internal implementation of a vector might change in
  2609. the future.
  2610. In your own code, or if you define your own API, you can, of course, still use
  2611. other representations of vectors.
  2612. Vectors provided by API functions will provide an instance of this class if not
  2613. stated otherwise. Mods should adapt this for convenience reasons.
  2614. Special properties of the class
  2615. -------------------------------
  2616. Vectors can be indexed with numbers and allow method and operator syntax.
  2617. All these forms of addressing a vector `v` are valid:
  2618. `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
  2619. Note: Prefer letter over number indexing for performance and compatibility reasons.
  2620. Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
  2621. the same as `vector.foo(v, ...)`, apart from deprecated functionality.
  2622. `tostring` is defined for vectors, see `vector.to_string`.
  2623. The metatable that is used for vectors can be accessed via `vector.metatable`.
  2624. Do not modify it!
  2625. All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
  2626. Returned vectors always have a metatable set.
  2627. Common functions and methods
  2628. ----------------------------
  2629. For the following functions (and subchapters),
  2630. `v`, `v1`, `v2` are vectors,
  2631. `p1`, `p2` are position vectors,
  2632. `s` is a scalar (a number),
  2633. vectors are written like this: `(x, y, z)`:
  2634. * `vector.new([a[, b, c]])`:
  2635. * Returns a new vector `(a, b, c)`.
  2636. * Deprecated: `vector.new()` does the same as `vector.zero()` and
  2637. `vector.new(v)` does the same as `vector.copy(v)`
  2638. * `vector.zero()`:
  2639. * Returns a new vector `(0, 0, 0)`.
  2640. * `vector.copy(v)`:
  2641. * Returns a copy of the vector `v`.
  2642. * `vector.from_string(s[, init])`:
  2643. * Returns `v, np`, where `v` is a vector read from the given string `s` and
  2644. `np` is the next position in the string after the vector.
  2645. * Returns `nil` on failure.
  2646. * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
  2647. spaces, leaving away commas and adding an additional comma to the end
  2648. is allowed.
  2649. * `init`: If given starts looking for the vector at this string index.
  2650. * `vector.to_string(v)`:
  2651. * Returns a string of the form `"(x, y, z)"`.
  2652. * `tostring(v)` does the same.
  2653. * `vector.direction(p1, p2)`:
  2654. * Returns a vector of length 1 with direction `p1` to `p2`.
  2655. * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
  2656. * `vector.distance(p1, p2)`:
  2657. * Returns zero or a positive number, the distance between `p1` and `p2`.
  2658. * `vector.length(v)`:
  2659. * Returns zero or a positive number, the length of vector `v`.
  2660. * `vector.normalize(v)`:
  2661. * Returns a vector of length 1 with direction of vector `v`.
  2662. * If `v` has zero length, returns `(0, 0, 0)`.
  2663. * `vector.floor(v)`:
  2664. * Returns a vector, each dimension rounded down.
  2665. * `vector.round(v)`:
  2666. * Returns a vector, each dimension rounded to nearest integer.
  2667. * At a multiple of 0.5, rounds away from zero.
  2668. * `vector.apply(v, func)`:
  2669. * Returns a vector where the function `func` has been applied to each
  2670. component.
  2671. * `vector.combine(v, w, func)`:
  2672. * Returns a vector where the function `func` has combined both components of `v` and `w`
  2673. for each component
  2674. * `vector.equals(v1, v2)`:
  2675. * Returns a boolean, `true` if the vectors are identical.
  2676. * `vector.sort(v1, v2)`:
  2677. * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
  2678. * `vector.angle(v1, v2)`:
  2679. * Returns the angle between `v1` and `v2` in radians.
  2680. * `vector.dot(v1, v2)`:
  2681. * Returns the dot product of `v1` and `v2`.
  2682. * `vector.cross(v1, v2)`:
  2683. * Returns the cross product of `v1` and `v2`.
  2684. * `vector.offset(v, x, y, z)`:
  2685. * Returns the sum of the vectors `v` and `(x, y, z)`.
  2686. * `vector.check(v)`:
  2687. * Returns a boolean value indicating whether `v` is a real vector, eg. created
  2688. by a `vector.*` function.
  2689. * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
  2690. For the following functions `x` can be either a vector or a number:
  2691. * `vector.add(v, x)`:
  2692. * Returns a vector.
  2693. * If `x` is a vector: Returns the sum of `v` and `x`.
  2694. * If `x` is a number: Adds `x` to each component of `v`.
  2695. * `vector.subtract(v, x)`:
  2696. * Returns a vector.
  2697. * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
  2698. * If `x` is a number: Subtracts `x` from each component of `v`.
  2699. * `vector.multiply(v, s)`:
  2700. * Returns a scaled vector.
  2701. * Deprecated: If `s` is a vector: Returns the Schur product.
  2702. * `vector.divide(v, s)`:
  2703. * Returns a scaled vector.
  2704. * Deprecated: If `s` is a vector: Returns the Schur quotient.
  2705. Operators
  2706. ---------
  2707. Operators can be used if all of the involved vectors have metatables:
  2708. * `v1 == v2`:
  2709. * Returns whether `v1` and `v2` are identical.
  2710. * `-v`:
  2711. * Returns the additive inverse of v.
  2712. * `v1 + v2`:
  2713. * Returns the sum of both vectors.
  2714. * Note: `+` cannot be used together with scalars.
  2715. * `v1 - v2`:
  2716. * Returns the difference of `v1` subtracted by `v2`.
  2717. * Note: `-` cannot be used together with scalars.
  2718. * `v * s` or `s * v`:
  2719. * Returns `v` scaled by `s`.
  2720. * `v / s`:
  2721. * Returns `v` scaled by `1 / s`.
  2722. Rotation-related functions
  2723. --------------------------
  2724. For the following functions `a` is an angle in radians and `r` is a rotation
  2725. vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
  2726. angles in radians.
  2727. * `vector.rotate(v, r)`:
  2728. * Applies the rotation `r` to `v` and returns the result.
  2729. * `vector.rotate(vector.new(0, 0, 1), r)` and
  2730. `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
  2731. forward and up relative to an entity's rotation `r`.
  2732. * `vector.rotate_around_axis(v1, v2, a)`:
  2733. * Returns `v1` rotated around axis `v2` by `a` radians according to
  2734. the right hand rule.
  2735. * `vector.dir_to_rotation(direction[, up])`:
  2736. * Returns a rotation vector for `direction` pointing forward using `up`
  2737. as the up vector.
  2738. * If `up` is omitted, the roll of the returned vector defaults to zero.
  2739. * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
  2740. Further helpers
  2741. ---------------
  2742. There are more helper functions involving vectors, but they are listed elsewhere
  2743. because they only work on specific sorts of vectors or involve things that are not
  2744. vectors.
  2745. For example:
  2746. * `minetest.hash_node_position` (Only works on node positions.)
  2747. * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
  2748. Helper functions
  2749. ================
  2750. * `dump2(obj, name, dumped)`: returns a string which makes `obj`
  2751. human-readable, handles reference loops.
  2752. * `obj`: arbitrary variable
  2753. * `name`: string, default: `"_"`
  2754. * `dumped`: table, default: `{}`
  2755. * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
  2756. * `obj`: arbitrary variable
  2757. * `dumped`: table, default: `{}`
  2758. * `math.hypot(x, y)`
  2759. * Get the hypotenuse of a triangle with legs x and y.
  2760. Useful for distance calculation.
  2761. * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
  2762. * Get the sign of a number.
  2763. * tolerance: number, default: `0.0`
  2764. * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
  2765. `0` is returned.
  2766. * `math.factorial(x)`: returns the factorial of `x`
  2767. * `math.round(x)`: Returns `x` rounded to the nearest integer.
  2768. * At a multiple of 0.5, rounds away from zero.
  2769. * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
  2770. * `separator`: string, default: `","`
  2771. * `include_empty`: boolean, default: `false`
  2772. * `max_splits`: number, if it's negative, splits aren't limited,
  2773. default: `-1`
  2774. * `sep_is_pattern`: boolean, it specifies whether separator is a plain
  2775. string or a pattern (regex), default: `false`
  2776. * e.g. `"a,b":split","` returns `{"a","b"}`
  2777. * `string:trim()`: returns the string without whitespace pre- and suffixes
  2778. * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
  2779. * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
  2780. * Adds newlines to the string to keep it within the specified character
  2781. limit
  2782. * Note that the returned lines may be longer than the limit since it only
  2783. splits at word borders.
  2784. * `limit`: number, maximal amount of characters in one line
  2785. * `as_table`: boolean, if set to true, a table of lines instead of a string
  2786. is returned, default: `false`
  2787. * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
  2788. * `pos`: table {x=X, y=Y, z=Z}
  2789. * Converts the position `pos` to a human-readable, printable string
  2790. * `decimal_places`: number, if specified, the x, y and z values of
  2791. the position are rounded to the given decimal place.
  2792. * `minetest.string_to_pos(string)`: returns a position or `nil`
  2793. * Same but in reverse.
  2794. * If the string can't be parsed to a position, nothing is returned.
  2795. * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
  2796. * returns two positions
  2797. * Converts a string representing an area box into two positions
  2798. * X1, Y1, ... Z2 are coordinates
  2799. * `relative_to`: Optional. If set to a position, each coordinate
  2800. can use the tilde notation for relative positions
  2801. * Tilde notation: "~": Relative coordinate
  2802. "~<number>": Relative coordinate plus <number>
  2803. * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
  2804. returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
  2805. * `minetest.formspec_escape(string)`: returns a string
  2806. * escapes the characters "[", "]", "\", "," and ";", which cannot be used
  2807. in formspecs.
  2808. * `minetest.is_yes(arg)`
  2809. * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
  2810. * `minetest.is_nan(arg)`
  2811. * returns true when the passed number represents NaN.
  2812. * `minetest.get_us_time()`
  2813. * returns time with microsecond precision. May not return wall time.
  2814. * `table.copy(table)`: returns a table
  2815. * returns a deep copy of `table`
  2816. * `table.indexof(list, val)`: returns the smallest numerical index containing
  2817. the value `val` in the table `list`. Non-numerical indices are ignored.
  2818. If `val` could not be found, `-1` is returned. `list` must not have
  2819. negative indices.
  2820. * `table.insert_all(table, other_table)`:
  2821. * Appends all values in `other_table` to `table` - uses `#table + 1` to
  2822. find new indices.
  2823. * `table.key_value_swap(t)`: returns a table with keys and values swapped
  2824. * If multiple keys in `t` map to the same value, it is unspecified which
  2825. value maps to that key.
  2826. * `table.shuffle(table, [from], [to], [random_func])`:
  2827. * Shuffles elements `from` to `to` in `table` in place
  2828. * `from` defaults to `1`
  2829. * `to` defaults to `#table`
  2830. * `random_func` defaults to `math.random`. This function receives two
  2831. integers as arguments and should return a random integer inclusively
  2832. between them.
  2833. * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
  2834. position.
  2835. * returns the exact position on the surface of a pointed node
  2836. * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
  2837. * Simulates a tool being used once and returns the added wear,
  2838. such that, if only this function is used to calculate wear,
  2839. the tool will break exactly after `uses` times of uses
  2840. * `uses`: Number of times the tool can be used
  2841. * `initial_wear`: The initial wear the tool starts with (default: 0)
  2842. * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
  2843. Simulates an item that digs a node.
  2844. Returns a table with the following fields:
  2845. * `diggable`: `true` if node can be dug, `false` otherwise.
  2846. * `time`: Time it would take to dig the node.
  2847. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2848. `time` and `wear` are meaningless if node's not diggable
  2849. Parameters:
  2850. * `groups`: Table of the node groups of the node that would be dug
  2851. * `tool_capabilities`: Tool capabilities table of the item
  2852. * `wear`: Amount of wear the tool starts with (default: 0)
  2853. * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
  2854. Simulates an item that punches an object.
  2855. Returns a table with the following fields:
  2856. * `hp`: How much damage the punch would cause (between -65535 and 65535).
  2857. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2858. Parameters:
  2859. * `groups`: Damage groups of the object
  2860. * `tool_capabilities`: Tool capabilities table of the item
  2861. * `time_from_last_punch`: time in seconds since last punch action
  2862. * `wear`: Amount of wear the item starts with (default: 0)
  2863. Translations
  2864. ============
  2865. Texts can be translated client-side with the help of `minetest.translate` and
  2866. translation files.
  2867. Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
  2868. to generate and update translation files automatically from the Lua source.
  2869. Translating a string
  2870. --------------------
  2871. Two functions are provided to translate strings: `minetest.translate` and
  2872. `minetest.get_translator`.
  2873. * `minetest.get_translator(textdomain)` is a simple wrapper around
  2874. `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
  2875. equivalent to `minetest.translate(textdomain, str, ...)`.
  2876. It is intended to be used in the following way, so that it avoids verbose
  2877. repetitions of `minetest.translate`:
  2878. local S = minetest.get_translator(textdomain)
  2879. S(str, ...)
  2880. As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
  2881. * `minetest.translate(textdomain, str, ...)` translates the string `str` with
  2882. the given `textdomain` for disambiguation. The textdomain must match the
  2883. textdomain specified in the translation file in order to get the string
  2884. translated. This can be used so that a string is translated differently in
  2885. different contexts.
  2886. It is advised to use the name of the mod as textdomain whenever possible, to
  2887. avoid clashes with other mods.
  2888. This function must be given a number of arguments equal to the number of
  2889. arguments the translated string expects.
  2890. Arguments are literal strings -- they will not be translated, so if you want
  2891. them to be, they need to come as outputs of `minetest.translate` as well.
  2892. For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
  2893. by the translation of "Red". We can do the following:
  2894. local S = minetest.get_translator()
  2895. S("@1 Wool", S("Red"))
  2896. This will be displayed as "Red Wool" on old clients and on clients that do
  2897. not have localization enabled. However, if we have for instance a translation
  2898. file named `wool.fr.tr` containing the following:
  2899. @1 Wool=Laine @1
  2900. Red=Rouge
  2901. this will be displayed as "Laine Rouge" on clients with a French locale.
  2902. Operations on translated strings
  2903. --------------------------------
  2904. The output of `minetest.translate` is a string, with escape sequences adding
  2905. additional information to that string so that it can be translated on the
  2906. different clients. In particular, you can't expect operations like string.length
  2907. to work on them like you would expect them to, or string.gsub to work in the
  2908. expected manner. However, string concatenation will still work as expected
  2909. (note that you should only use this for things like formspecs; do not translate
  2910. sentences by breaking them into parts; arguments should be used instead), and
  2911. operations such as `minetest.colorize` which are also concatenation.
  2912. Translation file format
  2913. -----------------------
  2914. A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
  2915. it corresponds to. It must be put into the `locale` subdirectory of the mod.
  2916. The file should be a text file, with the following format:
  2917. * Lines beginning with `# textdomain:` (the space is significant) can be used
  2918. to specify the text domain of all following translations in the file.
  2919. * All other empty lines or lines beginning with `#` are ignored.
  2920. * Other lines should be in the format `original=translated`. Both `original`
  2921. and `translated` can contain escape sequences beginning with `@` to insert
  2922. arguments, literal `@`, `=` or newline (See [Escapes] below).
  2923. There must be no extraneous whitespace around the `=` or at the beginning or
  2924. the end of the line.
  2925. Escapes
  2926. -------
  2927. Strings that need to be translated can contain several escapes, preceded by `@`.
  2928. * `@@` acts as a literal `@`.
  2929. * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
  2930. string that will be inlined when translated. Due to how translations are
  2931. implemented, the original translation string **must** have its arguments in
  2932. increasing order, without gaps or repetitions, starting from 1.
  2933. * `@=` acts as a literal `=`. It is not required in strings given to
  2934. `minetest.translate`, but is in translation files to avoid being confused
  2935. with the `=` separating the original from the translation.
  2936. * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
  2937. As with `@=`, this escape is not required in strings given to
  2938. `minetest.translate`, but is in translation files.
  2939. * `@n` acts as a literal newline as well.
  2940. Server side translations
  2941. ------------------------
  2942. On some specific cases, server translation could be useful. For example, filter
  2943. a list on labels and send results to client. A method is supplied to achieve
  2944. that:
  2945. `minetest.get_translated_string(lang_code, string)`: Translates `string` using
  2946. translations for `lang_code` language. It gives the same result as if the string
  2947. was translated by the client.
  2948. The `lang_code` to use for a given player can be retrieved from
  2949. the table returned by `minetest.get_player_information(name)`.
  2950. IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
  2951. You do not need to use this to get translated strings to show up on the client.
  2952. Perlin noise
  2953. ============
  2954. Perlin noise creates a continuously-varying value depending on the input values.
  2955. Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
  2956. The result is used during map generation to create the terrain shape, vary heat
  2957. and humidity to distribute biomes, vary the density of decorations or vary the
  2958. structure of ores.
  2959. Structure of perlin noise
  2960. -------------------------
  2961. An 'octave' is a simple noise generator that outputs a value between -1 and 1.
  2962. The smooth wavy noise it generates has a single characteristic scale, almost
  2963. like a 'wavelength', so on its own does not create fine detail.
  2964. Due to this perlin noise combines several octaves to create variation on
  2965. multiple scales. Each additional octave has a smaller 'wavelength' than the
  2966. previous.
  2967. This combination results in noise varying very roughly between -2.0 and 2.0 and
  2968. with an average value of 0.0, so `scale` and `offset` are then used to multiply
  2969. and offset the noise variation.
  2970. The final perlin noise variation is created as follows:
  2971. noise = offset + scale * (octave1 +
  2972. octave2 * persistence +
  2973. octave3 * persistence ^ 2 +
  2974. octave4 * persistence ^ 3 +
  2975. ...)
  2976. Noise Parameters
  2977. ----------------
  2978. Noise Parameters are commonly called `NoiseParams`.
  2979. ### `offset`
  2980. After the multiplication by `scale` this is added to the result and is the final
  2981. step in creating the noise value.
  2982. Can be positive or negative.
  2983. ### `scale`
  2984. Once all octaves have been combined, the result is multiplied by this.
  2985. Can be positive or negative.
  2986. ### `spread`
  2987. For octave1, this is roughly the change of input value needed for a very large
  2988. variation in the noise value generated by octave1. It is almost like a
  2989. 'wavelength' for the wavy noise variation.
  2990. Each additional octave has a 'wavelength' that is smaller than the previous
  2991. octave, to create finer detail. `spread` will therefore roughly be the typical
  2992. size of the largest structures in the final noise variation.
  2993. `spread` is a vector with values for x, y, z to allow the noise variation to be
  2994. stretched or compressed in the desired axes.
  2995. Values are positive numbers.
  2996. ### `seed`
  2997. This is a whole number that determines the entire pattern of the noise
  2998. variation. Altering it enables different noise patterns to be created.
  2999. With other parameters equal, different seeds produce different noise patterns
  3000. and identical seeds produce identical noise patterns.
  3001. For this parameter you can randomly choose any whole number. Usually it is
  3002. preferable for this to be different from other seeds, but sometimes it is useful
  3003. to be able to create identical noise patterns.
  3004. In some noise APIs the world seed is added to the seed specified in noise
  3005. parameters. This is done to make the resulting noise pattern vary in different
  3006. worlds, and be 'world-specific'.
  3007. ### `octaves`
  3008. The number of simple noise generators that are combined.
  3009. A whole number, 1 or more.
  3010. Each additional octave adds finer detail to the noise but also increases the
  3011. noise calculation load.
  3012. 3 is a typical minimum for a high quality, complex and natural-looking noise
  3013. variation. 1 octave has a slight 'gridlike' appearance.
  3014. Choose the number of octaves according to the `spread` and `lacunarity`, and the
  3015. size of the finest detail you require. For example:
  3016. if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
  3017. nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
  3018. 512, 256, 128, 64, 32, 16 nodes.
  3019. Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
  3020. ### `persistence`
  3021. Each additional octave has an amplitude that is the amplitude of the previous
  3022. octave multiplied by `persistence`, to reduce the amplitude of finer details,
  3023. as is often helpful and natural to do so.
  3024. Since this controls the balance of fine detail to large-scale detail
  3025. `persistence` can be thought of as the 'roughness' of the noise.
  3026. A positive or negative non-zero number, often between 0.3 and 1.0.
  3027. A common medium value is 0.5, such that each octave has half the amplitude of
  3028. the previous octave.
  3029. This may need to be tuned when altering `lacunarity`; when doing so consider
  3030. that a common medium value is 1 / lacunarity.
  3031. ### `lacunarity`
  3032. Each additional octave has a 'wavelength' that is the 'wavelength' of the
  3033. previous octave multiplied by 1 / lacunarity, to create finer detail.
  3034. 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
  3035. A positive number no smaller than 1.0.
  3036. Values below 2.0 create higher quality noise at the expense of requiring more
  3037. octaves to cover a particular range of 'wavelengths'.
  3038. ### `flags`
  3039. Leave this field unset for no special handling.
  3040. Currently supported are `defaults`, `eased` and `absvalue`:
  3041. #### `defaults`
  3042. Specify this if you would like to keep auto-selection of eased/not-eased while
  3043. specifying some other flags.
  3044. #### `eased`
  3045. Maps noise gradient values onto a quintic S-curve before performing
  3046. interpolation. This results in smooth, rolling noise.
  3047. Disable this (`noeased`) for sharp-looking noise with a slightly gridded
  3048. appearance.
  3049. If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
  3050. not eased.
  3051. Easing a 3D noise significantly increases the noise calculation load, so use
  3052. with restraint.
  3053. #### `absvalue`
  3054. The absolute value of each octave's noise variation is used when combining the
  3055. octaves. The final perlin noise variation is created as follows:
  3056. noise = offset + scale * (abs(octave1) +
  3057. abs(octave2) * persistence +
  3058. abs(octave3) * persistence ^ 2 +
  3059. abs(octave4) * persistence ^ 3 +
  3060. ...)
  3061. ### Format example
  3062. For 2D or 3D perlin noise or perlin noise maps:
  3063. np_terrain = {
  3064. offset = 0,
  3065. scale = 1,
  3066. spread = {x = 500, y = 500, z = 500},
  3067. seed = 571347,
  3068. octaves = 5,
  3069. persistence = 0.63,
  3070. lacunarity = 2.0,
  3071. flags = "defaults, absvalue",
  3072. }
  3073. For 2D noise the Z component of `spread` is still defined but is ignored.
  3074. A single noise parameter table can be used for 2D or 3D noise.
  3075. Ores
  3076. ====
  3077. Ore types
  3078. ---------
  3079. These tell in what manner the ore is generated.
  3080. All default ores are of the uniformly-distributed scatter type.
  3081. ### `scatter`
  3082. Randomly chooses a location and generates a cluster of ore.
  3083. If `noise_params` is specified, the ore will be placed if the 3D perlin noise
  3084. at that point is greater than the `noise_threshold`, giving the ability to
  3085. create a non-equal distribution of ore.
  3086. ### `sheet`
  3087. Creates a sheet of ore in a blob shape according to the 2D perlin noise
  3088. described by `noise_params` and `noise_threshold`. This is essentially an
  3089. improved version of the so-called "stratus" ore seen in some unofficial mods.
  3090. This sheet consists of vertical columns of uniform randomly distributed height,
  3091. varying between the inclusive range `column_height_min` and `column_height_max`.
  3092. If `column_height_min` is not specified, this parameter defaults to 1.
  3093. If `column_height_max` is not specified, this parameter defaults to `clust_size`
  3094. for reverse compatibility. New code should prefer `column_height_max`.
  3095. The `column_midpoint_factor` parameter controls the position of the column at
  3096. which ore emanates from.
  3097. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
  3098. equally starting from each direction.
  3099. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
  3100. this parameter is not specified, the default is 0.5.
  3101. The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
  3102. ore type.
  3103. ### `puff`
  3104. Creates a sheet of ore in a cloud-like puff shape.
  3105. As with the `sheet` ore type, the size and shape of puffs are described by
  3106. `noise_params` and `noise_threshold` and are placed at random vertical
  3107. positions within the currently generated chunk.
  3108. The vertical top and bottom displacement of each puff are determined by the
  3109. noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
  3110. ### `blob`
  3111. Creates a deformed sphere of ore according to 3d perlin noise described by
  3112. `noise_params`. The maximum size of the blob is `clust_size`, and
  3113. `clust_scarcity` has the same meaning as with the `scatter` type.
  3114. ### `vein`
  3115. Creates veins of ore varying in density by according to the intersection of two
  3116. instances of 3d perlin noise with different seeds, both described by
  3117. `noise_params`.
  3118. `random_factor` varies the influence random chance has on placement of an ore
  3119. inside the vein, which is `1` by default. Note that modifying this parameter
  3120. may require adjusting `noise_threshold`.
  3121. The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
  3122. by this ore type.
  3123. This ore type is difficult to control since it is sensitive to small changes.
  3124. The following is a decent set of parameters to work from:
  3125. noise_params = {
  3126. offset = 0,
  3127. scale = 3,
  3128. spread = {x=200, y=200, z=200},
  3129. seed = 5390,
  3130. octaves = 4,
  3131. persistence = 0.5,
  3132. lacunarity = 2.0,
  3133. flags = "eased",
  3134. },
  3135. noise_threshold = 1.6
  3136. **WARNING**: Use this ore type *very* sparingly since it is ~200x more
  3137. computationally expensive than any other ore.
  3138. ### `stratum`
  3139. Creates a single undulating ore stratum that is continuous across mapchunk
  3140. borders and horizontally spans the world.
  3141. The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
  3142. the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
  3143. defines the stratum's vertical thickness (in units of nodes). Due to being
  3144. continuous across mapchunk borders the stratum's vertical thickness is
  3145. unlimited.
  3146. If the noise parameter `noise_params` is omitted the ore will occur from y_min
  3147. to y_max in a simple horizontal stratum.
  3148. A parameter `stratum_thickness` can be provided instead of the noise parameter
  3149. `np_stratum_thickness`, to create a constant thickness.
  3150. Leaving out one or both noise parameters makes the ore generation less
  3151. intensive, useful when adding multiple strata.
  3152. `y_min` and `y_max` define the limits of the ore generation and for performance
  3153. reasons should be set as close together as possible but without clipping the
  3154. stratum's Y variation.
  3155. Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
  3156. solid-ore stratum would require a `clust_scarcity` of 1.
  3157. The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
  3158. `random_factor` are ignored by this ore type.
  3159. Ore attributes
  3160. --------------
  3161. See section [Flag Specifier Format].
  3162. Currently supported flags:
  3163. `puff_cliffs`, `puff_additive_composition`.
  3164. ### `puff_cliffs`
  3165. If set, puff ore generation will not taper down large differences in
  3166. displacement when approaching the edge of a puff. This flag has no effect for
  3167. ore types other than `puff`.
  3168. ### `puff_additive_composition`
  3169. By default, when noise described by `np_puff_top` or `np_puff_bottom` results
  3170. in a negative displacement, the sub-column at that point is not generated. With
  3171. this attribute set, puff ore generation will instead generate the absolute
  3172. difference in noise displacement values. This flag has no effect for ore types
  3173. other than `puff`.
  3174. Decoration types
  3175. ================
  3176. The varying types of decorations that can be placed.
  3177. `simple`
  3178. --------
  3179. Creates a 1 times `H` times 1 column of a specified node (or a random node from
  3180. a list, if a decoration list is specified). Can specify a certain node it must
  3181. spawn next to, such as water or lava, for example. Can also generate a
  3182. decoration of random height between a specified lower and upper bound.
  3183. This type of decoration is intended for placement of grass, flowers, cacti,
  3184. papyri, waterlilies and so on.
  3185. `schematic`
  3186. -----------
  3187. Copies a box of `MapNodes` from a specified schematic file (or raw description).
  3188. Can specify a probability of a node randomly appearing when placed.
  3189. This decoration type is intended to be used for multi-node sized discrete
  3190. structures, such as trees, cave spikes, rocks, and so on.
  3191. Schematics
  3192. ==========
  3193. Schematic specifier
  3194. --------------------
  3195. A schematic specifier identifies a schematic by either a filename to a
  3196. Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  3197. in the form of a table. This table specifies the following fields:
  3198. * The `size` field is a 3D vector containing the dimensions of the provided
  3199. schematic. (required field)
  3200. * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
  3201. sets the probability of a particular horizontal slice of the schematic being
  3202. placed. (optional field)
  3203. `ypos` = 0 for the lowest horizontal slice of a schematic.
  3204. The default of `prob` is 255.
  3205. * The `data` field is a flat table of MapNode tables making up the schematic,
  3206. in the order of `[z [y [x]]]`. (required field)
  3207. Each MapNode table contains:
  3208. * `name`: the name of the map node to place (required)
  3209. * `prob` (alias `param1`): the probability of this node being placed
  3210. (default: 255)
  3211. * `param2`: the raw param2 value of the node being placed onto the map
  3212. (default: 0)
  3213. * `force_place`: boolean representing if the node should forcibly overwrite
  3214. any previous contents (default: false)
  3215. About probability values:
  3216. * A probability value of `0` or `1` means that node will never appear
  3217. (0% chance).
  3218. * A probability value of `254` or `255` means the node will always appear
  3219. (100% chance).
  3220. * If the probability value `p` is greater than `1`, then there is a
  3221. `(p / 256 * 100)` percent chance that node will appear when the schematic is
  3222. placed on the map.
  3223. Schematic attributes
  3224. --------------------
  3225. See section [Flag Specifier Format].
  3226. Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
  3227. `force_placement`.
  3228. * `place_center_x`: Placement of this decoration is centered along the X axis.
  3229. * `place_center_y`: Placement of this decoration is centered along the Y axis.
  3230. * `place_center_z`: Placement of this decoration is centered along the Z axis.
  3231. * `force_placement`: Schematic nodes other than "ignore" will replace existing
  3232. nodes.
  3233. Lua Voxel Manipulator
  3234. =====================
  3235. About VoxelManip
  3236. ----------------
  3237. VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
  3238. facility. The purpose of this object is for fast, low-level, bulk access to
  3239. reading and writing Map content. As such, setting map nodes through VoxelManip
  3240. will lack many of the higher level features and concepts you may be used to
  3241. with other methods of setting nodes. For example, nodes will not have their
  3242. construction and destruction callbacks run, and no rollback information is
  3243. logged.
  3244. It is important to note that VoxelManip is designed for speed, and *not* ease
  3245. of use or flexibility. If your mod requires a map manipulation facility that
  3246. will handle 100% of all edge cases, or the use of high level node placement
  3247. features, perhaps `minetest.set_node()` is better suited for the job.
  3248. In addition, VoxelManip might not be faster, or could even be slower, for your
  3249. specific use case. VoxelManip is most effective when setting large areas of map
  3250. at once - for example, if only setting a 3x3x3 node area, a
  3251. `minetest.set_node()` loop may be more optimal. Always profile code using both
  3252. methods of map manipulation to determine which is most appropriate for your
  3253. usage.
  3254. A recent simple test of setting cubic areas showed that `minetest.set_node()`
  3255. is faster than a VoxelManip for a 3x3x3 node cube or smaller.
  3256. Using VoxelManip
  3257. ----------------
  3258. A VoxelManip object can be created any time using either:
  3259. `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
  3260. If the optional position parameters are present for either of these routines,
  3261. the specified region will be pre-loaded into the VoxelManip object on creation.
  3262. Otherwise, the area of map you wish to manipulate must first be loaded into the
  3263. VoxelManip object using `VoxelManip:read_from_map()`.
  3264. Note that `VoxelManip:read_from_map()` returns two position vectors. The region
  3265. formed by these positions indicate the minimum and maximum (respectively)
  3266. positions of the area actually loaded in the VoxelManip, which may be larger
  3267. than the area requested. For convenience, the loaded area coordinates can also
  3268. be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
  3269. Now that the VoxelManip object is populated with map data, your mod can fetch a
  3270. copy of this data using either of two methods. `VoxelManip:get_node_at()`,
  3271. which retrieves an individual node in a MapNode formatted table at the position
  3272. requested is the simplest method to use, but also the slowest.
  3273. Nodes in a VoxelManip object may also be read in bulk to a flat array table
  3274. using:
  3275. * `VoxelManip:get_data()` for node content (in Content ID form, see section
  3276. [Content IDs]),
  3277. * `VoxelManip:get_light_data()` for node light levels, and
  3278. * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
  3279. See section [Flat array format] for more details.
  3280. It is very important to understand that the tables returned by any of the above
  3281. three functions represent a snapshot of the VoxelManip's internal state at the
  3282. time of the call. This copy of the data will not magically update itself if
  3283. another function modifies the internal VoxelManip state.
  3284. Any functions that modify a VoxelManip's contents work on the VoxelManip's
  3285. internal state unless otherwise explicitly stated.
  3286. Once the bulk data has been edited to your liking, the internal VoxelManip
  3287. state can be set using:
  3288. * `VoxelManip:set_data()` for node content (in Content ID form, see section
  3289. [Content IDs]),
  3290. * `VoxelManip:set_light_data()` for node light levels, and
  3291. * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
  3292. The parameter to each of the above three functions can use any table at all in
  3293. the same flat array format as produced by `get_data()` etc. and is not required
  3294. to be a table retrieved from `get_data()`.
  3295. Once the internal VoxelManip state has been modified to your liking, the
  3296. changes can be committed back to the map by calling `VoxelManip:write_to_map()`
  3297. ### Flat array format
  3298. Let
  3299. `Nx = p2.X - p1.X + 1`,
  3300. `Ny = p2.Y - p1.Y + 1`, and
  3301. `Nz = p2.Z - p1.Z + 1`.
  3302. Then, for a loaded region of p1..p2, this array ranges from `1` up to and
  3303. including the value of the expression `Nx * Ny * Nz`.
  3304. Positions offset from p1 are present in the array with the format of:
  3305. [
  3306. (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
  3307. (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
  3308. ...
  3309. (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
  3310. (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
  3311. ...
  3312. (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
  3313. ...
  3314. (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
  3315. ]
  3316. and the array index for a position p contained completely in p1..p2 is:
  3317. `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
  3318. Note that this is the same "flat 3D array" format as
  3319. `PerlinNoiseMap:get3dMap_flat()`.
  3320. VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
  3321. of the index for a single point in a flat VoxelManip array.
  3322. ### Content IDs
  3323. A Content ID is a unique integer identifier for a specific node type.
  3324. These IDs are used by VoxelManip in place of the node name string for
  3325. `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
  3326. `minetest.get_content_id()` to look up the Content ID for the specified node
  3327. name, and `minetest.get_name_from_content_id()` to look up the node name string
  3328. for a given Content ID.
  3329. After registration of a node, its Content ID will remain the same throughout
  3330. execution of the mod.
  3331. Note that the node being queried needs to have already been been registered.
  3332. The following builtin node types have their Content IDs defined as constants:
  3333. * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
  3334. * `minetest.CONTENT_AIR`: ID for "air" nodes
  3335. * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
  3336. ### Mapgen VoxelManip objects
  3337. Inside of `on_generated()` callbacks, it is possible to retrieve the same
  3338. VoxelManip object used by the core's Map Generator (commonly abbreviated
  3339. Mapgen). Most of the rules previously described still apply but with a few
  3340. differences:
  3341. * The Mapgen VoxelManip object is retrieved using:
  3342. `minetest.get_mapgen_object("voxelmanip")`
  3343. * This VoxelManip object already has the region of map just generated loaded
  3344. into it; it's not necessary to call `VoxelManip:read_from_map()`.
  3345. Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
  3346. parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
  3347. * The `on_generated()` callbacks of some mods may place individual nodes in the
  3348. generated area using non-VoxelManip map modification methods. Because the
  3349. same Mapgen VoxelManip object is passed through each `on_generated()`
  3350. callback, it becomes necessary for the Mapgen VoxelManip object to maintain
  3351. consistency with the current map state. For this reason, calling any of
  3352. `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
  3353. will also update the Mapgen VoxelManip object's internal state active on the
  3354. current thread.
  3355. * After modifying the Mapgen VoxelManip object's internal buffer, it may be
  3356. necessary to update lighting information using either:
  3357. `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
  3358. ### Other API functions operating on a VoxelManip
  3359. If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
  3360. `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
  3361. flowing. It is recommended to call this function only after having written all
  3362. buffered data back to the VoxelManip object, save for special situations where
  3363. the modder desires to only have certain liquid nodes begin flowing.
  3364. The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
  3365. will generate all registered decorations and ores throughout the full area
  3366. inside of the specified VoxelManip object.
  3367. `minetest.place_schematic_on_vmanip()` is otherwise identical to
  3368. `minetest.place_schematic()`, except instead of placing the specified schematic
  3369. directly on the map at the specified position, it will place the schematic
  3370. inside the VoxelManip.
  3371. ### Notes
  3372. * Attempting to read data from a VoxelManip object before map is read will
  3373. result in a zero-length array table for `VoxelManip:get_data()`, and an
  3374. "ignore" node at any position for `VoxelManip:get_node_at()`.
  3375. * If either a region of map has not yet been generated or is out-of-bounds of
  3376. the map, that region is filled with "ignore" nodes.
  3377. * Other mods, or the core itself, could possibly modify the area of map
  3378. currently loaded into a VoxelManip object. With the exception of Mapgen
  3379. VoxelManips (see above section), the internal buffers are not updated. For
  3380. this reason, it is strongly encouraged to complete the usage of a particular
  3381. VoxelManip object in the same callback it had been created.
  3382. * If a VoxelManip object will be used often, such as in an `on_generated()`
  3383. callback, consider passing a file-scoped table as the optional parameter to
  3384. `VoxelManip:get_data()`, which serves as a static buffer the function can use
  3385. to write map data to instead of returning a new table each call. This greatly
  3386. enhances performance by avoiding unnecessary memory allocations.
  3387. Methods
  3388. -------
  3389. * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
  3390. containing the region formed by `p1` and `p2`.
  3391. * returns actual emerged `pmin`, actual emerged `pmax`
  3392. * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
  3393. the map.
  3394. * **important**: data must be set using `VoxelManip:set_data()` before
  3395. calling this.
  3396. * if `light` is true, then lighting is automatically recalculated.
  3397. The default value is true.
  3398. If `light` is false, no light calculations happen, and you should correct
  3399. all modified blocks with `minetest.fix_light()` as soon as possible.
  3400. Keep in mind that modifying the map where light is incorrect can cause
  3401. more lighting bugs.
  3402. * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
  3403. the `VoxelManip` at that position
  3404. * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
  3405. that position.
  3406. * `get_data([buffer])`: Retrieves the node content data loaded into the
  3407. `VoxelManip` object.
  3408. * returns raw node data in the form of an array of node content IDs
  3409. * if the param `buffer` is present, this table will be used to store the
  3410. result instead.
  3411. * `set_data(data)`: Sets the data contents of the `VoxelManip` object
  3412. * `update_map()`: Does nothing, kept for compatibility.
  3413. * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
  3414. a uniform value.
  3415. * `light` is a table, `{day=<0...15>, night=<0...15>}`
  3416. * To be used only by a `VoxelManip` object from
  3417. `minetest.get_mapgen_object`.
  3418. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3419. area if left out.
  3420. * `get_light_data([buffer])`: Gets the light data read into the
  3421. `VoxelManip` object
  3422. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3423. `255`.
  3424. * Each value is the bitwise combination of day and night light values
  3425. (`0` to `15` each).
  3426. * `light = day + (night * 16)`
  3427. * If the param `buffer` is present, this table will be used to store the
  3428. result instead.
  3429. * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
  3430. in the `VoxelManip`.
  3431. * expects lighting data in the same format that `get_light_data()` returns
  3432. * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
  3433. `VoxelManip` object.
  3434. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3435. `255`.
  3436. * If the param `buffer` is present, this table will be used to store the
  3437. result instead.
  3438. * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
  3439. the `VoxelManip`.
  3440. * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the
  3441. `VoxelManip`.
  3442. * To be used only by a `VoxelManip` object from
  3443. `minetest.get_mapgen_object`.
  3444. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3445. area if left out or nil. For almost all uses these should be left out
  3446. or nil to use the default.
  3447. * `propagate_shadow` is an optional boolean deciding whether shadows in a
  3448. generated mapchunk above are propagated down into the mapchunk, defaults
  3449. to `true` if left out.
  3450. * `update_liquids()`: Update liquid flow
  3451. * `was_modified()`: Returns `true` or `false` if the data in the voxel
  3452. manipulator had been modified since the last read from map, due to a call to
  3453. `minetest.set_data()` on the loaded area elsewhere.
  3454. * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
  3455. `VoxelArea`
  3456. -----------
  3457. A helper class for voxel areas.
  3458. It can be created via `VoxelArea(pmin, pmax)` or
  3459. `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
  3460. The coordinates are *inclusive*, like most other things in Minetest.
  3461. ### Methods
  3462. * `getExtent()`: returns a 3D vector containing the size of the area formed by
  3463. `MinEdge` and `MaxEdge`.
  3464. * `getVolume()`: returns the volume of the area formed by `MinEdge` and
  3465. `MaxEdge`.
  3466. * `index(x, y, z)`: returns the index of an absolute position in a flat array
  3467. starting at `1`.
  3468. * `x`, `y` and `z` must be integers to avoid an incorrect index result.
  3469. * The position (x, y, z) is not checked for being inside the area volume,
  3470. being outside can cause an incorrect index result.
  3471. * Useful for things like `VoxelManip`, raw Schematic specifiers,
  3472. `PerlinNoiseMap:get2d`/`3dMap`, and so on.
  3473. * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
  3474. * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
  3475. is not checked for being inside the area volume.
  3476. * `position(i)`: returns the absolute position vector corresponding to index
  3477. `i`.
  3478. * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
  3479. `MinEdge` and `MaxEdge`.
  3480. * `containsp(p)`: same as above, except takes a vector
  3481. * `containsi(i)`: same as above, except takes an index `i`
  3482. * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
  3483. indices.
  3484. * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
  3485. `[z [y [x]]]`.
  3486. * `iterp(minp, maxp)`: same as above, except takes a vector
  3487. ### Y stride and z stride of a flat array
  3488. For a particular position in a voxel area, whose flat array index is known,
  3489. it is often useful to know the index of a neighboring or nearby position.
  3490. The table below shows the changes of index required for 1 node movements along
  3491. the axes in a voxel area:
  3492. Movement Change of index
  3493. +x +1
  3494. -x -1
  3495. +y +ystride
  3496. -y -ystride
  3497. +z +zstride
  3498. -z -zstride
  3499. If, for example:
  3500. local area = VoxelArea(emin, emax)
  3501. The values of `ystride` and `zstride` can be obtained using `area.ystride` and
  3502. `area.zstride`.
  3503. Mapgen objects
  3504. ==============
  3505. A mapgen object is a construct used in map generation. Mapgen objects can be
  3506. used by an `on_generate` callback to speed up operations by avoiding
  3507. unnecessary recalculations, these can be retrieved using the
  3508. `minetest.get_mapgen_object()` function. If the requested Mapgen object is
  3509. unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
  3510. callback, `nil` is returned.
  3511. The following Mapgen objects are currently available:
  3512. ### `voxelmanip`
  3513. This returns three values; the `VoxelManip` object to be used, minimum and
  3514. maximum emerged position, in that order. All mapgens support this object.
  3515. ### `heightmap`
  3516. Returns an array containing the y coordinates of the ground levels of nodes in
  3517. the most recently generated chunk by the current mapgen.
  3518. ### `biomemap`
  3519. Returns an array containing the biome IDs of nodes in the most recently
  3520. generated chunk by the current mapgen.
  3521. ### `heatmap`
  3522. Returns an array containing the temperature values of nodes in the most
  3523. recently generated chunk by the current mapgen.
  3524. ### `humiditymap`
  3525. Returns an array containing the humidity values of nodes in the most recently
  3526. generated chunk by the current mapgen.
  3527. ### `gennotify`
  3528. Returns a table mapping requested generation notification types to arrays of
  3529. positions at which the corresponding generated structures are located within
  3530. the current chunk. To enable the capture of positions of interest to be recorded
  3531. call `minetest.set_gen_notify()` first.
  3532. Possible fields of the returned table are:
  3533. * `dungeon`: bottom center position of dungeon rooms
  3534. * `temple`: as above but for desert temples (mgv6 only)
  3535. * `cave_begin`
  3536. * `cave_end`
  3537. * `large_cave_begin`
  3538. * `large_cave_end`
  3539. * `decoration#id` (see below)
  3540. Decorations have a key in the format of `"decoration#id"`, where `id` is the
  3541. numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
  3542. For example, `decoration#123`.
  3543. The returned positions are the ground surface 'place_on' nodes,
  3544. not the decorations themselves. A 'simple' type decoration is often 1
  3545. node above the returned position and possibly displaced by 'place_offset_y'.
  3546. Registered entities
  3547. ===================
  3548. Functions receive a "luaentity" table as `self`:
  3549. * It has the member `name`, which is the registered name `("mod:thing")`
  3550. * It has the member `object`, which is an `ObjectRef` pointing to the object
  3551. * The original prototype is visible directly via a metatable
  3552. Callbacks:
  3553. * `on_activate(self, staticdata, dtime_s)`
  3554. * Called when the object is instantiated.
  3555. * `dtime_s` is the time passed since the object was unloaded, which can be
  3556. used for updating the entity state.
  3557. * `on_deactivate(self, removal)`
  3558. * Called when the object is about to get removed or unloaded.
  3559. * `removal`: boolean indicating whether the object is about to get removed.
  3560. Calling `object:remove()` on an active object will call this with `removal=true`.
  3561. The mapblock the entity resides in being unloaded will call this with `removal=false`.
  3562. * Note that this won't be called if the object hasn't been activated in the first place.
  3563. In particular, `minetest.clear_objects({mode = "full"})` won't call this,
  3564. whereas `minetest.clear_objects({mode = "quick"})` might call this.
  3565. * `on_step(self, dtime, moveresult)`
  3566. * Called on every server tick, after movement and collision processing.
  3567. * `dtime`: elapsed time since last call
  3568. * `moveresult`: table with collision info (only available if physical=true)
  3569. * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
  3570. * Called when somebody punches the object.
  3571. * Note that you probably want to handle most punches using the automatic
  3572. armor group system.
  3573. * `puncher`: an `ObjectRef` (can be `nil`)
  3574. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3575. (can be `nil`).
  3576. * `tool_capabilities`: capability table of used item (can be `nil`)
  3577. * `dir`: unit vector of direction of punch. Always defined. Points from the
  3578. puncher to the punched.
  3579. * `damage`: damage that will be done to entity.
  3580. * Can return `true` to prevent the default damage mechanism.
  3581. * `on_death(self, killer)`
  3582. * Called when the object dies.
  3583. * `killer`: an `ObjectRef` (can be `nil`)
  3584. * `on_rightclick(self, clicker)`
  3585. * Called when `clicker` pressed the 'place/use' key while pointing
  3586. to the object (not necessarily an actual rightclick)
  3587. * `clicker`: an `ObjectRef` (may or may not be a player)
  3588. * `on_attach_child(self, child)`
  3589. * `child`: an `ObjectRef` of the child that attaches
  3590. * `on_detach_child(self, child)`
  3591. * `child`: an `ObjectRef` of the child that detaches
  3592. * `on_detach(self, parent)`
  3593. * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
  3594. * This happens before the parent object is removed from the world
  3595. * `get_staticdata(self)`
  3596. * Should return a string that will be passed to `on_activate` when the
  3597. object is instantiated the next time.
  3598. Collision info passed to `on_step` (`moveresult` argument):
  3599. {
  3600. touching_ground = boolean,
  3601. -- Note that touching_ground is only true if the entity was moving and
  3602. -- collided with ground.
  3603. collides = boolean,
  3604. standing_on_object = boolean,
  3605. collisions = {
  3606. {
  3607. type = string, -- "node" or "object",
  3608. axis = string, -- "x", "y" or "z"
  3609. node_pos = vector, -- if type is "node"
  3610. object = ObjectRef, -- if type is "object"
  3611. old_velocity = vector,
  3612. new_velocity = vector,
  3613. },
  3614. ...
  3615. }
  3616. -- `collisions` does not contain data of unloaded mapblock collisions
  3617. -- or when the velocity changes are negligibly small
  3618. }
  3619. L-system trees
  3620. ==============
  3621. Tree definition
  3622. ---------------
  3623. treedef={
  3624. axiom, --string initial tree axiom
  3625. rules_a, --string rules set A
  3626. rules_b, --string rules set B
  3627. rules_c, --string rules set C
  3628. rules_d, --string rules set D
  3629. trunk, --string trunk node name
  3630. leaves, --string leaves node name
  3631. leaves2, --string secondary leaves node name
  3632. leaves2_chance,--num chance (0-100) to replace leaves with leaves2
  3633. angle, --num angle in deg
  3634. iterations, --num max # of iterations, usually 2 -5
  3635. random_level, --num factor to lower number of iterations, usually 0 - 3
  3636. trunk_type, --string single/double/crossed) type of trunk: 1 node,
  3637. -- 2x2 nodes or 3x3 in cross shape
  3638. thin_branches, --boolean true -> use thin (1 node) branches
  3639. fruit, --string fruit node name
  3640. fruit_chance, --num chance (0-100) to replace leaves with fruit node
  3641. seed, --num random seed, if no seed is provided, the engine
  3642. will create one.
  3643. }
  3644. Key for special L-System symbols used in axioms
  3645. -----------------------------------------------
  3646. * `G`: move forward one unit with the pen up
  3647. * `F`: move forward one unit with the pen down drawing trunks and branches
  3648. * `f`: move forward one unit with the pen down drawing leaves (100% chance)
  3649. * `T`: move forward one unit with the pen down drawing trunks only
  3650. * `R`: move forward one unit with the pen down placing fruit
  3651. * `A`: replace with rules set A
  3652. * `B`: replace with rules set B
  3653. * `C`: replace with rules set C
  3654. * `D`: replace with rules set D
  3655. * `a`: replace with rules set A, chance 90%
  3656. * `b`: replace with rules set B, chance 80%
  3657. * `c`: replace with rules set C, chance 70%
  3658. * `d`: replace with rules set D, chance 60%
  3659. * `+`: yaw the turtle right by `angle` parameter
  3660. * `-`: yaw the turtle left by `angle` parameter
  3661. * `&`: pitch the turtle down by `angle` parameter
  3662. * `^`: pitch the turtle up by `angle` parameter
  3663. * `/`: roll the turtle to the right by `angle` parameter
  3664. * `*`: roll the turtle to the left by `angle` parameter
  3665. * `[`: save in stack current state info
  3666. * `]`: recover from stack state info
  3667. Example
  3668. -------
  3669. Spawn a small apple tree:
  3670. pos = {x=230,y=20,z=4}
  3671. apple_tree={
  3672. axiom="FFFFFAFFBF",
  3673. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  3674. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  3675. trunk="default:tree",
  3676. leaves="default:leaves",
  3677. angle=30,
  3678. iterations=2,
  3679. random_level=0,
  3680. trunk_type="single",
  3681. thin_branches=true,
  3682. fruit_chance=10,
  3683. fruit="default:apple"
  3684. }
  3685. minetest.spawn_tree(pos,apple_tree)
  3686. Privileges
  3687. ==========
  3688. Privileges provide a means for server administrators to give certain players
  3689. access to special abilities in the engine, games or mods.
  3690. For example, game moderators may need to travel instantly to any place in the world,
  3691. this ability is implemented in `/teleport` command which requires `teleport` privilege.
  3692. Registering privileges
  3693. ----------------------
  3694. A mod can register a custom privilege using `minetest.register_privilege` function
  3695. to give server administrators fine-grained access control over mod functionality.
  3696. For consistency and practical reasons, privileges should strictly increase the abilities of the user.
  3697. Do not register custom privileges that e.g. restrict the player from certain in-game actions.
  3698. Checking privileges
  3699. -------------------
  3700. A mod can call `minetest.check_player_privs` to test whether a player has privileges
  3701. to perform an operation.
  3702. Also, when registering a chat command with `minetest.register_chatcommand` a mod can
  3703. declare privileges that the command requires using the `privs` field of the command
  3704. definition.
  3705. Managing player privileges
  3706. --------------------------
  3707. A mod can update player privileges using `minetest.set_player_privs` function.
  3708. Players holding the `privs` privilege can see and manage privileges for all
  3709. players on the server.
  3710. A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
  3711. and `minetest.register_on_priv_revoke` functions.
  3712. Built-in privileges
  3713. -------------------
  3714. Minetest includes a set of built-in privileges that control capabilities
  3715. provided by the Minetest engine and can be used by mods:
  3716. * Basic privileges are normally granted to all players:
  3717. * `shout`: can communicate using the in-game chat.
  3718. * `interact`: can modify the world by digging, building and interacting
  3719. with the nodes, entities and other players. Players without the `interact`
  3720. privilege can only travel and observe the world.
  3721. * Advanced privileges allow bypassing certain aspects of the gameplay:
  3722. * `fast`: can use "fast mode" to move with maximum speed.
  3723. * `fly`: can use "fly mode" to move freely above the ground without falling.
  3724. * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
  3725. * `teleport`: can use `/teleport` command to move to any point in the world.
  3726. * `creative`: can access creative inventory.
  3727. * `bring`: can teleport other players to oneself.
  3728. * `give`: can use `/give` and `/giveme` commands to give any item
  3729. in the game to oneself or others.
  3730. * `settime`: can use `/time` command to change current in-game time.
  3731. * `debug`: can enable wireframe rendering mode.
  3732. * Security-related privileges:
  3733. * `privs`: can modify privileges of the players using `/grant[me]` and
  3734. `/revoke[me]` commands.
  3735. * `basic_privs`: can grant and revoke basic privileges as defined by
  3736. the `basic_privs` setting.
  3737. * `kick`: can kick other players from the server using `/kick` command.
  3738. * `ban`: can ban other players using `/ban` command.
  3739. * `password`: can use `/setpassword` and `/clearpassword` commands
  3740. to manage players' passwords.
  3741. * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
  3742. it is only an implementation suggestion for games.
  3743. * Administrative privileges:
  3744. * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
  3745. commands. Can clear inventory of other players using `/clearinv` command.
  3746. * `rollback`: can use `/rollback_check` and `/rollback` commands.
  3747. Related settings
  3748. ----------------
  3749. Minetest includes the following settings to control behavior of privileges:
  3750. * `default_privs`: defines privileges granted to new players.
  3751. * `basic_privs`: defines privileges that can be granted/revoked by players having
  3752. the `basic_privs` privilege. This can be used, for example, to give
  3753. limited moderation powers to selected users.
  3754. 'minetest' namespace reference
  3755. ==============================
  3756. Utilities
  3757. ---------
  3758. * `minetest.get_current_modname()`: returns the currently loading mod's name,
  3759. when loading a mod.
  3760. * `minetest.get_modpath(modname)`: returns the directory path for a mod,
  3761. e.g. `"/home/user/.minetest/usermods/modname"`.
  3762. * Returns nil if the mod is not enabled or does not exist (not installed).
  3763. * Works regardless of whether the mod has been loaded yet.
  3764. * Useful for loading additional `.lua` modules or static data from a mod,
  3765. or checking if a mod is enabled.
  3766. * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
  3767. * Does not include disabled mods, even if they are installed.
  3768. * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
  3769. * Useful for storing custom data
  3770. * `minetest.is_singleplayer()`
  3771. * `minetest.features`: Table containing API feature flags
  3772. {
  3773. glasslike_framed = true, -- 0.4.7
  3774. nodebox_as_selectionbox = true, -- 0.4.7
  3775. get_all_craft_recipes_works = true, -- 0.4.7
  3776. -- The transparency channel of textures can optionally be used on
  3777. -- nodes (0.4.7)
  3778. use_texture_alpha = true,
  3779. -- Tree and grass ABMs are no longer done from C++ (0.4.8)
  3780. no_legacy_abms = true,
  3781. -- Texture grouping is possible using parentheses (0.4.11)
  3782. texture_names_parens = true,
  3783. -- Unique Area ID for AreaStore:insert_area (0.4.14)
  3784. area_store_custom_ids = true,
  3785. -- add_entity supports passing initial staticdata to on_activate
  3786. -- (0.4.16)
  3787. add_entity_with_staticdata = true,
  3788. -- Chat messages are no longer predicted (0.4.16)
  3789. no_chat_message_prediction = true,
  3790. -- The transparency channel of textures can optionally be used on
  3791. -- objects (ie: players and lua entities) (5.0.0)
  3792. object_use_texture_alpha = true,
  3793. -- Object selectionbox is settable independently from collisionbox
  3794. -- (5.0.0)
  3795. object_independent_selectionbox = true,
  3796. -- Specifies whether binary data can be uploaded or downloaded using
  3797. -- the HTTP API (5.1.0)
  3798. httpfetch_binary_data = true,
  3799. -- Whether formspec_version[<version>] may be used (5.1.0)
  3800. formspec_version_element = true,
  3801. -- Whether AreaStore's IDs are kept on save/load (5.1.0)
  3802. area_store_persistent_ids = true,
  3803. -- Whether minetest.find_path is functional (5.2.0)
  3804. pathfinder_works = true,
  3805. -- Whether Collision info is available to an objects' on_step (5.3.0)
  3806. object_step_has_moveresult = true,
  3807. -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
  3808. direct_velocity_on_players = true,
  3809. -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
  3810. use_texture_alpha_string_modes = true,
  3811. -- degrotate param2 rotates in units of 1.5° instead of 2°
  3812. -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
  3813. degrotate_240_steps = true,
  3814. -- ABM supports min_y and max_y fields in definition (5.5.0)
  3815. abm_min_max_y = true,
  3816. -- dynamic_add_media supports passing a table with options (5.5.0)
  3817. dynamic_add_media_table = true,
  3818. -- particlespawners support texpools and animation of properties,
  3819. -- particle textures support smooth fade and scale animations, and
  3820. -- sprite-sheet particle animations can by synced to the lifetime
  3821. -- of individual particles (5.6.0)
  3822. particlespawner_tweenable = true,
  3823. -- allows get_sky to return a table instead of separate values (5.6.0)
  3824. get_sky_as_table = true,
  3825. -- VoxelManip:get_light_data accepts an optional buffer argument (5.7.0)
  3826. get_light_data_buffer = true,
  3827. -- When using a mod storage backend that is not "files" or "dummy",
  3828. -- the amount of data in mod storage is not constrained by
  3829. -- the amount of RAM available. (5.7.0)
  3830. mod_storage_on_disk = true,
  3831. -- "zstd" method for compress/decompress (5.7.0)
  3832. compress_zstd = true,
  3833. }
  3834. * `minetest.has_feature(arg)`: returns `boolean, missing_features`
  3835. * `arg`: string or table in format `{foo=true, bar=true}`
  3836. * `missing_features`: `{foo=true, bar=true}`
  3837. * `minetest.get_player_information(player_name)`: Table containing information
  3838. about a player. Example return value:
  3839. {
  3840. address = "127.0.0.1", -- IP address of client
  3841. ip_version = 4, -- IPv4 / IPv6
  3842. connection_uptime = 200, -- seconds since client connected
  3843. protocol_version = 32, -- protocol version used by client
  3844. formspec_version = 2, -- supported formspec version
  3845. lang_code = "fr" -- Language code used for translation
  3846. -- the following keys can be missing if no stats have been collected yet
  3847. min_rtt = 0.01, -- minimum round trip time
  3848. max_rtt = 0.2, -- maximum round trip time
  3849. avg_rtt = 0.02, -- average round trip time
  3850. min_jitter = 0.01, -- minimum packet time jitter
  3851. max_jitter = 0.5, -- maximum packet time jitter
  3852. avg_jitter = 0.03, -- average packet time jitter
  3853. -- the following information is available in a debug build only!!!
  3854. -- DO NOT USE IN MODS
  3855. --ser_vers = 26, -- serialization version used by client
  3856. --major = 0, -- major version number
  3857. --minor = 4, -- minor version number
  3858. --patch = 10, -- patch version number
  3859. --vers_string = "0.4.9-git", -- full version string
  3860. --state = "Active" -- current client state
  3861. }
  3862. * `minetest.mkdir(path)`: returns success.
  3863. * Creates a directory specified by `path`, creating parent directories
  3864. if they don't exist.
  3865. * `minetest.rmdir(path, recursive)`: returns success.
  3866. * Removes a directory specified by `path`.
  3867. * If `recursive` is set to `true`, the directory is recursively removed.
  3868. Otherwise, the directory will only be removed if it is empty.
  3869. * Returns true on success, false on failure.
  3870. * `minetest.cpdir(source, destination)`: returns success.
  3871. * Copies a directory specified by `path` to `destination`
  3872. * Any files in `destination` will be overwritten if they already exist.
  3873. * Returns true on success, false on failure.
  3874. * `minetest.mvdir(source, destination)`: returns success.
  3875. * Moves a directory specified by `path` to `destination`.
  3876. * If the `destination` is a non-empty directory, then the move will fail.
  3877. * Returns true on success, false on failure.
  3878. * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
  3879. * is_dir is one of:
  3880. * nil: return all entries,
  3881. * true: return only subdirectory names, or
  3882. * false: return only file names.
  3883. * `minetest.safe_file_write(path, content)`: returns boolean indicating success
  3884. * Replaces contents of file at path with new contents in a safe (atomic)
  3885. way. Use this instead of below code when writing e.g. database files:
  3886. `local f = io.open(path, "wb"); f:write(content); f:close()`
  3887. * `minetest.get_version()`: returns a table containing components of the
  3888. engine version. Components:
  3889. * `project`: Name of the project, eg, "Minetest"
  3890. * `string`: Simple version, eg, "1.2.3-dev"
  3891. * `hash`: Full git version (only set if available),
  3892. eg, "1.2.3-dev-01234567-dirty".
  3893. * `is_dev`: Boolean value indicating whether it's a development build
  3894. Use this for informational purposes only. The information in the returned
  3895. table does not represent the capabilities of the engine, nor is it
  3896. reliable or verifiable. Compatible forks will have a different name and
  3897. version entirely. To check for the presence of engine features, test
  3898. whether the functions exported by the wanted features exist. For example:
  3899. `if minetest.check_for_falling then ... end`.
  3900. * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
  3901. * `data`: string of data to hash
  3902. * `raw`: return raw bytes instead of hex digits, default: false
  3903. * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
  3904. ColorString. If the ColorSpec is invalid, returns `nil`.
  3905. * `colorspec`: The ColorSpec to convert
  3906. * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
  3907. string of four bytes in an RGBA layout, returned as a string.
  3908. * `colorspec`: The ColorSpec to convert
  3909. * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
  3910. image and return it in string form.
  3911. * `width`: Width of the image
  3912. * `height`: Height of the image
  3913. * `data`: Image data, one of:
  3914. * array table of ColorSpec, length must be width*height
  3915. * string with raw RGBA pixels, length must be width*height*4
  3916. * `compression`: Optional zlib compression level, number in range 0 to 9.
  3917. The data is one-dimensional, starting in the upper left corner of the image
  3918. and laid out in scanlines going from left to right, then top to bottom.
  3919. Please note that it's not safe to use string.char to generate raw data,
  3920. use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
  3921. The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
  3922. You may use this to procedurally generate textures during server init.
  3923. Logging
  3924. -------
  3925. * `minetest.debug(...)`
  3926. * Equivalent to `minetest.log(table.concat({...}, "\t"))`
  3927. * `minetest.log([level,] text)`
  3928. * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
  3929. `"info"`, or `"verbose"`. Default is `"none"`.
  3930. Registration functions
  3931. ----------------------
  3932. Call these functions only at load time!
  3933. ### Environment
  3934. * `minetest.register_node(name, node definition)`
  3935. * `minetest.register_craftitem(name, item definition)`
  3936. * `minetest.register_tool(name, item definition)`
  3937. * `minetest.override_item(name, redefinition)`
  3938. * Overrides fields of an item registered with register_node/tool/craftitem.
  3939. * Note: Item must already be defined, (opt)depend on the mod defining it.
  3940. * Example: `minetest.override_item("default:mese",
  3941. {light_source=minetest.LIGHT_MAX})`
  3942. * `minetest.unregister_item(name)`
  3943. * Unregisters the item from the engine, and deletes the entry with key
  3944. `name` from `minetest.registered_items` and from the associated item table
  3945. according to its nature: `minetest.registered_nodes`, etc.
  3946. * `minetest.register_entity(name, entity definition)`
  3947. * `minetest.register_abm(abm definition)`
  3948. * `minetest.register_lbm(lbm definition)`
  3949. * `minetest.register_alias(alias, original_name)`
  3950. * Also use this to set the 'mapgen aliases' needed in a game for the core
  3951. mapgens. See [Mapgen aliases] section above.
  3952. * `minetest.register_alias_force(alias, original_name)`
  3953. * `minetest.register_ore(ore definition)`
  3954. * Returns an integer object handle uniquely identifying the registered
  3955. ore on success.
  3956. * The order of ore registrations determines the order of ore generation.
  3957. * `minetest.register_biome(biome definition)`
  3958. * Returns an integer object handle uniquely identifying the registered
  3959. biome on success. To get the biome ID, use `minetest.get_biome_id`.
  3960. * `minetest.unregister_biome(name)`
  3961. * Unregisters the biome from the engine, and deletes the entry with key
  3962. `name` from `minetest.registered_biomes`.
  3963. * Warning: This alters the biome to biome ID correspondences, so any
  3964. decorations or ores using the 'biomes' field must afterwards be cleared
  3965. and re-registered.
  3966. * `minetest.register_decoration(decoration definition)`
  3967. * Returns an integer object handle uniquely identifying the registered
  3968. decoration on success. To get the decoration ID, use
  3969. `minetest.get_decoration_id`.
  3970. * The order of decoration registrations determines the order of decoration
  3971. generation.
  3972. * `minetest.register_schematic(schematic definition)`
  3973. * Returns an integer object handle uniquely identifying the registered
  3974. schematic on success.
  3975. * If the schematic is loaded from a file, the `name` field is set to the
  3976. filename.
  3977. * If the function is called when loading the mod, and `name` is a relative
  3978. path, then the current mod path will be prepended to the schematic
  3979. filename.
  3980. * `minetest.clear_registered_biomes()`
  3981. * Clears all biomes currently registered.
  3982. * Warning: Clearing and re-registering biomes alters the biome to biome ID
  3983. correspondences, so any decorations or ores using the 'biomes' field must
  3984. afterwards be cleared and re-registered.
  3985. * `minetest.clear_registered_decorations()`
  3986. * Clears all decorations currently registered.
  3987. * `minetest.clear_registered_ores()`
  3988. * Clears all ores currently registered.
  3989. * `minetest.clear_registered_schematics()`
  3990. * Clears all schematics currently registered.
  3991. ### Gameplay
  3992. * `minetest.register_craft(recipe)`
  3993. * Check recipe table syntax for different types below.
  3994. * `minetest.clear_craft(recipe)`
  3995. * Will erase existing craft based either on output item or on input recipe.
  3996. * Specify either output or input only. If you specify both, input will be
  3997. ignored. For input use the same recipe table syntax as for
  3998. `minetest.register_craft(recipe)`. For output specify only the item,
  3999. without a quantity.
  4000. * Returns false if no erase candidate could be found, otherwise returns true.
  4001. * **Warning**! The type field ("shaped", "cooking" or any other) will be
  4002. ignored if the recipe contains output. Erasing is then done independently
  4003. from the crafting method.
  4004. * `minetest.register_chatcommand(cmd, chatcommand definition)`
  4005. * `minetest.override_chatcommand(name, redefinition)`
  4006. * Overrides fields of a chatcommand registered with `register_chatcommand`.
  4007. * `minetest.unregister_chatcommand(name)`
  4008. * Unregisters a chatcommands registered with `register_chatcommand`.
  4009. * `minetest.register_privilege(name, definition)`
  4010. * `definition` can be a description or a definition table (see [Privilege
  4011. definition]).
  4012. * If it is a description, the priv will be granted to singleplayer and admin
  4013. by default.
  4014. * To allow players with `basic_privs` to grant, see the `basic_privs`
  4015. minetest.conf setting.
  4016. * `minetest.register_authentication_handler(authentication handler definition)`
  4017. * Registers an auth handler that overrides the builtin one.
  4018. * This function can be called by a single mod once only.
  4019. Global callback registration functions
  4020. --------------------------------------
  4021. Call these functions only at load time!
  4022. * `minetest.register_globalstep(function(dtime))`
  4023. * Called every server step, usually interval of 0.1s
  4024. * `minetest.register_on_mods_loaded(function())`
  4025. * Called after mods have finished loading and before the media is cached or the
  4026. aliases handled.
  4027. * `minetest.register_on_shutdown(function())`
  4028. * Called before server shutdown
  4029. * **Warning**: If the server terminates abnormally (i.e. crashes), the
  4030. registered callbacks **will likely not be run**. Data should be saved at
  4031. semi-frequent intervals as well as on server shutdown.
  4032. * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
  4033. * Called when a node has been placed
  4034. * If return `true` no item is taken from `itemstack`
  4035. * `placer` may be any valid ObjectRef or nil.
  4036. * **Not recommended**; use `on_construct` or `after_place_node` in node
  4037. definition whenever possible.
  4038. * `minetest.register_on_dignode(function(pos, oldnode, digger))`
  4039. * Called when a node has been dug.
  4040. * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
  4041. definition whenever possible.
  4042. * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
  4043. * Called when a node is punched
  4044. * `minetest.register_on_generated(function(minp, maxp, blockseed))`
  4045. * Called after generating a piece of world. Modifying nodes inside the area
  4046. is a bit faster than usual.
  4047. * `minetest.register_on_newplayer(function(ObjectRef))`
  4048. * Called when a new player enters the world for the first time
  4049. * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
  4050. * Called when a player is punched
  4051. * Note: This callback is invoked even if the punched player is dead.
  4052. * `player`: ObjectRef - Player that was punched
  4053. * `hitter`: ObjectRef - Player that hit
  4054. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  4055. (can be nil).
  4056. * `tool_capabilities`: Capability table of used item (can be nil)
  4057. * `dir`: Unit vector of direction of punch. Always defined. Points from
  4058. the puncher to the punched.
  4059. * `damage`: Number that represents the damage calculated by the engine
  4060. * should return `true` to prevent the default damage mechanism
  4061. * `minetest.register_on_rightclickplayer(function(player, clicker))`
  4062. * Called when the 'place/use' key was used while pointing a player
  4063. (not necessarily an actual rightclick)
  4064. * `player`: ObjectRef - Player that is acted upon
  4065. * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
  4066. * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
  4067. * Called when the player gets damaged or healed
  4068. * `player`: ObjectRef of the player
  4069. * `hp_change`: the amount of change. Negative when it is damage.
  4070. * `reason`: a PlayerHPChangeReason table.
  4071. * The `type` field will have one of the following values:
  4072. * `set_hp`: A mod or the engine called `set_hp` without
  4073. giving a type - use this for custom damage types.
  4074. * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
  4075. * `fall`
  4076. * `node_damage`: `damage_per_second` from a neighboring node.
  4077. `reason.node` will hold the node name or nil.
  4078. * `drown`
  4079. * `respawn`
  4080. * Any of the above types may have additional fields from mods.
  4081. * `reason.from` will be `mod` or `engine`.
  4082. * `modifier`: when true, the function should return the actual `hp_change`.
  4083. Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
  4084. Modifiers can return true as a second argument to stop the execution of further functions.
  4085. Non-modifiers receive the final HP change calculated by the modifiers.
  4086. * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
  4087. * Called when a player dies
  4088. * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
  4089. * `minetest.register_on_respawnplayer(function(ObjectRef))`
  4090. * Called when player is to be respawned
  4091. * Called _before_ repositioning of player occurs
  4092. * return true in func to disable regular player placement
  4093. * `minetest.register_on_prejoinplayer(function(name, ip))`
  4094. * Called when a client connects to the server, prior to authentication
  4095. * If it returns a string, the client is disconnected with that string as
  4096. reason.
  4097. * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
  4098. * Called when a player joins the game
  4099. * `last_login`: The timestamp of the previous login, or nil if player is new
  4100. * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
  4101. * Called when a player leaves the game
  4102. * `timed_out`: True for timeout, false for other reasons.
  4103. * `minetest.register_on_authplayer(function(name, ip, is_success))`
  4104. * Called when a client attempts to log into an account.
  4105. * `name`: The name of the account being authenticated.
  4106. * `ip`: The IP address of the client
  4107. * `is_success`: Whether the client was successfully authenticated
  4108. * For newly registered accounts, `is_success` will always be true
  4109. * `minetest.register_on_auth_fail(function(name, ip))`
  4110. * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
  4111. * `minetest.register_on_cheat(function(ObjectRef, cheat))`
  4112. * Called when a player cheats
  4113. * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
  4114. * `moved_too_fast`
  4115. * `interacted_too_far`
  4116. * `interacted_with_self`
  4117. * `interacted_while_dead`
  4118. * `finished_unknown_dig`
  4119. * `dug_unbreakable`
  4120. * `dug_too_fast`
  4121. * `minetest.register_on_chat_message(function(name, message))`
  4122. * Called always when a player says something
  4123. * Return `true` to mark the message as handled, which means that it will
  4124. not be sent to other players.
  4125. * `minetest.register_on_chatcommand(function(name, command, params))`
  4126. * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
  4127. is checked to see if the command exists, but after the input is parsed.
  4128. * Return `true` to mark the command as handled, which means that the default
  4129. handlers will be prevented.
  4130. * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
  4131. * Called when the server received input from `player` in a formspec with
  4132. the given `formname`. Specifically, this is called on any of the
  4133. following events:
  4134. * a button was pressed,
  4135. * Enter was pressed while the focus was on a text field
  4136. * a checkbox was toggled,
  4137. * something was selected in a dropdown list,
  4138. * a different tab was selected,
  4139. * selection was changed in a textlist or table,
  4140. * an entry was double-clicked in a textlist or table,
  4141. * a scrollbar was moved, or
  4142. * the form was actively closed by the player.
  4143. * Fields are sent for formspec elements which define a field. `fields`
  4144. is a table containing each formspecs element value (as string), with
  4145. the `name` parameter as index for each. The value depends on the
  4146. formspec element type:
  4147. * `animated_image`: Returns the index of the current frame.
  4148. * `button` and variants: If pressed, contains the user-facing button
  4149. text as value. If not pressed, is `nil`
  4150. * `field`, `textarea` and variants: Text in the field
  4151. * `dropdown`: Either the index or value, depending on the `index event`
  4152. dropdown argument.
  4153. * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
  4154. * `checkbox`: `"true"` if checked, `"false"` if unchecked
  4155. * `textlist`: See `minetest.explode_textlist_event`
  4156. * `table`: See `minetest.explode_table_event`
  4157. * `scrollbar`: See `minetest.explode_scrollbar_event`
  4158. * Special case: `["quit"]="true"` is sent when the user actively
  4159. closed the form by mouse click, keypress or through a button_exit[]
  4160. element.
  4161. * Special case: `["key_enter"]="true"` is sent when the user pressed
  4162. the Enter key and the focus was either nowhere (causing the formspec
  4163. to be closed) or on a button. If the focus was on a text field,
  4164. additionally, the index `key_enter_field` contains the name of the
  4165. text field. See also: `field_close_on_enter`.
  4166. * Newest functions are called first
  4167. * If function returns `true`, remaining functions are not called
  4168. * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
  4169. * Called when `player` crafts something
  4170. * `itemstack` is the output
  4171. * `old_craft_grid` contains the recipe (Note: the one in the inventory is
  4172. cleared).
  4173. * `craft_inv` is the inventory with the crafting grid
  4174. * Return either an `ItemStack`, to replace the output, or `nil`, to not
  4175. modify it.
  4176. * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
  4177. * The same as before, except that it is called before the player crafts, to
  4178. make craft prediction, and it should not change anything.
  4179. * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
  4180. * Determines how much of a stack may be taken, put or moved to a
  4181. player inventory.
  4182. * `player` (type `ObjectRef`) is the player who modified the inventory
  4183. `inventory` (type `InvRef`).
  4184. * List of possible `action` (string) values and their
  4185. `inventory_info` (table) contents:
  4186. * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  4187. * `put`: `{listname=string, index=number, stack=ItemStack}`
  4188. * `take`: Same as `put`
  4189. * Return a numeric value to limit the amount of items to be taken, put or
  4190. moved. A value of `-1` for `take` will make the source stack infinite.
  4191. * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
  4192. * Called after a take, put or move event from/to/in a player inventory
  4193. * Function arguments: see `minetest.register_allow_player_inventory_action`
  4194. * Does not accept or handle any return value.
  4195. * `minetest.register_on_protection_violation(function(pos, name))`
  4196. * Called by `builtin` and mods when a player violates protection at a
  4197. position (eg, digs a node or punches a protected entity).
  4198. * The registered functions can be called using
  4199. `minetest.record_protection_violation`.
  4200. * The provided function should check that the position is protected by the
  4201. mod calling this function before it prints a message, if it does, to
  4202. allow for multiple protection mods.
  4203. * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
  4204. * Called when an item is eaten, by `minetest.item_eat`
  4205. * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
  4206. * `minetest.register_on_item_pickup(function(itemstack, picker, pointed_thing, time_from_last_punch, ...))`
  4207. * Called by `minetest.item_pickup` before an item is picked up.
  4208. * Function is added to `minetest.registered_on_item_pickups`.
  4209. * Oldest functions are called first.
  4210. * Parameters are the same as in the `on_pickup` callback.
  4211. * Return an itemstack to cancel the default item pick-up response (i.e.: adding
  4212. the item into inventory).
  4213. * `minetest.register_on_priv_grant(function(name, granter, priv))`
  4214. * Called when `granter` grants the priv `priv` to `name`.
  4215. * Note that the callback will be called twice if it's done by a player,
  4216. once with granter being the player name, and again with granter being nil.
  4217. * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
  4218. * Called when `revoker` revokes the priv `priv` from `name`.
  4219. * Note that the callback will be called twice if it's done by a player,
  4220. once with revoker being the player name, and again with revoker being nil.
  4221. * `minetest.register_can_bypass_userlimit(function(name, ip))`
  4222. * Called when `name` user connects with `ip`.
  4223. * Return `true` to by pass the player limit
  4224. * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
  4225. * Called when an incoming mod channel message is received
  4226. * You should have joined some channels to receive events.
  4227. * If message comes from a server mod, `sender` field is an empty string.
  4228. * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
  4229. * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
  4230. engine's liquid transformation process.
  4231. * `pos_list` is an array of all modified positions.
  4232. * `node_list` is an array of the old node that was previously at the position
  4233. with the corresponding index in pos_list.
  4234. Setting-related
  4235. ---------------
  4236. * `minetest.settings`: Settings object containing all of the settings from the
  4237. main config file (`minetest.conf`).
  4238. * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
  4239. parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
  4240. Authentication
  4241. --------------
  4242. * `minetest.string_to_privs(str[, delim])`:
  4243. * Converts string representation of privs into table form
  4244. * `delim`: String separating the privs. Defaults to `","`.
  4245. * Returns `{ priv1 = true, ... }`
  4246. * `minetest.privs_to_string(privs[, delim])`:
  4247. * Returns the string representation of `privs`
  4248. * `delim`: String to delimit privs. Defaults to `","`.
  4249. * `minetest.get_player_privs(name) -> {priv1=true,...}`
  4250. * `minetest.check_player_privs(player_or_name, ...)`:
  4251. returns `bool, missing_privs`
  4252. * A quickhand for checking privileges.
  4253. * `player_or_name`: Either a Player object or the name of a player.
  4254. * `...` is either a list of strings, e.g. `"priva", "privb"` or
  4255. a table, e.g. `{ priva = true, privb = true }`.
  4256. * `minetest.check_password_entry(name, entry, password)`
  4257. * Returns true if the "password entry" for a player with name matches given
  4258. password, false otherwise.
  4259. * The "password entry" is the password representation generated by the
  4260. engine as returned as part of a `get_auth()` call on the auth handler.
  4261. * Only use this function for making it possible to log in via password from
  4262. external protocols such as IRC, other uses are frowned upon.
  4263. * `minetest.get_password_hash(name, raw_password)`
  4264. * Convert a name-password pair to a password hash that Minetest can use.
  4265. * The returned value alone is not a good basis for password checks based
  4266. on comparing the password hash in the database with the password hash
  4267. from the function, with an externally provided password, as the hash
  4268. in the db might use the new SRP verifier format.
  4269. * For this purpose, use `minetest.check_password_entry` instead.
  4270. * `minetest.get_player_ip(name)`: returns an IP address string for the player
  4271. `name`.
  4272. * The player needs to be online for this to be successful.
  4273. * `minetest.get_auth_handler()`: Return the currently active auth handler
  4274. * See the [Authentication handler definition]
  4275. * Use this to e.g. get the authentication data for a player:
  4276. `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  4277. * `minetest.notify_authentication_modified(name)`
  4278. * Must be called by the authentication handler for privilege changes.
  4279. * `name`: string; if omitted, all auth data should be considered modified
  4280. * `minetest.set_player_password(name, password_hash)`: Set password hash of
  4281. player `name`.
  4282. * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
  4283. `name`.
  4284. * `minetest.auth_reload()`
  4285. * See `reload()` in authentication handler definition
  4286. `minetest.set_player_password`, `minetest.set_player_privs`,
  4287. `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
  4288. handler.
  4289. Chat
  4290. ----
  4291. * `minetest.chat_send_all(text)`
  4292. * `minetest.chat_send_player(name, text)`
  4293. * `minetest.format_chat_message(name, message)`
  4294. * Used by the server to format a chat message, based on the setting `chat_message_format`.
  4295. Refer to the documentation of the setting for a list of valid placeholders.
  4296. * Takes player name and message, and returns the formatted string to be sent to players.
  4297. * Can be redefined by mods if required, for things like colored names or messages.
  4298. * **Only** the first occurrence of each placeholder will be replaced.
  4299. Environment access
  4300. ------------------
  4301. * `minetest.set_node(pos, node)`
  4302. * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
  4303. * Set node at position `pos`
  4304. * `node`: table `{name=string, param1=number, param2=number}`
  4305. * If param1 or param2 is omitted, it's set to `0`.
  4306. * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
  4307. * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
  4308. * Set node on all positions set in the first argument.
  4309. * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
  4310. * For node specification or position syntax see `minetest.set_node` call
  4311. * Faster than set_node due to single call, but still considerably slower
  4312. than Lua Voxel Manipulators (LVM) for large numbers of nodes.
  4313. Unlike LVMs, this will call node callbacks. It also allows setting nodes
  4314. in spread out positions which would cause LVMs to waste memory.
  4315. For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
  4316. times faster.
  4317. * `minetest.swap_node(pos, node)`
  4318. * Set node at position, but don't remove metadata
  4319. * `minetest.remove_node(pos)`
  4320. * By default it does the same as `minetest.set_node(pos, {name="air"})`
  4321. * `minetest.get_node(pos)`
  4322. * Returns the node at the given position as table in the format
  4323. `{name="node_name", param1=0, param2=0}`,
  4324. returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
  4325. * `minetest.get_node_or_nil(pos)`
  4326. * Same as `get_node` but returns `nil` for unloaded areas.
  4327. * `minetest.get_node_light(pos, timeofday)`
  4328. * Gets the light value at the given position. Note that the light value
  4329. "inside" the node at the given position is returned, so you usually want
  4330. to get the light value of a neighbor.
  4331. * `pos`: The position where to measure the light.
  4332. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4333. * Returns a number between `0` and `15` or `nil`
  4334. * `nil` is returned e.g. when the map isn't loaded at `pos`
  4335. * `minetest.get_natural_light(pos[, timeofday])`
  4336. * Figures out the sunlight (or moonlight) value at pos at the given time of
  4337. day.
  4338. * `pos`: The position of the node
  4339. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4340. * Returns a number between `0` and `15` or `nil`
  4341. * This function tests 203 nodes in the worst case, which happens very
  4342. unlikely
  4343. * `minetest.get_artificial_light(param1)`
  4344. * Calculates the artificial light (light from e.g. torches) value from the
  4345. `param1` value.
  4346. * `param1`: The param1 value of a `paramtype = "light"` node.
  4347. * Returns a number between `0` and `15`
  4348. * Currently it's the same as `math.floor(param1 / 16)`, except that it
  4349. ensures compatibility.
  4350. * `minetest.place_node(pos, node)`
  4351. * Place node with the same effects that a player would cause
  4352. * `minetest.dig_node(pos)`
  4353. * Dig node with the same effects that a player would cause
  4354. * Returns `true` if successful, `false` on failure (e.g. protected location)
  4355. * `minetest.punch_node(pos)`
  4356. * Punch node with the same effects that a player would cause
  4357. * `minetest.spawn_falling_node(pos)`
  4358. * Change node into falling node
  4359. * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
  4360. * `minetest.find_nodes_with_meta(pos1, pos2)`
  4361. * Get a table of positions of nodes that have metadata within a region
  4362. {pos1, pos2}.
  4363. * `minetest.get_meta(pos)`
  4364. * Get a `NodeMetaRef` at that position
  4365. * `minetest.get_node_timer(pos)`
  4366. * Get `NodeTimerRef`
  4367. * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
  4368. position.
  4369. * Returns `ObjectRef`, or `nil` if failed
  4370. * `minetest.add_item(pos, item)`: Spawn item
  4371. * Returns `ObjectRef`, or `nil` if failed
  4372. * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
  4373. * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  4374. ObjectRefs.
  4375. * `radius`: using a Euclidean metric
  4376. * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
  4377. ObjectRefs.
  4378. * `pos1` and `pos2` are the min and max positions of the area to search.
  4379. * `minetest.set_timeofday(val)`
  4380. * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
  4381. * `minetest.get_timeofday()`
  4382. * `minetest.get_gametime()`: returns the time, in seconds, since the world was
  4383. created.
  4384. * `minetest.get_day_count()`: returns number days elapsed since world was
  4385. created.
  4386. * accounts for time changes.
  4387. * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
  4388. pos or `nil`.
  4389. * `radius`: using a maximum metric
  4390. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4391. * `search_center` is an optional boolean (default: `false`)
  4392. If true `pos` is also checked for the nodes
  4393. * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
  4394. * `pos1` and `pos2` are the min and max positions of the area to search.
  4395. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4396. * If `grouped` is true the return value is a table indexed by node name
  4397. which contains lists of positions.
  4398. * If `grouped` is false or absent the return values are as follows:
  4399. first value: Table with all node positions
  4400. second value: Table with the count of each node with the node name
  4401. as index
  4402. * Area volume is limited to 4,096,000 nodes
  4403. * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
  4404. list of positions.
  4405. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4406. * Return value: Table with all node positions with a node air above
  4407. * Area volume is limited to 4,096,000 nodes
  4408. * `minetest.get_perlin(noiseparams)`
  4409. * Return world-specific perlin noise.
  4410. * The actual seed used is the noiseparams seed plus the world seed.
  4411. * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
  4412. * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
  4413. * Return world-specific perlin noise.
  4414. * `minetest.get_voxel_manip([pos1, pos2])`
  4415. * Return voxel manipulator object.
  4416. * Loads the manipulator from the map if positions are passed.
  4417. * `minetest.set_gen_notify(flags, {deco_ids})`
  4418. * Set the types of on-generate notifications that should be collected.
  4419. * `flags` is a flag field with the available flags:
  4420. * dungeon
  4421. * temple
  4422. * cave_begin
  4423. * cave_end
  4424. * large_cave_begin
  4425. * large_cave_end
  4426. * decoration
  4427. * The second parameter is a list of IDs of decorations which notification
  4428. is requested for.
  4429. * `minetest.get_gen_notify()`
  4430. * Returns a flagstring and a table with the `deco_id`s.
  4431. * `minetest.get_decoration_id(decoration_name)`
  4432. * Returns the decoration ID number for the provided decoration name string,
  4433. or `nil` on failure.
  4434. * `minetest.get_mapgen_object(objectname)`
  4435. * Return requested mapgen object if available (see [Mapgen objects])
  4436. * `minetest.get_heat(pos)`
  4437. * Returns the heat at the position, or `nil` on failure.
  4438. * `minetest.get_humidity(pos)`
  4439. * Returns the humidity at the position, or `nil` on failure.
  4440. * `minetest.get_biome_data(pos)`
  4441. * Returns a table containing:
  4442. * `biome` the biome id of the biome at that position
  4443. * `heat` the heat at the position
  4444. * `humidity` the humidity at the position
  4445. * Or returns `nil` on failure.
  4446. * `minetest.get_biome_id(biome_name)`
  4447. * Returns the biome id, as used in the biomemap Mapgen object and returned
  4448. by `minetest.get_biome_data(pos)`, for a given biome_name string.
  4449. * `minetest.get_biome_name(biome_id)`
  4450. * Returns the biome name string for the provided biome id, or `nil` on
  4451. failure.
  4452. * If no biomes have been registered, such as in mgv6, returns `default`.
  4453. * `minetest.get_mapgen_params()`
  4454. * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
  4455. * Returns a table containing:
  4456. * `mgname`
  4457. * `seed`
  4458. * `chunksize`
  4459. * `water_level`
  4460. * `flags`
  4461. * `minetest.set_mapgen_params(MapgenParams)`
  4462. * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
  4463. instead.
  4464. * Set map generation parameters.
  4465. * Function cannot be called after the registration period.
  4466. * Takes a table as an argument with the fields:
  4467. * `mgname`
  4468. * `seed`
  4469. * `chunksize`
  4470. * `water_level`
  4471. * `flags`
  4472. * Leave field unset to leave that parameter unchanged.
  4473. * `flags` contains a comma-delimited string of flags to set, or if the
  4474. prefix `"no"` is attached, clears instead.
  4475. * `flags` is in the same format and has the same options as `mg_flags` in
  4476. `minetest.conf`.
  4477. * `minetest.get_mapgen_setting(name)`
  4478. * Gets the *active* mapgen setting (or nil if none exists) in string
  4479. format with the following order of precedence:
  4480. 1) Settings loaded from map_meta.txt or overrides set during mod
  4481. execution.
  4482. 2) Settings set by mods without a metafile override
  4483. 3) Settings explicitly set in the user config file, minetest.conf
  4484. 4) Settings set as the user config default
  4485. * `minetest.get_mapgen_setting_noiseparams(name)`
  4486. * Same as above, but returns the value as a NoiseParams table if the
  4487. setting `name` exists and is a valid NoiseParams.
  4488. * `minetest.set_mapgen_setting(name, value, [override_meta])`
  4489. * Sets a mapgen param to `value`, and will take effect if the corresponding
  4490. mapgen setting is not already present in map_meta.txt.
  4491. * `override_meta` is an optional boolean (default: `false`). If this is set
  4492. to true, the setting will become the active setting regardless of the map
  4493. metafile contents.
  4494. * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
  4495. * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
  4496. * Same as above, except value is a NoiseParams table.
  4497. * `minetest.set_noiseparams(name, noiseparams, set_default)`
  4498. * Sets the noiseparams setting of `name` to the noiseparams table specified
  4499. in `noiseparams`.
  4500. * `set_default` is an optional boolean (default: `true`) that specifies
  4501. whether the setting should be applied to the default config or current
  4502. active config.
  4503. * `minetest.get_noiseparams(name)`
  4504. * Returns a table of the noiseparams for name.
  4505. * `minetest.generate_ores(vm, pos1, pos2)`
  4506. * Generate all registered ores within the VoxelManip `vm` and in the area
  4507. from `pos1` to `pos2`.
  4508. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4509. * `minetest.generate_decorations(vm, pos1, pos2)`
  4510. * Generate all registered decorations within the VoxelManip `vm` and in the
  4511. area from `pos1` to `pos2`.
  4512. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4513. * `minetest.clear_objects([options])`
  4514. * Clear all objects in the environment
  4515. * Takes an optional table as an argument with the field `mode`.
  4516. * mode = `"full"`: Load and go through every mapblock, clearing
  4517. objects (default).
  4518. * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
  4519. clear objects in unloaded mapblocks only when the
  4520. mapblocks are next activated.
  4521. * `minetest.load_area(pos1[, pos2])`
  4522. * Load the mapblocks containing the area from `pos1` to `pos2`.
  4523. `pos2` defaults to `pos1` if not specified.
  4524. * This function does not trigger map generation.
  4525. * `minetest.emerge_area(pos1, pos2, [callback], [param])`
  4526. * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
  4527. asynchronously fetched from memory, loaded from disk, or if inexistent,
  4528. generates them.
  4529. * If `callback` is a valid Lua function, this will be called for each block
  4530. emerged.
  4531. * The function signature of callback is:
  4532. `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
  4533. * `blockpos` is the *block* coordinates of the block that had been
  4534. emerged.
  4535. * `action` could be one of the following constant values:
  4536. * `minetest.EMERGE_CANCELLED`
  4537. * `minetest.EMERGE_ERRORED`
  4538. * `minetest.EMERGE_FROM_MEMORY`
  4539. * `minetest.EMERGE_FROM_DISK`
  4540. * `minetest.EMERGE_GENERATED`
  4541. * `calls_remaining` is the number of callbacks to be expected after
  4542. this one.
  4543. * `param` is the user-defined parameter passed to emerge_area (or
  4544. nil if the parameter was absent).
  4545. * `minetest.delete_area(pos1, pos2)`
  4546. * delete all mapblocks in the area from pos1 to pos2, inclusive
  4547. * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
  4548. * Checks if there is anything other than air between pos1 and pos2.
  4549. * Returns false if something is blocking the sight.
  4550. * Returns the position of the blocking node when `false`
  4551. * `pos1`: First position
  4552. * `pos2`: Second position
  4553. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
  4554. * Creates a `Raycast` object.
  4555. * `pos1`: start of the ray
  4556. * `pos2`: end of the ray
  4557. * `objects`: if false, only nodes will be returned. Default is `true`.
  4558. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  4559. returned. Default is `false`.
  4560. * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
  4561. * returns table containing path that can be walked on
  4562. * returns a table of 3D points representing a path from `pos1` to `pos2` or
  4563. `nil` on failure.
  4564. * Reasons for failure:
  4565. * No path exists at all
  4566. * No path exists within `searchdistance` (see below)
  4567. * Start or end pos is buried in land
  4568. * `pos1`: start position
  4569. * `pos2`: end position
  4570. * `searchdistance`: maximum distance from the search positions to search in.
  4571. In detail: Path must be completely inside a cuboid. The minimum
  4572. `searchdistance` of 1 will confine search between `pos1` and `pos2`.
  4573. Larger values will increase the size of this cuboid in all directions
  4574. * `max_jump`: maximum height difference to consider walkable
  4575. * `max_drop`: maximum height difference to consider droppable
  4576. * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
  4577. Difference between `"A*"` and `"A*_noprefetch"` is that
  4578. `"A*"` will pre-calculate the cost-data, the other will calculate it
  4579. on-the-fly
  4580. * `minetest.spawn_tree (pos, {treedef})`
  4581. * spawns L-system tree at given `pos` with definition in `treedef` table
  4582. * `minetest.transforming_liquid_add(pos)`
  4583. * add node to liquid flow update queue
  4584. * `minetest.get_node_max_level(pos)`
  4585. * get max available level for leveled node
  4586. * `minetest.get_node_level(pos)`
  4587. * get level of leveled node (water, snow)
  4588. * `minetest.set_node_level(pos, level)`
  4589. * set level of leveled node, default `level` equals `1`
  4590. * if `totallevel > maxlevel`, returns rest (`total-max`).
  4591. * `minetest.add_node_level(pos, level)`
  4592. * increase level of leveled node by level, default `level` equals `1`
  4593. * if `totallevel > maxlevel`, returns rest (`total-max`)
  4594. * `level` must be between -127 and 127
  4595. * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
  4596. * resets the light in a cuboid-shaped part of
  4597. the map and removes lighting bugs.
  4598. * Loads the area if it is not loaded.
  4599. * `pos1` is the corner of the cuboid with the least coordinates
  4600. (in node coordinates), inclusive.
  4601. * `pos2` is the opposite corner of the cuboid, inclusive.
  4602. * The actual updated cuboid might be larger than the specified one,
  4603. because only whole map blocks can be updated.
  4604. The actual updated area consists of those map blocks that intersect
  4605. with the given cuboid.
  4606. * However, the neighborhood of the updated area might change
  4607. as well, as light can spread out of the cuboid, also light
  4608. might be removed.
  4609. * returns `false` if the area is not fully generated,
  4610. `true` otherwise
  4611. * `minetest.check_single_for_falling(pos)`
  4612. * causes an unsupported `group:falling_node` node to fall and causes an
  4613. unattached `group:attached_node` node to fall.
  4614. * does not spread these updates to neighbors.
  4615. * `minetest.check_for_falling(pos)`
  4616. * causes an unsupported `group:falling_node` node to fall and causes an
  4617. unattached `group:attached_node` node to fall.
  4618. * spread these updates to neighbors and can cause a cascade
  4619. of nodes to fall.
  4620. * `minetest.get_spawn_level(x, z)`
  4621. * Returns a player spawn y co-ordinate for the provided (x, z)
  4622. co-ordinates, or `nil` for an unsuitable spawn point.
  4623. * For most mapgens a 'suitable spawn point' is one with y between
  4624. `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
  4625. so `nil` will be returned for many (x, z) co-ordinates.
  4626. * The spawn level returned is for a player spawn in unmodified terrain.
  4627. * The spawn level is intentionally above terrain level to cope with
  4628. full-node biome 'dust' nodes.
  4629. Mod channels
  4630. ------------
  4631. You can find mod channels communication scheme in `doc/mod_channels.png`.
  4632. * `minetest.mod_channel_join(channel_name)`
  4633. * Server joins channel `channel_name`, and creates it if necessary. You
  4634. should listen for incoming messages with
  4635. `minetest.register_on_modchannel_message`
  4636. Inventory
  4637. ---------
  4638. `minetest.get_inventory(location)`: returns an `InvRef`
  4639. * `location` = e.g.
  4640. * `{type="player", name="celeron55"}`
  4641. * `{type="node", pos={x=, y=, z=}}`
  4642. * `{type="detached", name="creative"}`
  4643. * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
  4644. an `InvRef`.
  4645. * `callbacks`: See [Detached inventory callbacks]
  4646. * `player_name`: Make detached inventory available to one player
  4647. exclusively, by default they will be sent to every player (even if not
  4648. used).
  4649. Note that this parameter is mostly just a workaround and will be removed
  4650. in future releases.
  4651. * Creates a detached inventory. If it already exists, it is cleared.
  4652. * `minetest.remove_detached_inventory(name)`
  4653. * Returns a `boolean` indicating whether the removal succeeded.
  4654. * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
  4655. returns leftover ItemStack or nil to indicate no inventory change
  4656. * See `minetest.item_eat` and `minetest.register_on_item_eat`
  4657. Formspec
  4658. --------
  4659. * `minetest.show_formspec(playername, formname, formspec)`
  4660. * `playername`: name of player to show formspec
  4661. * `formname`: name passed to `on_player_receive_fields` callbacks.
  4662. It should follow the `"modname:<whatever>"` naming convention
  4663. * `formspec`: formspec to display
  4664. * `minetest.close_formspec(playername, formname)`
  4665. * `playername`: name of player to close formspec
  4666. * `formname`: has to exactly match the one given in `show_formspec`, or the
  4667. formspec will not close.
  4668. * calling `show_formspec(playername, formname, "")` is equal to this
  4669. expression.
  4670. * to close a formspec regardless of the formname, call
  4671. `minetest.close_formspec(playername, "")`.
  4672. **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  4673. * `minetest.formspec_escape(string)`: returns a string
  4674. * escapes the characters "[", "]", "\", "," and ";", which cannot be used
  4675. in formspecs.
  4676. * `minetest.explode_table_event(string)`: returns a table
  4677. * returns e.g. `{type="CHG", row=1, column=2}`
  4678. * `type` is one of:
  4679. * `"INV"`: no row selected
  4680. * `"CHG"`: selected
  4681. * `"DCL"`: double-click
  4682. * `minetest.explode_textlist_event(string)`: returns a table
  4683. * returns e.g. `{type="CHG", index=1}`
  4684. * `type` is one of:
  4685. * `"INV"`: no row selected
  4686. * `"CHG"`: selected
  4687. * `"DCL"`: double-click
  4688. * `minetest.explode_scrollbar_event(string)`: returns a table
  4689. * returns e.g. `{type="CHG", value=500}`
  4690. * `type` is one of:
  4691. * `"INV"`: something failed
  4692. * `"CHG"`: has been changed
  4693. * `"VAL"`: not changed
  4694. Item handling
  4695. -------------
  4696. * `minetest.inventorycube(img1, img2, img3)`
  4697. * Returns a string for making an image of a cube (useful as an item image)
  4698. * `minetest.get_pointed_thing_position(pointed_thing, above)`
  4699. * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
  4700. does not refer to a node or entity.
  4701. * If the optional `above` parameter is true and the `pointed_thing` refers
  4702. to a node, then it will return the `above` position of the `pointed_thing`.
  4703. * `minetest.dir_to_facedir(dir, is6d)`
  4704. * Convert a vector to a facedir value, used in `param2` for
  4705. `paramtype2="facedir"`.
  4706. * passing something non-`nil`/`false` for the optional second parameter
  4707. causes it to take the y component into account.
  4708. * `minetest.facedir_to_dir(facedir)`
  4709. * Convert a facedir back into a vector aimed directly out the "back" of a
  4710. node.
  4711. * `minetest.dir_to_fourdir(dir)`
  4712. * Convert a vector to a 4dir value, used in `param2` for
  4713. `paramtype2="4dir"`.
  4714. * `minetest.fourdir_to_dir(fourdir)`
  4715. * Convert a 4dir back into a vector aimed directly out the "back" of a
  4716. node.
  4717. * `minetest.dir_to_wallmounted(dir)`
  4718. * Convert a vector to a wallmounted value, used for
  4719. `paramtype2="wallmounted"`.
  4720. * `minetest.wallmounted_to_dir(wallmounted)`
  4721. * Convert a wallmounted value back into a vector aimed directly out the
  4722. "back" of a node.
  4723. * `minetest.dir_to_yaw(dir)`
  4724. * Convert a vector into a yaw (angle)
  4725. * `minetest.yaw_to_dir(yaw)`
  4726. * Convert yaw (angle) to a vector
  4727. * `minetest.is_colored_paramtype(ptype)`
  4728. * Returns a boolean. Returns `true` if the given `paramtype2` contains
  4729. color information (`color`, `colorwallmounted`, `colorfacedir`, etc.).
  4730. * `minetest.strip_param2_color(param2, paramtype2)`
  4731. * Removes everything but the color information from the
  4732. given `param2` value.
  4733. * Returns `nil` if the given `paramtype2` does not contain color
  4734. information.
  4735. * `minetest.get_node_drops(node, toolname)`
  4736. * Returns list of itemstrings that are dropped by `node` when dug
  4737. with the item `toolname` (not limited to tools).
  4738. * `node`: node as table or node name
  4739. * `toolname`: name of the item used to dig (can be `nil`)
  4740. * `minetest.get_craft_result(input)`: returns `output, decremented_input`
  4741. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4742. * `input.width` = for example `3`
  4743. * `input.items` = for example
  4744. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4745. * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
  4746. * `output.time` = a number, if unsuccessful: `0`
  4747. * `output.replacements` = List of replacement `ItemStack`s that couldn't be
  4748. placed in `decremented_input.items`. Replacements can be placed in
  4749. `decremented_input` if the stack of the replaced item has a count of 1.
  4750. * `decremented_input` = like `input`
  4751. * `minetest.get_craft_recipe(output)`: returns input
  4752. * returns last registered recipe for output item (node)
  4753. * `output` is a node or item type such as `"default:torch"`
  4754. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4755. * `input.width` = for example `3`
  4756. * `input.items` = for example
  4757. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4758. * `input.items` = `nil` if no recipe found
  4759. * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
  4760. * returns indexed table with all registered recipes for query item (node)
  4761. or `nil` if no recipe was found.
  4762. * recipe entry table:
  4763. * `method`: 'normal' or 'cooking' or 'fuel'
  4764. * `width`: 0-3, 0 means shapeless recipe
  4765. * `items`: indexed [1-9] table with recipe items
  4766. * `output`: string with item name and quantity
  4767. * Example result for `"default:gold_ingot"` with two recipes:
  4768. {
  4769. {
  4770. method = "cooking", width = 3,
  4771. output = "default:gold_ingot", items = {"default:gold_lump"}
  4772. },
  4773. {
  4774. method = "normal", width = 1,
  4775. output = "default:gold_ingot 9", items = {"default:goldblock"}
  4776. }
  4777. }
  4778. * `minetest.handle_node_drops(pos, drops, digger)`
  4779. * `drops`: list of itemstrings
  4780. * Handles drops from nodes after digging: Default action is to put them
  4781. into digger's inventory.
  4782. * Can be overridden to get different functionality (e.g. dropping items on
  4783. ground)
  4784. * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
  4785. string.
  4786. * Creates an item string which contains palette index information
  4787. for hardware colorization. You can use the returned string
  4788. as an output in a craft recipe.
  4789. * `item`: the item stack which becomes colored. Can be in string,
  4790. table and native form.
  4791. * `palette_index`: this index is added to the item stack
  4792. * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
  4793. * Creates an item string which contains static color information
  4794. for hardware colorization. Use this method if you wish to colorize
  4795. an item that does not own a palette. You can use the returned string
  4796. as an output in a craft recipe.
  4797. * `item`: the item stack which becomes colored. Can be in string,
  4798. table and native form.
  4799. * `colorstring`: the new color of the item stack
  4800. Rollback
  4801. --------
  4802. * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
  4803. returns `{{actor, pos, time, oldnode, newnode}, ...}`
  4804. * Find who has done something to a node, or near a node
  4805. * `actor`: `"player:<name>"`, also `"liquid"`.
  4806. * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
  4807. `boolean, log_messages`.
  4808. * Revert latest actions of someone
  4809. * `actor`: `"player:<name>"`, also `"liquid"`.
  4810. Defaults for the `on_place` and `on_drop` item definition functions
  4811. -------------------------------------------------------------------
  4812. * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
  4813. * Place item as a node
  4814. * `param2` overrides `facedir` and wallmounted `param2`
  4815. * `prevent_after_place`: if set to `true`, `after_place_node` is not called
  4816. for the newly placed node to prevent a callback and placement loop
  4817. * returns `itemstack, position`
  4818. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4819. * `minetest.item_place_object(itemstack, placer, pointed_thing)`
  4820. * Place item as-is
  4821. * returns the leftover itemstack
  4822. * **Note**: This function is deprecated and will never be called.
  4823. * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
  4824. * Wrapper that calls `minetest.item_place_node` if appropriate
  4825. * Calls `on_rightclick` of `pointed_thing.under` if defined instead
  4826. * **Note**: is not called when wielded item overrides `on_place`
  4827. * `param2` overrides facedir and wallmounted `param2`
  4828. * returns `itemstack, position`
  4829. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4830. * `minetest.item_pickup(itemstack, picker, pointed_thing, time_from_last_punch, ...)`
  4831. * Runs callbacks registered by `minetest.register_on_item_pickup` and adds
  4832. the item to the picker's `"main"` inventory list.
  4833. * Parameters are the same as in `on_pickup`.
  4834. * Returns the leftover itemstack.
  4835. * `minetest.item_drop(itemstack, dropper, pos)`
  4836. * Drop the item
  4837. * returns the leftover itemstack
  4838. * `minetest.item_eat(hp_change[, replace_with_item])`
  4839. * Returns `function(itemstack, user, pointed_thing)` as a
  4840. function wrapper for `minetest.do_item_eat`.
  4841. * `replace_with_item` is the itemstring which is added to the inventory.
  4842. If the player is eating a stack, then replace_with_item goes to a
  4843. different spot.
  4844. Defaults for the `on_punch` and `on_dig` node definition callbacks
  4845. ------------------------------------------------------------------
  4846. * `minetest.node_punch(pos, node, puncher, pointed_thing)`
  4847. * Calls functions registered by `minetest.register_on_punchnode()`
  4848. * `minetest.node_dig(pos, node, digger)`
  4849. * Checks if node can be dug, puts item into inventory, removes node
  4850. * Calls functions registered by `minetest.registered_on_dignodes()`
  4851. Sounds
  4852. ------
  4853. * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
  4854. * `spec` is a `SimpleSoundSpec`
  4855. * `parameters` is a sound parameter table
  4856. * `ephemeral` is a boolean (default: false)
  4857. Ephemeral sounds will not return a handle and can't be stopped or faded.
  4858. It is recommend to use this for short sounds that happen in response to
  4859. player actions (e.g. door closing).
  4860. * `minetest.sound_stop(handle)`
  4861. * `handle` is a handle returned by `minetest.sound_play`
  4862. * `minetest.sound_fade(handle, step, gain)`
  4863. * `handle` is a handle returned by `minetest.sound_play`
  4864. * `step` determines how fast a sound will fade.
  4865. The gain will change by this much per second,
  4866. until it reaches the target gain.
  4867. Note: Older versions used a signed step. This is deprecated, but old
  4868. code will still work. (the client uses abs(step) to correct it)
  4869. * `gain` the target gain for the fade.
  4870. Fading to zero will delete the sound.
  4871. Timing
  4872. ------
  4873. * `minetest.after(time, func, ...)`: returns job table to use as below.
  4874. * Call the function `func` after `time` seconds, may be fractional
  4875. * Optional: Variable number of arguments that are passed to `func`
  4876. * `job:cancel()`
  4877. * Cancels the job function from being called
  4878. Async environment
  4879. -----------------
  4880. The engine allows you to submit jobs to be ran in an isolated environment
  4881. concurrently with normal server operation.
  4882. A job consists of a function to be ran in the async environment, any amount of
  4883. arguments (will be serialized) and a callback that will be called with the return
  4884. value of the job function once it is finished.
  4885. The async environment does *not* have access to the map, entities, players or any
  4886. globals defined in the 'usual' environment. Consequently, functions like
  4887. `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
  4888. Arguments and return values passed through this can contain certain userdata
  4889. objects that will be seamlessly copied (not shared) to the async environment.
  4890. This allows you easy interoperability for delegating work to jobs.
  4891. * `minetest.handle_async(func, callback, ...)`:
  4892. * Queue the function `func` to be ran in an async environment.
  4893. Note that there are multiple persistent workers and any of them may
  4894. end up running a given job. The engine will scale the amount of
  4895. worker threads automatically.
  4896. * When `func` returns the callback is called (in the normal environment)
  4897. with all of the return values as arguments.
  4898. * Optional: Variable number of arguments that are passed to `func`
  4899. * `minetest.register_async_dofile(path)`:
  4900. * Register a path to a Lua file to be imported when an async environment
  4901. is initialized. You can use this to preload code which you can then call
  4902. later using `minetest.handle_async()`.
  4903. ### List of APIs available in an async environment
  4904. Classes:
  4905. * `ItemStack`
  4906. * `PerlinNoise`
  4907. * `PerlinNoiseMap`
  4908. * `PseudoRandom`
  4909. * `PcgRandom`
  4910. * `SecureRandom`
  4911. * `VoxelArea`
  4912. * `VoxelManip`
  4913. * only if transferred into environment; can't read/write to map
  4914. * `Settings`
  4915. Class instances that can be transferred between environments:
  4916. * `ItemStack`
  4917. * `PerlinNoise`
  4918. * `PerlinNoiseMap`
  4919. * `VoxelManip`
  4920. Functions:
  4921. * Standalone helpers such as logging, filesystem, encoding,
  4922. hashing or compression APIs
  4923. * `minetest.request_insecure_environment` (same restrictions apply)
  4924. Variables:
  4925. * `minetest.settings`
  4926. * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
  4927. `registered_craftitems` and `registered_aliases`
  4928. * with all functions and userdata values replaced by `true`, calling any
  4929. callbacks here is obviously not possible
  4930. Server
  4931. ------
  4932. * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
  4933. server shutdown. Will display `message` to clients.
  4934. * `reconnect` == true displays a reconnect button
  4935. * `delay` adds an optional delay (in seconds) before shutdown.
  4936. Negative delay cancels the current active shutdown.
  4937. Zero delay triggers an immediate shutdown.
  4938. * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
  4939. * `minetest.get_server_status(name, joined)`
  4940. * Returns the server status string when a player joins or when the command
  4941. `/status` is called. Returns `nil` or an empty string when the message is
  4942. disabled.
  4943. * `joined`: Boolean value, indicates whether the function was called when
  4944. a player joined.
  4945. * This function may be overwritten by mods to customize the status message.
  4946. * `minetest.get_server_uptime()`: returns the server uptime in seconds
  4947. * `minetest.get_server_max_lag()`: returns the current maximum lag
  4948. of the server in seconds or nil if server is not fully loaded yet
  4949. * `minetest.remove_player(name)`: remove player from database (if they are not
  4950. connected).
  4951. * As auth data is not removed, minetest.player_exists will continue to
  4952. return true. Call the below method as well if you want to remove auth
  4953. data too.
  4954. * Returns a code (0: successful, 1: no such player, 2: player is connected)
  4955. * `minetest.remove_player_auth(name)`: remove player authentication data
  4956. * Returns boolean indicating success (false if player nonexistent)
  4957. * `minetest.dynamic_add_media(options, callback)`
  4958. * `options`: table containing the following parameters
  4959. * `filepath`: path to a media file on the filesystem
  4960. * `to_player`: name of the player the media should be sent to instead of
  4961. all players (optional)
  4962. * `ephemeral`: boolean that marks the media as ephemeral,
  4963. it will not be cached on the client (optional, default false)
  4964. * `callback`: function with arguments `name`, which is a player name
  4965. * Pushes the specified media file to client(s). (details below)
  4966. The file must be a supported image, sound or model format.
  4967. Dynamically added media is not persisted between server restarts.
  4968. * Returns false on error, true if the request was accepted
  4969. * The given callback will be called for every player as soon as the
  4970. media is available on the client.
  4971. * Details/Notes:
  4972. * If `ephemeral`=false and `to_player` is unset the file is added to the media
  4973. sent to clients on startup, this means the media will appear even on
  4974. old clients if they rejoin the server.
  4975. * If `ephemeral`=false the file must not be modified, deleted, moved or
  4976. renamed after calling this function.
  4977. * Regardless of any use of `ephemeral`, adding media files with the same
  4978. name twice is not possible/guaranteed to work. An exception to this is the
  4979. use of `to_player` to send the same, already existent file to multiple
  4980. chosen players.
  4981. * Clients will attempt to fetch files added this way via remote media,
  4982. this can make transfer of bigger files painless (if set up). Nevertheless
  4983. it is advised not to use dynamic media for big media files.
  4984. Bans
  4985. ----
  4986. * `minetest.get_ban_list()`: returns a list of all bans formatted as string
  4987. * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
  4988. IP address or name formatted as string
  4989. * `minetest.ban_player(name)`: ban the IP of a currently connected player
  4990. * Returns boolean indicating success
  4991. * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
  4992. IP address or name
  4993. * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
  4994. reason.
  4995. * Returns boolean indicating success (false if player nonexistent)
  4996. * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
  4997. optional reason, this will not prefix with 'Kicked: ' like kick_player.
  4998. If no reason is given, it will default to 'Disconnected.'
  4999. * Returns boolean indicating success (false if player nonexistent)
  5000. Particles
  5001. ---------
  5002. * `minetest.add_particle(particle definition)`
  5003. * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
  5004. expirationtime, size, collisiondetection, texture, playername)`
  5005. * `minetest.add_particlespawner(particlespawner definition)`
  5006. * Add a `ParticleSpawner`, an object that spawns an amount of particles
  5007. over `time` seconds.
  5008. * Returns an `id`, and -1 if adding didn't succeed
  5009. * Deprecated: `minetest.add_particlespawner(amount, time,
  5010. minpos, maxpos,
  5011. minvel, maxvel,
  5012. minacc, maxacc,
  5013. minexptime, maxexptime,
  5014. minsize, maxsize,
  5015. collisiondetection, texture, playername)`
  5016. * `minetest.delete_particlespawner(id, player)`
  5017. * Delete `ParticleSpawner` with `id` (return value from
  5018. `minetest.add_particlespawner`).
  5019. * If playername is specified, only deletes on the player's client,
  5020. otherwise on all clients.
  5021. Schematics
  5022. ----------
  5023. * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
  5024. * Create a schematic from the volume of map specified by the box formed by
  5025. p1 and p2.
  5026. * Apply the specified probability and per-node force-place to the specified
  5027. nodes according to the `probability_list`.
  5028. * `probability_list` is an array of tables containing two fields, `pos`
  5029. and `prob`.
  5030. * `pos` is the 3D vector specifying the absolute coordinates of the
  5031. node being modified,
  5032. * `prob` is an integer value from `0` to `255` that encodes
  5033. probability and per-node force-place. Probability has levels
  5034. 0-127, then 128 may be added to encode per-node force-place.
  5035. For probability stated as 0-255, divide by 2 and round down to
  5036. get values 0-127, then add 128 to apply per-node force-place.
  5037. * If there are two or more entries with the same pos value, the
  5038. last entry is used.
  5039. * If `pos` is not inside the box formed by `p1` and `p2`, it is
  5040. ignored.
  5041. * If `probability_list` equals `nil`, no probabilities are applied.
  5042. * Apply the specified probability to the specified horizontal slices
  5043. according to the `slice_prob_list`.
  5044. * `slice_prob_list` is an array of tables containing two fields, `ypos`
  5045. and `prob`.
  5046. * `ypos` indicates the y position of the slice with a probability
  5047. applied, the lowest slice being `ypos = 0`.
  5048. * If slice probability list equals `nil`, no slice probabilities
  5049. are applied.
  5050. * Saves schematic in the Minetest Schematic format to filename.
  5051. * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
  5052. * Place the schematic specified by schematic (see [Schematic specifier]) at
  5053. `pos`.
  5054. * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
  5055. * If the `rotation` parameter is omitted, the schematic is not rotated.
  5056. * `replacements` = `{["old_name"] = "convert_to", ...}`
  5057. * `force_placement` is a boolean indicating whether nodes other than `air`
  5058. and `ignore` are replaced by the schematic.
  5059. * Returns nil if the schematic could not be loaded.
  5060. * **Warning**: Once you have loaded a schematic from a file, it will be
  5061. cached. Future calls will always use the cached version and the
  5062. replacement list defined for it, regardless of whether the file or the
  5063. replacement list parameter have changed. The only way to load the file
  5064. anew is to restart the server.
  5065. * `flags` is a flag field with the available flags:
  5066. * place_center_x
  5067. * place_center_y
  5068. * place_center_z
  5069. * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
  5070. * This function is analogous to minetest.place_schematic, but places a
  5071. schematic onto the specified VoxelManip object `vmanip` instead of the
  5072. map.
  5073. * Returns false if any part of the schematic was cut-off due to the
  5074. VoxelManip not containing the full area required, and true if the whole
  5075. schematic was able to fit.
  5076. * Returns nil if the schematic could not be loaded.
  5077. * After execution, any external copies of the VoxelManip contents are
  5078. invalidated.
  5079. * `flags` is a flag field with the available flags:
  5080. * place_center_x
  5081. * place_center_y
  5082. * place_center_z
  5083. * `minetest.serialize_schematic(schematic, format, options)`
  5084. * Return the serialized schematic specified by schematic
  5085. (see [Schematic specifier])
  5086. * in the `format` of either "mts" or "lua".
  5087. * "mts" - a string containing the binary MTS data used in the MTS file
  5088. format.
  5089. * "lua" - a string containing Lua code representing the schematic in table
  5090. format.
  5091. * `options` is a table containing the following optional parameters:
  5092. * If `lua_use_comments` is true and `format` is "lua", the Lua code
  5093. generated will have (X, Z) position comments for every X row
  5094. generated in the schematic data for easier reading.
  5095. * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
  5096. the Lua code generated will use that number of spaces as indentation
  5097. instead of a tab character.
  5098. * `minetest.read_schematic(schematic, options)`
  5099. * Returns a Lua table representing the schematic (see: [Schematic specifier])
  5100. * `schematic` is the schematic to read (see: [Schematic specifier])
  5101. * `options` is a table containing the following optional parameters:
  5102. * `write_yslice_prob`: string value:
  5103. * `none`: no `write_yslice_prob` table is inserted,
  5104. * `low`: only probabilities that are not 254 or 255 are written in
  5105. the `write_ylisce_prob` table,
  5106. * `all`: write all probabilities to the `write_yslice_prob` table.
  5107. * The default for this option is `all`.
  5108. * Any invalid value will be interpreted as `all`.
  5109. HTTP Requests
  5110. -------------
  5111. * `minetest.request_http_api()`:
  5112. * returns `HTTPApiTable` containing http functions if the calling mod has
  5113. been granted access by being listed in the `secure.http_mods` or
  5114. `secure.trusted_mods` setting, otherwise returns `nil`.
  5115. * The returned table contains the functions `fetch`, `fetch_async` and
  5116. `fetch_async_get` described below.
  5117. * Only works at init time and must be called from the mod's main scope
  5118. (not from a function).
  5119. * Function only exists if minetest server was built with cURL support.
  5120. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
  5121. A LOCAL VARIABLE!**
  5122. * `HTTPApiTable.fetch(HTTPRequest req, callback)`
  5123. * Performs given request asynchronously and calls callback upon completion
  5124. * callback: `function(HTTPRequestResult res)`
  5125. * Use this HTTP function if you are unsure, the others are for advanced use
  5126. * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
  5127. * Performs given request asynchronously and returns handle for
  5128. `HTTPApiTable.fetch_async_get`
  5129. * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
  5130. * Return response data for given asynchronous HTTP request
  5131. Storage API
  5132. -----------
  5133. * `minetest.get_mod_storage()`:
  5134. * returns reference to mod private `StorageRef`
  5135. * must be called during mod load time
  5136. Misc.
  5137. -----
  5138. * `minetest.get_connected_players()`: returns list of `ObjectRefs`
  5139. * `minetest.is_player(obj)`: boolean, whether `obj` is a player
  5140. * `minetest.player_exists(name)`: boolean, whether player exists
  5141. (regardless of online status)
  5142. * `minetest.hud_replace_builtin(name, hud_definition)`
  5143. * Replaces definition of a builtin hud element
  5144. * `name`: `"breath"` or `"health"`
  5145. * `hud_definition`: definition to replace builtin definition
  5146. * `minetest.parse_relative_number(arg, relative_to)`: returns number or nil
  5147. * Helper function for chat commands.
  5148. * For parsing an optionally relative number of a chat command
  5149. parameter, using the chat command tilde notation.
  5150. * `arg`: String snippet containing the number; possible values:
  5151. * `"<number>"`: return as number
  5152. * `"~<number>"`: return `relative_to + <number>`
  5153. * `"~"`: return `relative_to`
  5154. * Anything else will return `nil`
  5155. * `relative_to`: Number to which the `arg` number might be relative to
  5156. * Examples:
  5157. * `minetest.parse_relative_number("5", 10)` returns 5
  5158. * `minetest.parse_relative_number("~5", 10)` returns 15
  5159. * `minetest.parse_relative_number("~", 10)` returns 10
  5160. * `minetest.send_join_message(player_name)`
  5161. * This function can be overridden by mods to change the join message.
  5162. * `minetest.send_leave_message(player_name, timed_out)`
  5163. * This function can be overridden by mods to change the leave message.
  5164. * `minetest.hash_node_position(pos)`: returns a 48-bit integer
  5165. * `pos`: table {x=number, y=number, z=number},
  5166. * Gives a unique hash number for a node position (16+16+16=48bit)
  5167. * `minetest.get_position_from_hash(hash)`: returns a position
  5168. * Inverse transform of `minetest.hash_node_position`
  5169. * `minetest.get_item_group(name, group)`: returns a rating
  5170. * Get rating of a group of an item. (`0` means: not in group)
  5171. * `minetest.get_node_group(name, group)`: returns a rating
  5172. * Deprecated: An alias for the former.
  5173. * `minetest.raillike_group(name)`: returns a rating
  5174. * Returns rating of the connect_to_raillike group corresponding to name
  5175. * If name is not yet the name of a connect_to_raillike group, a new group
  5176. id is created, with that name.
  5177. * `minetest.get_content_id(name)`: returns an integer
  5178. * Gets the internal content ID of `name`
  5179. * `minetest.get_name_from_content_id(content_id)`: returns a string
  5180. * Gets the name of the content with that content ID
  5181. * `minetest.parse_json(string[, nullvalue])`: returns something
  5182. * Convert a string containing JSON data into the Lua equivalent
  5183. * `nullvalue`: returned in place of the JSON null; defaults to `nil`
  5184. * On success returns a table, a string, a number, a boolean or `nullvalue`
  5185. * On failure outputs an error message and returns `nil`
  5186. * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
  5187. * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
  5188. message.
  5189. * Convert a Lua table into a JSON string
  5190. * styled: Outputs in a human-readable format if this is set, defaults to
  5191. false.
  5192. * Unserializable things like functions and userdata will cause an error.
  5193. * **Warning**: JSON is more strict than the Lua table format.
  5194. 1. You can only use strings and positive integers of at least one as
  5195. keys.
  5196. 2. You cannot mix string and integer keys.
  5197. This is due to the fact that JSON has two distinct array and object
  5198. values.
  5199. * Example: `write_json({10, {a = false}})`,
  5200. returns `'[10, {"a": false}]'`
  5201. * `minetest.serialize(table)`: returns a string
  5202. * Convert a table containing tables, strings, numbers, booleans and `nil`s
  5203. into string form readable by `minetest.deserialize`
  5204. * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
  5205. * `minetest.deserialize(string[, safe])`: returns a table
  5206. * Convert a string returned by `minetest.serialize` into a table
  5207. * `string` is loaded in an empty sandbox environment.
  5208. * Will load functions if safe is false or omitted. Although these functions
  5209. cannot directly access the global environment, they could bypass this
  5210. restriction with maliciously crafted Lua bytecode if mod security is
  5211. disabled.
  5212. * This function should not be used on untrusted data, regardless of the
  5213. value of `safe`. It is fine to serialize then deserialize user-provided
  5214. data, but directly providing user input to deserialize is always unsafe.
  5215. * Example: `deserialize('return { ["foo"] = "bar" }')`,
  5216. returns `{foo="bar"}`
  5217. * Example: `deserialize('print("foo")')`, returns `nil`
  5218. (function call fails), returns
  5219. `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
  5220. * `minetest.compress(data, method, ...)`: returns `compressed_data`
  5221. * Compress a string of data.
  5222. * `method` is a string identifying the compression method to be used.
  5223. * Supported compression methods:
  5224. * Deflate (zlib): `"deflate"`
  5225. * Zstandard: `"zstd"`
  5226. * `...` indicates method-specific arguments. Currently defined arguments
  5227. are:
  5228. * Deflate: `level` - Compression level, `0`-`9` or `nil`.
  5229. * Zstandard: `level` - Compression level. Integer or `nil`. Default `3`.
  5230. Note any supported Zstandard compression level could be used here,
  5231. but these are subject to change between Zstandard versions.
  5232. * `minetest.decompress(compressed_data, method, ...)`: returns data
  5233. * Decompress a string of data using the algorithm specified by `method`.
  5234. * See documentation on `minetest.compress()` for supported compression
  5235. methods.
  5236. * `...` indicates method-specific arguments. Currently, no methods use this
  5237. * `minetest.rgba(red, green, blue[, alpha])`: returns a string
  5238. * Each argument is an 8 Bit unsigned integer
  5239. * Returns the ColorString from rgb or rgba values
  5240. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
  5241. * `minetest.encode_base64(string)`: returns string encoded in base64
  5242. * Encodes a string in base64.
  5243. * `minetest.decode_base64(string)`: returns string or nil on failure
  5244. * Padding characters are only supported starting at version 5.4.0, where
  5245. 5.5.0 and newer perform proper checks.
  5246. * Decodes a string encoded in base64.
  5247. * `minetest.is_protected(pos, name)`: returns boolean
  5248. * Returning `true` restricts the player `name` from modifying (i.e. digging,
  5249. placing) the node at position `pos`.
  5250. * `name` will be `""` for non-players or unknown players.
  5251. * This function should be overridden by protection mods. It is highly
  5252. recommended to grant access to players with the `protection_bypass` privilege.
  5253. * Cache and call the old version of this function if the position is
  5254. not protected by the mod. This will allow using multiple protection mods.
  5255. * Example:
  5256. local old_is_protected = minetest.is_protected
  5257. function minetest.is_protected(pos, name)
  5258. if mymod:position_protected_from(pos, name) then
  5259. return true
  5260. end
  5261. return old_is_protected(pos, name)
  5262. end
  5263. * `minetest.record_protection_violation(pos, name)`
  5264. * This function calls functions registered with
  5265. `minetest.register_on_protection_violation`.
  5266. * `minetest.is_creative_enabled(name)`: returns boolean
  5267. * Returning `true` means that Creative Mode is enabled for player `name`.
  5268. * `name` will be `""` for non-players or if the player is unknown.
  5269. * This function should be overridden by Creative Mode-related mods to
  5270. implement a per-player Creative Mode.
  5271. * By default, this function returns `true` if the setting
  5272. `creative_mode` is `true` and `false` otherwise.
  5273. * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
  5274. * Returns the position of the first node that `player_name` may not modify
  5275. in the specified cuboid between `pos1` and `pos2`.
  5276. * Returns `false` if no protections were found.
  5277. * Applies `is_protected()` to a 3D lattice of points in the defined volume.
  5278. The points are spaced evenly throughout the volume and have a spacing
  5279. similar to, but no larger than, `interval`.
  5280. * All corners and edges of the defined volume are checked.
  5281. * `interval` defaults to 4.
  5282. * `interval` should be carefully chosen and maximized to avoid an excessive
  5283. number of points being checked.
  5284. * Like `minetest.is_protected`, this function may be extended or
  5285. overwritten by mods to provide a faster implementation to check the
  5286. cuboid for intersections.
  5287. * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
  5288. orient_flags, prevent_after_place])`
  5289. * Attempt to predict the desired orientation of the facedir-capable node
  5290. defined by `itemstack`, and place it accordingly (on-wall, on the floor,
  5291. or hanging from the ceiling).
  5292. * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
  5293. stacks are handled normally.
  5294. * `orient_flags`: Optional table containing extra tweaks to the placement code:
  5295. * `invert_wall`: if `true`, place wall-orientation on the ground and
  5296. ground-orientation on the wall.
  5297. * `force_wall`: if `true`, always place the node in wall orientation.
  5298. * `force_ceiling`: if `true`, always place on the ceiling.
  5299. * `force_floor`: if `true`, always place the node on the floor.
  5300. * `force_facedir`: if `true`, forcefully reset the facedir to north
  5301. when placing on the floor or ceiling.
  5302. * The first four options are mutually-exclusive; the last in the list
  5303. takes precedence over the first.
  5304. * `prevent_after_place` is directly passed to `minetest.item_place_node`
  5305. * Returns the new itemstack after placement
  5306. * `minetest.rotate_node(itemstack, placer, pointed_thing)`
  5307. * calls `rotate_and_place()` with `infinitestacks` set according to the state
  5308. of the creative mode setting, checks for "sneak" to set the `invert_wall`
  5309. parameter and `prevent_after_place` set to `true`.
  5310. * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
  5311. tool_capabilities, dir, distance, damage)`
  5312. * Returns the amount of knockback applied on the punched player.
  5313. * Arguments are equivalent to `register_on_punchplayer`, except the following:
  5314. * `distance`: distance between puncher and punched player
  5315. * This function can be overridden by mods that wish to modify this behavior.
  5316. * You may want to cache and call the old function to allow multiple mods to
  5317. change knockback behavior.
  5318. * `minetest.forceload_block(pos[, transient])`
  5319. * forceloads the position `pos`.
  5320. * returns `true` if area could be forceloaded
  5321. * If `transient` is `false` or absent, the forceload will be persistent
  5322. (saved between server runs). If `true`, the forceload will be transient
  5323. (not saved between server runs).
  5324. * `minetest.forceload_free_block(pos[, transient])`
  5325. * stops forceloading the position `pos`
  5326. * If `transient` is `false` or absent, frees a persistent forceload.
  5327. If `true`, frees a transient forceload.
  5328. * `minetest.compare_block_status(pos, condition)`
  5329. * Checks whether the mapblock at position `pos` is in the wanted condition.
  5330. * `condition` may be one of the following values:
  5331. * `"unknown"`: not in memory
  5332. * `"emerging"`: in the queue for loading from disk or generating
  5333. * `"loaded"`: in memory but inactive (no ABMs are executed)
  5334. * `"active"`: in memory and active
  5335. * Other values are reserved for future functionality extensions
  5336. * Return value, the comparison status:
  5337. * `false`: Mapblock does not fulfill the wanted condition
  5338. * `true`: Mapblock meets the requirement
  5339. * `nil`: Unsupported `condition` value
  5340. * `minetest.request_insecure_environment()`: returns an environment containing
  5341. insecure functions if the calling mod has been listed as trusted in the
  5342. `secure.trusted_mods` setting or security is disabled, otherwise returns
  5343. `nil`.
  5344. * Only works at init time and must be called from the mod's main scope
  5345. (ie: the init.lua of the mod, not from another Lua file or within a function).
  5346. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
  5347. IT IN A LOCAL VARIABLE!**
  5348. * `minetest.global_exists(name)`
  5349. * Checks if a global variable has been set, without triggering a warning.
  5350. Global objects
  5351. --------------
  5352. * `minetest.env`: `EnvRef` of the server environment and world.
  5353. * Any function in the minetest namespace can be called using the syntax
  5354. `minetest.env:somefunction(somearguments)`
  5355. instead of `minetest.somefunction(somearguments)`
  5356. * Deprecated, but support is not to be dropped soon
  5357. Global tables
  5358. -------------
  5359. ### Registered definition tables
  5360. * `minetest.registered_items`
  5361. * Map of registered items, indexed by name
  5362. * `minetest.registered_nodes`
  5363. * Map of registered node definitions, indexed by name
  5364. * `minetest.registered_craftitems`
  5365. * Map of registered craft item definitions, indexed by name
  5366. * `minetest.registered_tools`
  5367. * Map of registered tool definitions, indexed by name
  5368. * `minetest.registered_entities`
  5369. * Map of registered entity prototypes, indexed by name
  5370. * Values in this table may be modified directly.
  5371. Note: changes to initial properties will only affect entities spawned afterwards,
  5372. as they are only read when spawning.
  5373. * `minetest.object_refs`
  5374. * Map of object references, indexed by active object id
  5375. * `minetest.luaentities`
  5376. * Map of Lua entities, indexed by active object id
  5377. * `minetest.registered_abms`
  5378. * List of ABM definitions
  5379. * `minetest.registered_lbms`
  5380. * List of LBM definitions
  5381. * `minetest.registered_aliases`
  5382. * Map of registered aliases, indexed by name
  5383. * `minetest.registered_ores`
  5384. * Map of registered ore definitions, indexed by the `name` field.
  5385. * If `name` is nil, the key is the object handle returned by
  5386. `minetest.register_ore`.
  5387. * `minetest.registered_biomes`
  5388. * Map of registered biome definitions, indexed by the `name` field.
  5389. * If `name` is nil, the key is the object handle returned by
  5390. `minetest.register_biome`.
  5391. * `minetest.registered_decorations`
  5392. * Map of registered decoration definitions, indexed by the `name` field.
  5393. * If `name` is nil, the key is the object handle returned by
  5394. `minetest.register_decoration`.
  5395. * `minetest.registered_schematics`
  5396. * Map of registered schematic definitions, indexed by the `name` field.
  5397. * If `name` is nil, the key is the object handle returned by
  5398. `minetest.register_schematic`.
  5399. * `minetest.registered_chatcommands`
  5400. * Map of registered chat command definitions, indexed by name
  5401. * `minetest.registered_privileges`
  5402. * Map of registered privilege definitions, indexed by name
  5403. * Registered privileges can be modified directly in this table.
  5404. ### Registered callback tables
  5405. All callbacks registered with [Global callback registration functions] are added
  5406. to corresponding `minetest.registered_*` tables.
  5407. Class reference
  5408. ===============
  5409. Sorted alphabetically.
  5410. `AreaStore`
  5411. -----------
  5412. AreaStore is a data structure to calculate intersections of 3D cuboid volumes
  5413. and points. The `data` field (string) may be used to store and retrieve any
  5414. mod-relevant information to the specified area.
  5415. Despite its name, mods must take care of persisting AreaStore data. They may
  5416. use the provided load and write functions for this.
  5417. ### Methods
  5418. * `AreaStore(type_name)`
  5419. * Returns a new AreaStore instance
  5420. * `type_name`: optional, forces the internally used API.
  5421. * Possible values: `"LibSpatial"` (default).
  5422. * When other values are specified, or SpatialIndex is not available,
  5423. the custom Minetest functions are used.
  5424. * `get_area(id, include_corners, include_data)`
  5425. * Returns the area information about the specified ID.
  5426. * Returned values are either of these:
  5427. nil -- Area not found
  5428. true -- Without `include_corners` and `include_data`
  5429. {
  5430. min = pos, max = pos -- `include_corners == true`
  5431. data = string -- `include_data == true`
  5432. }
  5433. * `get_areas_for_pos(pos, include_corners, include_data)`
  5434. * Returns all areas as table, indexed by the area ID.
  5435. * Table values: see `get_area`.
  5436. * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
  5437. * Returns all areas that contain all nodes inside the area specified by`
  5438. `corner1 and `corner2` (inclusive).
  5439. * `accept_overlap`: if `true`, areas are returned that have nodes in
  5440. common (intersect) with the specified area.
  5441. * Returns the same values as `get_areas_for_pos`.
  5442. * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
  5443. * Returns the new area's ID, or nil if the insertion failed.
  5444. * The (inclusive) positions `corner1` and `corner2` describe the area.
  5445. * `data` is a string stored with the area.
  5446. * `id` (optional): will be used as the internal area ID if it is a unique
  5447. number between 0 and 2^32-2.
  5448. * `reserve(count)`
  5449. * Requires SpatialIndex, no-op function otherwise.
  5450. * Reserves resources for `count` many contained areas to improve
  5451. efficiency when working with many area entries. Additional areas can still
  5452. be inserted afterwards at the usual complexity.
  5453. * `remove_area(id)`: removes the area with the given id from the store, returns
  5454. success.
  5455. * `set_cache_params(params)`: sets params for the included prefiltering cache.
  5456. Calling invalidates the cache, so that its elements have to be newly
  5457. generated.
  5458. * `params` is a table with the following fields:
  5459. enabled = boolean, -- Whether to enable, default true
  5460. block_radius = int, -- The radius (in nodes) of the areas the cache
  5461. -- generates prefiltered lists for, minimum 16,
  5462. -- default 64
  5463. limit = int, -- The cache size, minimum 20, default 1000
  5464. * `to_string()`: Experimental. Returns area store serialized as a (binary)
  5465. string.
  5466. * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
  5467. a file.
  5468. * `from_string(str)`: Experimental. Deserializes string and loads it into the
  5469. AreaStore.
  5470. Returns success and, optionally, an error message.
  5471. * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
  5472. from a file.
  5473. `InvRef`
  5474. --------
  5475. An `InvRef` is a reference to an inventory.
  5476. ### Methods
  5477. * `is_empty(listname)`: return `true` if list is empty
  5478. * `get_size(listname)`: get size of a list
  5479. * `set_size(listname, size)`: set size of a list
  5480. * returns `false` on error (e.g. invalid `listname` or `size`)
  5481. * `get_width(listname)`: get width of a list
  5482. * `set_width(listname, width)`: set width of list; currently used for crafting
  5483. * `get_stack(listname, i)`: get a copy of stack index `i` in list
  5484. * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
  5485. * `get_list(listname)`: return full list (list of `ItemStack`s)
  5486. * `set_list(listname, list)`: set full list (size will not change)
  5487. * `get_lists()`: returns table that maps listnames to inventory lists
  5488. * `set_lists(lists)`: sets inventory lists (size will not change)
  5489. * `add_item(listname, stack)`: add item somewhere in list, returns leftover
  5490. `ItemStack`.
  5491. * `room_for_item(listname, stack):` returns `true` if the stack of items
  5492. can be fully added to the list
  5493. * `contains_item(listname, stack, [match_meta])`: returns `true` if
  5494. the stack of items can be fully taken from the list.
  5495. If `match_meta` is false, only the items' names are compared
  5496. (default: `false`).
  5497. * `remove_item(listname, stack)`: take as many items as specified from the
  5498. list, returns the items that were actually removed (as an `ItemStack`)
  5499. -- note that any item metadata is ignored, so attempting to remove a specific
  5500. unique item this way will likely remove the wrong one -- to do that use
  5501. `set_stack` with an empty `ItemStack`.
  5502. * `get_location()`: returns a location compatible to
  5503. `minetest.get_inventory(location)`.
  5504. * returns `{type="undefined"}` in case location is not known
  5505. ### Callbacks
  5506. Detached & nodemeta inventories provide the following callbacks for move actions:
  5507. #### Before
  5508. The `allow_*` callbacks return how many items can be moved.
  5509. * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
  5510. * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
  5511. * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
  5512. #### After
  5513. The `on_*` callbacks are called after the items have been placed in the inventories.
  5514. * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
  5515. * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
  5516. * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
  5517. #### Swapping
  5518. When a player tries to put an item to a place where another item is, the items are *swapped*.
  5519. This means that all callbacks will be called twice (once for each action).
  5520. `ItemStack`
  5521. -----------
  5522. An `ItemStack` is a stack of items.
  5523. It can be created via `ItemStack(x)`, where x is an `ItemStack`,
  5524. an itemstring, a table or `nil`.
  5525. ### Methods
  5526. * `is_empty()`: returns `true` if stack is empty.
  5527. * `get_name()`: returns item name (e.g. `"default:stone"`).
  5528. * `set_name(item_name)`: returns a boolean indicating whether the item was
  5529. cleared.
  5530. * `get_count()`: Returns number of items on the stack.
  5531. * `set_count(count)`: returns a boolean indicating whether the item was cleared
  5532. * `count`: number, unsigned 16 bit integer
  5533. * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
  5534. * `set_wear(wear)`: returns boolean indicating whether item was cleared
  5535. * `wear`: number, unsigned 16 bit integer
  5536. * `get_meta()`: returns ItemStackMetaRef. See section for more details
  5537. * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
  5538. stack).
  5539. * `set_metadata(metadata)`: (DEPRECATED) Returns true.
  5540. * `get_description()`: returns the description shown in inventory list tooltips.
  5541. * The engine uses this when showing item descriptions in tooltips.
  5542. * Fields for finding the description, in order:
  5543. * `description` in item metadata (See [Item Metadata].)
  5544. * `description` in item definition
  5545. * item name
  5546. * `get_short_description()`: returns the short description or nil.
  5547. * Unlike the description, this does not include new lines.
  5548. * Fields for finding the short description, in order:
  5549. * `short_description` in item metadata (See [Item Metadata].)
  5550. * `short_description` in item definition
  5551. * first line of the description (From item meta or def, see `get_description()`.)
  5552. * Returns nil if none of the above are set
  5553. * `clear()`: removes all items from the stack, making it empty.
  5554. * `replace(item)`: replace the contents of this stack.
  5555. * `item` can also be an itemstring or table.
  5556. * `to_string()`: returns the stack in itemstring form.
  5557. * `to_table()`: returns the stack in Lua table form.
  5558. * `get_stack_max()`: returns the maximum size of the stack (depends on the
  5559. item).
  5560. * `get_free_space()`: returns `get_stack_max() - get_count()`.
  5561. * `is_known()`: returns `true` if the item name refers to a defined item type.
  5562. * `get_definition()`: returns the item definition table.
  5563. * `get_tool_capabilities()`: returns the digging properties of the item,
  5564. or those of the hand if none are defined for this item type
  5565. * `add_wear(amount)`
  5566. * Increases wear by `amount` if the item is a tool, otherwise does nothing
  5567. * Valid `amount` range is [0,65536]
  5568. * `amount`: number, integer
  5569. * `add_wear_by_uses(max_uses)`
  5570. * Increases wear in such a way that, if only this function is called,
  5571. the item breaks after `max_uses` times
  5572. * Valid `max_uses` range is [0,65536]
  5573. * Does nothing if item is not a tool or if `max_uses` is 0
  5574. * `add_item(item)`: returns leftover `ItemStack`
  5575. * Put some item or stack onto this stack
  5576. * `item_fits(item)`: returns `true` if item or stack can be fully added to
  5577. this one.
  5578. * `take_item(n)`: returns taken `ItemStack`
  5579. * Take (and remove) up to `n` items from this stack
  5580. * `n`: number, default: `1`
  5581. * `peek_item(n)`: returns taken `ItemStack`
  5582. * Copy (don't remove) up to `n` items from this stack
  5583. * `n`: number, default: `1`
  5584. * `equals(other)`:
  5585. * returns `true` if this stack is identical to `other`.
  5586. * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
  5587. as stack metadata can be serialized in arbitrary order.
  5588. * Note: if `other` is an itemstring or table representation of an
  5589. ItemStack, this will always return false, even if it is
  5590. "equivalent".
  5591. ### Operators
  5592. * `stack1 == stack2`:
  5593. * Returns whether `stack1` and `stack2` are identical.
  5594. * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
  5595. as stack metadata can be serialized in arbitrary order.
  5596. * Note: if `stack2` is an itemstring or table representation of an
  5597. ItemStack, this will always return false, even if it is
  5598. "equivalent".
  5599. `ItemStackMetaRef`
  5600. ------------------
  5601. ItemStack metadata: reference extra data and functionality stored in a stack.
  5602. Can be obtained via `item:get_meta()`.
  5603. ### Methods
  5604. * All methods in MetaDataRef
  5605. * `set_tool_capabilities([tool_capabilities])`
  5606. * Overrides the item's tool capabilities
  5607. * A nil value will clear the override data and restore the original
  5608. behavior.
  5609. `MetaDataRef`
  5610. -------------
  5611. Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
  5612. and [`PlayerMetaRef`].
  5613. ### Methods
  5614. * `contains(key)`: Returns true if key present, otherwise false.
  5615. * Returns `nil` when the MetaData is inexistent.
  5616. * `get(key)`: Returns `nil` if key not present, else the stored string.
  5617. * `set_string(key, value)`: Value of `""` will delete the key.
  5618. * `get_string(key)`: Returns `""` if key not present.
  5619. * `set_int(key, value)`
  5620. * `get_int(key)`: Returns `0` if key not present.
  5621. * `set_float(key, value)`
  5622. * `get_float(key)`: Returns `0` if key not present.
  5623. * `to_table()`: returns `nil` or a table with keys:
  5624. * `fields`: key-value storage
  5625. * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
  5626. * `from_table(nil or {})`
  5627. * Any non-table value will clear the metadata
  5628. * See [Node Metadata] for an example
  5629. * returns `true` on success
  5630. * `equals(other)`
  5631. * returns `true` if this metadata has the same key-value pairs as `other`
  5632. `ModChannel`
  5633. ------------
  5634. An interface to use mod channels on client and server
  5635. ### Methods
  5636. * `leave()`: leave the mod channel.
  5637. * Server leaves channel `channel_name`.
  5638. * No more incoming or outgoing messages can be sent to this channel from
  5639. server mods.
  5640. * This invalidate all future object usage.
  5641. * Ensure you set mod_channel to nil after that to free Lua resources.
  5642. * `is_writeable()`: returns true if channel is writeable and mod can send over
  5643. it.
  5644. * `send_all(message)`: Send `message` though the mod channel.
  5645. * If mod channel is not writeable or invalid, message will be dropped.
  5646. * Message size is limited to 65535 characters by protocol.
  5647. `NodeMetaRef`
  5648. -------------
  5649. Node metadata: reference extra data and functionality stored in a node.
  5650. Can be obtained via `minetest.get_meta(pos)`.
  5651. ### Methods
  5652. * All methods in MetaDataRef
  5653. * `get_inventory()`: returns `InvRef`
  5654. * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
  5655. This will prevent them from being sent to the client. Note that the "private"
  5656. status will only be remembered if an associated key-value pair exists,
  5657. meaning it's best to call this when initializing all other meta (e.g.
  5658. `on_construct`).
  5659. `NodeTimerRef`
  5660. --------------
  5661. Node Timers: a high resolution persistent per-node timer.
  5662. Can be gotten via `minetest.get_node_timer(pos)`.
  5663. ### Methods
  5664. * `set(timeout,elapsed)`
  5665. * set a timer's state
  5666. * `timeout` is in seconds, and supports fractional values (0.1 etc)
  5667. * `elapsed` is in seconds, and supports fractional values (0.1 etc)
  5668. * will trigger the node's `on_timer` function after `(timeout - elapsed)`
  5669. seconds.
  5670. * `start(timeout)`
  5671. * start a timer
  5672. * equivalent to `set(timeout,0)`
  5673. * `stop()`
  5674. * stops the timer
  5675. * `get_timeout()`: returns current timeout in seconds
  5676. * if `timeout` equals `0`, timer is inactive
  5677. * `get_elapsed()`: returns current elapsed time in seconds
  5678. * the node's `on_timer` function will be called after `(timeout - elapsed)`
  5679. seconds.
  5680. * `is_started()`: returns boolean state of timer
  5681. * returns `true` if timer is started, otherwise `false`
  5682. `ObjectRef`
  5683. -----------
  5684. Moving things in the game are generally these.
  5685. This is basically a reference to a C++ `ServerActiveObject`.
  5686. ### Advice on handling `ObjectRefs`
  5687. When you receive an `ObjectRef` as a callback argument or from another API
  5688. function, it is possible to store the reference somewhere and keep it around.
  5689. It will keep functioning until the object is unloaded or removed.
  5690. However, doing this is **NOT** recommended as there is (intentionally) no method
  5691. to test if a previously acquired `ObjectRef` is still valid.
  5692. Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
  5693. Lua back to the engine.
  5694. Doing so is much less error-prone and you will never need to wonder if the
  5695. object you are working with still exists.
  5696. ### Attachments
  5697. It is possible to attach objects to other objects (`set_attach` method).
  5698. When an object is attached, it is positioned relative to the parent's position
  5699. and rotation. `get_pos` and `get_rotation` will always return the parent's
  5700. values and changes via their setter counterparts are ignored.
  5701. To change position or rotation call `set_attach` again with the new values.
  5702. **Note**: Just like model dimensions, the relative position in `set_attach`
  5703. must be multiplied by 10 compared to world positions.
  5704. It is also possible to attach to a bone of the parent object. In that case the
  5705. child will follow movement and rotation of that bone.
  5706. ### Methods
  5707. * `get_pos()`: returns `{x=num, y=num, z=num}`
  5708. * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
  5709. * `get_velocity()`: returns the velocity, a vector.
  5710. * `add_velocity(vel)`
  5711. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5712. * In comparison to using get_velocity, adding the velocity and then using
  5713. set_velocity, add_velocity is supposed to avoid synchronization problems.
  5714. Additionally, players also do not support set_velocity.
  5715. * If a player:
  5716. * Does not apply during free_move.
  5717. * Note that since the player speed is normalized at each move step,
  5718. increasing e.g. Y velocity beyond what would usually be achieved
  5719. (see: physics overrides) will cause existing X/Z velocity to be reduced.
  5720. * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
  5721. pressing the jump key (assuming default settings)
  5722. * `move_to(pos, continuous=false)`
  5723. * Does an interpolated move for Lua entities for visually smooth transitions.
  5724. * If `continuous` is true, the Lua entity will not be moved to the current
  5725. position before starting the interpolated move.
  5726. * For players this does the same as `set_pos`,`continuous` is ignored.
  5727. * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
  5728. * `puncher` = another `ObjectRef`,
  5729. * `time_from_last_punch` = time since last punch action of the puncher
  5730. * `direction`: can be `nil`
  5731. * `right_click(clicker)`; `clicker` is another `ObjectRef`
  5732. * `get_hp()`: returns number of health points
  5733. * `set_hp(hp, reason)`: set number of health points
  5734. * See reason in register_on_player_hpchange
  5735. * Is limited to the range of 0 ... 65535 (2^16 - 1)
  5736. * For players: HP are also limited by `hp_max` specified in object properties
  5737. * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
  5738. * `get_wield_list()`: returns the name of the inventory list the wielded item
  5739. is in.
  5740. * `get_wield_index()`: returns the index of the wielded item
  5741. * `get_wielded_item()`: returns an `ItemStack`
  5742. * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
  5743. successful.
  5744. * `set_armor_groups({group1=rating, group2=rating, ...})`
  5745. * `get_armor_groups()`: returns a table with the armor group ratings
  5746. * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
  5747. * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
  5748. * `frame_speed`: number, default: `15.0`
  5749. * `frame_blend`: number, default: `0.0`
  5750. * `frame_loop`: boolean, default: `true`
  5751. * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
  5752. `frame_loop`.
  5753. * `set_animation_frame_speed(frame_speed)`
  5754. * `frame_speed`: number, default: `15.0`
  5755. * `set_attach(parent[, bone, position, rotation, forced_visible])`
  5756. * `parent`: `ObjectRef` to attach to
  5757. * `bone`: default `""` (the root bone)
  5758. * `position`: relative position, default `{x=0, y=0, z=0}`
  5759. * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
  5760. * `forced_visible`: Boolean to control whether the attached entity
  5761. should appear in first person, default `false`.
  5762. * Please also read the [Attachments] section above.
  5763. * This command may fail silently (do nothing) when it would result
  5764. in circular attachments.
  5765. * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
  5766. or nil if it isn't attached.
  5767. * `get_children()`: returns a list of ObjectRefs that are attached to the
  5768. object.
  5769. * `set_detach()`
  5770. * `set_bone_position([bone, position, rotation])`
  5771. * `bone`: string. Default is `""`, the root bone
  5772. * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
  5773. * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
  5774. * `get_bone_position(bone)`: returns position and rotation of the bone
  5775. * `set_properties(object property table)`
  5776. * `get_properties()`: returns object property table
  5777. * `is_player()`: returns true for players, false otherwise
  5778. * `get_nametag_attributes()`
  5779. * returns a table with the attributes of the nametag of an object
  5780. * {
  5781. text = "",
  5782. color = {a=0..255, r=0..255, g=0..255, b=0..255},
  5783. bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
  5784. }
  5785. * `set_nametag_attributes(attributes)`
  5786. * sets the attributes of the nametag of an object
  5787. * `attributes`:
  5788. {
  5789. text = "My Nametag",
  5790. color = ColorSpec,
  5791. -- ^ Text color
  5792. bgcolor = ColorSpec or false,
  5793. -- ^ Sets background color of nametag
  5794. -- `false` will cause the background to be set automatically based on user settings
  5795. -- Default: false
  5796. }
  5797. #### Lua entity only (no-op for other objects)
  5798. * `remove()`: remove object
  5799. * The object is removed after returning from Lua. However the `ObjectRef`
  5800. itself instantly becomes unusable with all further method calls having
  5801. no effect and returning `nil`.
  5802. * `set_velocity(vel)`
  5803. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5804. * `set_acceleration(acc)`
  5805. * `acc` is a vector
  5806. * `get_acceleration()`: returns the acceleration, a vector
  5807. * `set_rotation(rot)`
  5808. * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
  5809. and Z is roll (bank).
  5810. * Does not reset rotation incurred through `automatic_rotate`.
  5811. Remove & readd your objects to force a certain rotation.
  5812. * `get_rotation()`: returns the rotation, a vector (radians)
  5813. * `set_yaw(yaw)`: sets the yaw in radians (heading).
  5814. * `get_yaw()`: returns number in radians
  5815. * `set_texture_mod(mod)`
  5816. * Set a texture modifier to the base texture, for sprites and meshes.
  5817. * When calling `set_texture_mod` again, the previous one is discarded.
  5818. * `mod` the texture modifier. See [Texture modifiers].
  5819. * `get_texture_mod()` returns current texture modifier
  5820. * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
  5821. * Specifies and starts a sprite animation
  5822. * Animations iterate along the frame `y` position.
  5823. * `start_frame`: {x=column number, y=row number}, the coordinate of the
  5824. first frame, default: `{x=0, y=0}`
  5825. * `num_frames`: Total frames in the texture, default: `1`
  5826. * `framelength`: Time per animated frame in seconds, default: `0.2`
  5827. * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
  5828. position according to the view direction. default: `false`.
  5829. * First column: subject facing the camera
  5830. * Second column: subject looking to the left
  5831. * Third column: subject backing the camera
  5832. * Fourth column: subject looking to the right
  5833. * Fifth column: subject viewed from above
  5834. * Sixth column: subject viewed from below
  5835. * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
  5836. * `get_luaentity()`
  5837. #### Player only (no-op for other objects)
  5838. * `get_player_name()`: returns `""` if is not a player
  5839. * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
  5840. table {x, y, z} representing the player's instantaneous velocity in nodes/s
  5841. * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
  5842. * `get_look_dir()`: get camera direction as a unit vector
  5843. * `get_look_vertical()`: pitch in radians
  5844. * Angle ranges between -pi/2 and pi/2, which are straight up and down
  5845. respectively.
  5846. * `get_look_horizontal()`: yaw in radians
  5847. * Angle is counter-clockwise from the +z direction.
  5848. * `set_look_vertical(radians)`: sets look pitch
  5849. * radians: Angle from looking forward, where positive is downwards.
  5850. * `set_look_horizontal(radians)`: sets look yaw
  5851. * radians: Angle from the +z direction, where positive is counter-clockwise.
  5852. * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
  5853. `get_look_vertical`.
  5854. * Angle ranges between -pi/2 and pi/2, which are straight down and up
  5855. respectively.
  5856. * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
  5857. `get_look_horizontal`.
  5858. * Angle is counter-clockwise from the +x direction.
  5859. * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
  5860. `set_look_vertical`.
  5861. * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
  5862. `set_look_horizontal`.
  5863. * `get_breath()`: returns player's breath
  5864. * `set_breath(value)`: sets player's breath
  5865. * values:
  5866. * `0`: player is drowning
  5867. * max: bubbles bar is not shown
  5868. * See [Object properties] for more information
  5869. * Is limited to range 0 ... 65535 (2^16 - 1)
  5870. * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
  5871. * `fov`: FOV value.
  5872. * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
  5873. Defaults to `false`.
  5874. * `transition_time`: If defined, enables smooth FOV transition.
  5875. Interpreted as the time (in seconds) to reach target FOV.
  5876. If set to 0, FOV change is instantaneous. Defaults to 0.
  5877. * Set `fov` to 0 to clear FOV override.
  5878. * `get_fov()`: Returns the following:
  5879. * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
  5880. * Boolean indicating whether the FOV value is a multiplier.
  5881. * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
  5882. * `set_attribute(attribute, value)`: DEPRECATED, use get_meta() instead
  5883. * Sets an extra attribute with value on player.
  5884. * `value` must be a string, or a number which will be converted to a
  5885. string.
  5886. * If `value` is `nil`, remove attribute from player.
  5887. * `get_attribute(attribute)`: DEPRECATED, use get_meta() instead
  5888. * Returns value (a string) for extra attribute.
  5889. * Returns `nil` if no attribute found.
  5890. * `get_meta()`: Returns a PlayerMetaRef.
  5891. * `set_inventory_formspec(formspec)`
  5892. * Redefine player's inventory form
  5893. * Should usually be called in `on_joinplayer`
  5894. * If `formspec` is `""`, the player's inventory is disabled.
  5895. * `get_inventory_formspec()`: returns a formspec string
  5896. * `set_formspec_prepend(formspec)`:
  5897. * the formspec string will be added to every formspec shown to the user,
  5898. except for those with a no_prepend[] tag.
  5899. * This should be used to set style elements such as background[] and
  5900. bgcolor[], any non-style elements (eg: label) may result in weird behavior.
  5901. * Only affects formspecs shown after this is called.
  5902. * `get_formspec_prepend(formspec)`: returns a formspec string.
  5903. * `get_player_control()`: returns table with player pressed keys
  5904. * The table consists of fields with the following boolean values
  5905. representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
  5906. `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
  5907. * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
  5908. and exist only to preserve backwards compatibility.
  5909. * Returns an empty table `{}` if the object is not a player.
  5910. * `get_player_control_bits()`: returns integer with bit packed player pressed
  5911. keys.
  5912. * Bits:
  5913. * 0 - up
  5914. * 1 - down
  5915. * 2 - left
  5916. * 3 - right
  5917. * 4 - jump
  5918. * 5 - aux1
  5919. * 6 - sneak
  5920. * 7 - dig
  5921. * 8 - place
  5922. * 9 - zoom
  5923. * Returns `0` (no bits set) if the object is not a player.
  5924. * `set_physics_override(override_table)`
  5925. * `override_table` is a table with the following fields:
  5926. * `speed`: multiplier to default walking speed value (default: `1`)
  5927. * `jump`: multiplier to default jump value (default: `1`)
  5928. * `gravity`: multiplier to default gravity value (default: `1`)
  5929. * `sneak`: whether player can sneak (default: `true`)
  5930. * `sneak_glitch`: whether player can use the new move code replications
  5931. of the old sneak side-effects: sneak ladders and 2 node sneak jump
  5932. (default: `false`)
  5933. * `new_move`: use new move/sneak code. When `false` the exact old code
  5934. is used for the specific old sneak behavior (default: `true`)
  5935. * `get_physics_override()`: returns the table given to `set_physics_override`
  5936. * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
  5937. number on success
  5938. * `hud_remove(id)`: remove the HUD element of the specified id
  5939. * `hud_change(id, stat, value)`: change a value of a previously added HUD
  5940. element.
  5941. * `stat` supports the same keys as in the hud definition table except for
  5942. `"hud_elem_type"`.
  5943. * `hud_get(id)`: gets the HUD element definition structure of the specified ID
  5944. * `hud_set_flags(flags)`: sets specified HUD flags of player.
  5945. * `flags`: A table with the following fields set to boolean values
  5946. * `hotbar`
  5947. * `healthbar`
  5948. * `crosshair`
  5949. * `wielditem`
  5950. * `breathbar`
  5951. * `minimap`: Modifies the client's permission to view the minimap.
  5952. The client may locally elect to not view the minimap.
  5953. * `minimap_radar`: is only usable when `minimap` is true
  5954. * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
  5955. This includes map seed, player position, look direction, the pointed node and block bounds.
  5956. Does not affect players with the `debug` privilege.
  5957. * If a flag equals `nil`, the flag is not modified
  5958. * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
  5959. * See `hud_set_flags` for a list of flags that can be toggled.
  5960. * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
  5961. * `count`: number of items, must be between `1` and `32`
  5962. * `hud_get_hotbar_itemcount`: returns number of visible items
  5963. * `hud_set_hotbar_image(texturename)`
  5964. * sets background image for hotbar
  5965. * `hud_get_hotbar_image`: returns texturename
  5966. * `hud_set_hotbar_selected_image(texturename)`
  5967. * sets image for selected item of hotbar
  5968. * `hud_get_hotbar_selected_image`: returns texturename
  5969. * `set_minimap_modes({mode, mode, ...}, selected_mode)`
  5970. * Overrides the available minimap modes (and toggle order), and changes the
  5971. selected mode.
  5972. * `mode` is a table consisting of up to four fields:
  5973. * `type`: Available type:
  5974. * `off`: Minimap off
  5975. * `surface`: Minimap in surface mode
  5976. * `radar`: Minimap in radar mode
  5977. * `texture`: Texture to be displayed instead of terrain map
  5978. (texture is centered around 0,0 and can be scaled).
  5979. Texture size is limited to 512 x 512 pixel.
  5980. * `label`: Optional label to display on minimap mode toggle
  5981. The translation must be handled within the mod.
  5982. * `size`: Sidelength or diameter, in number of nodes, of the terrain
  5983. displayed in minimap
  5984. * `texture`: Only for texture type, name of the texture to display
  5985. * `scale`: Only for texture type, scale of the texture map in nodes per
  5986. pixel (for example a `scale` of 2 means each pixel represents a 2x2
  5987. nodes square)
  5988. * `selected_mode` is the mode index to be selected after modes have been changed
  5989. (0 is the first mode).
  5990. * `set_sky(sky_parameters)`
  5991. * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
  5992. whether `set_sky` accepts this format. Check the legacy format otherwise.
  5993. * Passing no arguments resets the sky to its default values.
  5994. * `sky_parameters` is a table with the following optional fields:
  5995. * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
  5996. (default: `#ffffff`)
  5997. * `type`: Available types:
  5998. * `"regular"`: Uses 0 textures, `base_color` ignored
  5999. * `"skybox"`: Uses 6 textures, `base_color` used as fog.
  6000. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
  6001. (default: `"regular"`)
  6002. * `textures`: A table containing up to six textures in the following
  6003. order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
  6004. * `clouds`: Boolean for whether clouds appear. (default: `true`)
  6005. * `sky_color`: A table used in `"regular"` type only, containing the
  6006. following values (alpha is ignored):
  6007. * `day_sky`: ColorSpec, for the top half of the sky during the day.
  6008. (default: `#61b5f5`)
  6009. * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
  6010. (default: `#90d3f6`)
  6011. * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
  6012. (default: `#b4bafa`)
  6013. The resulting sky color will be a darkened version of the ColorSpec.
  6014. Warning: The darkening of the ColorSpec is subject to change.
  6015. * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
  6016. (default: `#bac1f0`)
  6017. The resulting sky color will be a darkened version of the ColorSpec.
  6018. Warning: The darkening of the ColorSpec is subject to change.
  6019. * `night_sky`: ColorSpec, for the top half of the sky during the night.
  6020. (default: `#006bff`)
  6021. The resulting sky color will be a dark version of the ColorSpec.
  6022. Warning: The darkening of the ColorSpec is subject to change.
  6023. * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
  6024. (default: `#4090ff`)
  6025. The resulting sky color will be a dark version of the ColorSpec.
  6026. Warning: The darkening of the ColorSpec is subject to change.
  6027. * `indoors`: ColorSpec, for when you're either indoors or underground.
  6028. (default: `#646464`)
  6029. * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
  6030. at sunrise and sunset. (default: `#f47d1d`)
  6031. * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
  6032. at sunrise and sunset. (default: `#7f99cc`)
  6033. * `fog_tint_type`: string, changes which mode the directional fog
  6034. abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
  6035. `"default"` uses the classic Minetest sun and moon tinting.
  6036. Will use tonemaps, if set to `"default"`. (default: `"default"`)
  6037. * `set_sky(base_color, type, {texture names}, clouds)`
  6038. * Deprecated. Use `set_sky(sky_parameters)`
  6039. * `base_color`: ColorSpec, defaults to white
  6040. * `type`: Available types:
  6041. * `"regular"`: Uses 0 textures, `bgcolor` ignored
  6042. * `"skybox"`: Uses 6 textures, `bgcolor` used
  6043. * `"plain"`: Uses 0 textures, `bgcolor` used
  6044. * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
  6045. `"plain"` custom skyboxes (default: `true`)
  6046. * `get_sky(as_table)`:
  6047. * `as_table`: boolean that determines whether the deprecated version of this
  6048. function is being used.
  6049. * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
  6050. * Deprecated: `false` or `nil` returns base_color, type, table of textures,
  6051. clouds.
  6052. * `get_sky_color()`:
  6053. * Deprecated: Use `get_sky(as_table)` instead.
  6054. * returns a table with the `sky_color` parameters as in `set_sky`.
  6055. * `set_sun(sun_parameters)`:
  6056. * Passing no arguments resets the sun to its default values.
  6057. * `sun_parameters` is a table with the following optional fields:
  6058. * `visible`: Boolean for whether the sun is visible.
  6059. (default: `true`)
  6060. * `texture`: A regular texture for the sun. Setting to `""`
  6061. will re-enable the mesh sun. (default: "sun.png", if it exists)
  6062. The texture appears non-rotated at sunrise and rotated 180 degrees
  6063. (upside down) at sunset.
  6064. * `tonemap`: A 512x1 texture containing the tonemap for the sun
  6065. (default: `"sun_tonemap.png"`)
  6066. * `sunrise`: A regular texture for the sunrise texture.
  6067. (default: `"sunrisebg.png"`)
  6068. * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
  6069. (default: `true`)
  6070. * `scale`: Float controlling the overall size of the sun. (default: `1`)
  6071. Note: For legacy reasons, the sun is bigger than the moon by a factor
  6072. of about `1.57` for equal `scale` values.
  6073. * `get_sun()`: returns a table with the current sun parameters as in
  6074. `set_sun`.
  6075. * `set_moon(moon_parameters)`:
  6076. * Passing no arguments resets the moon to its default values.
  6077. * `moon_parameters` is a table with the following optional fields:
  6078. * `visible`: Boolean for whether the moon is visible.
  6079. (default: `true`)
  6080. * `texture`: A regular texture for the moon. Setting to `""`
  6081. will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
  6082. The texture appears non-rotated at sunrise / moonset and rotated 180
  6083. degrees (upside down) at sunset / moonrise.
  6084. Note: Relative to the sun, the moon texture is hence rotated by 180°.
  6085. You can use the `^[transformR180` texture modifier to achieve the same orientation.
  6086. * `tonemap`: A 512x1 texture containing the tonemap for the moon
  6087. (default: `"moon_tonemap.png"`)
  6088. * `scale`: Float controlling the overall size of the moon (default: `1`)
  6089. Note: For legacy reasons, the sun is bigger than the moon by a factor
  6090. of about `1.57` for equal `scale` values.
  6091. * `get_moon()`: returns a table with the current moon parameters as in
  6092. `set_moon`.
  6093. * `set_stars(star_parameters)`:
  6094. * Passing no arguments resets stars to their default values.
  6095. * `star_parameters` is a table with the following optional fields:
  6096. * `visible`: Boolean for whether the stars are visible.
  6097. (default: `true`)
  6098. * `day_opacity`: Float for maximum opacity of stars at day.
  6099. No effect if `visible` is false.
  6100. (default: 0.0; maximum: 1.0; minimum: 0.0)
  6101. * `count`: Integer number to set the number of stars in
  6102. the skybox. Only applies to `"skybox"` and `"regular"` sky types.
  6103. (default: `1000`)
  6104. * `star_color`: ColorSpec, sets the colors of the stars,
  6105. alpha channel is used to set overall star brightness.
  6106. (default: `#ebebff69`)
  6107. * `scale`: Float controlling the overall size of the stars (default: `1`)
  6108. * `get_stars()`: returns a table with the current stars parameters as in
  6109. `set_stars`.
  6110. * `set_clouds(cloud_parameters)`: set cloud parameters
  6111. * Passing no arguments resets clouds to their default values.
  6112. * `cloud_parameters` is a table with the following optional fields:
  6113. * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
  6114. * `color`: basic cloud color with alpha channel, ColorSpec
  6115. (default `#fff0f0e5`).
  6116. * `ambient`: cloud color lower bound, use for a "glow at night" effect.
  6117. ColorSpec (alpha ignored, default `#000000`)
  6118. * `height`: cloud height, i.e. y of cloud base (default per conf,
  6119. usually `120`)
  6120. * `thickness`: cloud thickness in nodes (default `16`)
  6121. * `speed`: 2D cloud speed + direction in nodes per second
  6122. (default `{x=0, z=-2}`).
  6123. * `get_clouds()`: returns a table with the current cloud parameters as in
  6124. `set_clouds`.
  6125. * `override_day_night_ratio(ratio or nil)`
  6126. * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
  6127. amount.
  6128. * `nil`: Disables override, defaulting to sunlight based on day-night cycle
  6129. * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
  6130. * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
  6131. set animation for player model in third person view.
  6132. * Every animation equals to a `{x=starting frame, y=ending frame}` table.
  6133. * `frame_speed` sets the animations frame speed. Default is 30.
  6134. * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
  6135. `frame_speed`.
  6136. * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
  6137. camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
  6138. * in first person view
  6139. * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
  6140. * `get_eye_offset()`: returns first and third person offsets.
  6141. * `send_mapblock(blockpos)`:
  6142. * Sends an already loaded mapblock to the player.
  6143. * Returns `false` if nothing was sent (note that this can also mean that
  6144. the client already has the block)
  6145. * Resource intensive - use sparsely
  6146. * `set_lighting(light_definition)`: sets lighting for the player
  6147. * `light_definition` is a table with the following optional fields:
  6148. * `shadows` is a table that controls ambient shadows
  6149. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
  6150. * `get_lighting()`: returns the current state of lighting for the player.
  6151. * Result is a table with the same fields as `light_definition` in `set_lighting`.
  6152. * `respawn()`: Respawns the player using the same mechanism as the death screen,
  6153. including calling on_respawnplayer callbacks.
  6154. `PcgRandom`
  6155. -----------
  6156. A 32-bit pseudorandom number generator.
  6157. Uses PCG32, an algorithm of the permuted congruential generator family,
  6158. offering very strong randomness.
  6159. It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
  6160. ### Methods
  6161. * `next()`: return next integer random number [`-2147483648`...`2147483647`]
  6162. * `next(min, max)`: return next integer random number [`min`...`max`]
  6163. * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
  6164. random number [`min`...`max`].
  6165. * This is only a rough approximation of a normal distribution with:
  6166. * `mean = (max - min) / 2`, and
  6167. * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
  6168. * Increasing `num_trials` improves accuracy of the approximation
  6169. `PerlinNoise`
  6170. -------------
  6171. A perlin noise generator.
  6172. It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
  6173. For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
  6174. plus the world seed, to create world-specific noise.
  6175. `PerlinNoise(noiseparams)`
  6176. `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
  6177. `minetest.get_perlin(noiseparams)`
  6178. `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
  6179. ### Methods
  6180. * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
  6181. * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
  6182. `PerlinNoiseMap`
  6183. ----------------
  6184. A fast, bulk perlin noise generator.
  6185. It can be created via `PerlinNoiseMap(noiseparams, size)` or
  6186. `minetest.get_perlin_map(noiseparams, size)`.
  6187. For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
  6188. plus the world seed, to create world-specific noise.
  6189. Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
  6190. for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
  6191. `nil` is returned).
  6192. For each of the functions with an optional `buffer` parameter: If `buffer` is
  6193. not nil, this table will be used to store the result instead of creating a new
  6194. table.
  6195. ### Methods
  6196. * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
  6197. with values starting at `pos={x=,y=}`
  6198. * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
  6199. 3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
  6200. * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
  6201. array of 2D noise with values starting at `pos={x=,y=}`
  6202. * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
  6203. * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
  6204. is stored internally.
  6205. * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
  6206. is stored internally.
  6207. * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
  6208. returns a slice of the most recently computed noise results. The result slice
  6209. begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
  6210. E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
  6211. offset y = 20:
  6212. `noisevals = noise:get_map_slice({y=20}, {y=2})`
  6213. It is important to note that `slice_offset` offset coordinates begin at 1,
  6214. and are relative to the starting position of the most recently calculated
  6215. noise.
  6216. To grab a single vertical column of noise starting at map coordinates
  6217. x = 1023, y=1000, z = 1000:
  6218. `noise:calc_3d_map({x=1000, y=1000, z=1000})`
  6219. `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
  6220. `PlayerMetaRef`
  6221. ---------------
  6222. Player metadata.
  6223. Uses the same method of storage as the deprecated player attribute API, so
  6224. data there will also be in player meta.
  6225. Can be obtained using `player:get_meta()`.
  6226. ### Methods
  6227. * All methods in MetaDataRef
  6228. `PseudoRandom`
  6229. --------------
  6230. A 16-bit pseudorandom number generator.
  6231. Uses a well-known LCG algorithm introduced by K&R.
  6232. It can be created via `PseudoRandom(seed)`.
  6233. ### Methods
  6234. * `next()`: return next integer random number [`0`...`32767`]
  6235. * `next(min, max)`: return next integer random number [`min`...`max`]
  6236. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
  6237. due to the simple implementation making bad distribution otherwise.
  6238. `Raycast`
  6239. ---------
  6240. A raycast on the map. It works with selection boxes.
  6241. Can be used as an iterator in a for loop as:
  6242. local ray = Raycast(...)
  6243. for pointed_thing in ray do
  6244. ...
  6245. end
  6246. The map is loaded as the ray advances. If the map is modified after the
  6247. `Raycast` is created, the changes may or may not have an effect on the object.
  6248. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  6249. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  6250. * `pos1`: start of the ray
  6251. * `pos2`: end of the ray
  6252. * `objects`: if false, only nodes will be returned. Default is true.
  6253. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  6254. returned. Default is false.
  6255. ### Limitations
  6256. Raycasts don't always work properly for attached objects as the server has no knowledge of models & bones.
  6257. **Rotated selectionboxes paired with `automatic_rotate` are not reliable** either since the server
  6258. can't reliably know the total rotation of the objects on different clients (which may differ on a per-client basis).
  6259. The server calculates the total rotation incurred through `automatic_rotate` as a "best guess"
  6260. assuming the object was active & rotating on the client all the time since its creation.
  6261. This may be significantly out of sync with what clients see.
  6262. Additionally, network latency and delayed property sending may create a mismatch of client- & server rotations.
  6263. In singleplayer mode, raycasts on objects with rotated selectionboxes & automatic rotate will usually only be slightly off;
  6264. toggling automatic rotation may however cause errors to add up.
  6265. In multiplayer mode, the error may be arbitrarily large.
  6266. ### Methods
  6267. * `next()`: returns a `pointed_thing` with exact pointing location
  6268. * Returns the next thing pointed by the ray or nil.
  6269. `SecureRandom`
  6270. --------------
  6271. Interface for the operating system's crypto-secure PRNG.
  6272. It can be created via `SecureRandom()`. The constructor returns nil if a
  6273. secure random device cannot be found on the system.
  6274. ### Methods
  6275. * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
  6276. random bytes, as a string.
  6277. `Settings`
  6278. ----------
  6279. An interface to read config files in the format of `minetest.conf`.
  6280. It can be created via `Settings(filename)`.
  6281. ### Methods
  6282. * `get(key)`: returns a value
  6283. * `get_bool(key, [default])`: returns a boolean
  6284. * `default` is the value returned if `key` is not found.
  6285. * Returns `nil` if `key` is not found and `default` not specified.
  6286. * `get_np_group(key)`: returns a NoiseParams table
  6287. * `get_flags(key)`:
  6288. * Returns `{flag = true/false, ...}` according to the set flags.
  6289. * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
  6290. flags like `mgv5_spflags`.
  6291. * `set(key, value)`
  6292. * Setting names can't contain whitespace or any of `="{}#`.
  6293. * Setting values can't contain the sequence `\n"""`.
  6294. * Setting names starting with "secure." can't be set on the main settings
  6295. object (`minetest.settings`).
  6296. * `set_bool(key, value)`
  6297. * See documentation for set() above.
  6298. * `set_np_group(key, value)`
  6299. * `value` is a NoiseParams table.
  6300. * Also, see documentation for set() above.
  6301. * `remove(key)`: returns a boolean (`true` for success)
  6302. * `get_names()`: returns `{key1,...}`
  6303. * `write()`: returns a boolean (`true` for success)
  6304. * Writes changes to file.
  6305. * `to_table()`: returns `{[key1]=value1,...}`
  6306. ### Format
  6307. The settings have the format `key = value`. Example:
  6308. foo = example text
  6309. bar = """
  6310. Multiline
  6311. value
  6312. """
  6313. `StorageRef`
  6314. ------------
  6315. Mod metadata: per mod metadata, saved automatically.
  6316. Can be obtained via `minetest.get_mod_storage()` during load time.
  6317. WARNING: This storage backend is incapable of saving raw binary data due
  6318. to restrictions of JSON.
  6319. ### Methods
  6320. * All methods in MetaDataRef
  6321. Definition tables
  6322. =================
  6323. Object properties
  6324. -----------------
  6325. Used by `ObjectRef` methods. Part of an Entity definition.
  6326. These properties are not persistent, but are applied automatically to the
  6327. corresponding Lua entity using the given registration fields.
  6328. Player properties need to be saved manually.
  6329. {
  6330. hp_max = 10,
  6331. -- Defines the maximum and default HP of the entity
  6332. -- For Lua entities the maximum is not enforced.
  6333. -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
  6334. breath_max = 0,
  6335. -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
  6336. zoom_fov = 0.0,
  6337. -- For players only. Zoom FOV in degrees.
  6338. -- Note that zoom loads and/or generates world beyond the server's
  6339. -- maximum send and generate distances, so acts like a telescope.
  6340. -- Smaller zoom_fov values increase the distance loaded/generated.
  6341. -- Defaults to 15 in creative mode, 0 in survival mode.
  6342. -- zoom_fov = 0 disables zooming for the player.
  6343. eye_height = 1.625,
  6344. -- For players only. Camera height above feet position in nodes.
  6345. physical = false,
  6346. -- Collide with `walkable` nodes.
  6347. collide_with_objects = true,
  6348. -- Collide with other objects if physical = true
  6349. collisionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, -- default
  6350. selectionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, rotate = false },
  6351. -- { xmin, ymin, zmin, xmax, ymax, zmax } in nodes from object position.
  6352. -- Collision boxes cannot rotate, setting `rotate = true` on it has no effect.
  6353. -- If not set, the selection box copies the collision box, and will also not rotate.
  6354. -- If `rotate = false`, the selection box will not rotate with the object itself, remaining fixed to the axes.
  6355. -- If `rotate = true`, it will match the object's rotation and any attachment rotations.
  6356. -- Raycasts use the selection box and object's rotation, but do *not* obey attachment rotations.
  6357. pointable = true,
  6358. -- Whether the object can be pointed at
  6359. visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
  6360. -- "cube" is a node-sized cube.
  6361. -- "sprite" is a flat texture always facing the player.
  6362. -- "upright_sprite" is a vertical flat texture.
  6363. -- "mesh" uses the defined mesh model.
  6364. -- "wielditem" is used for dropped items.
  6365. -- (see builtin/game/item_entity.lua).
  6366. -- For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
  6367. -- If the item has a 'wield_image' the object will be an extrusion of
  6368. -- that, otherwise:
  6369. -- If 'itemname' is a cubic node or nodebox the object will appear
  6370. -- identical to 'itemname'.
  6371. -- If 'itemname' is a plantlike node the object will be an extrusion
  6372. -- of its texture.
  6373. -- Otherwise for non-node items, the object will be an extrusion of
  6374. -- 'inventory_image'.
  6375. -- If 'itemname' contains a ColorString or palette index (e.g. from
  6376. -- `minetest.itemstring_with_palette()`), the entity will inherit the color.
  6377. -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
  6378. visual_size = {x = 1, y = 1, z = 1},
  6379. -- Multipliers for the visual size. If `z` is not specified, `x` will be used
  6380. -- to scale the entity along both horizontal axes.
  6381. mesh = "model.obj",
  6382. -- File name of mesh when using "mesh" visual
  6383. textures = {},
  6384. -- Number of required textures depends on visual.
  6385. -- "cube" uses 6 textures just like a node, but all 6 must be defined.
  6386. -- "sprite" uses 1 texture.
  6387. -- "upright_sprite" uses 2 textures: {front, back}.
  6388. -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
  6389. -- "mesh" requires one texture for each mesh buffer/material (in order)
  6390. colors = {},
  6391. -- Number of required colors depends on visual
  6392. use_texture_alpha = false,
  6393. -- Use texture's alpha channel.
  6394. -- Excludes "upright_sprite" and "wielditem".
  6395. -- Note: currently causes visual issues when viewed through other
  6396. -- semi-transparent materials such as water.
  6397. spritediv = {x = 1, y = 1},
  6398. -- Used with spritesheet textures for animation and/or frame selection
  6399. -- according to position relative to player.
  6400. -- Defines the number of columns and rows in the spritesheet:
  6401. -- {columns, rows}.
  6402. initial_sprite_basepos = {x = 0, y = 0},
  6403. -- Used with spritesheet textures.
  6404. -- Defines the {column, row} position of the initially used frame in the
  6405. -- spritesheet.
  6406. is_visible = true,
  6407. -- If false, object is invisible and can't be pointed.
  6408. makes_footstep_sound = false,
  6409. -- If true, is able to make footstep sounds of nodes
  6410. -- (see node sound definition for details).
  6411. automatic_rotate = 0,
  6412. -- Set constant rotation in radians per second, positive or negative.
  6413. -- Object rotates along the local Y-axis, and works with set_rotation.
  6414. -- Set to 0 to disable constant rotation.
  6415. stepheight = 0,
  6416. -- If positive number, object will climb upwards when it moves
  6417. -- horizontally against a `walkable` node, if the height difference
  6418. -- is within `stepheight`.
  6419. automatic_face_movement_dir = 0.0,
  6420. -- Automatically set yaw to movement direction, offset in degrees.
  6421. -- 'false' to disable.
  6422. automatic_face_movement_max_rotation_per_sec = -1,
  6423. -- Limit automatic rotation to this value in degrees per second.
  6424. -- No limit if value <= 0.
  6425. backface_culling = true,
  6426. -- Set to false to disable backface_culling for model
  6427. glow = 0,
  6428. -- Add this much extra lighting when calculating texture color.
  6429. -- Value < 0 disables light's effect on texture color.
  6430. -- For faking self-lighting, UI style entities, or programmatic coloring
  6431. -- in mods.
  6432. nametag = "",
  6433. -- The name to display on the head of the object. By default empty.
  6434. -- If the object is a player, a nil or empty nametag is replaced by the player's name.
  6435. -- For all other objects, a nil or empty string removes the nametag.
  6436. -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
  6437. nametag_color = <ColorSpec>,
  6438. -- Sets text color of nametag
  6439. nametag_bgcolor = <ColorSpec>,
  6440. -- Sets background color of nametag
  6441. -- `false` will cause the background to be set automatically based on user settings.
  6442. -- Default: false
  6443. infotext = "",
  6444. -- Same as infotext for nodes. Empty by default
  6445. static_save = true,
  6446. -- If false, never save this object statically. It will simply be
  6447. -- deleted when the block gets unloaded.
  6448. -- The get_staticdata() callback is never called then.
  6449. -- Defaults to 'true'.
  6450. damage_texture_modifier = "^[brighten",
  6451. -- Texture modifier to be applied for a short duration when object is hit
  6452. shaded = true,
  6453. -- Setting this to 'false' disables diffuse lighting of entity
  6454. show_on_minimap = false,
  6455. -- Defaults to true for players, false for other entities.
  6456. -- If set to true the entity will show as a marker on the minimap.
  6457. }
  6458. Entity definition
  6459. -----------------
  6460. Used by `minetest.register_entity`.
  6461. {
  6462. initial_properties = {
  6463. visual = "mesh",
  6464. mesh = "boats_boat.obj",
  6465. ...,
  6466. },
  6467. -- A table of object properties, see the `Object properties` section.
  6468. -- The properties in this table are applied to the object
  6469. -- once when it is spawned.
  6470. -- Refer to the "Registered entities" section for explanations
  6471. on_activate = function(self, staticdata, dtime_s),
  6472. on_deactivate = function(self, removal),
  6473. on_step = function(self, dtime, moveresult),
  6474. on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
  6475. on_death = function(self, killer),
  6476. on_rightclick = function(self, clicker),
  6477. on_attach_child = function(self, child),
  6478. on_detach_child = function(self, child),
  6479. on_detach = function(self, parent),
  6480. get_staticdata = function(self),
  6481. _custom_field = whatever,
  6482. -- You can define arbitrary member variables here (see Item definition
  6483. -- for more info) by using a '_' prefix
  6484. }
  6485. ABM (ActiveBlockModifier) definition
  6486. ------------------------------------
  6487. Used by `minetest.register_abm`.
  6488. {
  6489. label = "Lava cooling",
  6490. -- Descriptive label for profiling purposes (optional).
  6491. -- Definitions with identical labels will be listed as one.
  6492. nodenames = {"default:lava_source"},
  6493. -- Apply `action` function to these nodes.
  6494. -- `group:groupname` can also be used here.
  6495. neighbors = {"default:water_source", "default:water_flowing"},
  6496. -- Only apply `action` to nodes that have one of, or any
  6497. -- combination of, these neighbors.
  6498. -- If left out or empty, any neighbor will do.
  6499. -- `group:groupname` can also be used here.
  6500. interval = 1.0,
  6501. -- Operation interval in seconds
  6502. chance = 1,
  6503. -- Chance of triggering `action` per-node per-interval is 1.0 / this
  6504. -- value
  6505. min_y = -32768,
  6506. max_y = 32767,
  6507. -- min and max height levels where ABM will be processed (inclusive)
  6508. -- can be used to reduce CPU usage
  6509. catch_up = true,
  6510. -- If true, catch-up behavior is enabled: The `chance` value is
  6511. -- temporarily reduced when returning to an area to simulate time lost
  6512. -- by the area being unattended. Note that the `chance` value can often
  6513. -- be reduced to 1.
  6514. action = function(pos, node, active_object_count, active_object_count_wider),
  6515. -- Function triggered for each qualifying node.
  6516. -- `active_object_count` is number of active objects in the node's
  6517. -- mapblock.
  6518. -- `active_object_count_wider` is number of active objects in the node's
  6519. -- mapblock plus all 26 neighboring mapblocks. If any neighboring
  6520. -- mapblocks are unloaded an estimate is calculated for them based on
  6521. -- loaded mapblocks.
  6522. }
  6523. LBM (LoadingBlockModifier) definition
  6524. -------------------------------------
  6525. Used by `minetest.register_lbm`.
  6526. A loading block modifier (LBM) is used to define a function that is called for
  6527. specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
  6528. gets activated (not loaded!)
  6529. {
  6530. label = "Upgrade legacy doors",
  6531. -- Descriptive label for profiling purposes (optional).
  6532. -- Definitions with identical labels will be listed as one.
  6533. name = "modname:replace_legacy_door",
  6534. -- Identifier of the LBM, should follow the modname:<whatever> convention
  6535. nodenames = {"default:lava_source"},
  6536. -- List of node names to trigger the LBM on.
  6537. -- Names of non-registered nodes and groups (as group:groupname)
  6538. -- will work as well.
  6539. run_at_every_load = false,
  6540. -- Whether to run the LBM's action every time a block gets activated,
  6541. -- and not only the first time the block gets activated after the LBM
  6542. -- was introduced.
  6543. action = function(pos, node),
  6544. -- Function triggered for each qualifying node.
  6545. }
  6546. Tile definition
  6547. ---------------
  6548. * `"image.png"`
  6549. * `{name="image.png", animation={Tile Animation definition}}`
  6550. * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
  6551. * backface culling enabled by default for most nodes
  6552. * align style determines whether the texture will be rotated with the node
  6553. or kept aligned with its surroundings. "user" means that client
  6554. setting will be used, similar to `glasslike_framed_optional`.
  6555. Note: supported by solid nodes and nodeboxes only.
  6556. * scale is used to make texture span several (exactly `scale`) nodes,
  6557. instead of just one, in each direction. Works for world-aligned
  6558. textures only.
  6559. Note that as the effect is applied on per-mapblock basis, `16` should
  6560. be equally divisible by `scale` or you may get wrong results.
  6561. * `{name="image.png", color=ColorSpec}`
  6562. * the texture's color will be multiplied with this color.
  6563. * the tile's color overrides the owning node's color in all cases.
  6564. * deprecated, yet still supported field names:
  6565. * `image` (name)
  6566. Tile animation definition
  6567. -------------------------
  6568. {
  6569. type = "vertical_frames",
  6570. aspect_w = 16,
  6571. -- Width of a frame in pixels
  6572. aspect_h = 16,
  6573. -- Height of a frame in pixels
  6574. length = 3.0,
  6575. -- Full loop length
  6576. }
  6577. {
  6578. type = "sheet_2d",
  6579. frames_w = 5,
  6580. -- Width in number of frames
  6581. frames_h = 3,
  6582. -- Height in number of frames
  6583. frame_length = 0.5,
  6584. -- Length of a single frame
  6585. }
  6586. Item definition
  6587. ---------------
  6588. Used by `minetest.register_node`, `minetest.register_craftitem`, and
  6589. `minetest.register_tool`.
  6590. {
  6591. description = "",
  6592. -- Can contain new lines. "\n" has to be used as new line character.
  6593. -- See also: `get_description` in [`ItemStack`]
  6594. short_description = "",
  6595. -- Must not contain new lines.
  6596. -- Defaults to nil.
  6597. -- Use an [`ItemStack`] to get the short description, e.g.:
  6598. -- ItemStack(itemname):get_short_description()
  6599. groups = {},
  6600. -- key = name, value = rating; rating = <number>.
  6601. -- If rating not applicable, use 1.
  6602. -- e.g. {wool = 1, fluffy = 3}
  6603. -- {soil = 2, outerspace = 1, crumbly = 1}
  6604. -- {bendy = 2, snappy = 1},
  6605. -- {hard = 1, metal = 1, spikes = 1}
  6606. inventory_image = "",
  6607. -- Texture shown in the inventory GUI
  6608. -- Defaults to a 3D rendering of the node if left empty.
  6609. inventory_overlay = "",
  6610. -- An overlay texture which is not affected by colorization
  6611. wield_image = "",
  6612. -- Texture shown when item is held in hand
  6613. -- Defaults to a 3D rendering of the node if left empty.
  6614. wield_overlay = "",
  6615. -- Like inventory_overlay but only used in the same situation as wield_image
  6616. wield_scale = {x = 1, y = 1, z = 1},
  6617. -- Scale for the item when held in hand
  6618. palette = "",
  6619. -- An image file containing the palette of a node.
  6620. -- You can set the currently used color as the "palette_index" field of
  6621. -- the item stack metadata.
  6622. -- The palette is always stretched to fit indices between 0 and 255, to
  6623. -- ensure compatibility with "colorfacedir" (and similar) nodes.
  6624. color = "#ffffffff",
  6625. -- Color the item is colorized with. The palette overrides this.
  6626. stack_max = 99,
  6627. -- Maximum amount of items that can be in a single stack.
  6628. -- The default can be changed by the setting `default_stack_max`
  6629. range = 4.0,
  6630. -- Range of node and object pointing that is possible with this item held
  6631. liquids_pointable = false,
  6632. -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
  6633. -- even those for which `pointable = false`
  6634. light_source = 0,
  6635. -- When used for nodes: Defines amount of light emitted by node.
  6636. -- Otherwise: Defines texture glow when viewed as a dropped item
  6637. -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
  6638. -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
  6639. -- behavior.
  6640. -- See "Tool Capabilities" section for an example including explanation
  6641. tool_capabilities = {
  6642. full_punch_interval = 1.0,
  6643. max_drop_level = 0,
  6644. groupcaps = {
  6645. -- For example:
  6646. choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
  6647. },
  6648. damage_groups = {groupname = damage},
  6649. -- Damage values must be between -32768 and 32767 (2^15)
  6650. punch_attack_uses = nil,
  6651. -- Amount of uses this tool has for attacking players and entities
  6652. -- by punching them (0 = infinite uses).
  6653. -- For compatibility, this is automatically set from the first
  6654. -- suitable groupcap using the formula "uses * 3^(maxlevel - 1)".
  6655. -- It is recommend to set this explicitly instead of relying on the
  6656. -- fallback behavior.
  6657. },
  6658. node_placement_prediction = nil,
  6659. -- If nil and item is node, prediction is made automatically.
  6660. -- If nil and item is not a node, no prediction is made.
  6661. -- If "" and item is anything, no prediction is made.
  6662. -- Otherwise should be name of node which the client immediately places
  6663. -- on ground when the player places the item. Server will always update
  6664. -- with actual result shortly.
  6665. node_dig_prediction = "air",
  6666. -- if "", no prediction is made.
  6667. -- if "air", node is removed.
  6668. -- Otherwise should be name of node which the client immediately places
  6669. -- upon digging. Server will always update with actual result shortly.
  6670. sound = {
  6671. -- Definition of item sounds to be played at various events.
  6672. -- All fields in this table are optional.
  6673. breaks = <SimpleSoundSpec>,
  6674. -- When tool breaks due to wear. Ignored for non-tools
  6675. eat = <SimpleSoundSpec>,
  6676. -- When item is eaten with `minetest.do_item_eat`
  6677. punch_use = <SimpleSoundSpec>,
  6678. -- When item is used with the 'punch/mine' key pointing at a node or entity
  6679. punch_use_air = <SimpleSoundSpec>,
  6680. -- When item is used with the 'punch/mine' key pointing at nothing (air)
  6681. },
  6682. on_place = function(itemstack, placer, pointed_thing),
  6683. -- When the 'place' key was pressed with the item in hand
  6684. -- and a node was pointed at.
  6685. -- Shall place item and return the leftover itemstack
  6686. -- or nil to not modify the inventory.
  6687. -- The placer may be any ObjectRef or nil.
  6688. -- default: minetest.item_place
  6689. on_secondary_use = function(itemstack, user, pointed_thing),
  6690. -- Same as on_place but called when not pointing at a node.
  6691. -- Function must return either nil if inventory shall not be modified,
  6692. -- or an itemstack to replace the original itemstack.
  6693. -- The user may be any ObjectRef or nil.
  6694. -- default: nil
  6695. on_drop = function(itemstack, dropper, pos),
  6696. -- Shall drop item and return the leftover itemstack.
  6697. -- The dropper may be any ObjectRef or nil.
  6698. -- default: minetest.item_drop
  6699. on_pickup = function(itemstack, picker, pointed_thing, time_from_last_punch, ...),
  6700. -- Called when a dropped item is punched by a player.
  6701. -- Shall pick-up the item and return the leftover itemstack or nil to not
  6702. -- modify the dropped item.
  6703. -- Parameters:
  6704. -- * `itemstack`: The `ItemStack` to be picked up.
  6705. -- * `picker`: Any `ObjectRef` or `nil`.
  6706. -- * `pointed_thing` (optional): The dropped item (a `"__builtin:item"`
  6707. -- luaentity) as `type="object"` `pointed_thing`.
  6708. -- * `time_from_last_punch, ...` (optional): Other parameters from
  6709. -- `luaentity:on_punch`.
  6710. -- default: `minetest.item_pickup`
  6711. on_use = function(itemstack, user, pointed_thing),
  6712. -- default: nil
  6713. -- When user pressed the 'punch/mine' key with the item in hand.
  6714. -- Function must return either nil if inventory shall not be modified,
  6715. -- or an itemstack to replace the original itemstack.
  6716. -- e.g. itemstack:take_item(); return itemstack
  6717. -- Otherwise, the function is free to do what it wants.
  6718. -- The user may be any ObjectRef or nil.
  6719. -- The default functions handle regular use cases.
  6720. after_use = function(itemstack, user, node, digparams),
  6721. -- default: nil
  6722. -- If defined, should return an itemstack and will be called instead of
  6723. -- wearing out the item (if tool). If returns nil, does nothing.
  6724. -- If after_use doesn't exist, it is the same as:
  6725. -- function(itemstack, user, node, digparams)
  6726. -- itemstack:add_wear(digparams.wear)
  6727. -- return itemstack
  6728. -- end
  6729. -- The user may be any ObjectRef or nil.
  6730. _custom_field = whatever,
  6731. -- Add your own custom fields. By convention, all custom field names
  6732. -- should start with `_` to avoid naming collisions with future engine
  6733. -- usage.
  6734. }
  6735. Node definition
  6736. ---------------
  6737. Used by `minetest.register_node`.
  6738. {
  6739. -- <all fields allowed in item definitions>
  6740. drawtype = "normal", -- See "Node drawtypes"
  6741. visual_scale = 1.0,
  6742. -- Supported for drawtypes "plantlike", "signlike", "torchlike",
  6743. -- "firelike", "mesh", "nodebox", "allfaces".
  6744. -- For plantlike and firelike, the image will start at the bottom of the
  6745. -- node. For torchlike, the image will start at the surface to which the
  6746. -- node "attaches". For the other drawtypes the image will be centered
  6747. -- on the node.
  6748. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6749. -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
  6750. -- List can be shortened to needed length.
  6751. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6752. -- Same as `tiles`, but these textures are drawn on top of the base
  6753. -- tiles. You can use this to colorize only specific parts of your
  6754. -- texture. If the texture name is an empty string, that overlay is not
  6755. -- drawn. Since such tiles are drawn twice, it is not recommended to use
  6756. -- overlays on very common nodes.
  6757. special_tiles = {tile definition 1, Tile definition 2},
  6758. -- Special textures of node; used rarely.
  6759. -- List can be shortened to needed length.
  6760. color = ColorSpec,
  6761. -- The node's original color will be multiplied with this color.
  6762. -- If the node has a palette, then this setting only has an effect in
  6763. -- the inventory and on the wield item.
  6764. use_texture_alpha = ...,
  6765. -- Specifies how the texture's alpha channel will be used for rendering.
  6766. -- possible values:
  6767. -- * "opaque": Node is rendered opaque regardless of alpha channel
  6768. -- * "clip": A given pixel is either fully see-through or opaque
  6769. -- depending on the alpha channel being below/above 50% in value
  6770. -- * "blend": The alpha channel specifies how transparent a given pixel
  6771. -- of the rendered node is
  6772. -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
  6773. -- "clip" otherwise.
  6774. -- If set to a boolean value (deprecated): true either sets it to blend
  6775. -- or clip, false sets it to clip or opaque mode depending on the drawtype.
  6776. palette = "",
  6777. -- The node's `param2` is used to select a pixel from the image.
  6778. -- Pixels are arranged from left to right and from top to bottom.
  6779. -- The node's color will be multiplied with the selected pixel's color.
  6780. -- Tiles can override this behavior.
  6781. -- Only when `paramtype2` supports palettes.
  6782. post_effect_color = "#00000000",
  6783. -- Screen tint if player is inside node, see "ColorSpec"
  6784. paramtype = "none", -- See "Nodes"
  6785. paramtype2 = "none", -- See "Nodes"
  6786. place_param2 = 0,
  6787. -- Value for param2 that is set when player places node
  6788. is_ground_content = true,
  6789. -- If false, the cave generator and dungeon generator will not carve
  6790. -- through this node.
  6791. -- Specifically, this stops mod-added nodes being removed by caves and
  6792. -- dungeons when those generate in a neighbor mapchunk and extend out
  6793. -- beyond the edge of that mapchunk.
  6794. sunlight_propagates = false,
  6795. -- If true, sunlight will go infinitely through this node
  6796. walkable = true, -- If true, objects collide with node
  6797. pointable = true, -- If true, can be pointed at
  6798. diggable = true, -- If false, can never be dug
  6799. climbable = false, -- If true, can be climbed on like a ladder
  6800. move_resistance = 0,
  6801. -- Slows down movement of players through this node (max. 7).
  6802. -- If this is nil, it will be equal to liquid_viscosity.
  6803. -- Note: If liquid movement physics apply to the node
  6804. -- (see `liquid_move_physics`), the movement speed will also be
  6805. -- affected by the `movement_liquid_*` settings.
  6806. buildable_to = false, -- If true, placed nodes can replace this node
  6807. floodable = false,
  6808. -- If true, liquids flow into and replace this node.
  6809. -- Warning: making a liquid node 'floodable' will cause problems.
  6810. liquidtype = "none", -- specifies liquid flowing physics
  6811. -- * "none": no liquid flowing physics
  6812. -- * "source": spawns flowing liquid nodes at all 4 sides and below;
  6813. -- recommended drawtype: "liquid".
  6814. -- * "flowing": spawned from source, spawns more flowing liquid nodes
  6815. -- around it until `liquid_range` is reached;
  6816. -- will drain out without a source;
  6817. -- recommended drawtype: "flowingliquid".
  6818. -- If it's "source" or "flowing", then the
  6819. -- `liquid_alternative_*` fields _must_ be specified
  6820. liquid_alternative_flowing = "",
  6821. liquid_alternative_source = "",
  6822. -- These fields may contain node names that represent the
  6823. -- flowing version (`liquid_alternative_flowing`) and
  6824. -- source version (`liquid_alternative_source`) of a liquid.
  6825. --
  6826. -- Specifically, these fields are required if any of these is true:
  6827. -- * `liquidtype ~= "none" or
  6828. -- * `drawtype == "liquid" or
  6829. -- * `drawtype == "flowingliquid"
  6830. --
  6831. -- Liquids consist of up to two nodes: source and flowing.
  6832. --
  6833. -- There are two ways to define a liquid:
  6834. -- 1) Source node and flowing node. This requires both fields to be
  6835. -- specified for both nodes.
  6836. -- 2) Standalone source node (cannot flow). `liquid_alternative_source`
  6837. -- must be specified and `liquid_range` must be set to 0.
  6838. --
  6839. -- Example:
  6840. -- liquid_alternative_flowing = "example:water_flowing",
  6841. -- liquid_alternative_source = "example:water_source",
  6842. liquid_viscosity = 0,
  6843. -- Controls speed at which the liquid spreads/flows (max. 7).
  6844. -- 0 is fastest, 7 is slowest.
  6845. -- By default, this also slows down movement of players inside the node
  6846. -- (can be overridden using `move_resistance`)
  6847. liquid_renewable = true,
  6848. -- If true, a new liquid source can be created by placing two or more
  6849. -- sources nearby
  6850. liquid_move_physics = nil, -- specifies movement physics if inside node
  6851. -- * false: No liquid movement physics apply.
  6852. -- * true: Enables liquid movement physics. Enables things like
  6853. -- ability to "swim" up/down, sinking slowly if not moving,
  6854. -- smoother speed change when falling into, etc. The `movement_liquid_*`
  6855. -- settings apply.
  6856. -- * nil: Will be treated as true if `liquidtype ~= "none"`
  6857. -- and as false otherwise.
  6858. leveled = 0,
  6859. -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
  6860. -- Allows defining the nodebox height without using param2.
  6861. -- The nodebox height is 'leveled' / 64 nodes.
  6862. -- The maximum value of 'leveled' is `leveled_max`.
  6863. leveled_max = 127,
  6864. -- Maximum value for `leveled` (0-127), enforced in
  6865. -- `minetest.set_node_level` and `minetest.add_node_level`.
  6866. -- Values above 124 might causes collision detection issues.
  6867. liquid_range = 8,
  6868. -- Maximum distance that flowing liquid nodes can spread around
  6869. -- source on flat land;
  6870. -- maximum = 8; set to 0 to disable liquid flow
  6871. drowning = 0,
  6872. -- Player will take this amount of damage if no bubbles are left
  6873. damage_per_second = 0,
  6874. -- If player is inside node, this damage is caused
  6875. node_box = {type = "regular"}, -- See "Node boxes"
  6876. connects_to = {},
  6877. -- Used for nodebox nodes with the type == "connected".
  6878. -- Specifies to what neighboring nodes connections will be drawn.
  6879. -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
  6880. connect_sides = {},
  6881. -- Tells connected nodebox nodes to connect only to these sides of this
  6882. -- node. possible: "top", "bottom", "front", "left", "back", "right"
  6883. mesh = "",
  6884. -- File name of mesh when using "mesh" drawtype
  6885. selection_box = {
  6886. -- see [Node boxes] for possibilities
  6887. },
  6888. -- Custom selection box definition. Multiple boxes can be defined.
  6889. -- If "nodebox" drawtype is used and selection_box is nil, then node_box
  6890. -- definition is used for the selection box.
  6891. collision_box = {
  6892. -- see [Node boxes] for possibilities
  6893. },
  6894. -- Custom collision box definition. Multiple boxes can be defined.
  6895. -- If "nodebox" drawtype is used and collision_box is nil, then node_box
  6896. -- definition is used for the collision box.
  6897. -- Support maps made in and before January 2012
  6898. legacy_facedir_simple = false,
  6899. legacy_wallmounted = false,
  6900. waving = 0,
  6901. -- Valid for drawtypes:
  6902. -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
  6903. -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
  6904. -- 2 - wave node like leaves (whole node moves side-to-side)
  6905. -- 3 - wave node like liquids (whole node moves up and down)
  6906. -- Not all models will properly wave.
  6907. -- plantlike drawtype can only wave like plants.
  6908. -- allfaces_optional drawtype can only wave like leaves.
  6909. -- liquid, flowingliquid drawtypes can only wave like liquids.
  6910. sounds = {
  6911. -- Definition of node sounds to be played at various events.
  6912. -- All fields in this table are optional.
  6913. footstep = <SimpleSoundSpec>,
  6914. -- If walkable, played when object walks on it. If node is
  6915. -- climbable or a liquid, played when object moves through it
  6916. dig = <SimpleSoundSpec> or "__group",
  6917. -- While digging node.
  6918. -- If `"__group"`, then the sound will be
  6919. -- `default_dig_<groupname>`, where `<groupname>` is the
  6920. -- name of the item's digging group with the fastest digging time.
  6921. -- In case of a tie, one of the sounds will be played (but we
  6922. -- cannot predict which one)
  6923. -- Default value: `"__group"`
  6924. dug = <SimpleSoundSpec>,
  6925. -- Node was dug
  6926. place = <SimpleSoundSpec>,
  6927. -- Node was placed. Also played after falling
  6928. place_failed = <SimpleSoundSpec>,
  6929. -- When node placement failed.
  6930. -- Note: This happens if the _built-in_ node placement failed.
  6931. -- This sound will still be played if the node is placed in the
  6932. -- `on_place` callback manually.
  6933. fall = <SimpleSoundSpec>,
  6934. -- When node starts to fall or is detached
  6935. },
  6936. drop = "",
  6937. -- Name of dropped item when dug.
  6938. -- Default dropped item is the node itself.
  6939. -- Using a table allows multiple items, drop chances and item filtering:
  6940. drop = {
  6941. max_items = 1,
  6942. -- Maximum number of item lists to drop.
  6943. -- The entries in 'items' are processed in order. For each:
  6944. -- Item filtering is applied, chance of drop is applied, if both are
  6945. -- successful the entire item list is dropped.
  6946. -- Entry processing continues until the number of dropped item lists
  6947. -- equals 'max_items'.
  6948. -- Therefore, entries should progress from low to high drop chance.
  6949. items = {
  6950. -- Examples:
  6951. {
  6952. -- 1 in 1000 chance of dropping a diamond.
  6953. -- Default rarity is '1'.
  6954. rarity = 1000,
  6955. items = {"default:diamond"},
  6956. },
  6957. {
  6958. -- Only drop if using an item whose name is identical to one
  6959. -- of these.
  6960. tools = {"default:shovel_mese", "default:shovel_diamond"},
  6961. rarity = 5,
  6962. items = {"default:dirt"},
  6963. -- Whether all items in the dropped item list inherit the
  6964. -- hardware coloring palette color from the dug node.
  6965. -- Default is 'false'.
  6966. inherit_color = true,
  6967. },
  6968. {
  6969. -- Only drop if using an item whose name contains
  6970. -- "default:shovel_" (this item filtering by string matching
  6971. -- is deprecated, use tool_groups instead).
  6972. tools = {"~default:shovel_"},
  6973. rarity = 2,
  6974. -- The item list dropped.
  6975. items = {"default:sand", "default:desert_sand"},
  6976. },
  6977. {
  6978. -- Only drop if using an item in the "magicwand" group, or
  6979. -- an item that is in both the "pickaxe" and the "lucky"
  6980. -- groups.
  6981. tool_groups = {
  6982. "magicwand",
  6983. {"pickaxe", "lucky"}
  6984. },
  6985. items = {"default:coal_lump"},
  6986. },
  6987. },
  6988. },
  6989. on_construct = function(pos),
  6990. -- Node constructor; called after adding node.
  6991. -- Can set up metadata and stuff like that.
  6992. -- Not called for bulk node placement (i.e. schematics and VoxelManip).
  6993. -- default: nil
  6994. on_destruct = function(pos),
  6995. -- Node destructor; called before removing node.
  6996. -- Not called for bulk node placement.
  6997. -- default: nil
  6998. after_destruct = function(pos, oldnode),
  6999. -- Node destructor; called after removing node.
  7000. -- Not called for bulk node placement.
  7001. -- default: nil
  7002. on_flood = function(pos, oldnode, newnode),
  7003. -- Called when a liquid (newnode) is about to flood oldnode, if it has
  7004. -- `floodable = true` in the nodedef. Not called for bulk node placement
  7005. -- (i.e. schematics and VoxelManip) or air nodes. If return true the
  7006. -- node is not flooded, but on_flood callback will most likely be called
  7007. -- over and over again every liquid update interval.
  7008. -- Default: nil
  7009. -- Warning: making a liquid node 'floodable' will cause problems.
  7010. preserve_metadata = function(pos, oldnode, oldmeta, drops),
  7011. -- Called when oldnode is about be converted to an item, but before the
  7012. -- node is deleted from the world or the drops are added. This is
  7013. -- generally the result of either the node being dug or an attached node
  7014. -- becoming detached.
  7015. -- oldmeta are the metadata fields (table) of the node before deletion.
  7016. -- drops is a table of ItemStacks, so any metadata to be preserved can
  7017. -- be added directly to one or more of the dropped items. See
  7018. -- "ItemStackMetaRef".
  7019. -- default: nil
  7020. after_place_node = function(pos, placer, itemstack, pointed_thing),
  7021. -- Called after constructing node when node was placed using
  7022. -- minetest.item_place_node / minetest.place_node.
  7023. -- If return true no item is taken from itemstack.
  7024. -- `placer` may be any valid ObjectRef or nil.
  7025. -- default: nil
  7026. after_dig_node = function(pos, oldnode, oldmetadata, digger),
  7027. -- oldmetadata is in table format.
  7028. -- Called after destructing node when node was dug using
  7029. -- minetest.node_dig / minetest.dig_node.
  7030. -- default: nil
  7031. can_dig = function(pos, [player]),
  7032. -- Returns true if node can be dug, or false if not.
  7033. -- default: nil
  7034. on_punch = function(pos, node, puncher, pointed_thing),
  7035. -- default: minetest.node_punch
  7036. -- Called when puncher (an ObjectRef) punches the node at pos.
  7037. -- By default calls minetest.register_on_punchnode callbacks.
  7038. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
  7039. -- default: nil
  7040. -- Called when clicker (an ObjectRef) used the 'place/build' key
  7041. -- (not necessarily an actual rightclick)
  7042. -- while pointing at the node at pos with 'node' being the node table.
  7043. -- itemstack will hold clicker's wielded item.
  7044. -- Shall return the leftover itemstack.
  7045. -- Note: pointed_thing can be nil, if a mod calls this function.
  7046. -- This function does not get triggered by clients <=0.4.16 if the
  7047. -- "formspec" node metadata field is set.
  7048. on_dig = function(pos, node, digger),
  7049. -- default: minetest.node_dig
  7050. -- By default checks privileges, wears out item (if tool) and removes node.
  7051. -- return true if the node was dug successfully, false otherwise.
  7052. -- Deprecated: returning nil is the same as returning true.
  7053. on_timer = function(pos, elapsed),
  7054. -- default: nil
  7055. -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
  7056. -- elapsed is the total time passed since the timer was started.
  7057. -- return true to run the timer for another cycle with the same timeout
  7058. -- value.
  7059. on_receive_fields = function(pos, formname, fields, sender),
  7060. -- fields = {name1 = value1, name2 = value2, ...}
  7061. -- Called when an UI form (e.g. sign text input) returns data.
  7062. -- See minetest.register_on_player_receive_fields for more info.
  7063. -- default: nil
  7064. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  7065. -- Called when a player wants to move items inside the inventory.
  7066. -- Return value: number of items allowed to move.
  7067. allow_metadata_inventory_put = function(pos, listname, index, stack, player),
  7068. -- Called when a player wants to put something into the inventory.
  7069. -- Return value: number of items allowed to put.
  7070. -- Return value -1: Allow and don't modify item count in inventory.
  7071. allow_metadata_inventory_take = function(pos, listname, index, stack, player),
  7072. -- Called when a player wants to take something out of the inventory.
  7073. -- Return value: number of items allowed to take.
  7074. -- Return value -1: Allow and don't modify item count in inventory.
  7075. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  7076. on_metadata_inventory_put = function(pos, listname, index, stack, player),
  7077. on_metadata_inventory_take = function(pos, listname, index, stack, player),
  7078. -- Called after the actual action has happened, according to what was
  7079. -- allowed.
  7080. -- No return value.
  7081. on_blast = function(pos, intensity),
  7082. -- intensity: 1.0 = mid range of regular TNT.
  7083. -- If defined, called when an explosion touches the node, instead of
  7084. -- removing the node.
  7085. mod_origin = "modname",
  7086. -- stores which mod actually registered a node
  7087. -- If the source could not be determined it contains "??"
  7088. -- Useful for getting which mod truly registered something
  7089. -- example: if a node is registered as ":othermodname:nodename",
  7090. -- nodename will show "othermodname", but mod_origin will say "modname"
  7091. }
  7092. Crafting recipes
  7093. ----------------
  7094. Crafting converts one or more inputs to one output itemstack of arbitrary
  7095. count (except for fuels, which don't have an output). The conversion reduces
  7096. each input ItemStack by 1.
  7097. Craft recipes are registered by `minetest.register_craft` and use a
  7098. table format. The accepted parameters are listed below.
  7099. Recipe input items can either be specified by item name (item count = 1)
  7100. or by group (see "Groups in crafting recipes" for details).
  7101. The following sections describe the types and syntaxes of recipes.
  7102. ### Shaped
  7103. This is the default recipe type (when no `type` is specified).
  7104. A shaped recipe takes one or multiple items as input and has
  7105. a single item stack as output. The input items must be specified
  7106. in a 2-dimensional matrix (see parameters below) to specify the
  7107. exact arrangement (the "shape") in which the player must place them
  7108. in the crafting grid.
  7109. For example, for a 3x3 recipe, the `recipes` table must have
  7110. 3 rows and 3 columns.
  7111. In order to craft the recipe, the players' crafting grid must
  7112. have equal or larger dimensions (both width and height).
  7113. Parameters:
  7114. * `type = "shaped"`: (optional) specifies recipe type as shaped
  7115. * `output`: Itemstring of output itemstack (item counts >= 1 are allowed)
  7116. * `recipe`: A 2-dimensional matrix of items, with a width *w* and height *h*.
  7117. * *w* and *h* are chosen by you, they don't have to be equal but must be at least 1
  7118. * The matrix is specified as a table containing tables containing itemnames
  7119. * The inner tables are the rows. There must be *h* tables, specified from the top to the bottom row
  7120. * Values inside of the inner table are the columns.
  7121. Each inner table must contain a list of *w* items, specified from left to right
  7122. * Empty slots *must* be filled with the empty string
  7123. * `replacements`: (optional) Allows you to replace input items with some other items
  7124. when something is crafted
  7125. * Provided as a list of item pairs of the form `{ old_item, new_item }` where
  7126. `old_item` is the input item to replace (same syntax as for a regular input
  7127. slot; groups are allowed) and `new_item` is an itemstring for the item stack
  7128. it will become
  7129. * When the output is crafted, Minetest iterates through the list
  7130. of input items if the crafting grid. For each input item stack, it checks if
  7131. it matches with an `old_item` in the item pair list.
  7132. * If it matches, the item will be replaced. Also, this item pair
  7133. will *not* be applied again for the remaining items
  7134. * If it does not match, the item is consumed (reduced by 1) normally
  7135. * The `new_item` will appear in one of 3 places:
  7136. * Crafting grid, if the input stack size was exactly 1
  7137. * Player inventory, if input stack size was larger
  7138. * Drops as item entity, if it fits neither in craft grid or inventory
  7139. #### Examples
  7140. A typical shaped recipe:
  7141. -- Stone pickaxe
  7142. {
  7143. output = "example:stone_pickaxe",
  7144. -- A 3x3 recipe which needs 3 stone in the 1st row,
  7145. -- and 1 stick in the horizontal middle in each of the 2nd and 3nd row.
  7146. -- The 4 remaining slots have to be empty.
  7147. recipe = {
  7148. {"example:stone", "example:stone", "example:stone"}, -- row 1
  7149. {"", "example:stick", "" }, -- row 2
  7150. {"", "example:stick", "" }, -- row 3
  7151. -- ^ column 1 ^ column 2 ^ column 3
  7152. },
  7153. -- There is no replacements table, so every input item
  7154. -- will be consumed.
  7155. }
  7156. Simple replacement example:
  7157. -- Wet sponge
  7158. {
  7159. output = "example:wet_sponge",
  7160. -- 1x2 recipe with a water bucket above a dry sponge
  7161. recipe = {
  7162. {"example:water_bucket"},
  7163. {"example:dry_sponge"},
  7164. },
  7165. -- When the wet sponge is crafted, the water bucket
  7166. -- in the input slot is replaced with an empty
  7167. -- bucket
  7168. replacements = {
  7169. {"example:water_bucket", "example:empty_bucket"},
  7170. },
  7171. }
  7172. Complex replacement example 1:
  7173. -- Very wet sponge
  7174. {
  7175. output = "example:very_wet_sponge",
  7176. -- 3x3 recipe with a wet sponge in the center
  7177. -- and 4 water buckets around it
  7178. recipe = {
  7179. {"","example:water_bucket",""},
  7180. {"example:water_bucket","example:wet_sponge","example:water_bucket"},
  7181. {"","example:water_bucket",""},
  7182. },
  7183. -- When the wet sponge is crafted, all water buckets
  7184. -- in the input slot become empty
  7185. replacements = {
  7186. -- Without these repetitions, only the first
  7187. -- water bucket would be replaced.
  7188. {"example:water_bucket", "example:empty_bucket"},
  7189. {"example:water_bucket", "example:empty_bucket"},
  7190. {"example:water_bucket", "example:empty_bucket"},
  7191. {"example:water_bucket", "example:empty_bucket"},
  7192. },
  7193. }
  7194. Complex replacement example 2:
  7195. -- Magic book:
  7196. -- 3 magic orbs + 1 book crafts a magic book,
  7197. -- and the orbs will be replaced with 3 different runes.
  7198. {
  7199. output = "example:magic_book",
  7200. -- 3x2 recipe
  7201. recipe = {
  7202. -- 3 items in the group `magic_orb` on top of a book in the middle
  7203. {"group:magic_orb", "group:magic_orb", "group:magic_orb"},
  7204. {"", "example:book", ""},
  7205. },
  7206. -- When the book is crafted, the 3 magic orbs will be turned into
  7207. -- 3 runes: ice rune, earth rune and fire rune (from left to right)
  7208. replacements = {
  7209. {"group:magic_orb", "example:ice_rune"},
  7210. {"group:magic_orb", "example:earth_rune"},
  7211. {"group:magic_orb", "example:fire_rune"},
  7212. },
  7213. }
  7214. ### Shapeless
  7215. Takes a list of input items (at least 1). The order or arrangement
  7216. of input items does not matter.
  7217. In order to craft the recipe, the players' crafting grid must have matching or
  7218. larger *count* of slots. The grid dimensions do not matter.
  7219. Parameters:
  7220. * `type = "shapeless"`: Mandatory
  7221. * `output`: Same as for shaped recipe
  7222. * `recipe`: List of item names
  7223. * `replacements`: Same as for shaped recipe
  7224. #### Example
  7225. {
  7226. -- Craft a mushroom stew from a bowl, a brown mushroom and a red mushroom
  7227. -- (no matter where in the input grid the items are placed)
  7228. type = "shapeless",
  7229. output = "example:mushroom_stew",
  7230. recipe = {
  7231. "example:bowl",
  7232. "example:mushroom_brown",
  7233. "example:mushroom_red",
  7234. },
  7235. }
  7236. ### Tool repair
  7237. Syntax:
  7238. {
  7239. type = "toolrepair",
  7240. additional_wear = -0.02, -- multiplier of 65536
  7241. }
  7242. Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
  7243. group. If this recipe is used, repairing is possible with any crafting grid
  7244. with at least 2 slots.
  7245. The player can put 2 equal tools in the craft grid to get one "repaired" tool
  7246. back.
  7247. The wear of the output is determined by the wear of both tools, plus a
  7248. 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
  7249. you want `additional_wear` to be negative.
  7250. The formula used to calculate the resulting wear is:
  7251. 65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear))
  7252. The result is rounded and can't be lower than 0. If the result is 65536 or higher,
  7253. no crafting is possible.
  7254. ### Cooking
  7255. A cooking recipe has a single input item, a single output item stack
  7256. and a cooking time. It represents cooking/baking/smelting/etc. items in
  7257. an oven, furnace, or something similar; the exact meaning is up for games
  7258. to decide, if they choose to use cooking at all.
  7259. The engine does not implement anything specific to cooking recipes, but
  7260. the recipes can be retrieved later using `minetest.get_craft_result` to
  7261. have a consistent interface across different games/mods.
  7262. Parameters:
  7263. * `type = "cooking"`: Mandatory
  7264. * `output`: Same as for shaped recipe
  7265. * `recipe`: An itemname of the single input item
  7266. * `cooktime`: (optional) Time it takes to cook this item, in seconds.
  7267. A floating-point number. (default: 3.0)
  7268. * `replacements`: Same meaning as for shaped recipes, but the mods
  7269. that utilize cooking recipes (e.g. for adding a furnace
  7270. node) need to implement replacements on their own
  7271. Note: Games and mods are free to re-interpret the cooktime in special
  7272. cases, e.g. for a super furnace that cooks items twice as fast.
  7273. #### Example
  7274. Cooking sand to glass in 3 seconds:
  7275. {
  7276. type = "cooking",
  7277. output = "example:glass",
  7278. recipe = "example:sand",
  7279. cooktime = 3.0,
  7280. }
  7281. ### Fuel
  7282. A fuel recipe is an item associated with a "burning time" and an optional
  7283. item replacement. There is no output. This is usually used as fuel for
  7284. furnaces, ovens, stoves, etc.
  7285. Like with cooking recipes, the engine does not do anything specific with
  7286. fuel recipes and it's up to games and mods to use them by retrieving
  7287. them via `minetest.get_craft_result`.
  7288. Parameters:
  7289. * `type = "fuel"`: Mandatory
  7290. * `recipe`: Itemname of the item to be used as fuel
  7291. * `burntime`: (optional) Burning time this item provides, in seconds.
  7292. A floating-point number. (default: 1.0)
  7293. * `replacements`: Same meaning as for shaped recipes, but the mods
  7294. that utilize fuels need to implement replacements
  7295. on their own
  7296. Note: Games and mods are free to re-interpret the burntime in special
  7297. cases, e.g. for an efficient furnace in which fuels burn twice as
  7298. long.
  7299. #### Examples
  7300. Coal lump with a burntime of 20 seconds. Will be consumed when used.
  7301. {
  7302. type = "fuel",
  7303. recipe = "example:coal_lump",
  7304. burntime = 20.0,
  7305. }
  7306. Lava bucket with a burn time of 60 seconds. Will become an empty bucket
  7307. if used:
  7308. {
  7309. type = "fuel",
  7310. recipe = "example:lava_bucket",
  7311. burntime = 60.0,
  7312. replacements = {{"example:lava_bucket", "example:empty_bucket"}},
  7313. }
  7314. Ore definition
  7315. --------------
  7316. Used by `minetest.register_ore`.
  7317. See [Ores] section above for essential information.
  7318. {
  7319. ore_type = "",
  7320. -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
  7321. ore = "",
  7322. -- Ore node to place
  7323. ore_param2 = 0,
  7324. -- Param2 to set for ore (e.g. facedir rotation)
  7325. wherein = "",
  7326. -- Node to place ore in. Multiple are possible by passing a list.
  7327. clust_scarcity = 8 * 8 * 8,
  7328. -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
  7329. -- If the desired average distance between ores is 'd', set this to
  7330. -- d * d * d.
  7331. clust_num_ores = 8,
  7332. -- Number of ores in a cluster
  7333. clust_size = 3,
  7334. -- Size of the bounding box of the cluster.
  7335. -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
  7336. -- nodes are coal ore.
  7337. y_min = -31000,
  7338. y_max = 31000,
  7339. -- Lower and upper limits for ore (inclusive)
  7340. flags = "",
  7341. -- Attributes for the ore generation, see 'Ore attributes' section above
  7342. noise_threshold = 0,
  7343. -- If noise is above this threshold, ore is placed. Not needed for a
  7344. -- uniform distribution.
  7345. noise_params = {
  7346. offset = 0,
  7347. scale = 1,
  7348. spread = {x = 100, y = 100, z = 100},
  7349. seed = 23,
  7350. octaves = 3,
  7351. persistence = 0.7
  7352. },
  7353. -- NoiseParams structure describing one of the perlin noises used for
  7354. -- ore distribution.
  7355. -- Needed by "sheet", "puff", "blob" and "vein" ores.
  7356. -- Omit from "scatter" ore for a uniform ore distribution.
  7357. -- Omit from "stratum" ore for a simple horizontal strata from y_min to
  7358. -- y_max.
  7359. biomes = {"desert", "rainforest"},
  7360. -- List of biomes in which this ore occurs.
  7361. -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
  7362. -- being used does not support biomes.
  7363. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7364. -- Type-specific parameters
  7365. -- "sheet"
  7366. column_height_min = 1,
  7367. column_height_max = 16,
  7368. column_midpoint_factor = 0.5,
  7369. -- "puff"
  7370. np_puff_top = {
  7371. offset = 4,
  7372. scale = 2,
  7373. spread = {x = 100, y = 100, z = 100},
  7374. seed = 47,
  7375. octaves = 3,
  7376. persistence = 0.7
  7377. },
  7378. np_puff_bottom = {
  7379. offset = 4,
  7380. scale = 2,
  7381. spread = {x = 100, y = 100, z = 100},
  7382. seed = 11,
  7383. octaves = 3,
  7384. persistence = 0.7
  7385. },
  7386. -- "vein"
  7387. random_factor = 1.0,
  7388. -- "stratum"
  7389. np_stratum_thickness = {
  7390. offset = 8,
  7391. scale = 4,
  7392. spread = {x = 100, y = 100, z = 100},
  7393. seed = 17,
  7394. octaves = 3,
  7395. persistence = 0.7
  7396. },
  7397. stratum_thickness = 8, -- only used if no noise defined
  7398. }
  7399. Biome definition
  7400. ----------------
  7401. Used by `minetest.register_biome`.
  7402. The maximum number of biomes that can be used is 65535. However, using an
  7403. excessive number of biomes will slow down map generation. Depending on desired
  7404. performance and computing power the practical limit is much lower.
  7405. {
  7406. name = "tundra",
  7407. node_dust = "default:snow",
  7408. -- Node dropped onto upper surface after all else is generated
  7409. node_top = "default:dirt_with_snow",
  7410. depth_top = 1,
  7411. -- Node forming surface layer of biome and thickness of this layer
  7412. node_filler = "default:permafrost",
  7413. depth_filler = 3,
  7414. -- Node forming lower layer of biome and thickness of this layer
  7415. node_stone = "default:bluestone",
  7416. -- Node that replaces all stone nodes between roughly y_min and y_max.
  7417. node_water_top = "default:ice",
  7418. depth_water_top = 10,
  7419. -- Node forming a surface layer in seawater with the defined thickness
  7420. node_water = "",
  7421. -- Node that replaces all seawater nodes not in the surface layer
  7422. node_river_water = "default:ice",
  7423. -- Node that replaces river water in mapgens that use
  7424. -- default:river_water
  7425. node_riverbed = "default:gravel",
  7426. depth_riverbed = 2,
  7427. -- Node placed under river water and thickness of this layer
  7428. node_cave_liquid = "default:lava_source",
  7429. node_cave_liquid = {"default:water_source", "default:lava_source"},
  7430. -- Nodes placed inside 50% of the medium size caves.
  7431. -- Multiple nodes can be specified, each cave will use a randomly
  7432. -- chosen node from the list.
  7433. -- If this field is left out or 'nil', cave liquids fall back to
  7434. -- classic behavior of lava and water distributed using 3D noise.
  7435. -- For no cave liquid, specify "air".
  7436. node_dungeon = "default:cobble",
  7437. -- Node used for primary dungeon structure.
  7438. -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
  7439. -- alias, if that is also absent, dungeon nodes fall back to the biome
  7440. -- 'node_stone'.
  7441. -- If present, the following two nodes are also used.
  7442. node_dungeon_alt = "default:mossycobble",
  7443. -- Node used for randomly-distributed alternative structure nodes.
  7444. -- If alternative structure nodes are not wanted leave this absent.
  7445. node_dungeon_stair = "stairs:stair_cobble",
  7446. -- Node used for dungeon stairs.
  7447. -- If absent, stairs fall back to 'node_dungeon'.
  7448. y_max = 31000,
  7449. y_min = 1,
  7450. -- Upper and lower limits for biome.
  7451. -- Alternatively you can use xyz limits as shown below.
  7452. max_pos = {x = 31000, y = 128, z = 31000},
  7453. min_pos = {x = -31000, y = 9, z = -31000},
  7454. -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
  7455. -- Biome is limited to a cuboid defined by these positions.
  7456. -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
  7457. -- 31000 in 'max_pos'.
  7458. vertical_blend = 8,
  7459. -- Vertical distance in nodes above 'y_max' over which the biome will
  7460. -- blend with the biome above.
  7461. -- Set to 0 for no vertical blend. Defaults to 0.
  7462. heat_point = 0,
  7463. humidity_point = 50,
  7464. -- Characteristic temperature and humidity for the biome.
  7465. -- These values create 'biome points' on a voronoi diagram with heat and
  7466. -- humidity as axes. The resulting voronoi cells determine the
  7467. -- distribution of the biomes.
  7468. -- Heat and humidity have average values of 50, vary mostly between
  7469. -- 0 and 100 but can exceed these values.
  7470. }
  7471. Decoration definition
  7472. ---------------------
  7473. See [Decoration types]. Used by `minetest.register_decoration`.
  7474. {
  7475. deco_type = "simple",
  7476. -- Type. "simple" or "schematic" supported
  7477. place_on = "default:dirt_with_grass",
  7478. -- Node (or list of nodes) that the decoration can be placed on
  7479. sidelen = 8,
  7480. -- Size of the square (X / Z) divisions of the mapchunk being generated.
  7481. -- Determines the resolution of noise variation if used.
  7482. -- If the chunk size is not evenly divisible by sidelen, sidelen is made
  7483. -- equal to the chunk size.
  7484. fill_ratio = 0.02,
  7485. -- The value determines 'decorations per surface node'.
  7486. -- Used only if noise_params is not specified.
  7487. -- If >= 10.0 complete coverage is enabled and decoration placement uses
  7488. -- a different and much faster method.
  7489. noise_params = {
  7490. offset = 0,
  7491. scale = 0.45,
  7492. spread = {x = 100, y = 100, z = 100},
  7493. seed = 354,
  7494. octaves = 3,
  7495. persistence = 0.7,
  7496. lacunarity = 2.0,
  7497. flags = "absvalue"
  7498. },
  7499. -- NoiseParams structure describing the perlin noise used for decoration
  7500. -- distribution.
  7501. -- A noise value is calculated for each square division and determines
  7502. -- 'decorations per surface node' within each division.
  7503. -- If the noise value >= 10.0 complete coverage is enabled and
  7504. -- decoration placement uses a different and much faster method.
  7505. biomes = {"Oceanside", "Hills", "Plains"},
  7506. -- List of biomes in which this decoration occurs. Occurs in all biomes
  7507. -- if this is omitted, and ignored if the Mapgen being used does not
  7508. -- support biomes.
  7509. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7510. y_min = -31000,
  7511. y_max = 31000,
  7512. -- Lower and upper limits for decoration (inclusive).
  7513. -- These parameters refer to the Y co-ordinate of the 'place_on' node.
  7514. spawn_by = "default:water",
  7515. -- Node (or list of nodes) that the decoration only spawns next to.
  7516. -- Checks the 8 neighboring nodes on the same Y, and also the ones
  7517. -- at Y+1, excluding both center nodes.
  7518. num_spawn_by = 1,
  7519. -- Number of spawn_by nodes that must be surrounding the decoration
  7520. -- position to occur.
  7521. -- If absent or -1, decorations occur next to any nodes.
  7522. flags = "liquid_surface, force_placement, all_floors, all_ceilings",
  7523. -- Flags for all decoration types.
  7524. -- "liquid_surface": Instead of placement on the highest solid surface
  7525. -- in a mapchunk column, placement is on the highest liquid surface.
  7526. -- Placement is disabled if solid nodes are found above the liquid
  7527. -- surface.
  7528. -- "force_placement": Nodes other than "air" and "ignore" are replaced
  7529. -- by the decoration.
  7530. -- "all_floors", "all_ceilings": Instead of placement on the highest
  7531. -- surface in a mapchunk the decoration is placed on all floor and/or
  7532. -- ceiling surfaces, for example in caves and dungeons.
  7533. -- Ceiling decorations act as an inversion of floor decorations so the
  7534. -- effect of 'place_offset_y' is inverted.
  7535. -- Y-slice probabilities do not function correctly for ceiling
  7536. -- schematic decorations as the behavior is unchanged.
  7537. -- If a single decoration registration has both flags the floor and
  7538. -- ceiling decorations will be aligned vertically.
  7539. ----- Simple-type parameters
  7540. decoration = "default:grass",
  7541. -- The node name used as the decoration.
  7542. -- If instead a list of strings, a randomly selected node from the list
  7543. -- is placed as the decoration.
  7544. height = 1,
  7545. -- Decoration height in nodes.
  7546. -- If height_max is not 0, this is the lower limit of a randomly
  7547. -- selected height.
  7548. height_max = 0,
  7549. -- Upper limit of the randomly selected height.
  7550. -- If absent, the parameter 'height' is used as a constant.
  7551. param2 = 0,
  7552. -- Param2 value of decoration nodes.
  7553. -- If param2_max is not 0, this is the lower limit of a randomly
  7554. -- selected param2.
  7555. param2_max = 0,
  7556. -- Upper limit of the randomly selected param2.
  7557. -- If absent, the parameter 'param2' is used as a constant.
  7558. place_offset_y = 0,
  7559. -- Y offset of the decoration base node relative to the standard base
  7560. -- node position.
  7561. -- Can be positive or negative. Default is 0.
  7562. -- Effect is inverted for "all_ceilings" decorations.
  7563. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7564. -- to the 'place_on' node.
  7565. ----- Schematic-type parameters
  7566. schematic = "foobar.mts",
  7567. -- If schematic is a string, it is the filepath relative to the current
  7568. -- working directory of the specified Minetest schematic file.
  7569. -- Could also be the ID of a previously registered schematic.
  7570. schematic = {
  7571. size = {x = 4, y = 6, z = 4},
  7572. data = {
  7573. {name = "default:cobble", param1 = 255, param2 = 0},
  7574. {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
  7575. {name = "air", param1 = 255, param2 = 0},
  7576. ...
  7577. },
  7578. yslice_prob = {
  7579. {ypos = 2, prob = 128},
  7580. {ypos = 5, prob = 64},
  7581. ...
  7582. },
  7583. },
  7584. -- Alternative schematic specification by supplying a table. The fields
  7585. -- size and data are mandatory whereas yslice_prob is optional.
  7586. -- See 'Schematic specifier' for details.
  7587. replacements = {["oldname"] = "convert_to", ...},
  7588. -- Map of node names to replace in the schematic after reading it.
  7589. flags = "place_center_x, place_center_y, place_center_z",
  7590. -- Flags for schematic decorations. See 'Schematic attributes'.
  7591. rotation = "90",
  7592. -- Rotation can be "0", "90", "180", "270", or "random"
  7593. place_offset_y = 0,
  7594. -- If the flag 'place_center_y' is set this parameter is ignored.
  7595. -- Y offset of the schematic base node layer relative to the 'place_on'
  7596. -- node.
  7597. -- Can be positive or negative. Default is 0.
  7598. -- Effect is inverted for "all_ceilings" decorations.
  7599. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7600. -- to the 'place_on' node.
  7601. }
  7602. Chat command definition
  7603. -----------------------
  7604. Used by `minetest.register_chatcommand`.
  7605. {
  7606. params = "<name> <privilege>", -- Short parameter description
  7607. description = "Remove privilege from player", -- Full description
  7608. privs = {privs=true}, -- Require the "privs" privilege to run
  7609. func = function(name, param),
  7610. -- Called when command is run. Returns boolean success and text output.
  7611. -- Special case: The help message is shown to the player if `func`
  7612. -- returns false without a text output.
  7613. }
  7614. Note that in params, use of symbols is as follows:
  7615. * `<>` signifies a placeholder to be replaced when the command is used. For
  7616. example, when a player name is needed: `<name>`
  7617. * `[]` signifies param is optional and not required when the command is used.
  7618. For example, if you require param1 but param2 is optional:
  7619. `<param1> [<param2>]`
  7620. * `|` signifies exclusive or. The command requires one param from the options
  7621. provided. For example: `<param1> | <param2>`
  7622. * `()` signifies grouping. For example, when param1 and param2 are both
  7623. required, or only param3 is required: `(<param1> <param2>) | <param3>`
  7624. Privilege definition
  7625. --------------------
  7626. Used by `minetest.register_privilege`.
  7627. {
  7628. description = "",
  7629. -- Privilege description
  7630. give_to_singleplayer = true,
  7631. -- Whether to grant the privilege to singleplayer.
  7632. give_to_admin = true,
  7633. -- Whether to grant the privilege to the server admin.
  7634. -- Uses value of 'give_to_singleplayer' by default.
  7635. on_grant = function(name, granter_name),
  7636. -- Called when given to player 'name' by 'granter_name'.
  7637. -- 'granter_name' will be nil if the priv was granted by a mod.
  7638. on_revoke = function(name, revoker_name),
  7639. -- Called when taken from player 'name' by 'revoker_name'.
  7640. -- 'revoker_name' will be nil if the priv was revoked by a mod.
  7641. -- Note that the above two callbacks will be called twice if a player is
  7642. -- responsible, once with the player name, and then with a nil player
  7643. -- name.
  7644. -- Return true in the above callbacks to stop register_on_priv_grant or
  7645. -- revoke being called.
  7646. }
  7647. Detached inventory callbacks
  7648. ----------------------------
  7649. Used by `minetest.create_detached_inventory`.
  7650. {
  7651. allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7652. -- Called when a player wants to move items inside the inventory.
  7653. -- Return value: number of items allowed to move.
  7654. allow_put = function(inv, listname, index, stack, player),
  7655. -- Called when a player wants to put something into the inventory.
  7656. -- Return value: number of items allowed to put.
  7657. -- Return value -1: Allow and don't modify item count in inventory.
  7658. allow_take = function(inv, listname, index, stack, player),
  7659. -- Called when a player wants to take something out of the inventory.
  7660. -- Return value: number of items allowed to take.
  7661. -- Return value -1: Allow and don't modify item count in inventory.
  7662. on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7663. on_put = function(inv, listname, index, stack, player),
  7664. on_take = function(inv, listname, index, stack, player),
  7665. -- Called after the actual action has happened, according to what was
  7666. -- allowed.
  7667. -- No return value.
  7668. }
  7669. HUD Definition
  7670. --------------
  7671. Since most values have multiple different functions, please see the
  7672. documentation in [HUD] section.
  7673. Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
  7674. {
  7675. hud_elem_type = "image",
  7676. -- Type of element, can be "image", "text", "statbar", "inventory",
  7677. -- "waypoint", "image_waypoint", "compass" or "minimap"
  7678. position = {x=0.5, y=0.5},
  7679. -- Top left corner position of element
  7680. name = "<name>",
  7681. scale = {x = 1, y = 1},
  7682. text = "<text>",
  7683. text2 = "<text>",
  7684. number = 0,
  7685. item = 0,
  7686. direction = 0,
  7687. -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  7688. alignment = {x=0, y=0},
  7689. offset = {x=0, y=0},
  7690. world_pos = {x=0, y=0, z=0},
  7691. size = {x=0, y=0},
  7692. z_index = 0,
  7693. -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
  7694. style = 0,
  7695. }
  7696. Particle definition
  7697. -------------------
  7698. Used by `minetest.add_particle`.
  7699. {
  7700. pos = {x=0, y=0, z=0},
  7701. velocity = {x=0, y=0, z=0},
  7702. acceleration = {x=0, y=0, z=0},
  7703. -- Spawn particle at pos with velocity and acceleration
  7704. expirationtime = 1,
  7705. -- Disappears after expirationtime seconds
  7706. size = 1,
  7707. -- Scales the visual size of the particle texture.
  7708. -- If `node` is set, size can be set to 0 to spawn a randomly-sized
  7709. -- particle (just like actual node dig particles).
  7710. collisiondetection = false,
  7711. -- If true collides with `walkable` nodes and, depending on the
  7712. -- `object_collision` field, objects too.
  7713. collision_removal = false,
  7714. -- If true particle is removed when it collides.
  7715. -- Requires collisiondetection = true to have any effect.
  7716. object_collision = false,
  7717. -- If true particle collides with objects that are defined as
  7718. -- `physical = true,` and `collide_with_objects = true,`.
  7719. -- Requires collisiondetection = true to have any effect.
  7720. vertical = false,
  7721. -- If true faces player using y axis only
  7722. texture = "image.png",
  7723. -- The texture of the particle
  7724. -- v5.6.0 and later: also supports the table format described in the
  7725. -- following section
  7726. playername = "singleplayer",
  7727. -- Optional, if specified spawns particle only on the player's client
  7728. animation = {Tile Animation definition},
  7729. -- Optional, specifies how to animate the particle texture
  7730. glow = 0
  7731. -- Optional, specify particle self-luminescence in darkness.
  7732. -- Values 0-14.
  7733. node = {name = "ignore", param2 = 0},
  7734. -- Optional, if specified the particle will have the same appearance as
  7735. -- node dig particles for the given node.
  7736. -- `texture` and `animation` will be ignored if this is set.
  7737. node_tile = 0,
  7738. -- Optional, only valid in combination with `node`
  7739. -- If set to a valid number 1-6, specifies the tile from which the
  7740. -- particle texture is picked.
  7741. -- Otherwise, the default behavior is used. (currently: any random tile)
  7742. drag = {x=0, y=0, z=0},
  7743. -- v5.6.0 and later: Optional drag value, consult the following section
  7744. bounce = {min = ..., max = ..., bias = 0},
  7745. -- v5.6.0 and later: Optional bounce range, consult the following section
  7746. }
  7747. `ParticleSpawner` definition
  7748. ----------------------------
  7749. Used by `minetest.add_particlespawner`.
  7750. Before v5.6.0, particlespawners used a different syntax and had a more limited set
  7751. of features. Definition fields that are the same in both legacy and modern versions
  7752. are shown in the next listing, and the fields that are used by legacy versions are
  7753. shown separated by a comment; the modern fields are too complex to compactly
  7754. describe in this manner and are documented after the listing.
  7755. The older syntax can be used in combination with the newer syntax (e.g. having
  7756. `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
  7757. the new syntax will override the older syntax; on older servers, the newer syntax
  7758. will be ignored.
  7759. {
  7760. -- Common fields (same name and meaning in both new and legacy syntax)
  7761. amount = 1,
  7762. -- Number of particles spawned over the time period `time`.
  7763. time = 1,
  7764. -- Lifespan of spawner in seconds.
  7765. -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
  7766. -- a per-second basis.
  7767. collisiondetection = false,
  7768. -- If true collide with `walkable` nodes and, depending on the
  7769. -- `object_collision` field, objects too.
  7770. collision_removal = false,
  7771. -- If true particles are removed when they collide.
  7772. -- Requires collisiondetection = true to have any effect.
  7773. object_collision = false,
  7774. -- If true particles collide with objects that are defined as
  7775. -- `physical = true,` and `collide_with_objects = true,`.
  7776. -- Requires collisiondetection = true to have any effect.
  7777. attached = ObjectRef,
  7778. -- If defined, particle positions, velocities and accelerations are
  7779. -- relative to this object's position and yaw
  7780. vertical = false,
  7781. -- If true face player using y axis only
  7782. texture = "image.png",
  7783. -- The texture of the particle
  7784. playername = "singleplayer",
  7785. -- Optional, if specified spawns particles only on the player's client
  7786. animation = {Tile Animation definition},
  7787. -- Optional, specifies how to animate the particles' texture
  7788. -- v5.6.0 and later: set length to -1 to synchronize the length
  7789. -- of the animation with the expiration time of individual particles.
  7790. -- (-2 causes the animation to be played twice, and so on)
  7791. glow = 0,
  7792. -- Optional, specify particle self-luminescence in darkness.
  7793. -- Values 0-14.
  7794. node = {name = "ignore", param2 = 0},
  7795. -- Optional, if specified the particles will have the same appearance as
  7796. -- node dig particles for the given node.
  7797. -- `texture` and `animation` will be ignored if this is set.
  7798. node_tile = 0,
  7799. -- Optional, only valid in combination with `node`
  7800. -- If set to a valid number 1-6, specifies the tile from which the
  7801. -- particle texture is picked.
  7802. -- Otherwise, the default behavior is used. (currently: any random tile)
  7803. -- Legacy definition fields
  7804. minpos = {x=0, y=0, z=0},
  7805. maxpos = {x=0, y=0, z=0},
  7806. minvel = {x=0, y=0, z=0},
  7807. maxvel = {x=0, y=0, z=0},
  7808. minacc = {x=0, y=0, z=0},
  7809. maxacc = {x=0, y=0, z=0},
  7810. minexptime = 1,
  7811. maxexptime = 1,
  7812. minsize = 1,
  7813. maxsize = 1,
  7814. -- The particles' properties are random values between the min and max
  7815. -- values.
  7816. -- applies to: pos, velocity, acceleration, expirationtime, size
  7817. -- If `node` is set, min and maxsize can be set to 0 to spawn
  7818. -- randomly-sized particles (just like actual node dig particles).
  7819. }
  7820. ### Modern definition fields
  7821. After v5.6.0, spawner properties can be defined in several different ways depending
  7822. on the level of control you need. `pos` for instance can be set as a single vector,
  7823. in which case all particles will appear at that exact point throughout the lifetime
  7824. of the spawner. Alternately, it can be specified as a min-max pair, specifying a
  7825. cubic range the particles can appear randomly within. Finally, some properties can
  7826. be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
  7827. a tween table.
  7828. The following definitions are all equivalent, listed in order of precedence from
  7829. lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
  7830. property definition are present, the highest-precedence form will be selected
  7831. and all lower-precedence fields will be ignored, allowing for graceful
  7832. degradation in older clients).
  7833. {
  7834. -- old syntax
  7835. maxpos = {x = 0, y = 0, z = 0},
  7836. minpos = {x = 0, y = 0, z = 0},
  7837. -- absolute value
  7838. pos = 0,
  7839. -- all components of every particle's position vector will be set to this
  7840. -- value
  7841. -- vec3
  7842. pos = vector.new(0,0,0),
  7843. -- all particles will appear at this exact position throughout the lifetime
  7844. -- of the particlespawner
  7845. -- vec3 range
  7846. pos = {
  7847. -- the particle will appear at a position that is picked at random from
  7848. -- within a cubic range
  7849. min = vector.new(0,0,0),
  7850. -- `min` is the minimum value this property will be set to in particles
  7851. -- spawned by the generator
  7852. max = vector.new(0,0,0),
  7853. -- `max` is the minimum value this property will be set to in particles
  7854. -- spawned by the generator
  7855. bias = 0,
  7856. -- when `bias` is 0, all random values are exactly as likely as any
  7857. -- other. when it is positive, the higher it is, the more likely values
  7858. -- will appear towards the minimum end of the allowed spectrum. when
  7859. -- it is negative, the lower it is, the more likely values will appear
  7860. -- towards the maximum end of the allowed spectrum. the curve is
  7861. -- exponential and there is no particular maximum or minimum value
  7862. },
  7863. -- tween table
  7864. pos_tween = {...},
  7865. -- a tween table should consist of a list of frames in the same form as the
  7866. -- untweened pos property above, which the engine will interpolate between,
  7867. -- and optionally a number of properties that control how the interpolation
  7868. -- takes place. currently **only two frames**, the first and the last, are
  7869. -- used, but extra frames are accepted for the sake of forward compatibility.
  7870. -- any of the above definition styles can be used here as well in any combination
  7871. -- supported by the property type
  7872. pos_tween = {
  7873. style = "fwd",
  7874. -- linear animation from first to last frame (default)
  7875. style = "rev",
  7876. -- linear animation from last to first frame
  7877. style = "pulse",
  7878. -- linear animation from first to last then back to first again
  7879. style = "flicker",
  7880. -- like "pulse", but slightly randomized to add a bit of stutter
  7881. reps = 1,
  7882. -- number of times the animation is played over the particle's lifespan
  7883. start = 0.0,
  7884. -- point in the spawner's lifespan at which the animation begins. 0 is
  7885. -- the very beginning, 1 is the very end
  7886. -- frames can be defined in a number of different ways, depending on the
  7887. -- underlying type of the property. for now, all but the first and last
  7888. -- frame are ignored
  7889. -- frames
  7890. -- floats
  7891. 0, 0,
  7892. -- vec3s
  7893. vector.new(0,0,0),
  7894. vector.new(0,0,0),
  7895. -- vec3 ranges
  7896. { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7897. { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7898. -- mixed
  7899. 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7900. },
  7901. }
  7902. All of the properties that can be defined in this way are listed in the next
  7903. section, along with the datatypes they accept.
  7904. #### List of particlespawner properties
  7905. All of the properties in this list can be animated with `*_tween` tables
  7906. unless otherwise specified. For example, `jitter` can be tweened by setting
  7907. a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
  7908. Types used are defined in the previous section.
  7909. * vec3 range `pos`: the position at which particles can appear
  7910. * vec3 range `vel`: the initial velocity of the particle
  7911. * vec3 range `acc`: the direction and speed with which the particle
  7912. accelerates
  7913. * vec3 range `jitter`: offsets the velocity of each particle by a random
  7914. amount within the specified range each frame. used to create Brownian motion.
  7915. * vec3 range `drag`: the amount by which absolute particle velocity along
  7916. each axis is decreased per second. a value of 1.0 means that the particle
  7917. will be slowed to a stop over the space of a second; a value of -1.0 means
  7918. that the particle speed will be doubled every second. to avoid interfering
  7919. with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
  7920. be used instead of a uniform value.
  7921. * float range `bounce`: how bouncy the particles are when `collisiondetection`
  7922. is turned on. values less than or equal to `0` turn off particle bounce;
  7923. `1` makes the particles bounce without losing any velocity, and `2` makes
  7924. them double their velocity with every bounce. `bounce` is not bounded but
  7925. values much larger than `1.0` probably aren't very useful.
  7926. * float range `exptime`: the number of seconds after which the particle
  7927. disappears.
  7928. * table `attract`: sets the birth orientation of particles relative to various
  7929. shapes defined in world coordinate space. this is an alternative means of
  7930. setting the velocity which allows particles to emerge from or enter into
  7931. some entity or node on the map, rather than simply being assigned random
  7932. velocity values within a range. the velocity calculated by this method will
  7933. be **added** to that specified by `vel` if `vel` is also set, so in most
  7934. cases **`vel` should be set to 0**. `attract` has the fields:
  7935. * string `kind`: selects the kind of shape towards which the particles will
  7936. be oriented. it must have one of the following values:
  7937. * `"none"`: no attractor is set and the `attractor` table is ignored
  7938. * `"point"`: the particles are attracted to a specific point in space.
  7939. use this also if you want a sphere-like effect, in combination with
  7940. the `radius` property.
  7941. * `"line"`: the particles are attracted to an (infinite) line passing
  7942. through the points `origin` and `angle`. use this for e.g. beacon
  7943. effects, energy beam effects, etc.
  7944. * `"plane"`: the particles are attracted to an (infinite) plane on whose
  7945. surface `origin` designates a point in world coordinate space. use this
  7946. for e.g. particles entering or emerging from a portal.
  7947. * float range `strength`: the speed with which particles will move towards
  7948. `attractor`. If negative, the particles will instead move away from that
  7949. point.
  7950. * vec3 `origin`: the origin point of the shape towards which particles will
  7951. initially be oriented. functions as an offset if `origin_attached` is also
  7952. set.
  7953. * vec3 `direction`: sets the direction in which the attractor shape faces. for
  7954. lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
  7955. create a vertical line that passes through `origin`. for planes, `direction`
  7956. is the surface normal of an infinite plane on whose surface `origin` is
  7957. a point. functions as an offset if `direction_attached` is also set.
  7958. * entity `origin_attached`: allows the origin to be specified as an offset
  7959. from the position of an entity rather than a coordinate in world space.
  7960. * entity `direction_attached`: allows the direction to be specified as an offset
  7961. from the position of an entity rather than a coordinate in world space.
  7962. * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
  7963. that they will die as they cross the attractor threshold. this behavior
  7964. is the default but is undesirable for some kinds of animations; set it to
  7965. false to allow particles to live out their natural lives.
  7966. * vec3 range `radius`: if set, particles will be arranged in a sphere around
  7967. `pos`. A constant can be used to create a spherical shell of particles, a
  7968. vector to create an ovoid shell, and a range to create a volume; e.g.
  7969. `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
  7970. and 1 nodes away from `pos` but will cluster them towards the center of the
  7971. sphere. Usually if `radius` is used, `pos` should be a single point, but it
  7972. can still be a range if you really know what you're doing (e.g. to create a
  7973. "roundcube" emitter volume).
  7974. ### Textures
  7975. In versions before v5.6.0, particlespawner textures could only be specified as a single
  7976. texture string. After v5.6.0, textures can now be specified as a table as well. This
  7977. table contains options that allow simple animations to be applied to the texture.
  7978. texture = {
  7979. name = "mymod_particle_texture.png",
  7980. -- the texture specification string
  7981. alpha = 1.0,
  7982. -- controls how visible the particle is; at 1.0 the particle is fully
  7983. -- visible, at 0, it is completely invisible.
  7984. alpha_tween = {1, 0},
  7985. -- can be used instead of `alpha` to animate the alpha value over the
  7986. -- particle's lifetime. these tween tables work identically to the tween
  7987. -- tables used in particlespawner properties, except that time references
  7988. -- are understood with respect to the particle's lifetime, not the
  7989. -- spawner's. {1,0} fades the particle out over its lifetime.
  7990. scale = 1,
  7991. scale = {x = 1, y = 1},
  7992. -- scales the texture onscreen
  7993. scale_tween = {
  7994. {x = 1, y = 1},
  7995. {x = 0, y = 1},
  7996. },
  7997. -- animates the scale over the particle's lifetime. works like the
  7998. -- alpha_tween table, but can accept two-dimensional vectors as well as
  7999. -- integer values. the example value would cause the particle to shrink
  8000. -- in one dimension over the course of its life until it disappears
  8001. blend = "alpha",
  8002. -- (default) blends transparent pixels with those they are drawn atop
  8003. -- according to the alpha channel of the source texture. useful for
  8004. -- e.g. material objects like rocks, dirt, smoke, or node chunks
  8005. blend = "add",
  8006. -- adds the value of pixels to those underneath them, modulo the sources
  8007. -- alpha channel. useful for e.g. bright light effects like sparks or fire
  8008. blend = "screen",
  8009. -- like "add" but less bright. useful for subtler light effects. note that
  8010. -- this is NOT formally equivalent to the "screen" effect used in image
  8011. -- editors and compositors, as it does not respect the alpha channel of
  8012. -- of the image being blended
  8013. blend = "sub",
  8014. -- the inverse of "add"; the value of the source pixel is subtracted from
  8015. -- the pixel underneath it. a white pixel will turn whatever is underneath
  8016. -- it black; a black pixel will be "transparent". useful for creating
  8017. -- darkening effects
  8018. animation = {Tile Animation definition},
  8019. -- overrides the particlespawner's global animation property for a single
  8020. -- specific texture
  8021. }
  8022. Instead of setting a single texture definition, it is also possible to set a
  8023. `texpool` property. A `texpool` consists of a list of possible particle textures.
  8024. Every time a particle is spawned, the engine will pick a texture at random from
  8025. the `texpool` and assign it as that particle's texture. You can also specify a
  8026. `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
  8027. clients but will be sent to older (pre-v5.6.0) clients that do not implement
  8028. texpools.
  8029. texpool = {
  8030. "mymod_particle_texture.png";
  8031. { name = "mymod_spark.png", fade = "out" },
  8032. {
  8033. name = "mymod_dust.png",
  8034. alpha = 0.3,
  8035. scale = 1.5,
  8036. animation = {
  8037. type = "vertical_frames",
  8038. aspect_w = 16, aspect_h = 16,
  8039. length = 3,
  8040. -- the animation lasts for 3s and then repeats
  8041. length = -3,
  8042. -- repeat the animation three times over the particle's lifetime
  8043. -- (post-v5.6.0 clients only)
  8044. },
  8045. },
  8046. }
  8047. #### List of animatable texture properties
  8048. While animated particlespawner values vary over the course of the particlespawner's
  8049. lifetime, animated texture properties vary over the lifespans of the individual
  8050. particles spawned with that texture. So a particle with the texture property
  8051. alpha_tween = {
  8052. 0.0, 1.0,
  8053. style = "pulse",
  8054. reps = 4,
  8055. }
  8056. would be invisible at its spawning, pulse visible four times throughout its
  8057. lifespan, and then vanish again before expiring.
  8058. * float `alpha` (0.0 - 1.0): controls the visibility of the texture
  8059. * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
  8060. are multiples of the parent particle's assigned size (see the `size` property above)
  8061. `HTTPRequest` definition
  8062. ------------------------
  8063. Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
  8064. {
  8065. url = "http://example.org",
  8066. timeout = 10,
  8067. -- Timeout for request to be completed in seconds. Default depends on engine settings.
  8068. method = "GET", "POST", "PUT" or "DELETE"
  8069. -- The http method to use. Defaults to "GET".
  8070. data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
  8071. -- Data for the POST, PUT or DELETE request.
  8072. -- Accepts both a string and a table. If a table is specified, encodes
  8073. -- table as x-www-form-urlencoded key-value pairs.
  8074. user_agent = "ExampleUserAgent",
  8075. -- Optional, if specified replaces the default minetest user agent with
  8076. -- given string
  8077. extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
  8078. -- Optional, if specified adds additional headers to the HTTP request.
  8079. -- You must make sure that the header strings follow HTTP specification
  8080. -- ("Key: Value").
  8081. multipart = boolean
  8082. -- Optional, if true performs a multipart HTTP request.
  8083. -- Default is false.
  8084. -- Post only, data must be array
  8085. post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
  8086. -- Deprecated, use `data` instead. Forces `method = "POST"`.
  8087. }
  8088. `HTTPRequestResult` definition
  8089. ------------------------------
  8090. Passed to `HTTPApiTable.fetch` callback. Returned by
  8091. `HTTPApiTable.fetch_async_get`.
  8092. {
  8093. completed = true,
  8094. -- If true, the request has finished (either succeeded, failed or timed
  8095. -- out)
  8096. succeeded = true,
  8097. -- If true, the request was successful
  8098. timeout = false,
  8099. -- If true, the request timed out
  8100. code = 200,
  8101. -- HTTP status code
  8102. data = "response"
  8103. }
  8104. Authentication handler definition
  8105. ---------------------------------
  8106. Used by `minetest.register_authentication_handler`.
  8107. {
  8108. get_auth = function(name),
  8109. -- Get authentication data for existing player `name` (`nil` if player
  8110. -- doesn't exist).
  8111. -- Returns following structure:
  8112. -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
  8113. create_auth = function(name, password),
  8114. -- Create new auth data for player `name`.
  8115. -- Note that `password` is not plain-text but an arbitrary
  8116. -- representation decided by the engine.
  8117. delete_auth = function(name),
  8118. -- Delete auth data of player `name`.
  8119. -- Returns boolean indicating success (false if player is nonexistent).
  8120. set_password = function(name, password),
  8121. -- Set password of player `name` to `password`.
  8122. -- Auth data should be created if not present.
  8123. set_privileges = function(name, privileges),
  8124. -- Set privileges of player `name`.
  8125. -- `privileges` is in table form, auth data should be created if not
  8126. -- present.
  8127. reload = function(),
  8128. -- Reload authentication data from the storage location.
  8129. -- Returns boolean indicating success.
  8130. record_login = function(name),
  8131. -- Called when player joins, used for keeping track of last_login
  8132. iterate = function(),
  8133. -- Returns an iterator (use with `for` loops) for all player names
  8134. -- currently in the auth database
  8135. }
  8136. Bit Library
  8137. -----------
  8138. Functions: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
  8139. See http://bitop.luajit.org/ for advanced information.