lua_api.txt 286 KB

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