lua_api.txt 353 KB

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