lua_api.txt 318 KB

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