lua_api.txt 293 KB

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