lua_api.txt 367 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035
  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. * `title`: Required, a human-readable title to address the game, e.g. `title = Minetest Game`.
  45. * `name`: (Deprecated) same as title.
  46. * `description`: Short description to be shown in the content tab
  47. * `allowed_mapgens = <comma-separated mapgens>`
  48. e.g. `allowed_mapgens = v5,v6,flat`
  49. Mapgens not in this list are removed from the list of mapgens for the
  50. game.
  51. If not specified, all mapgens are allowed.
  52. * `disallowed_mapgens = <comma-separated mapgens>`
  53. e.g. `disallowed_mapgens = v5,v6,flat`
  54. These mapgens are removed from the list of mapgens for the game.
  55. When both `allowed_mapgens` and `disallowed_mapgens` are
  56. specified, `allowed_mapgens` is applied before
  57. `disallowed_mapgens`.
  58. * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
  59. e.g. `disallowed_mapgen_settings = mgv5_spflags`
  60. These mapgen settings are hidden for this game in the world creation
  61. dialog and game start menu. Add `seed` to hide the seed input field.
  62. * `disabled_settings = <comma-separated settings>`
  63. e.g. `disabled_settings = enable_damage, creative_mode`
  64. These settings are hidden for this game in the "Start game" tab
  65. and will be initialized as `false` when the game is started.
  66. Prepend a setting name with an exclamation mark to initialize it to `true`
  67. (this does not work for `enable_server`).
  68. Only these settings are supported:
  69. `enable_damage`, `creative_mode`, `enable_server`.
  70. * `author`: The author of the game. It only appears when downloaded from
  71. ContentDB.
  72. * `release`: Ignore this: Should only ever be set by ContentDB, as it is
  73. an internal ID used to track versions.
  74. * `minetest.conf`:
  75. Used to set default settings when running this game.
  76. * `settingtypes.txt`:
  77. In the same format as the one in builtin.
  78. This settingtypes.txt will be parsed by the menu and the settings will be
  79. displayed in the "Games" category in the advanced settings tab.
  80. * If the game contains a folder called `textures` the server will load it as a
  81. texturepack, overriding mod textures.
  82. Any server texturepack will override mod textures and the game texturepack.
  83. Menu images
  84. -----------
  85. Games can provide custom main menu images. They are put inside a `menu`
  86. directory inside the game directory.
  87. The images are named `$identifier.png`, where `$identifier` is one of
  88. `overlay`, `background`, `footer`, `header`.
  89. If you want to specify multiple images for one identifier, add additional
  90. images named like `$identifier.$n.png`, with an ascending number $n starting
  91. with 1, and a random image will be chosen from the provided ones.
  92. Menu music
  93. -----------
  94. Games can provide custom main menu music. They are put inside a `menu`
  95. directory inside the game directory.
  96. The music files are named `theme.ogg`.
  97. If you want to specify multiple music files for one game, add additional
  98. images named like `theme.$n.ogg`, with an ascending number $n starting
  99. with 1 (max 10), and a random music file will be chosen from the provided ones.
  100. Mods
  101. ====
  102. Mod load path
  103. -------------
  104. Paths are relative to the directories listed in the [Paths] section above.
  105. * `games/<gameid>/mods/`
  106. * `mods/`
  107. * `worlds/<worldname>/worldmods/`
  108. World-specific games
  109. --------------------
  110. It is possible to include a game in a world; in this case, no mods or
  111. games are loaded or checked from anywhere else.
  112. This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
  113. directory exists.
  114. Mods should then be placed in `<worldname>/game/mods/`.
  115. Modpacks
  116. --------
  117. Mods can be put in a subdirectory, if the parent directory, which otherwise
  118. should be a mod, contains a file named `modpack.conf`.
  119. The file is a key-value store of modpack details.
  120. * `name`: The modpack name. Allows Minetest to determine the modpack name even
  121. if the folder is wrongly named.
  122. * `description`: Description of mod to be shown in the Mods tab of the main
  123. menu.
  124. * `author`: The author of the modpack. It only appears when downloaded from
  125. ContentDB.
  126. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  127. internal ID used to track versions.
  128. * `title`: A human-readable title to address the modpack.
  129. Note: to support 0.4.x, please also create an empty modpack.txt file.
  130. Mod directory structure
  131. -----------------------
  132. mods
  133. ├── modname
  134. │   ├── mod.conf
  135. │   ├── screenshot.png
  136. │   ├── settingtypes.txt
  137. │   ├── init.lua
  138. │   ├── models
  139. │   ├── textures
  140. │   │   ├── modname_stuff.png
  141. │   │   ├── modname_stuff_normal.png
  142. │   │   ├── modname_something_else.png
  143. │   │   ├── subfolder_foo
  144. │   │   │ ├── modname_more_stuff.png
  145. │   │   │ └── another_subfolder
  146. │   │   └── bar_subfolder
  147. │   ├── sounds
  148. │   ├── media
  149. │   ├── locale
  150. │   └── <custom data>
  151. └── another
  152. ### modname
  153. The location of this directory can be fetched by using
  154. `minetest.get_modpath(modname)`.
  155. ### mod.conf
  156. A `Settings` file that provides meta information about the mod.
  157. * `name`: The mod name. Allows Minetest to determine the mod name even if the
  158. folder is wrongly named.
  159. * `description`: Description of mod to be shown in the Mods tab of the main
  160. menu.
  161. * `depends`: A comma separated list of dependencies. These are mods that must be
  162. loaded before this mod.
  163. * `optional_depends`: A comma separated list of optional dependencies.
  164. Like a dependency, but no error if the mod doesn't exist.
  165. * `author`: The author of the mod. It only appears when downloaded from
  166. ContentDB.
  167. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  168. internal ID used to track versions.
  169. * `title`: A human-readable title to address the mod.
  170. Note: to support 0.4.x, please also provide depends.txt.
  171. ### `screenshot.png`
  172. A screenshot shown in the mod manager within the main menu. It should
  173. have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
  174. ### `depends.txt`
  175. **Deprecated:** you should use mod.conf instead.
  176. This file is used if there are no dependencies in mod.conf.
  177. List of mods that have to be loaded before loading this mod.
  178. A single line contains a single modname.
  179. Optional dependencies can be defined by appending a question mark
  180. to a single modname. This means that if the specified mod
  181. is missing, it does not prevent this mod from being loaded.
  182. ### `description.txt`
  183. **Deprecated:** you should use mod.conf instead.
  184. This file is used if there is no description in mod.conf.
  185. A file containing a description to be shown in the Mods tab of the main menu.
  186. ### `settingtypes.txt`
  187. The format is documented in `builtin/settingtypes.txt`.
  188. It is parsed by the main menu settings dialogue to list mod-specific
  189. settings in the "Mods" category.
  190. ### `init.lua`
  191. The main Lua script. Running this script should register everything it
  192. wants to register. Subsequent execution depends on minetest calling the
  193. registered callbacks.
  194. `minetest.settings` can be used to read custom or existing settings at load
  195. time, if necessary. (See [`Settings`])
  196. ### `textures`, `sounds`, `media`, `models`, `locale`
  197. Media files (textures, sounds, whatever) that will be transferred to the
  198. client and will be available for use by the mod and translation files for
  199. the clients (see [Translations]).
  200. It is suggested to use the folders for the purpose they are thought for,
  201. eg. put textures into `textures`, translation files into `locale`,
  202. models for entities or meshnodes into `models` et cetera.
  203. These folders and subfolders can contain subfolders.
  204. Subfolders with names starting with `_` or `.` are ignored.
  205. If a subfolder contains a media file with the same name as a media file
  206. in one of its parents, the parent's file is used.
  207. Although it is discouraged, a mod can overwrite a media file of any mod that it
  208. depends on by supplying a file with an equal name.
  209. Naming conventions
  210. ------------------
  211. Registered names should generally be in this format:
  212. modname:<whatever>
  213. `<whatever>` can have these characters:
  214. a-zA-Z0-9_
  215. This is to prevent conflicting names from corrupting maps and is
  216. enforced by the mod loader.
  217. Registered names can be overridden by prefixing the name with `:`. This can
  218. be used for overriding the registrations of some other mod.
  219. The `:` prefix can also be used for maintaining backwards compatibility.
  220. ### Example
  221. In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
  222. So the name should be `experimental:tnt`.
  223. Any mod can redefine `experimental:tnt` by using the name
  224. :experimental:tnt
  225. when registering it. That mod is required to have `experimental` as a
  226. dependency.
  227. Aliases
  228. =======
  229. Aliases of itemnames can be added by using
  230. `minetest.register_alias(alias, original_name)` or
  231. `minetest.register_alias_force(alias, original_name)`.
  232. This adds an alias `alias` for the item called `original_name`.
  233. From now on, you can use `alias` to refer to the item `original_name`.
  234. The only difference between `minetest.register_alias` and
  235. `minetest.register_alias_force` is that if an item named `alias` already exists,
  236. `minetest.register_alias` will do nothing while
  237. `minetest.register_alias_force` will unregister it.
  238. This can be used for maintaining backwards compatibility.
  239. This can also set quick access names for things, e.g. if
  240. you have an item called `epiclylongmodname:stuff`, you could do
  241. minetest.register_alias("stuff", "epiclylongmodname:stuff")
  242. and be able to use `/giveme stuff`.
  243. Mapgen aliases
  244. --------------
  245. In a game, a certain number of these must be set to tell core mapgens which
  246. of the game's nodes are to be used for core mapgen generation. For example:
  247. minetest.register_alias("mapgen_stone", "default:stone")
  248. ### Aliases for non-V6 mapgens
  249. #### Essential aliases
  250. * mapgen_stone
  251. * mapgen_water_source
  252. * mapgen_river_water_source
  253. `mapgen_river_water_source` is required for mapgens with sloping rivers where
  254. it is necessary to have a river liquid node with a short `liquid_range` and
  255. `liquid_renewable = false` to avoid flooding.
  256. #### Optional aliases
  257. * mapgen_lava_source
  258. Fallback lava node used if cave liquids are not defined in biome definitions.
  259. Deprecated for non-V6 mapgens, define cave liquids in biome definitions instead.
  260. * mapgen_cobble
  261. Fallback node used if dungeon nodes are not defined in biome definitions.
  262. Deprecated for non-V6 mapgens, define dungeon nodes in biome definitions instead.
  263. ### Aliases needed for Mapgen V6
  264. * mapgen_stone
  265. * mapgen_water_source
  266. * mapgen_lava_source
  267. * mapgen_dirt
  268. * mapgen_dirt_with_grass
  269. * mapgen_sand
  270. * mapgen_gravel
  271. * mapgen_desert_stone
  272. * mapgen_desert_sand
  273. * mapgen_dirt_with_snow
  274. * mapgen_snowblock
  275. * mapgen_snow
  276. * mapgen_ice
  277. * mapgen_tree
  278. * mapgen_leaves
  279. * mapgen_apple
  280. * mapgen_jungletree
  281. * mapgen_jungleleaves
  282. * mapgen_junglegrass
  283. * mapgen_pine_tree
  284. * mapgen_pine_needles
  285. * mapgen_cobble
  286. * mapgen_stair_cobble
  287. * mapgen_mossycobble
  288. * mapgen_stair_desert_stone
  289. ### Setting the node used in Mapgen Singlenode
  290. By default the world is filled with air nodes. To set a different node use, for
  291. example:
  292. minetest.register_alias("mapgen_singlenode", "default:stone")
  293. Textures
  294. ========
  295. Mods should generally prefix their textures with `modname_`, e.g. given
  296. the mod name `foomod`, a texture could be called:
  297. foomod_foothing.png
  298. Textures are referred to by their complete name, or alternatively by
  299. stripping out the file extension:
  300. * e.g. `foomod_foothing.png`
  301. * e.g. `foomod_foothing`
  302. Texture modifiers
  303. -----------------
  304. There are various texture modifiers that can be used
  305. to let the client generate textures on-the-fly.
  306. The modifiers are applied directly in sRGB colorspace,
  307. i.e. without gamma-correction.
  308. ### Texture overlaying
  309. Textures can be overlaid by putting a `^` between them.
  310. Example:
  311. default_dirt.png^default_grass_side.png
  312. `default_grass_side.png` is overlaid over `default_dirt.png`.
  313. The texture with the lower resolution will be automatically upscaled to
  314. the higher resolution texture.
  315. ### Texture grouping
  316. Textures can be grouped together by enclosing them in `(` and `)`.
  317. Example: `cobble.png^(thing1.png^thing2.png)`
  318. A texture for `thing1.png^thing2.png` is created and the resulting
  319. texture is overlaid on top of `cobble.png`.
  320. ### Escaping
  321. Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
  322. passing complex texture names as arguments. Escaping is done with backslash and
  323. is required for `^` and `:`.
  324. Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
  325. The lower 50 percent of `color.png^[mask:trans.png` are overlaid
  326. on top of `cobble.png`.
  327. ### Advanced texture modifiers
  328. #### Crack
  329. * `[crack:<n>:<p>`
  330. * `[cracko:<n>:<p>`
  331. * `[crack:<t>:<n>:<p>`
  332. * `[cracko:<t>:<n>:<p>`
  333. Parameters:
  334. * `<t>`: tile count (in each direction)
  335. * `<n>`: animation frame count
  336. * `<p>`: current animation frame
  337. Draw a step of the crack animation on the texture.
  338. `crack` draws it normally, while `cracko` lays it over, keeping transparent
  339. pixels intact.
  340. Example:
  341. default_cobble.png^[crack:10:1
  342. #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
  343. * `<w>`: width
  344. * `<h>`: height
  345. * `<x>`: x position
  346. * `<y>`: y position
  347. * `<file>`: texture to combine
  348. Creates a texture of size `<w>` times `<h>` and blits the listed files to their
  349. specified coordinates.
  350. Example:
  351. [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
  352. #### `[resize:<w>x<h>`
  353. Resizes the texture to the given dimensions.
  354. Example:
  355. default_sandstone.png^[resize:16x16
  356. #### `[opacity:<r>`
  357. Makes the base image transparent according to the given ratio.
  358. `r` must be between 0 (transparent) and 255 (opaque).
  359. Example:
  360. default_sandstone.png^[opacity:127
  361. #### `[invert:<mode>`
  362. Inverts the given channels of the base image.
  363. Mode may contain the characters "r", "g", "b", "a".
  364. Only the channels that are mentioned in the mode string will be inverted.
  365. Example:
  366. default_apple.png^[invert:rgb
  367. #### `[brighten`
  368. Brightens the texture.
  369. Example:
  370. tnt_tnt_side.png^[brighten
  371. #### `[noalpha`
  372. Makes the texture completely opaque.
  373. Example:
  374. default_leaves.png^[noalpha
  375. #### `[makealpha:<r>,<g>,<b>`
  376. Convert one color to transparency.
  377. Example:
  378. default_cobble.png^[makealpha:128,128,128
  379. #### `[transform<t>`
  380. * `<t>`: transformation(s) to apply
  381. Rotates and/or flips the image.
  382. `<t>` can be a number (between 0 and 7) or a transform name.
  383. Rotations are counter-clockwise.
  384. 0 I identity
  385. 1 R90 rotate by 90 degrees
  386. 2 R180 rotate by 180 degrees
  387. 3 R270 rotate by 270 degrees
  388. 4 FX flip X
  389. 5 FXR90 flip X then rotate by 90 degrees
  390. 6 FY flip Y
  391. 7 FYR90 flip Y then rotate by 90 degrees
  392. Example:
  393. default_stone.png^[transformFXR90
  394. #### `[inventorycube{<top>{<left>{<right>`
  395. Escaping does not apply here and `^` is replaced by `&` in texture names
  396. instead.
  397. Create an inventory cube texture using the side textures.
  398. Example:
  399. [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
  400. Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
  401. `dirt.png^grass_side.png` textures
  402. #### `[lowpart:<percent>:<file>`
  403. Blit the lower `<percent>`% part of `<file>` on the texture.
  404. Example:
  405. base.png^[lowpart:25:overlay.png
  406. #### `[verticalframe:<t>:<n>`
  407. * `<t>`: animation frame count
  408. * `<n>`: current animation frame
  409. Crops the texture to a frame of a vertical animation.
  410. Example:
  411. default_torch_animated.png^[verticalframe:16:8
  412. #### `[mask:<file>`
  413. Apply a mask to the base image.
  414. The mask is applied using binary AND.
  415. #### `[sheet:<w>x<h>:<x>,<y>`
  416. Retrieves a tile at position x,y from the base image
  417. which it assumes to be a tilesheet with dimensions w,h.
  418. #### `[colorize:<color>:<ratio>`
  419. Colorize the textures with the given color.
  420. `<color>` is specified as a `ColorString`.
  421. `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
  422. it is an int, then it specifies how far to interpolate between the
  423. colors where 0 is only the texture color and 255 is only `<color>`. If
  424. omitted, the alpha of `<color>` will be used as the ratio. If it is
  425. the word "`alpha`", then each texture pixel will contain the RGB of
  426. `<color>` and the alpha of `<color>` multiplied by the alpha of the
  427. texture pixel.
  428. #### `[multiply:<color>`
  429. Multiplies texture colors with the given color.
  430. `<color>` is specified as a `ColorString`.
  431. Result is more like what you'd expect if you put a color on top of another
  432. color, meaning white surfaces get a lot of your new color while black parts
  433. don't change very much.
  434. #### `[png:<base64>`
  435. Embed a base64 encoded PNG image in the texture string.
  436. You can produce a valid string for this by calling
  437. `minetest.encode_base64(minetest.encode_png(tex))`,
  438. refer to the documentation of these functions for details.
  439. You can use this to send disposable images such as captchas
  440. to individual clients, or render things that would be too
  441. expensive to compose with `[combine:`.
  442. IMPORTANT: Avoid sending large images this way.
  443. This is not a replacement for asset files, do not use it to do anything
  444. that you could instead achieve by just using a file.
  445. In particular consider `minetest.dynamic_add_media` and test whether
  446. using other texture modifiers could result in a shorter string than
  447. embedding a whole image, this may vary by use case.
  448. Hardware coloring
  449. -----------------
  450. The goal of hardware coloring is to simplify the creation of
  451. colorful nodes. If your textures use the same pattern, and they only
  452. differ in their color (like colored wool blocks), you can use hardware
  453. coloring instead of creating and managing many texture files.
  454. All of these methods use color multiplication (so a white-black texture
  455. with red coloring will result in red-black color).
  456. ### Static coloring
  457. This method is useful if you wish to create nodes/items with
  458. the same texture, in different colors, each in a new node/item definition.
  459. #### Global color
  460. When you register an item or node, set its `color` field (which accepts a
  461. `ColorSpec`) to the desired color.
  462. An `ItemStack`'s static color can be overwritten by the `color` metadata
  463. field. If you set that field to a `ColorString`, that color will be used.
  464. #### Tile color
  465. Each tile may have an individual static color, which overwrites every
  466. other coloring method. To disable the coloring of a face,
  467. set its color to white (because multiplying with white does nothing).
  468. You can set the `color` property of the tiles in the node's definition
  469. if the tile is in table format.
  470. ### Palettes
  471. For nodes and items which can have many colors, a palette is more
  472. suitable. A palette is a texture, which can contain up to 256 pixels.
  473. Each pixel is one possible color for the node/item.
  474. You can register one node/item, which can have up to 256 colors.
  475. #### Palette indexing
  476. When using palettes, you always provide a pixel index for the given
  477. node or `ItemStack`. The palette is read from left to right and from
  478. top to bottom. If the palette has less than 256 pixels, then it is
  479. stretched to contain exactly 256 pixels (after arranging the pixels
  480. to one line). The indexing starts from 0.
  481. Examples:
  482. * 16x16 palette, index = 0: the top left corner
  483. * 16x16 palette, index = 4: the fifth pixel in the first row
  484. * 16x16 palette, index = 16: the pixel below the top left corner
  485. * 16x16 palette, index = 255: the bottom right corner
  486. * 2 (width) x 4 (height) palette, index = 31: the top left corner.
  487. The palette has 8 pixels, so each pixel is stretched to 32 pixels,
  488. to ensure the total 256 pixels.
  489. * 2x4 palette, index = 32: the top right corner
  490. * 2x4 palette, index = 63: the top right corner
  491. * 2x4 palette, index = 64: the pixel below the top left corner
  492. #### Using palettes with items
  493. When registering an item, set the item definition's `palette` field to
  494. a texture. You can also use texture modifiers.
  495. The `ItemStack`'s color depends on the `palette_index` field of the
  496. stack's metadata. `palette_index` is an integer, which specifies the
  497. index of the pixel to use.
  498. #### Linking palettes with nodes
  499. When registering a node, set the item definition's `palette` field to
  500. a texture. You can also use texture modifiers.
  501. The node's color depends on its `param2`, so you also must set an
  502. appropriate `paramtype2`:
  503. * `paramtype2 = "color"` for nodes which use their full `param2` for
  504. palette indexing. These nodes can have 256 different colors.
  505. The palette should contain 256 pixels.
  506. * `paramtype2 = "colorwallmounted"` for nodes which use the first
  507. five bits (most significant) of `param2` for palette indexing.
  508. The remaining three bits are describing rotation, as in `wallmounted`
  509. paramtype2. Division by 8 yields the palette index (without stretching the
  510. palette). These nodes can have 32 different colors, and the palette
  511. should contain 32 pixels.
  512. Examples:
  513. * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
  514. pixel will be picked from the palette.
  515. * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
  516. pixel will be picked from the palette.
  517. * `paramtype2 = "colorfacedir"` for nodes which use the first
  518. three bits of `param2` for palette indexing. The remaining
  519. five bits are describing rotation, as in `facedir` paramtype2.
  520. Division by 32 yields the palette index (without stretching the
  521. palette). These nodes can have 8 different colors, and the
  522. palette should contain 8 pixels.
  523. Examples:
  524. * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
  525. first (= 0 + 1) pixel will be picked from the palette.
  526. * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
  527. second (= 1 + 1) pixel will be picked from the palette.
  528. To colorize a node on the map, set its `param2` value (according
  529. to the node's paramtype2).
  530. ### Conversion between nodes in the inventory and on the map
  531. Static coloring is the same for both cases, there is no need
  532. for conversion.
  533. If the `ItemStack`'s metadata contains the `color` field, it will be
  534. lost on placement, because nodes on the map can only use palettes.
  535. If the `ItemStack`'s metadata contains the `palette_index` field, it is
  536. automatically transferred between node and item forms by the engine,
  537. when a player digs or places a colored node.
  538. You can disable this feature by setting the `drop` field of the node
  539. to itself (without metadata).
  540. To transfer the color to a special drop, you need a drop table.
  541. Example:
  542. minetest.register_node("mod:stone", {
  543. description = "Stone",
  544. tiles = {"default_stone.png"},
  545. paramtype2 = "color",
  546. palette = "palette.png",
  547. drop = {
  548. items = {
  549. -- assume that mod:cobblestone also has the same palette
  550. {items = {"mod:cobblestone"}, inherit_color = true },
  551. }
  552. }
  553. })
  554. ### Colored items in craft recipes
  555. Craft recipes only support item strings, but fortunately item strings
  556. can also contain metadata. Example craft recipe registration:
  557. minetest.register_craft({
  558. output = minetest.itemstring_with_palette("wool:block", 3),
  559. type = "shapeless",
  560. recipe = {
  561. "wool:block",
  562. "dye:red",
  563. },
  564. })
  565. To set the `color` field, you can use `minetest.itemstring_with_color`.
  566. Metadata field filtering in the `recipe` field are not supported yet,
  567. so the craft output is independent of the color of the ingredients.
  568. Soft texture overlay
  569. --------------------
  570. Sometimes hardware coloring is not enough, because it affects the
  571. whole tile. Soft texture overlays were added to Minetest to allow
  572. the dynamic coloring of only specific parts of the node's texture.
  573. For example a grass block may have colored grass, while keeping the
  574. dirt brown.
  575. These overlays are 'soft', because unlike texture modifiers, the layers
  576. are not merged in the memory, but they are simply drawn on top of each
  577. other. This allows different hardware coloring, but also means that
  578. tiles with overlays are drawn slower. Using too much overlays might
  579. cause FPS loss.
  580. For inventory and wield images you can specify overlays which
  581. hardware coloring does not modify. You have to set `inventory_overlay`
  582. and `wield_overlay` fields to an image name.
  583. To define a node overlay, simply set the `overlay_tiles` field of the node
  584. definition. These tiles are defined in the same way as plain tiles:
  585. they can have a texture name, color etc.
  586. To skip one face, set that overlay tile to an empty string.
  587. Example (colored grass block):
  588. minetest.register_node("default:dirt_with_grass", {
  589. description = "Dirt with Grass",
  590. -- Regular tiles, as usual
  591. -- The dirt tile disables palette coloring
  592. tiles = {{name = "default_grass.png"},
  593. {name = "default_dirt.png", color = "white"}},
  594. -- Overlay tiles: define them in the same style
  595. -- The top and bottom tile does not have overlay
  596. overlay_tiles = {"", "",
  597. {name = "default_grass_side.png"}},
  598. -- Global color, used in inventory
  599. color = "green",
  600. -- Palette in the world
  601. paramtype2 = "color",
  602. palette = "default_foilage.png",
  603. })
  604. Sounds
  605. ======
  606. Only Ogg Vorbis files are supported.
  607. For positional playing of sounds, only single-channel (mono) files are
  608. supported. Otherwise OpenAL will play them non-positionally.
  609. Mods should generally prefix their sounds with `modname_`, e.g. given
  610. the mod name "`foomod`", a sound could be called:
  611. foomod_foosound.ogg
  612. Sounds are referred to by their name with a dot, a single digit and the
  613. file extension stripped out. When a sound is played, the actual sound file
  614. is chosen randomly from the matching sounds.
  615. When playing the sound `foomod_foosound`, the sound is chosen randomly
  616. from the available ones of the following files:
  617. * `foomod_foosound.ogg`
  618. * `foomod_foosound.0.ogg`
  619. * `foomod_foosound.1.ogg`
  620. * (...)
  621. * `foomod_foosound.9.ogg`
  622. Examples of sound parameter tables:
  623. -- Play locationless on all clients
  624. {
  625. gain = 1.0, -- default
  626. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  627. pitch = 1.0, -- default
  628. }
  629. -- Play locationless to one player
  630. {
  631. to_player = name,
  632. gain = 1.0, -- default
  633. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  634. pitch = 1.0, -- default
  635. }
  636. -- Play locationless to one player, looped
  637. {
  638. to_player = name,
  639. gain = 1.0, -- default
  640. loop = true,
  641. }
  642. -- Play at a location
  643. {
  644. pos = {x = 1, y = 2, z = 3},
  645. gain = 1.0, -- default
  646. max_hear_distance = 32, -- default, uses an euclidean metric
  647. }
  648. -- Play connected to an object, looped
  649. {
  650. object = <an ObjectRef>,
  651. gain = 1.0, -- default
  652. max_hear_distance = 32, -- default, uses an euclidean metric
  653. loop = true,
  654. }
  655. -- Play at a location, heard by anyone *but* the given player
  656. {
  657. pos = {x = 32, y = 0, z = 100},
  658. max_hear_distance = 40,
  659. exclude_player = name,
  660. }
  661. Looped sounds must either be connected to an object or played locationless to
  662. one player using `to_player = name`.
  663. A positional sound will only be heard by players that are within
  664. `max_hear_distance` of the sound position, at the start of the sound.
  665. `exclude_player = name` can be applied to locationless, positional and object-
  666. bound sounds to exclude a single player from hearing them.
  667. `SimpleSoundSpec`
  668. -----------------
  669. Specifies a sound name, gain (=volume) and pitch.
  670. This is either a string or a table.
  671. In string form, you just specify the sound name or
  672. the empty string for no sound.
  673. Table form has the following fields:
  674. * `name`: Sound name
  675. * `gain`: Volume (`1.0` = 100%)
  676. * `pitch`: Pitch (`1.0` = 100%)
  677. `gain` and `pitch` are optional and default to `1.0`.
  678. Examples:
  679. * `""`: No sound
  680. * `{}`: No sound
  681. * `"default_place_node"`: Play e.g. `default_place_node.ogg`
  682. * `{name = "default_place_node"}`: Same as above
  683. * `{name = "default_place_node", gain = 0.5}`: 50% volume
  684. * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
  685. Special sound files
  686. -------------------
  687. These sound files are played back by the engine if provided.
  688. * `player_damage`: Played when the local player takes damage (gain = 0.5)
  689. * `player_falling_damage`: Played when the local player takes
  690. damage by falling (gain = 0.5)
  691. * `player_jump`: Played when the local player jumps
  692. * `default_dig_<groupname>`: Default node digging sound
  693. (see node sound definition for details)
  694. Registered definitions
  695. ======================
  696. Anything added using certain [Registration functions] gets added to one or more
  697. of the global [Registered definition tables].
  698. Note that in some cases you will stumble upon things that are not contained
  699. in these tables (e.g. when a mod has been removed). Always check for
  700. existence before trying to access the fields.
  701. Example:
  702. All nodes register with `minetest.register_node` get added to the table
  703. `minetest.registered_nodes`.
  704. If you want to check the drawtype of a node, you could do:
  705. local function get_nodedef_field(nodename, fieldname)
  706. if not minetest.registered_nodes[nodename] then
  707. return nil
  708. end
  709. return minetest.registered_nodes[nodename][fieldname]
  710. end
  711. local drawtype = get_nodedef_field(nodename, "drawtype")
  712. Nodes
  713. =====
  714. Nodes are the bulk data of the world: cubes and other things that take the
  715. space of a cube. Huge amounts of them are handled efficiently, but they
  716. are quite static.
  717. The definition of a node is stored and can be accessed by using
  718. minetest.registered_nodes[node.name]
  719. See [Registered definitions].
  720. Nodes are passed by value between Lua and the engine.
  721. They are represented by a table:
  722. {name="name", param1=num, param2=num}
  723. `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
  724. them for certain automated functions. If you don't use these functions, you can
  725. use them to store arbitrary values.
  726. Node paramtypes
  727. ---------------
  728. The functions of `param1` and `param2` are determined by certain fields in the
  729. node definition.
  730. The function of `param1` is determined by `paramtype` in node definition.
  731. `param1` is reserved for the engine when `paramtype != "none"`.
  732. * `paramtype = "light"`
  733. * The value stores light with and without sun in its lower and upper 4 bits
  734. respectively.
  735. * Required by a light source node to enable spreading its light.
  736. * Required by the following drawtypes as they determine their visual
  737. brightness from their internal light value:
  738. * torchlike
  739. * signlike
  740. * firelike
  741. * fencelike
  742. * raillike
  743. * nodebox
  744. * mesh
  745. * plantlike
  746. * plantlike_rooted
  747. * `paramtype = "none"`
  748. * `param1` will not be used by the engine and can be used to store
  749. an arbitrary value
  750. The function of `param2` is determined by `paramtype2` in node definition.
  751. `param2` is reserved for the engine when `paramtype2 != "none"`.
  752. * `paramtype2 = "flowingliquid"`
  753. * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
  754. * The liquid level and a flag of the liquid are stored in `param2`
  755. * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
  756. see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
  757. to access/manipulate the content of this field
  758. * Bit 3: If set, liquid is flowing downwards (no graphical effect)
  759. * `paramtype2 = "wallmounted"`
  760. * Supported drawtypes: "torchlike", "signlike", "plantlike",
  761. "plantlike_rooted", "normal", "nodebox", "mesh"
  762. * The rotation of the node is stored in `param2`
  763. * You can make this value by using `minetest.dir_to_wallmounted()`
  764. * Values range 0 - 5
  765. * The value denotes at which direction the node is "mounted":
  766. 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z-
  767. * `paramtype2 = "facedir"`
  768. * Supported drawtypes: "normal", "nodebox", "mesh"
  769. * The rotation of the node is stored in `param2`. Furnaces and chests are
  770. rotated this way. Can be made by using `minetest.dir_to_facedir()`.
  771. * Values range 0 - 23
  772. * facedir / 4 = axis direction:
  773. 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y-
  774. * facedir modulo 4 = rotation around that axis
  775. * `paramtype2 = "leveled"`
  776. * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
  777. * Leveled nodebox:
  778. * The level of the top face of the nodebox is stored in `param2`.
  779. * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
  780. nodeboxes.
  781. * The nodebox height is (`param2` / 64) nodes.
  782. * The maximum accepted value of `param2` is 127.
  783. * Rooted plantlike:
  784. * The height of the 'plantlike' section is stored in `param2`.
  785. * The height is (`param2` / 16) nodes.
  786. * `paramtype2 = "degrotate"`
  787. * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
  788. stored in `param2`.
  789. * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
  790. get the actual rotation in degrees of the node.
  791. * `paramtype2 = "meshoptions"`
  792. * Only valid for "plantlike" drawtype. `param2` encodes the shape and
  793. optional modifiers of the "plant". `param2` is a bitfield.
  794. * Bits 0 to 2 select the shape.
  795. Use only one of the values below:
  796. * 0 = a "x" shaped plant (ordinary plant)
  797. * 1 = a "+" shaped plant (just rotated 45 degrees)
  798. * 2 = a "*" shaped plant with 3 faces instead of 2
  799. * 3 = a "#" shaped plant with 4 faces instead of 2
  800. * 4 = a "#" shaped plant with 4 faces that lean outwards
  801. * 5-7 are unused and reserved for future meshes.
  802. * Bits 3 to 7 are used to enable any number of optional modifiers.
  803. Just add the corresponding value(s) below to `param2`:
  804. * 8 - Makes the plant slightly vary placement horizontally
  805. * 16 - Makes the plant mesh 1.4x larger
  806. * 32 - Moves each face randomly a small bit down (1/8 max)
  807. * values 64 and 128 (bits 6-7) are reserved for future use.
  808. * Example: `param2 = 0` selects a normal "x" shaped plant
  809. * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
  810. * `paramtype2 = "color"`
  811. * `param2` tells which color is picked from the palette.
  812. The palette should have 256 pixels.
  813. * `paramtype2 = "colorfacedir"`
  814. * Same as `facedir`, but with colors.
  815. * The first three bits of `param2` tells which color is picked from the
  816. palette. The palette should have 8 pixels.
  817. * `paramtype2 = "colorwallmounted"`
  818. * Same as `wallmounted`, but with colors.
  819. * The first five bits of `param2` tells which color is picked from the
  820. palette. The palette should have 32 pixels.
  821. * `paramtype2 = "glasslikeliquidlevel"`
  822. * Only valid for "glasslike_framed" or "glasslike_framed_optional"
  823. drawtypes. "glasslike_framed_optional" nodes are only affected if the
  824. "Connected Glass" setting is enabled.
  825. * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
  826. full.
  827. * Bits 6 and 7 modify the appearance of the frame and node faces. One or
  828. both of these values may be added to `param2`:
  829. * 64 - Makes the node not connect with neighbors above or below it.
  830. * 128 - Makes the node not connect with neighbors to its sides.
  831. * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
  832. * `paramtype2 = "colordegrotate"`
  833. * Same as `degrotate`, but with colors.
  834. * The first (most-significant) three bits of `param2` tells which color
  835. is picked from the palette. The palette should have 8 pixels.
  836. * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
  837. * `paramtype2 = "none"`
  838. * `param2` will not be used by the engine and can be used to store
  839. an arbitrary value
  840. Nodes can also contain extra data. See [Node Metadata].
  841. Node drawtypes
  842. --------------
  843. There are a bunch of different looking node types.
  844. Look for examples in `games/devtest` or `games/minetest_game`.
  845. * `normal`
  846. * A node-sized cube.
  847. * `airlike`
  848. * Invisible, uses no texture.
  849. * `liquid`
  850. * The cubic source node for a liquid.
  851. * Faces bordering to the same node are never rendered.
  852. * Connects to node specified in `liquid_alternative_flowing`.
  853. * Use `backface_culling = false` for the tiles you want to make
  854. visible when inside the node.
  855. * `flowingliquid`
  856. * The flowing version of a liquid, appears with various heights and slopes.
  857. * Faces bordering to the same node are never rendered.
  858. * Connects to node specified in `liquid_alternative_source`.
  859. * Node textures are defined with `special_tiles` where the first tile
  860. is for the top and bottom faces and the second tile is for the side
  861. faces.
  862. * `tiles` is used for the item/inventory/wield image rendering.
  863. * Use `backface_culling = false` for the special tiles you want to make
  864. visible when inside the node
  865. * `glasslike`
  866. * Often used for partially-transparent nodes.
  867. * Only external sides of textures are visible.
  868. * `glasslike_framed`
  869. * All face-connected nodes are drawn as one volume within a surrounding
  870. frame.
  871. * The frame appearance is generated from the edges of the first texture
  872. specified in `tiles`. The width of the edges used are 1/16th of texture
  873. size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
  874. * The glass 'shine' (or other desired detail) on each node face is supplied
  875. by the second texture specified in `tiles`.
  876. * `glasslike_framed_optional`
  877. * This switches between the above 2 drawtypes according to the menu setting
  878. 'Connected Glass'.
  879. * `allfaces`
  880. * Often used for partially-transparent nodes.
  881. * External and internal sides of textures are visible.
  882. * `allfaces_optional`
  883. * Often used for leaves nodes.
  884. * This switches between `normal`, `glasslike` and `allfaces` according to
  885. the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
  886. * With 'Simple Leaves' selected, the texture specified in `special_tiles`
  887. is used instead, if present. This allows a visually thicker texture to be
  888. used to compensate for how `glasslike` reduces visual thickness.
  889. * `torchlike`
  890. * A single vertical texture.
  891. * If `paramtype2="[color]wallmounted":
  892. * If placed on top of a node, uses the first texture specified in `tiles`.
  893. * If placed against the underside of a node, uses the second texture
  894. specified in `tiles`.
  895. * If placed on the side of a node, uses the third texture specified in
  896. `tiles` and is perpendicular to that node.
  897. * If `paramtype2="none"`:
  898. * Will be rendered as if placed on top of a node (see
  899. above) and only the first texture is used.
  900. * `signlike`
  901. * A single texture parallel to, and mounted against, the top, underside or
  902. side of a node.
  903. * If `paramtype2="[color]wallmounted", it rotates according to `param2`
  904. * If `paramtype2="none"`, it will always be on the floor.
  905. * `plantlike`
  906. * Two vertical and diagonal textures at right-angles to each other.
  907. * See `paramtype2 = "meshoptions"` above for other options.
  908. * `firelike`
  909. * When above a flat surface, appears as 6 textures, the central 2 as
  910. `plantlike` plus 4 more surrounding those.
  911. * If not above a surface the central 2 do not appear, but the texture
  912. appears against the faces of surrounding nodes if they are present.
  913. * `fencelike`
  914. * A 3D model suitable for a wooden fence.
  915. * One placed node appears as a single vertical post.
  916. * Adjacently-placed nodes cause horizontal bars to appear between them.
  917. * `raillike`
  918. * Often used for tracks for mining carts.
  919. * Requires 4 textures to be specified in `tiles`, in order: Straight,
  920. curved, t-junction, crossing.
  921. * Each placed node automatically switches to a suitable rotated texture
  922. determined by the adjacent `raillike` nodes, in order to create a
  923. continuous track network.
  924. * Becomes a sloping node if placed against stepped nodes.
  925. * `nodebox`
  926. * Often used for stairs and slabs.
  927. * Allows defining nodes consisting of an arbitrary number of boxes.
  928. * See [Node boxes] below for more information.
  929. * `mesh`
  930. * Uses models for nodes.
  931. * Tiles should hold model materials textures.
  932. * Only static meshes are implemented.
  933. * For supported model formats see Irrlicht engine documentation.
  934. * `plantlike_rooted`
  935. * Enables underwater `plantlike` without air bubbles around the nodes.
  936. * Consists of a base cube at the co-ordinates of the node plus a
  937. `plantlike` extension above
  938. * If `paramtype2="leveled", the `plantlike` extension has a height
  939. of `param2 / 16` nodes, otherwise it's the height of 1 node
  940. * If `paramtype2="wallmounted"`, the `plantlike` extension
  941. will be at one of the corresponding 6 sides of the base cube.
  942. Also, the base cube rotates like a `normal` cube would
  943. * The `plantlike` extension visually passes through any nodes above the
  944. base cube without affecting them.
  945. * The base cube texture tiles are defined as normal, the `plantlike`
  946. extension uses the defined special tile, for example:
  947. `special_tiles = {{name = "default_papyrus.png"}},`
  948. `*_optional` drawtypes need less rendering time if deactivated
  949. (always client-side).
  950. Node boxes
  951. ----------
  952. Node selection boxes are defined using "node boxes".
  953. A nodebox is defined as any of:
  954. {
  955. -- A normal cube; the default in most things
  956. type = "regular"
  957. }
  958. {
  959. -- A fixed box (or boxes) (facedir param2 is used, if applicable)
  960. type = "fixed",
  961. fixed = box OR {box1, box2, ...}
  962. }
  963. {
  964. -- A variable height box (or boxes) with the top face position defined
  965. -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
  966. -- by param2.
  967. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
  968. type = "leveled",
  969. fixed = box OR {box1, box2, ...}
  970. }
  971. {
  972. -- A box like the selection box for torches
  973. -- (wallmounted param2 is used, if applicable)
  974. type = "wallmounted",
  975. wall_top = box,
  976. wall_bottom = box,
  977. wall_side = box
  978. }
  979. {
  980. -- A node that has optional boxes depending on neighbouring nodes'
  981. -- presence and type. See also `connects_to`.
  982. type = "connected",
  983. fixed = box OR {box1, box2, ...}
  984. connect_top = box OR {box1, box2, ...}
  985. connect_bottom = box OR {box1, box2, ...}
  986. connect_front = box OR {box1, box2, ...}
  987. connect_left = box OR {box1, box2, ...}
  988. connect_back = box OR {box1, box2, ...}
  989. connect_right = box OR {box1, box2, ...}
  990. -- The following `disconnected_*` boxes are the opposites of the
  991. -- `connect_*` ones above, i.e. when a node has no suitable neighbour
  992. -- on the respective side, the corresponding disconnected box is drawn.
  993. disconnected_top = box OR {box1, box2, ...}
  994. disconnected_bottom = box OR {box1, box2, ...}
  995. disconnected_front = box OR {box1, box2, ...}
  996. disconnected_left = box OR {box1, box2, ...}
  997. disconnected_back = box OR {box1, box2, ...}
  998. disconnected_right = box OR {box1, box2, ...}
  999. disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
  1000. disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
  1001. -- neighbours to the sides
  1002. }
  1003. A `box` is defined as:
  1004. {x1, y1, z1, x2, y2, z2}
  1005. A box of a regular node would look like:
  1006. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  1007. To avoid collision issues, keep each value within the range of +/- 1.45.
  1008. This also applies to leveled nodeboxes, where the final height shall not
  1009. exceed this soft limit.
  1010. Map terminology and coordinates
  1011. ===============================
  1012. Nodes, mapblocks, mapchunks
  1013. ---------------------------
  1014. A 'node' is the fundamental cubic unit of a world and appears to a player as
  1015. roughly 1x1x1 meters in size.
  1016. A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
  1017. fundamental region of a world that is stored in the world database, sent to
  1018. clients and handled by many parts of the engine.
  1019. 'mapblock' is preferred terminology to 'block' to help avoid confusion with
  1020. 'node', however 'block' often appears in the API.
  1021. A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
  1022. (80x80x80 nodes) and is the volume of world generated in one operation by
  1023. the map generator.
  1024. The size in mapblocks has been chosen to optimise map generation.
  1025. Coordinates
  1026. -----------
  1027. ### Orientation of axes
  1028. For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
  1029. ### Node coordinates
  1030. Almost all positions used in the API use node coordinates.
  1031. ### Mapblock coordinates
  1032. Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
  1033. specify a particular mapblock.
  1034. For example blockpos (0,0,0) specifies the mapblock that extends from
  1035. node position (0,0,0) to node position (15,15,15).
  1036. #### Converting node position to the containing blockpos
  1037. To calculate the blockpos of the mapblock that contains the node at 'nodepos',
  1038. for each axis:
  1039. * blockpos = math.floor(nodepos / 16)
  1040. #### Converting blockpos to min/max node positions
  1041. To calculate the min/max node positions contained in the mapblock at 'blockpos',
  1042. for each axis:
  1043. * Minimum:
  1044. nodepos = blockpos * 16
  1045. * Maximum:
  1046. nodepos = blockpos * 16 + 15
  1047. HUD
  1048. ===
  1049. HUD element types
  1050. -----------------
  1051. The position field is used for all element types.
  1052. To account for differing resolutions, the position coordinates are the
  1053. percentage of the screen, ranging in value from `0` to `1`.
  1054. The name field is not yet used, but should contain a description of what the
  1055. HUD element represents.
  1056. The `direction` field is the direction in which something is drawn.
  1057. `0` draws from left to right, `1` draws from right to left, `2` draws from
  1058. top to bottom, and `3` draws from bottom to top.
  1059. The `alignment` field specifies how the item will be aligned. It is a table
  1060. where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
  1061. moved to the left/up, and `1` is to the right/down. Fractional values can be
  1062. used.
  1063. The `offset` field specifies a pixel offset from the position. Contrary to
  1064. position, the offset is not scaled to screen size. This allows for some
  1065. precisely positioned items in the HUD.
  1066. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
  1067. factor!
  1068. The `z_index` field specifies the order of HUD elements from back to front.
  1069. Lower z-index elements are displayed behind higher z-index elements. Elements
  1070. with same z-index are displayed in an arbitrary order. Default 0.
  1071. Supports negative values. By convention, the following values are recommended:
  1072. * -400: Graphical effects, such as vignette
  1073. * -300: Name tags, waypoints
  1074. * -200: Wieldhand
  1075. * -100: Things that block the player's view, e.g. masks
  1076. * 0: Default. For standard in-game HUD elements like crosshair, hotbar,
  1077. minimap, builtin statbars, etc.
  1078. * 100: Temporary text messages or notification icons
  1079. * 1000: Full-screen effects such as full-black screen or credits.
  1080. This includes effects that cover the entire screen
  1081. * Other: If your HUD element doesn't fit into any category, pick a number
  1082. between the suggested values
  1083. Below are the specific uses for fields in each type; fields not listed for that
  1084. type are ignored.
  1085. ### `image`
  1086. Displays an image on the HUD.
  1087. * `scale`: The scale of the image, with 1 being the original texture size.
  1088. Only the X coordinate scale is used (positive values).
  1089. Negative values represent that percentage of the screen it
  1090. should take; e.g. `x=-100` means 100% (width).
  1091. * `text`: The name of the texture that is displayed.
  1092. * `alignment`: The alignment of the image.
  1093. * `offset`: offset in pixels from position.
  1094. ### `text`
  1095. Displays text on the HUD.
  1096. * `scale`: Defines the bounding rectangle of the text.
  1097. A value such as `{x=100, y=100}` should work.
  1098. * `text`: The text to be displayed in the HUD element.
  1099. * `number`: An integer containing the RGB value of the color used to draw the
  1100. text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
  1101. * `alignment`: The alignment of the text.
  1102. * `offset`: offset in pixels from position.
  1103. * `size`: size of the text.
  1104. The player-set font size is multiplied by size.x (y value isn't used).
  1105. ### `statbar`
  1106. Displays a horizontal bar made up of half-images with an optional background.
  1107. * `text`: The name of the texture to use.
  1108. * `text2`: Optional texture name to enable a background / "off state"
  1109. texture (useful to visualize the maximal value). Both textures
  1110. must have the same size.
  1111. * `number`: The number of half-textures that are displayed.
  1112. If odd, will end with a vertically center-split texture.
  1113. * `item`: Same as `number` but for the "off state" texture
  1114. * `direction`: To which direction the images will extend to
  1115. * `offset`: offset in pixels from position.
  1116. * `size`: If used, will force full-image size to this value (override texture
  1117. pack image size)
  1118. ### `inventory`
  1119. * `text`: The name of the inventory list to be displayed.
  1120. * `number`: Number of items in the inventory to be displayed.
  1121. * `item`: Position of item that is selected.
  1122. * `direction`
  1123. * `offset`: offset in pixels from position.
  1124. ### `waypoint`
  1125. Displays distance to selected world position.
  1126. * `name`: The name of the waypoint.
  1127. * `text`: Distance suffix. Can be blank.
  1128. * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
  1129. If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
  1130. When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
  1131. `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
  1132. `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
  1133. `precision = n` will show multiples of `1/n`
  1134. * `number:` An integer containing the RGB value of the color used to draw the
  1135. text.
  1136. * `world_pos`: World position of the waypoint.
  1137. * `offset`: offset in pixels from position.
  1138. * `alignment`: The alignment of the waypoint.
  1139. ### `image_waypoint`
  1140. Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
  1141. * `scale`: The scale of the image, with 1 being the original texture size.
  1142. Only the X coordinate scale is used (positive values).
  1143. Negative values represent that percentage of the screen it
  1144. should take; e.g. `x=-100` means 100% (width).
  1145. * `text`: The name of the texture that is displayed.
  1146. * `alignment`: The alignment of the image.
  1147. * `world_pos`: World position of the waypoint.
  1148. * `offset`: offset in pixels from position.
  1149. ### `compass`
  1150. Displays an image oriented or translated according to current heading direction.
  1151. * `size`: The size of this element. Negative values represent percentage
  1152. of the screen; e.g. `x=-100` means 100% (width).
  1153. * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
  1154. * `text`: The name of the texture to use.
  1155. * `alignment`: The alignment of the image.
  1156. * `offset`: Offset in pixels from position.
  1157. * `dir`: How the image is rotated/translated:
  1158. * 0 - Rotate as heading direction
  1159. * 1 - Rotate in reverse direction
  1160. * 2 - Translate as landscape direction
  1161. * 3 - Translate in reverse direction
  1162. If translation is chosen, texture is repeated horizontally to fill the whole element.
  1163. ### `minimap`
  1164. Displays a minimap on the HUD.
  1165. * `size`: Size of the minimap to display. Minimap should be a square to avoid
  1166. distortion.
  1167. * `alignment`: The alignment of the minimap.
  1168. * `offset`: offset in pixels from position.
  1169. Representations of simple things
  1170. ================================
  1171. Vector (ie. a position)
  1172. -----------------------
  1173. vector.new(x, y, z)
  1174. See [Spatial Vectors] for details.
  1175. `pointed_thing`
  1176. ---------------
  1177. * `{type="nothing"}`
  1178. * `{type="node", under=pos, above=pos}`
  1179. * Indicates a pointed node selection box.
  1180. * `under` refers to the node position behind the pointed face.
  1181. * `above` refers to the node position in front of the pointed face.
  1182. * `{type="object", ref=ObjectRef}`
  1183. Exact pointing location (currently only `Raycast` supports these fields):
  1184. * `pointed_thing.intersection_point`: The absolute world coordinates of the
  1185. point on the selection box which is pointed at. May be in the selection box
  1186. if the pointer is in the box too.
  1187. * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
  1188. from 1).
  1189. * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
  1190. selected selection box. This specifies which face is pointed at.
  1191. Is a null vector `vector.zero()` when the pointer is inside the selection box.
  1192. Flag Specifier Format
  1193. =====================
  1194. Flags using the standardized flag specifier format can be specified in either
  1195. of two ways, by string or table.
  1196. The string format is a comma-delimited set of flag names; whitespace and
  1197. unrecognized flag fields are ignored. Specifying a flag in the string sets the
  1198. flag, and specifying a flag prefixed by the string `"no"` explicitly
  1199. clears the flag from whatever the default may be.
  1200. In addition to the standard string flag format, the schematic flags field can
  1201. also be a table of flag names to boolean values representing whether or not the
  1202. flag is set. Additionally, if a field with the flag name prefixed with `"no"`
  1203. is present, mapped to a boolean of any value, the specified flag is unset.
  1204. E.g. A flag field of value
  1205. {place_center_x = true, place_center_y=false, place_center_z=true}
  1206. is equivalent to
  1207. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  1208. which is equivalent to
  1209. "place_center_x, noplace_center_y, place_center_z"
  1210. or even
  1211. "place_center_x, place_center_z"
  1212. since, by default, no schematic attributes are set.
  1213. Items
  1214. =====
  1215. Items are things that can be held by players, dropped in the map and
  1216. stored in inventories.
  1217. Items come in the form of item stacks, which are collections of equal
  1218. items that occupy a single inventory slot.
  1219. Item types
  1220. ----------
  1221. There are three kinds of items: nodes, tools and craftitems.
  1222. * Node: Placeable item form of a node in the world's voxel grid
  1223. * Tool: Has a changable wear property but cannot be stacked
  1224. * Craftitem: Has no special properties
  1225. Every registered node (the voxel in the world) has a corresponding
  1226. item form (the thing in your inventory) that comes along with it.
  1227. This item form can be placed which will create a node in the
  1228. world (by default).
  1229. Both the 'actual' node and its item form share the same identifier.
  1230. For all practical purposes, you can treat the node and its item form
  1231. interchangeably. We usually just say 'node' to the item form of
  1232. the node as well.
  1233. Note the definition of tools is purely technical. The only really
  1234. unique thing about tools is their wear, and that's basically it.
  1235. Beyond that, you can't make any gameplay-relevant assumptions
  1236. about tools or non-tools. It is perfectly valid to register something
  1237. that acts as tool in a gameplay sense as a craftitem, and vice-versa.
  1238. Craftitems can be used for items that neither need to be a node
  1239. nor a tool.
  1240. Amount and wear
  1241. ---------------
  1242. All item stacks have an amount between 0 and 65535. It is 1 by
  1243. default. Tool item stacks can not have an amount greater than 1.
  1244. Tools use a wear (damage) value ranging from 0 to 65535. The
  1245. value 0 is the default and is used for unworn tools. The values
  1246. 1 to 65535 are used for worn tools, where a higher value stands for
  1247. a higher wear. Non-tools technically also have a wear property,
  1248. but it is always 0. There is also a special 'toolrepair' crafting
  1249. recipe that is only available to tools.
  1250. Item formats
  1251. ------------
  1252. Items and item stacks can exist in three formats: Serializes, table format
  1253. and `ItemStack`.
  1254. When an item must be passed to a function, it can usually be in any of
  1255. these formats.
  1256. ### Serialized
  1257. This is called "stackstring" or "itemstring". It is a simple string with
  1258. 1-3 components: the full item identifier, an optional amount and an optional
  1259. wear value. Syntax:
  1260. <identifier> [<amount>[ <wear>]]
  1261. Examples:
  1262. * `"default:apple"`: 1 apple
  1263. * `"default:dirt 5"`: 5 dirt
  1264. * `"default:pick_stone"`: a new stone pickaxe
  1265. * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
  1266. ### Table format
  1267. Examples:
  1268. 5 dirt nodes:
  1269. {name="default:dirt", count=5, wear=0, metadata=""}
  1270. A wooden pick about 1/3 worn out:
  1271. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  1272. An apple:
  1273. {name="default:apple", count=1, wear=0, metadata=""}
  1274. ### `ItemStack`
  1275. A native C++ format with many helper methods. Useful for converting
  1276. between formats. See the [Class reference] section for details.
  1277. Groups
  1278. ======
  1279. In a number of places, there is a group table. Groups define the
  1280. properties of a thing (item, node, armor of entity, tool capabilities)
  1281. in such a way that the engine and other mods can can interact with
  1282. the thing without actually knowing what the thing is.
  1283. Usage
  1284. -----
  1285. Groups are stored in a table, having the group names with keys and the
  1286. group ratings as values. Group ratings are integer values within the
  1287. range [-32767, 32767]. For example:
  1288. -- Default dirt
  1289. groups = {crumbly=3, soil=1}
  1290. -- A more special dirt-kind of thing
  1291. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  1292. Groups always have a rating associated with them. If there is no
  1293. useful meaning for a rating for an enabled group, it shall be `1`.
  1294. When not defined, the rating of a group defaults to `0`. Thus when you
  1295. read groups, you must interpret `nil` and `0` as the same value, `0`.
  1296. You can read the rating of a group for an item or a node by using
  1297. minetest.get_item_group(itemname, groupname)
  1298. Groups of items
  1299. ---------------
  1300. Groups of items can define what kind of an item it is (e.g. wool).
  1301. Groups of nodes
  1302. ---------------
  1303. In addition to the general item things, groups are used to define whether
  1304. a node is destroyable and how long it takes to destroy by a tool.
  1305. Groups of entities
  1306. ------------------
  1307. For entities, groups are, as of now, used only for calculating damage.
  1308. The rating is the percentage of damage caused by items with this damage group.
  1309. See [Entity damage mechanism].
  1310. object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
  1311. object.set_armor_groups({fleshy=30, cracky=80})
  1312. Groups of tool capabilities
  1313. ---------------------------
  1314. Groups in tool capabilities define which groups of nodes and entities they
  1315. are effective towards.
  1316. Groups in crafting recipes
  1317. --------------------------
  1318. An example: Make meat soup from any meat, any water and any bowl:
  1319. {
  1320. output = "food:meat_soup_raw",
  1321. recipe = {
  1322. {"group:meat"},
  1323. {"group:water"},
  1324. {"group:bowl"},
  1325. },
  1326. -- preserve = {"group:bowl"}, -- Not implemented yet (TODO)
  1327. }
  1328. Another example: Make red wool from white wool and red dye:
  1329. {
  1330. type = "shapeless",
  1331. output = "wool:red",
  1332. recipe = {"wool:white", "group:dye,basecolor_red"},
  1333. }
  1334. Special groups
  1335. --------------
  1336. The asterisk `(*)` after a group name describes that there is no engine
  1337. functionality bound to it, and implementation is left up as a suggestion
  1338. to games.
  1339. ### Node and item groups
  1340. * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
  1341. that the item should be hidden in item lists.
  1342. ### Node-only groups
  1343. * `attached_node`: if the node under it is not a walkable block the node will be
  1344. dropped as an item. If the node is wallmounted the wallmounted direction is
  1345. checked.
  1346. * `bouncy`: value is bounce speed in percent
  1347. * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
  1348. connect to each other
  1349. * `dig_immediate`: Player can always pick up node without reducing tool wear
  1350. * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
  1351. * `3`: the node always gets the digging time 0 seconds (torch)
  1352. * `disable_jump`: Player (and possibly other things) cannot jump from node
  1353. or if their feet are in the node. Note: not supported for `new_move = false`
  1354. * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
  1355. the top of this node. There's also an armor group with the same name.
  1356. The final player damage is determined by the following formula:
  1357. damage =
  1358. collision speed
  1359. * ((node_fall_damage_add_percent + 100) / 100) -- node group
  1360. * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
  1361. - (14) -- constant tolerance
  1362. Negative damage values are discarded as no damage.
  1363. * `falling_node`: if there is no walkable block under the node it will fall
  1364. * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
  1365. * `level`: Can be used to give an additional sense of progression in the game.
  1366. * A larger level will cause e.g. a weapon of a lower level make much less
  1367. damage, and get worn out much faster, or not be able to get drops
  1368. from destroyed nodes.
  1369. * `0` is something that is directly accessible at the start of gameplay
  1370. * There is no upper limit
  1371. * See also: `leveldiff` in [Tool Capabilities]
  1372. * `slippery`: Players and items will slide on the node.
  1373. Slipperiness rises steadily with `slippery` value, starting at 1.
  1374. ### Tool-only groups
  1375. * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
  1376. `"toolrepair"` crafting recipe
  1377. ### `ObjectRef` armor groups
  1378. * `immortal`: Skips all damage and breath handling for an object. This group
  1379. will also hide the integrated HUD status bars for players. It is
  1380. automatically set to all players when damage is disabled on the server and
  1381. cannot be reset (subject to change).
  1382. * `fall_damage_add_percent`: Modifies the fall damage suffered by players
  1383. when they hit the ground. It is analog to the node group with the same
  1384. name. See the node group above for the exact calculation.
  1385. * `punch_operable`: For entities; disables the regular damage mechanism for
  1386. players punching it by hand or a non-tool item, so that it can do something
  1387. else than take damage.
  1388. Known damage and digging time defining groups
  1389. ---------------------------------------------
  1390. * `crumbly`: dirt, sand
  1391. * `cracky`: tough but crackable stuff like stone.
  1392. * `snappy`: something that can be cut using things like scissors, shears,
  1393. bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
  1394. * `choppy`: something that can be cut using force; e.g. trees, wooden planks
  1395. * `fleshy`: Living things like animals and the player. This could imply
  1396. some blood effects when hitting.
  1397. * `explody`: Especially prone to explosions
  1398. * `oddly_breakable_by_hand`:
  1399. Can be added to nodes that shouldn't logically be breakable by the
  1400. hand but are. Somewhat similar to `dig_immediate`, but times are more
  1401. like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
  1402. digging speed of an item if it can dig at a faster speed than this
  1403. suggests for the hand.
  1404. Examples of custom groups
  1405. -------------------------
  1406. Item groups are often used for defining, well, _groups of items_.
  1407. * `meat`: any meat-kind of a thing (rating might define the size or healing
  1408. ability or be irrelevant -- it is not defined as of yet)
  1409. * `eatable`: anything that can be eaten. Rating might define HP gain in half
  1410. hearts.
  1411. * `flammable`: can be set on fire. Rating might define the intensity of the
  1412. fire, affecting e.g. the speed of the spreading of an open fire.
  1413. * `wool`: any wool (any origin, any color)
  1414. * `metal`: any metal
  1415. * `weapon`: any weapon
  1416. * `heavy`: anything considerably heavy
  1417. Digging time calculation specifics
  1418. ----------------------------------
  1419. Groups such as `crumbly`, `cracky` and `snappy` are used for this
  1420. purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
  1421. faster digging time.
  1422. The `level` group is used to limit the toughness of nodes an item capable
  1423. of digging can dig and to scale the digging times / damage to a greater extent.
  1424. **Please do understand this**, otherwise you cannot use the system to it's
  1425. full potential.
  1426. Items define their properties by a list of parameters for groups. They
  1427. cannot dig other groups; thus it is important to use a standard bunch of
  1428. groups to enable interaction with items.
  1429. Tool Capabilities
  1430. =================
  1431. 'Tool capabilities' is a property of items that defines two things:
  1432. 1) Which nodes it can dig and how fast
  1433. 2) Which objects it can hurt by punching and by how much
  1434. Tool capabilities are available for all items, not just tools.
  1435. But only tools can receive wear from digging and punching.
  1436. Missing or incomplete tool capabilities will default to the
  1437. player's hand.
  1438. Tool capabilities definition
  1439. ----------------------------
  1440. Tool capabilities define:
  1441. * Full punch interval
  1442. * Maximum drop level
  1443. * For an arbitrary list of node groups:
  1444. * Uses (until the tool breaks)
  1445. * Maximum level (usually `0`, `1`, `2` or `3`)
  1446. * Digging times
  1447. * Damage groups
  1448. * Punch attack uses (until the tool breaks)
  1449. ### Full punch interval
  1450. When used as a weapon, the item will do full damage if this time is spent
  1451. between punches. If e.g. half the time is spent, the item will do half
  1452. damage.
  1453. ### Maximum drop level
  1454. Suggests the maximum level of node, when dug with the item, that will drop
  1455. its useful item. (e.g. iron ore to drop a lump of iron).
  1456. This is not automated; it is the responsibility of the node definition
  1457. to implement this.
  1458. ### Uses (tools only)
  1459. Determines how many uses the tool has when it is used for digging a node,
  1460. of this group, of the maximum level. The maximum supported number of
  1461. uses is 65535. The special number 0 is used for infinite uses.
  1462. For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
  1463. `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
  1464. node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
  1465. * `uses=10, leveldiff=0`: actual uses: 10
  1466. * `uses=10, leveldiff=1`: actual uses: 30
  1467. * `uses=10, leveldiff=2`: actual uses: 90
  1468. For non-tools, this has no effect.
  1469. ### Maximum level
  1470. Tells what is the maximum level of a node of this group that the item will
  1471. be able to dig.
  1472. ### Digging times
  1473. List of digging times for different ratings of the group, for nodes of the
  1474. maximum level.
  1475. For example, as a Lua table, `times={2=2.00, 3=0.70}`. This would
  1476. result in the item to be able to dig nodes that have a rating of `2` or `3`
  1477. for this group, and unable to dig the rating `1`, which is the toughest.
  1478. Unless there is a matching group that enables digging otherwise.
  1479. If the result digging time is 0, a delay of 0.15 seconds is added between
  1480. digging nodes; If the player releases LMB after digging, this delay is set to 0,
  1481. i.e. players can more quickly click the nodes away instead of holding LMB.
  1482. ### Damage groups
  1483. List of damage for groups of entities. See [Entity damage mechanism].
  1484. ### Punch attack uses (tools only)
  1485. Determines how many uses (before breaking) the tool has when dealing damage
  1486. to an object, when the full punch interval (see above) was always
  1487. waited out fully.
  1488. Wear received by the tool is proportional to the time spent, scaled by
  1489. the full punch interval.
  1490. For non-tools, this has no effect.
  1491. Example definition of the capabilities of an item
  1492. -------------------------------------------------
  1493. tool_capabilities = {
  1494. full_punch_interval=1.5,
  1495. max_drop_level=1,
  1496. groupcaps={
  1497. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  1498. }
  1499. damage_groups = {fleshy=2},
  1500. }
  1501. This makes the item capable of digging nodes that fulfil both of these:
  1502. * Have the `crumbly` group
  1503. * Have a `level` group less or equal to `2`
  1504. Table of resulting digging times:
  1505. crumbly 0 1 2 3 4 <- level
  1506. -> 0 - - - - -
  1507. 1 0.80 1.60 1.60 - -
  1508. 2 0.60 1.20 1.20 - -
  1509. 3 0.40 0.80 0.80 - -
  1510. level diff: 2 1 0 -1 -2
  1511. Table of resulting tool uses:
  1512. -> 0 - - - - -
  1513. 1 180 60 20 - -
  1514. 2 180 60 20 - -
  1515. 3 180 60 20 - -
  1516. **Notes**:
  1517. * At `crumbly==0`, the node is not diggable.
  1518. * At `crumbly==3`, the level difference digging time divider kicks in and makes
  1519. easy nodes to be quickly breakable.
  1520. * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
  1521. Entity damage mechanism
  1522. =======================
  1523. Damage calculation:
  1524. damage = 0
  1525. foreach group in cap.damage_groups:
  1526. damage += cap.damage_groups[group]
  1527. * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
  1528. * (object.armor_groups[group] / 100.0)
  1529. -- Where object.armor_groups[group] is 0 for inexistent values
  1530. return damage
  1531. Client predicts damage based on damage groups. Because of this, it is able to
  1532. give an immediate response when an entity is damaged or dies; the response is
  1533. pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
  1534. TODO).
  1535. Currently a smoke puff will appear when an entity dies.
  1536. The group `immortal` completely disables normal damage.
  1537. Entities can define a special armor group, which is `punch_operable`. This
  1538. group disables the regular damage mechanism for players punching it by hand or
  1539. a non-tool item, so that it can do something else than take damage.
  1540. On the Lua side, every punch calls:
  1541. entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
  1542. damage)
  1543. This should never be called directly, because damage is usually not handled by
  1544. the entity itself.
  1545. * `puncher` is the object performing the punch. Can be `nil`. Should never be
  1546. accessed unless absolutely required, to encourage interoperability.
  1547. * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
  1548. * `tool_capabilities` can be `nil`.
  1549. * `direction` is a unit vector, pointing from the source of the punch to
  1550. the punched object.
  1551. * `damage` damage that will be done to entity
  1552. Return value of this function will determine if damage is done by this function
  1553. (retval true) or shall be done by engine (retval false)
  1554. To punch an entity/object in Lua, call:
  1555. object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1556. * Return value is tool wear.
  1557. * Parameters are equal to the above callback.
  1558. * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
  1559. will be automatically filled in based on the location of `puncher`.
  1560. Metadata
  1561. ========
  1562. Node Metadata
  1563. -------------
  1564. The instance of a node in the world normally only contains the three values
  1565. mentioned in [Nodes]. However, it is possible to insert extra data into a node.
  1566. It is called "node metadata"; See `NodeMetaRef`.
  1567. Node metadata contains two things:
  1568. * A key-value store
  1569. * An inventory
  1570. Some of the values in the key-value store are handled specially:
  1571. * `formspec`: Defines an inventory menu that is opened with the
  1572. 'place/use' key. Only works if no `on_rightclick` was
  1573. defined for the node. See also [Formspec].
  1574. * `infotext`: Text shown on the screen when the node is pointed at.
  1575. Line-breaks will be applied automatically.
  1576. If the infotext is very long, it will be truncated.
  1577. Example:
  1578. local meta = minetest.get_meta(pos)
  1579. meta:set_string("formspec",
  1580. "size[8,9]"..
  1581. "list[context;main;0,0;8,4;]"..
  1582. "list[current_player;main;0,5;8,4;]")
  1583. meta:set_string("infotext", "Chest");
  1584. local inv = meta:get_inventory()
  1585. inv:set_size("main", 8*4)
  1586. print(dump(meta:to_table()))
  1587. meta:from_table({
  1588. inventory = {
  1589. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
  1590. [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
  1591. [10] = "", [11] = "", [12] = "", [13] = "",
  1592. [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
  1593. [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
  1594. [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
  1595. [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
  1596. [32] = ""}
  1597. },
  1598. fields = {
  1599. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  1600. infotext = "Chest"
  1601. }
  1602. })
  1603. Item Metadata
  1604. -------------
  1605. Item stacks can store metadata too. See [`ItemStackMetaRef`].
  1606. Item metadata only contains a key-value store.
  1607. Some of the values in the key-value store are handled specially:
  1608. * `description`: Set the item stack's description.
  1609. See also: `get_description` in [`ItemStack`]
  1610. * `short_description`: Set the item stack's short description.
  1611. See also: `get_short_description` in [`ItemStack`]
  1612. * `color`: A `ColorString`, which sets the stack's color.
  1613. * `palette_index`: If the item has a palette, this is used to get the
  1614. current color from the palette.
  1615. * `count_meta`: Replace the displayed count with any string.
  1616. * `count_alignment`: Set the alignment of the displayed count value. This is an
  1617. int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
  1618. 4th bit specify the alignment in y-direction:
  1619. 0 = default, 1 = left / up, 2 = middle, 3 = right / down
  1620. The default currently is the same as right/down.
  1621. Example: 6 = 2 + 1*4 = middle,up
  1622. Example:
  1623. local meta = stack:get_meta()
  1624. meta:set_string("key", "value")
  1625. print(dump(meta:to_table()))
  1626. Example manipulations of "description" and expected output behaviors:
  1627. print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
  1628. print(ItemStack("foobar"):get_description()) --> Unknown Item
  1629. local stack = ItemStack("default:stone")
  1630. stack:get_meta():set_string("description", "Custom description\nAnother line")
  1631. print(stack:get_description()) --> Custom description\nAnother line
  1632. print(stack:get_short_description()) --> Custom description
  1633. stack:get_meta():set_string("short_description", "Short")
  1634. print(stack:get_description()) --> Custom description\nAnother line
  1635. print(stack:get_short_description()) --> Short
  1636. print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
  1637. Formspec
  1638. ========
  1639. Formspec defines a menu. This supports inventories and some of the
  1640. typical widgets like buttons, checkboxes, text input fields, etc.
  1641. It is a string, with a somewhat strange format.
  1642. A formspec is made out of formspec elements, which includes widgets
  1643. like buttons but also can be used to set stuff like background color.
  1644. Many formspec elements have a `name`, which is a unique identifier which
  1645. is used when the server receives user input. You must not use the name
  1646. "quit" for formspec elements.
  1647. Spaces and newlines can be inserted between the blocks, as is used in the
  1648. examples.
  1649. Position and size units are inventory slots unless the new coordinate system
  1650. is enabled. `X` and `Y` position the formspec element relative to the top left
  1651. of the menu or container. `W` and `H` are its width and height values.
  1652. If the new system is enabled, all elements have unified coordinates for all
  1653. elements with no padding or spacing in between. This is highly recommended
  1654. for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
  1655. Coordinates`.
  1656. Inventories with a `player:<name>` inventory location are only sent to the
  1657. player named `<name>`.
  1658. When displaying text which can contain formspec code, e.g. text set by a player,
  1659. use `minetest.formspec_escape`.
  1660. For coloured text you can use `minetest.colorize`.
  1661. Since formspec version 3, elements drawn in the order they are defined. All
  1662. background elements are drawn before all other elements.
  1663. **WARNING**: do _not_ use a element name starting with `key_`; those names are
  1664. reserved to pass key press events to formspec!
  1665. **WARNING**: Minetest allows you to add elements to every single formspec instance
  1666. using `player:set_formspec_prepend()`, which may be the reason backgrounds are
  1667. appearing when you don't expect them to, or why things are styled differently
  1668. to normal. See [`no_prepend[]`] and [Styling Formspecs].
  1669. Examples
  1670. --------
  1671. ### Chest
  1672. size[8,9]
  1673. list[context;main;0,0;8,4;]
  1674. list[current_player;main;0,5;8,4;]
  1675. ### Furnace
  1676. size[8,9]
  1677. list[context;fuel;2,3;1,1;]
  1678. list[context;src;2,1;1,1;]
  1679. list[context;dst;5,1;2,2;]
  1680. list[current_player;main;0,5;8,4;]
  1681. ### Minecraft-like player inventory
  1682. size[8,7.5]
  1683. image[1,0.6;1,2;player.png]
  1684. list[current_player;main;0,3.5;8,4;]
  1685. list[current_player;craft;3,0;3,3;]
  1686. list[current_player;craftpreview;7,1;1,1;]
  1687. Version History
  1688. ---------------
  1689. * Formspec version 1 (pre-5.1.0):
  1690. * (too much)
  1691. * Formspec version 2 (5.1.0):
  1692. * Forced real coordinates
  1693. * background9[]: 9-slice scaling parameters
  1694. * Formspec version 3 (5.2.0):
  1695. * Formspec elements are drawn in the order of definition
  1696. * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
  1697. * box[] and image[] elements enable clipping by default
  1698. * new element: scroll_container[]
  1699. * Formspec version 4 (5.4.0):
  1700. * Allow dropdown indexing events
  1701. * Formspec version 5 (5.5.0):
  1702. * Added padding[] element
  1703. Elements
  1704. --------
  1705. ### `formspec_version[<version>]`
  1706. * Set the formspec version to a certain number. If not specified,
  1707. version 1 is assumed.
  1708. * Must be specified before `size` element.
  1709. * Clients older than this version can neither show newer elements nor display
  1710. elements with new arguments correctly.
  1711. * Available since feature `formspec_version_element`.
  1712. * See also: [Version History]
  1713. ### `size[<W>,<H>,<fixed_size>]`
  1714. * Define the size of the menu in inventory slots
  1715. * `fixed_size`: `true`/`false` (optional)
  1716. * deprecated: `invsize[<W>,<H>;]`
  1717. ### `position[<X>,<Y>]`
  1718. * Must be used after `size` element.
  1719. * Defines the position on the game window of the formspec's `anchor` point.
  1720. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
  1721. for example:
  1722. * [0.0, 0.0] sets the position to the top left corner of the game window.
  1723. * [1.0, 1.0] sets the position to the bottom right of the game window.
  1724. * Defaults to the center of the game window [0.5, 0.5].
  1725. ### `anchor[<X>,<Y>]`
  1726. * Must be used after both `size` and `position` (if present) elements.
  1727. * Defines the location of the anchor point within the formspec.
  1728. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
  1729. for example:
  1730. * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
  1731. * [1.0, 0.0] sets the anchor to the top right of the formspec.
  1732. * Defaults to the center of the formspec [0.5, 0.5].
  1733. * `position` and `anchor` elements need suitable values to avoid a formspec
  1734. extending off the game window due to particular game window sizes.
  1735. ### `padding[<X>,<Y>]`
  1736. * Must be used after the `size`, `position`, and `anchor` elements (if present).
  1737. * Defines how much space is padded around the formspec if the formspec tries to
  1738. increase past the size of the screen and coordinates have to be shrunk.
  1739. * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
  1740. screen), and 0.5 represents half the screen (which forces the coordinate size
  1741. to 0). If negative, the formspec can extend off the edge of the screen.
  1742. * Defaults to [0.05, 0.05].
  1743. ### `no_prepend[]`
  1744. * Must be used after the `size`, `position`, `anchor`, and `padding` elements
  1745. (if present).
  1746. * Disables player:set_formspec_prepend() from applying to this formspec.
  1747. ### `real_coordinates[<bool>]`
  1748. * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
  1749. * When set to true, all following formspec elements will use the new coordinate system.
  1750. * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
  1751. (if present), the form size will use the new coordinate system.
  1752. * **Note**: Formspec prepends are not affected by the coordinates in the main form.
  1753. They must enable it explicitly.
  1754. * For information on converting forms to the new coordinate system, see `Migrating
  1755. to Real Coordinates`.
  1756. ### `container[<X>,<Y>]`
  1757. * Start of a container block, moves all physical elements in the container by
  1758. (X, Y).
  1759. * Must have matching `container_end`
  1760. * Containers can be nested, in which case the offsets are added
  1761. (child containers are relative to parent containers)
  1762. ### `container_end[]`
  1763. * End of a container, following elements are no longer relative to this
  1764. container.
  1765. ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
  1766. * Start of a scroll_container block. All contained elements will ...
  1767. * take the scroll_container coordinate as position origin,
  1768. * be additionally moved by the current value of the scrollbar with the name
  1769. `scrollbar name` times `scroll factor` along the orientation `orientation` and
  1770. * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
  1771. * `orientation`: possible values are `vertical` and `horizontal`.
  1772. * `scroll factor`: optional, defaults to `0.1`.
  1773. * Nesting is possible.
  1774. * Some elements might work a little different if they are in a scroll_container.
  1775. * Note: If you want the scroll_container to actually work, you also need to add a
  1776. scrollbar element with the specified name. Furthermore, it is highly recommended
  1777. to use a scrollbaroptions element on this scrollbar.
  1778. ### `scroll_container_end[]`
  1779. * End of a scroll_container, following elements are no longer bound to this
  1780. container.
  1781. ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
  1782. * Show an inventory list if it has been sent to the client.
  1783. * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
  1784. are moved) while the formspec is open, the formspec element may (but is not guaranteed
  1785. to) adapt to the new inventory list.
  1786. * Item slots are drawn in a grid from left to right, then up to down, ordered
  1787. according to the slot index.
  1788. * `W` and `H` are in inventory slots, not in coordinates.
  1789. * `starting item index` (Optional): The index of the first (upper-left) item to draw.
  1790. Indices start at `0`. Default is `0`.
  1791. * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
  1792. `starting item index`.
  1793. * **Note**: With the new coordinate system, the spacing between inventory
  1794. slots is one-fourth the size of an inventory slot by default. Also see
  1795. [Styling Formspecs] for changing the size of slots and spacing.
  1796. ### `listring[<inventory location>;<list name>]`
  1797. * Allows to create a ring of inventory lists
  1798. * Shift-clicking on items in one element of the ring
  1799. will send them to the next inventory list inside the ring
  1800. * The first occurrence of an element inside the ring will
  1801. determine the inventory where items will be sent to
  1802. ### `listring[]`
  1803. * Shorthand for doing `listring[<inventory location>;<list name>]`
  1804. for the last two inventory lists added by list[...]
  1805. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
  1806. * Sets background color of slots as `ColorString`
  1807. * Sets background color of slots on mouse hovering
  1808. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
  1809. * Sets background color of slots as `ColorString`
  1810. * Sets background color of slots on mouse hovering
  1811. * Sets color of slots border
  1812. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
  1813. * Sets background color of slots as `ColorString`
  1814. * Sets background color of slots on mouse hovering
  1815. * Sets color of slots border
  1816. * Sets default background color of tooltips
  1817. * Sets default font color of tooltips
  1818. ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1819. * Adds tooltip for an element
  1820. * `bgcolor` tooltip background color as `ColorString` (optional)
  1821. * `fontcolor` tooltip font color as `ColorString` (optional)
  1822. ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1823. * Adds tooltip for an area. Other tooltips will take priority when present.
  1824. * `bgcolor` tooltip background color as `ColorString` (optional)
  1825. * `fontcolor` tooltip font color as `ColorString` (optional)
  1826. ### `image[<X>,<Y>;<W>,<H>;<texture name>]`
  1827. * Show an image
  1828. ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>]`
  1829. * Show an animated image. The image is drawn like a "vertical_frames" tile
  1830. animation (See [Tile animation definition]), but uses a frame count/duration
  1831. for simplicity
  1832. * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
  1833. * `texture name`: The image to use.
  1834. * `frame count`: The number of frames animating the image.
  1835. * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
  1836. * `frame start` (Optional): The index of the frame to start on. Default `1`.
  1837. ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
  1838. * Show a mesh model.
  1839. * `name`: Element name that can be used for styling
  1840. * `mesh`: The mesh model to use.
  1841. * `textures`: The mesh textures to use according to the mesh materials.
  1842. Texture names must be separated by commas.
  1843. * `rotation {X,Y}` (Optional): Initial rotation of the camera.
  1844. The axes are euler angles in degrees.
  1845. * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
  1846. * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
  1847. * `frame loop range` (Optional): Range of the animation frames.
  1848. * Defaults to the full range of all available frames.
  1849. * Syntax: `<begin>,<end>`
  1850. * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
  1851. ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
  1852. * Show an inventory image of registered item/node
  1853. ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
  1854. * Sets background color of formspec.
  1855. * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
  1856. of the non-fullscreen and the fullscreen background.
  1857. * `fullscreen` (optional) can be one of the following:
  1858. * `false`: Only the non-fullscreen background color is drawn. (default)
  1859. * `true`: Only the fullscreen background color is drawn.
  1860. * `both`: The non-fullscreen and the fullscreen background color are drawn.
  1861. * `neither`: No background color is drawn.
  1862. * Note: Leave a parameter empty to not modify the value.
  1863. * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
  1864. are not bools are only available since formspec version 3.
  1865. ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
  1866. * Example for formspec 8x4 in 16x resolution: image shall be sized
  1867. 8 times 16px times 4 times 16px.
  1868. ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
  1869. * Example for formspec 8x4 in 16x resolution:
  1870. image shall be sized 8 times 16px times 4 times 16px
  1871. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1872. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1873. ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
  1874. * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
  1875. * Middle is a rect which defines the middle of the 9-slice.
  1876. * `x` - The middle will be x pixels from all sides.
  1877. * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
  1878. * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
  1879. will be added to the width and height of the texture, allowing it to be used as the
  1880. distance from the far end.
  1881. * All numbers in middle are integers.
  1882. * Example for formspec 8x4 in 16x resolution:
  1883. image shall be sized 8 times 16px times 4 times 16px
  1884. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1885. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1886. * Available since formspec version 2
  1887. ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1888. * Textual password style field; will be sent to server when a button is clicked
  1889. * When enter is pressed in field, fields.key_enter_field will be sent with the
  1890. name of this field.
  1891. * With the old coordinate system, fields are a set height, but will be vertically
  1892. centred on `H`. With the new coordinate system, `H` will modify the height.
  1893. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1894. * `label`, if not blank, will be text printed on the top left above the field
  1895. * See `field_close_on_enter` to stop enter closing the formspec
  1896. ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1897. * Textual field; will be sent to server when a button is clicked
  1898. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1899. the name of this field.
  1900. * With the old coordinate system, fields are a set height, but will be vertically
  1901. centred on `H`. With the new coordinate system, `H` will modify the height.
  1902. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1903. * `label`, if not blank, will be text printed on the top left above the field
  1904. * `default` is the default value of the field
  1905. * `default` may contain variable references such as `${text}` which
  1906. will fill the value from the metadata value `text`
  1907. * **Note**: no extra text or more than a single variable is supported ATM.
  1908. * See `field_close_on_enter` to stop enter closing the formspec
  1909. ### `field[<name>;<label>;<default>]`
  1910. * As above, but without position/size units
  1911. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1912. the name of this field.
  1913. * Special field for creating simple forms, such as sign text input
  1914. * Must be used without a `size[]` element
  1915. * A "Proceed" button will be added automatically
  1916. * See `field_close_on_enter` to stop enter closing the formspec
  1917. ### `field_close_on_enter[<name>;<close_on_enter>]`
  1918. * <name> is the name of the field
  1919. * if <close_on_enter> is false, pressing enter in the field will submit the
  1920. form but not close it.
  1921. * defaults to true when not specified (ie: no tag for a field)
  1922. ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1923. * Same as fields above, but with multi-line input
  1924. * If the text overflows, a vertical scrollbar is added.
  1925. * If the name is empty, the textarea is read-only and
  1926. the background is not shown, which corresponds to a multi-line label.
  1927. ### `label[<X>,<Y>;<label>]`
  1928. * The label formspec element displays the text set in `label`
  1929. at the specified position.
  1930. * **Note**: If the new coordinate system is enabled, labels are
  1931. positioned from the center of the text, not the top.
  1932. * The text is displayed directly without automatic line breaking,
  1933. so label should not be used for big text chunks. Newlines can be
  1934. used to make labels multiline.
  1935. * **Note**: With the new coordinate system, newlines are spaced with
  1936. half a coordinate. With the old system, newlines are spaced 2/5 of
  1937. an inventory slot.
  1938. ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
  1939. * Displays a static formatted text with hyperlinks.
  1940. * **Note**: This element is currently unstable and subject to change.
  1941. * `x`, `y`, `w` and `h` work as per field
  1942. * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
  1943. * `text` is the formatted text using `Markup Language` described below.
  1944. ### `vertlabel[<X>,<Y>;<label>]`
  1945. * Textual label drawn vertically
  1946. * `label` is the text on the label
  1947. * **Note**: If the new coordinate system is enabled, vertlabels are
  1948. positioned from the center of the text, not the left.
  1949. ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1950. * Clickable button. When clicked, fields will be sent.
  1951. * With the old coordinate system, buttons are a set height, but will be vertically
  1952. centred on `H`. With the new coordinate system, `H` will modify the height.
  1953. * `label` is the text on the button
  1954. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1955. * `texture name` is the filename of an image
  1956. * **Note**: Height is supported on both the old and new coordinate systems
  1957. for image_buttons.
  1958. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
  1959. * `texture name` is the filename of an image
  1960. * `noclip=true` means the image button doesn't need to be within specified
  1961. formsize.
  1962. * `drawborder`: draw button border or not
  1963. * `pressed texture name` is the filename of an image on pressed state
  1964. ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
  1965. * `item name` is the registered name of an item/node
  1966. * The item description will be used as the tooltip. This can be overridden with
  1967. a tooltip element.
  1968. ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1969. * When clicked, fields will be sent and the form will quit.
  1970. * Same as `button` in all other respects.
  1971. ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1972. * When clicked, fields will be sent and the form will quit.
  1973. * Same as `image_button` in all other respects.
  1974. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
  1975. * Scrollable item list showing arbitrary text elements
  1976. * `name` fieldname sent to server on doubleclick value is current selected
  1977. element.
  1978. * `listelements` can be prepended by #color in hexadecimal format RRGGBB
  1979. (only).
  1980. * if you want a listelement to start with "#" write "##".
  1981. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
  1982. * Scrollable itemlist showing arbitrary text elements
  1983. * `name` fieldname sent to server on doubleclick value is current selected
  1984. element.
  1985. * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
  1986. * if you want a listelement to start with "#" write "##"
  1987. * Index to be selected within textlist
  1988. * `true`/`false`: draw transparent background
  1989. * See also `minetest.explode_textlist_event`
  1990. (main menu: `core.explode_textlist_event`).
  1991. ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  1992. * Show a tab**header** at specific position (ignores formsize)
  1993. * `X` and `Y`: position of the tabheader
  1994. * *Note*: Width and height are automatically chosen with this syntax
  1995. * `name` fieldname data is transferred to Lua
  1996. * `caption 1`...: name shown on top of tab
  1997. * `current_tab`: index of selected tab 1...
  1998. * `transparent` (optional): if true, tabs are semi-transparent
  1999. * `draw_border` (optional): if true, draw a thin line at tab base
  2000. ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2001. * Show a tab**header** at specific position (ignores formsize)
  2002. * **Important note**: This syntax for tabheaders can only be used with the
  2003. new coordinate system.
  2004. * `X` and `Y`: position of the tabheader
  2005. * `H`: height of the tabheader. Width is automatically determined with this syntax.
  2006. * `name` fieldname data is transferred to Lua
  2007. * `caption 1`...: name shown on top of tab
  2008. * `current_tab`: index of selected tab 1...
  2009. * `transparent` (optional): show transparent
  2010. * `draw_border` (optional): draw border
  2011. ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2012. * Show a tab**header** at specific position (ignores formsize)
  2013. * **Important note**: This syntax for tabheaders can only be used with the
  2014. new coordinate system.
  2015. * `X` and `Y`: position of the tabheader
  2016. * `W` and `H`: width and height of the tabheader
  2017. * `name` fieldname data is transferred to Lua
  2018. * `caption 1`...: name shown on top of tab
  2019. * `current_tab`: index of selected tab 1...
  2020. * `transparent` (optional): show transparent
  2021. * `draw_border` (optional): draw border
  2022. ### `box[<X>,<Y>;<W>,<H>;<color>]`
  2023. * Simple colored box
  2024. * `color` is color specified as a `ColorString`.
  2025. If the alpha component is left blank, the box will be semitransparent.
  2026. If the color is not specified, the box will use the options specified by
  2027. its style. If the color is specified, all styling options will be ignored.
  2028. ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2029. * Show a dropdown field
  2030. * **Important note**: There are two different operation modes:
  2031. 1. handle directly on change (only changed dropdown is submitted)
  2032. 2. read the value on pressing a button (all dropdown values are available)
  2033. * `X` and `Y`: position of the dropdown
  2034. * `W`: width of the dropdown. Height is automatically chosen with this syntax.
  2035. * Fieldname data is transferred to Lua
  2036. * Items to be shown in dropdown
  2037. * Index of currently selected dropdown item
  2038. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2039. event field value for selected items.
  2040. * `true`: Selected item index
  2041. * `false` (default): Selected item value
  2042. ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2043. * Show a dropdown field
  2044. * **Important note**: This syntax for dropdowns can only be used with the
  2045. new coordinate system.
  2046. * **Important note**: There are two different operation modes:
  2047. 1. handle directly on change (only changed dropdown is submitted)
  2048. 2. read the value on pressing a button (all dropdown values are available)
  2049. * `X` and `Y`: position of the dropdown
  2050. * `W` and `H`: width and height of the dropdown
  2051. * Fieldname data is transferred to Lua
  2052. * Items to be shown in dropdown
  2053. * Index of currently selected dropdown item
  2054. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2055. event field value for selected items.
  2056. * `true`: Selected item index
  2057. * `false` (default): Selected item value
  2058. ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
  2059. * Show a checkbox
  2060. * `name` fieldname data is transferred to Lua
  2061. * `label` to be shown left of checkbox
  2062. * `selected` (optional): `true`/`false`
  2063. * **Note**: If the new coordinate system is enabled, checkboxes are
  2064. positioned from the center of the checkbox, not the top.
  2065. ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
  2066. * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
  2067. * There are two ways to use it:
  2068. 1. handle the changed event (only changed scrollbar is available)
  2069. 2. read the value on pressing a button (all scrollbars are available)
  2070. * `orientation`: `vertical`/`horizontal`. Default horizontal.
  2071. * Fieldname data is transferred to Lua
  2072. * Value of this trackbar is set to (`0`-`1000`) by default
  2073. * See also `minetest.explode_scrollbar_event`
  2074. (main menu: `core.explode_scrollbar_event`).
  2075. ### `scrollbaroptions[opt1;opt2;...]`
  2076. * Sets options for all following `scrollbar[]` elements
  2077. * `min=<int>`
  2078. * Sets scrollbar minimum value, defaults to `0`.
  2079. * `max=<int>`
  2080. * Sets scrollbar maximum value, defaults to `1000`.
  2081. If the max is equal to the min, the scrollbar will be disabled.
  2082. * `smallstep=<int>`
  2083. * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
  2084. scrolled.
  2085. * If this is set to a negative number, the value will be reset to `10`.
  2086. * `largestep=<int>`
  2087. * Sets scrollbar step value used by page up and page down.
  2088. * If this is set to a negative number, the value will be reset to `100`.
  2089. * `thumbsize=<int>`
  2090. * Sets size of the thumb on the scrollbar. Size is calculated in the number of
  2091. units the thumb spans out of the range of the scrollbar values.
  2092. * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
  2093. would span a tenth of the scrollbar space.
  2094. * If this is set to zero or less, the value will be reset to `1`.
  2095. * `arrows=<show/hide/default>`
  2096. * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
  2097. when the scrollbar gets too small, but shows them otherwise.
  2098. ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
  2099. * Show scrollable table using options defined by the previous `tableoptions[]`
  2100. * Displays cells as defined by the previous `tablecolumns[]`
  2101. * `name`: fieldname sent to server on row select or doubleclick
  2102. * `cell 1`...`cell n`: cell contents given in row-major order
  2103. * `selected idx`: index of row to be selected within table (first row = `1`)
  2104. * See also `minetest.explode_table_event`
  2105. (main menu: `core.explode_table_event`).
  2106. ### `tableoptions[<opt 1>;<opt 2>;...]`
  2107. * Sets options for `table[]`
  2108. * `color=#RRGGBB`
  2109. * default text color (`ColorString`), defaults to `#FFFFFF`
  2110. * `background=#RRGGBB`
  2111. * table background color (`ColorString`), defaults to `#000000`
  2112. * `border=<true/false>`
  2113. * should the table be drawn with a border? (default: `true`)
  2114. * `highlight=#RRGGBB`
  2115. * highlight background color (`ColorString`), defaults to `#466432`
  2116. * `highlight_text=#RRGGBB`
  2117. * highlight text color (`ColorString`), defaults to `#FFFFFF`
  2118. * `opendepth=<value>`
  2119. * all subtrees up to `depth < value` are open (default value = `0`)
  2120. * only useful when there is a column of type "tree"
  2121. ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
  2122. * Sets columns for `table[]`
  2123. * Types: `text`, `image`, `color`, `indent`, `tree`
  2124. * `text`: show cell contents as text
  2125. * `image`: cell contents are an image index, use column options to define
  2126. images.
  2127. * `color`: cell contents are a ColorString and define color of following
  2128. cell.
  2129. * `indent`: cell contents are a number and define indentation of following
  2130. cell.
  2131. * `tree`: same as indent, but user can open and close subtrees
  2132. (treeview-like).
  2133. * Column options:
  2134. * `align=<value>`
  2135. * for `text` and `image`: content alignment within cells.
  2136. Available values: `left` (default), `center`, `right`, `inline`
  2137. * `width=<value>`
  2138. * for `text` and `image`: minimum width in em (default: `0`)
  2139. * for `indent` and `tree`: indent width in em (default: `1.5`)
  2140. * `padding=<value>`: padding left of the column, in em (default `0.5`).
  2141. Exception: defaults to 0 for indent columns
  2142. * `tooltip=<value>`: tooltip text (default: empty)
  2143. * `image` column options:
  2144. * `0=<value>` sets image for image index 0
  2145. * `1=<value>` sets image for image index 1
  2146. * `2=<value>` sets image for image index 2
  2147. * and so on; defined indices need not be contiguous empty or
  2148. non-numeric cells are treated as `0`.
  2149. * `color` column options:
  2150. * `span=<value>`: number of following columns to affect
  2151. (default: infinite).
  2152. ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2153. * Set the style for the element(s) matching `selector` by name.
  2154. * `selector` can be one of:
  2155. * `<name>` - An element name. Includes `*`, which represents every element.
  2156. * `<name>:<state>` - An element name, a colon, and one or more states.
  2157. * `state` is a list of states separated by the `+` character.
  2158. * If a state is provided, the style will only take effect when the element is in that state.
  2159. * All provided states must be active for the style to apply.
  2160. * Note: this **must** be before the element is defined.
  2161. * See [Styling Formspecs].
  2162. ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2163. * Set the style for the element(s) matching `selector` by type.
  2164. * `selector` can be one of:
  2165. * `<type>` - An element type. Includes `*`, which represents every element.
  2166. * `<type>:<state>` - An element type, a colon, and one or more states.
  2167. * `state` is a list of states separated by the `+` character.
  2168. * If a state is provided, the style will only take effect when the element is in that state.
  2169. * All provided states must be active for the style to apply.
  2170. * See [Styling Formspecs].
  2171. ### `set_focus[<name>;<force>]`
  2172. * Sets the focus to the element with the same `name` parameter.
  2173. * **Note**: This element must be placed before the element it focuses.
  2174. * `force` (optional, default `false`): By default, focus is not applied for
  2175. re-sent formspecs with the same name so that player-set focus is kept.
  2176. `true` sets the focus to the specified element for every sent formspec.
  2177. * The following elements have the ability to be focused:
  2178. * checkbox
  2179. * button
  2180. * button_exit
  2181. * image_button
  2182. * image_button_exit
  2183. * item_image_button
  2184. * table
  2185. * textlist
  2186. * dropdown
  2187. * field
  2188. * pwdfield
  2189. * textarea
  2190. * scrollbar
  2191. Migrating to Real Coordinates
  2192. -----------------------------
  2193. In the old system, positions included padding and spacing. Padding is a gap between
  2194. the formspec window edges and content, and spacing is the gaps between items. For
  2195. example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
  2196. and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
  2197. in the new coordinate system from scratch.
  2198. To recreate an old layout with padding, you'll need to pass the positions and sizes
  2199. through the following formula to re-introduce padding:
  2200. ```
  2201. pos = (oldpos + 1)*spacing + padding
  2202. where
  2203. padding = 3/8
  2204. spacing = 5/4
  2205. ```
  2206. You'll need to change the `size[]` tag like this:
  2207. ```
  2208. size = (oldsize-1)*spacing + padding*2 + 1
  2209. ```
  2210. A few elements had random offsets in the old system. Here is a table which shows these
  2211. offsets when migrating:
  2212. | Element | Position | Size | Notes
  2213. |---------|------------|---------|-------
  2214. | box | +0.3, +0.1 | 0, -0.4 |
  2215. | button | | | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
  2216. | list | | | Spacing is now 0.25 for both directions, meaning lists will be taller in height
  2217. | label | 0, +0.3 | | The first line of text is now positioned centered exactly at the position specified
  2218. Styling Formspecs
  2219. -----------------
  2220. Formspec elements can be themed using the style elements:
  2221. style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
  2222. style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
  2223. style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
  2224. style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
  2225. Where a prop is:
  2226. property_name=property_value
  2227. For example:
  2228. style_type[button;bgcolor=#006699]
  2229. style[world_delete;bgcolor=red;textcolor=yellow]
  2230. button[4,3.95;2.6,1;world_delete;Delete]
  2231. A name/type can optionally be a comma separated list of names/types, like so:
  2232. world_delete,world_create,world_configure
  2233. button,image_button
  2234. A `*` type can be used to select every element in the formspec.
  2235. Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
  2236. world_delete:hovered+pressed
  2237. button:pressed
  2238. States allow you to apply styles in response to changes in the element, instead of applying at all times.
  2239. Setting a property to nothing will reset it to the default value. For example:
  2240. style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
  2241. style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
  2242. ### Supported Element Types
  2243. Some types may inherit styles from parent types.
  2244. * animated_image, inherits from image
  2245. * box
  2246. * button
  2247. * button_exit, inherits from button
  2248. * checkbox
  2249. * dropdown
  2250. * field
  2251. * image
  2252. * image_button
  2253. * item_image_button
  2254. * label
  2255. * list
  2256. * model
  2257. * pwdfield, inherits from field
  2258. * scrollbar
  2259. * tabheader
  2260. * table
  2261. * textarea
  2262. * textlist
  2263. * vertlabel, inherits from label
  2264. ### Valid Properties
  2265. * animated_image
  2266. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2267. * box
  2268. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2269. * Defaults to false in formspec_version version 3 or higher
  2270. * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
  2271. * Single value (e.g. `#FF0`): All corners/borders.
  2272. * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
  2273. top and bottom,left and right.
  2274. * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
  2275. * These work similarly to CSS borders.
  2276. * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
  2277. * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
  2278. * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
  2279. negative, the border will extend inside the box, whereas positive extends outside
  2280. the box. A width of zero results in no border; this is default.
  2281. * button, button_exit, image_button, item_image_button
  2282. * alpha - boolean, whether to draw alpha in bgimg. Default true.
  2283. * bgcolor - color, sets button tint.
  2284. * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
  2285. * This is deprecated, use states instead.
  2286. * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
  2287. * This is deprecated, use states instead.
  2288. * bgimg - standard background image. Defaults to none.
  2289. * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
  2290. * This is deprecated, use states instead.
  2291. * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
  2292. See background9[] documentation for more details. This property also pads the
  2293. button's content when set.
  2294. * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
  2295. * This is deprecated, use states instead.
  2296. * font - Sets font type. This is a comma separated list of options. Valid options:
  2297. * Main font type options. These cannot be combined with each other:
  2298. * `normal`: Default font
  2299. * `mono`: Monospaced font
  2300. * Font modification options. If used without a main font type, `normal` is used:
  2301. * `bold`: Makes font bold.
  2302. * `italic`: Makes font italic.
  2303. Default `normal`.
  2304. * font_size - Sets font size. Default is user-set. Can have multiple values:
  2305. * `<number>`: Sets absolute font size to `number`.
  2306. * `+<number>`/`-<number>`: Offsets default font size by `number` points.
  2307. * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
  2308. * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
  2309. * content_offset - 2d vector, shifts the position of the button's content without resizing it.
  2310. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2311. * padding - rect, adds space between the edges of the button and the content. This value is
  2312. relative to bgimg_middle.
  2313. * sound - a sound to be played when triggered.
  2314. * textcolor - color, default white.
  2315. * checkbox
  2316. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2317. * sound - a sound to be played when triggered.
  2318. * dropdown
  2319. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2320. * sound - a sound to be played when the entry is changed.
  2321. * field, pwdfield, textarea
  2322. * border - set to false to hide the textbox background and border. Default true.
  2323. * font - Sets font type. See button `font` property for more information.
  2324. * font_size - Sets font size. See button `font_size` property for more information.
  2325. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2326. * textcolor - color. Default white.
  2327. * model
  2328. * bgcolor - color, sets background color.
  2329. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2330. * Default to false in formspec_version version 3 or higher
  2331. * image
  2332. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2333. * Default to false in formspec_version version 3 or higher
  2334. * item_image
  2335. * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
  2336. * label, vertlabel
  2337. * font - Sets font type. See button `font` property for more information.
  2338. * font_size - Sets font size. See button `font_size` property for more information.
  2339. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2340. * list
  2341. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2342. * size - 2d vector, sets the size of inventory slots in coordinates.
  2343. * spacing - 2d vector, sets the space between inventory slots in coordinates.
  2344. * image_button (additional properties)
  2345. * fgimg - standard image. Defaults to none.
  2346. * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
  2347. * This is deprecated, use states instead.
  2348. * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
  2349. * This is deprecated, use states instead.
  2350. * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
  2351. * sound - a sound to be played when triggered.
  2352. * scrollbar
  2353. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2354. * tabheader
  2355. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2356. * sound - a sound to be played when a different tab is selected.
  2357. * textcolor - color. Default white.
  2358. * table, textlist
  2359. * font - Sets font type. See button `font` property for more information.
  2360. * font_size - Sets font size. See button `font_size` property for more information.
  2361. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2362. ### Valid States
  2363. * *all elements*
  2364. * default - Equivalent to providing no states
  2365. * button, button_exit, image_button, item_image_button
  2366. * hovered - Active when the mouse is hovering over the element
  2367. * pressed - Active when the button is pressed
  2368. Markup Language
  2369. ---------------
  2370. Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
  2371. The markup language is currently unstable and subject to change. Use with caution.
  2372. Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
  2373. Tags can have attributes, in that case, attributes are in the opening tag in
  2374. form of a key/value separated with equal signs. Attribute values should not be quoted.
  2375. If you want to insert a literal greater-than sign or a backslash into the text,
  2376. you must escape it by preceding it with a backslash.
  2377. These are the technically basic tags but see below for usual tags. Base tags are:
  2378. `<style color=... font=... size=...>...</style>`
  2379. Changes the style of the text.
  2380. * `color`: Text color. Given color is a `colorspec`.
  2381. * `size`: Text size.
  2382. * `font`: Text font (`mono` or `normal`).
  2383. `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
  2384. Sets global style.
  2385. Global only styles:
  2386. * `background`: Text background, a `colorspec` or `none`.
  2387. * `margin`: Page margins in pixel.
  2388. * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
  2389. Inheriting styles (affects child elements):
  2390. * `color`: Default text color. Given color is a `colorspec`.
  2391. * `hovercolor`: Color of <action> tags when mouse is over.
  2392. * `size`: Default text size.
  2393. * `font`: Default text font (`mono` or `normal`).
  2394. * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
  2395. This tag needs to be placed only once as it changes the global settings of the
  2396. text. Anyway, if several tags are placed, each changed will be made in the order
  2397. tags appear.
  2398. `<tag name=... color=... hovercolor=... font=... size=...>`
  2399. Defines or redefines tag style. This can be used to define new tags.
  2400. * `name`: Name of the tag to define or change.
  2401. * `color`: Text color. Given color is a `colorspec`.
  2402. * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
  2403. * `size`: Text size.
  2404. * `font`: Text font (`mono` or `normal`).
  2405. Following tags are the usual tags for text layout. They are defined by default.
  2406. Other tags can be added using `<tag ...>` tag.
  2407. `<normal>...</normal>`: Normal size text
  2408. `<big>...</big>`: Big text
  2409. `<bigger>...</bigger>`: Bigger text
  2410. `<center>...</center>`: Centered text
  2411. `<left>...</left>`: Left-aligned text
  2412. `<right>...</right>`: Right-aligned text
  2413. `<justify>...</justify>`: Justified text
  2414. `<mono>...</mono>`: Monospaced font
  2415. `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
  2416. `<action name=...>...</action>`
  2417. Make that text a clickable text triggering an action.
  2418. * `name`: Name of the action (mandatory).
  2419. When clicked, the formspec is send to the server. The value of the text field
  2420. sent to `on_player_receive_fields` will be "action:" concatenated to the action
  2421. name.
  2422. `<img name=... float=... width=... height=...>`
  2423. Draws an image which is present in the client media cache.
  2424. * `name`: Name of the texture (mandatory).
  2425. * `float`: If present, makes the image floating (`left` or `right`).
  2426. * `width`: Force image width instead of taking texture width.
  2427. * `height`: Force image height instead of taking texture height.
  2428. If only width or height given, texture aspect is kept.
  2429. `<item name=... float=... width=... height=... rotate=...>`
  2430. Draws an item image.
  2431. * `name`: Item string of the item to draw (mandatory).
  2432. * `float`: If present, makes the image floating (`left` or `right`).
  2433. * `width`: Item image width.
  2434. * `height`: Item image height.
  2435. * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
  2436. rotation speeds in percent of standard speed (-1000 to 1000). Works only if
  2437. `inventory_items_animations` is set to true.
  2438. * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
  2439. X, Y and Z being angles around each three axes. Works only if
  2440. `inventory_items_animations` is set to true.
  2441. Inventory
  2442. =========
  2443. Inventory locations
  2444. -------------------
  2445. * `"context"`: Selected node metadata (deprecated: `"current_name"`)
  2446. * `"current_player"`: Player to whom the menu is shown
  2447. * `"player:<name>"`: Any player
  2448. * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
  2449. * `"detached:<name>"`: A detached inventory
  2450. Player Inventory lists
  2451. ----------------------
  2452. * `main`: list containing the default inventory
  2453. * `craft`: list containing the craft input
  2454. * `craftpreview`: list containing the craft prediction
  2455. * `craftresult`: list containing the crafted output
  2456. * `hand`: list containing an override for the empty hand
  2457. * Is not created automatically, use `InvRef:set_size`
  2458. * Is only used to enhance the empty hand's tool capabilities
  2459. Colors
  2460. ======
  2461. `ColorString`
  2462. -------------
  2463. `#RGB` defines a color in hexadecimal format.
  2464. `#RGBA` defines a color in hexadecimal format and alpha channel.
  2465. `#RRGGBB` defines a color in hexadecimal format.
  2466. `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
  2467. Named colors are also supported and are equivalent to
  2468. [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
  2469. To specify the value of the alpha channel, append `#A` or `#AA` to the end of
  2470. the color name (e.g. `colorname#08`).
  2471. `ColorSpec`
  2472. -----------
  2473. A ColorSpec specifies a 32-bit color. It can be written in any of the following
  2474. forms:
  2475. * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
  2476. * `colorspec = {a=255, r=0, g=255, b=0}`
  2477. * numerical form: The raw integer value of an ARGB8 quad:
  2478. * `colorspec = 0xFF00FF00`
  2479. * string form: A ColorString (defined above):
  2480. * `colorspec = "green"`
  2481. Escape sequences
  2482. ================
  2483. Most text can contain escape sequences, that can for example color the text.
  2484. There are a few exceptions: tab headers, dropdowns and vertical labels can't.
  2485. The following functions provide escape sequences:
  2486. * `minetest.get_color_escape_sequence(color)`:
  2487. * `color` is a ColorString
  2488. * The escape sequence sets the text color to `color`
  2489. * `minetest.colorize(color, message)`:
  2490. * Equivalent to:
  2491. `minetest.get_color_escape_sequence(color) ..
  2492. message ..
  2493. minetest.get_color_escape_sequence("#ffffff")`
  2494. * `minetest.get_background_escape_sequence(color)`
  2495. * `color` is a ColorString
  2496. * The escape sequence sets the background of the whole text element to
  2497. `color`. Only defined for item descriptions and tooltips.
  2498. * `minetest.strip_foreground_colors(str)`
  2499. * Removes foreground colors added by `get_color_escape_sequence`.
  2500. * `minetest.strip_background_colors(str)`
  2501. * Removes background colors added by `get_background_escape_sequence`.
  2502. * `minetest.strip_colors(str)`
  2503. * Removes all color escape sequences.
  2504. Spatial Vectors
  2505. ===============
  2506. Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
  2507. and has a class to represent them (`vector.*`), which this chapter is about.
  2508. For details on what a spatial vectors is, please refer to Wikipedia:
  2509. https://en.wikipedia.org/wiki/Euclidean_vector.
  2510. Spatial vectors are used for various things, including, but not limited to:
  2511. * any 3D spatial vector (x/y/z-directions)
  2512. * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
  2513. meaning here. Therefore, most vector operations make no sense in this use case.)
  2514. Note that they are *not* used for:
  2515. * n-dimensional vectors where n is not 3 (ie. n=2)
  2516. * arrays of the form `{num, num, num}`
  2517. The API documentation may refer to spatial vectors, as produced by `vector.new`,
  2518. by any of the following notations:
  2519. * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
  2520. * `vector.new(x, y, z)`
  2521. * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
  2522. Compatibility notes
  2523. -------------------
  2524. Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
  2525. Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
  2526. Note: Those old-style vectors can still be found in old mod code. Hence, mod and
  2527. engine APIs still need to be able to cope with them in many places.
  2528. Manually constructed tables are deprecated and highly discouraged. This interface
  2529. should be used to ensure seamless compatibility between mods and the Minetest API.
  2530. This is especially important to callback function parameters and functions overwritten
  2531. by mods.
  2532. Also, though not likely, the internal implementation of a vector might change in
  2533. the future.
  2534. In your own code, or if you define your own API, you can, of course, still use
  2535. other representations of vectors.
  2536. Vectors provided by API functions will provide an instance of this class if not
  2537. stated otherwise. Mods should adapt this for convenience reasons.
  2538. Special properties of the class
  2539. -------------------------------
  2540. Vectors can be indexed with numbers and allow method and operator syntax.
  2541. All these forms of addressing a vector `v` are valid:
  2542. `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
  2543. Note: Prefer letter over number indexing for performance and compatibility reasons.
  2544. Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
  2545. the same as `vector.foo(v, ...)`, apart from deprecated functionality.
  2546. `tostring` is defined for vectors, see `vector.to_string`.
  2547. The metatable that is used for vectors can be accessed via `vector.metatable`.
  2548. Do not modify it!
  2549. All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
  2550. Returned vectors always have a metatable set.
  2551. Common functions and methods
  2552. ----------------------------
  2553. For the following functions (and subchapters),
  2554. `v`, `v1`, `v2` are vectors,
  2555. `p1`, `p2` are position vectors,
  2556. `s` is a scalar (a number),
  2557. vectors are written like this: `(x, y, z)`:
  2558. * `vector.new([a[, b, c]])`:
  2559. * Returns a new vector `(a, b, c)`.
  2560. * Deprecated: `vector.new()` does the same as `vector.zero()` and
  2561. `vector.new(v)` does the same as `vector.copy(v)`
  2562. * `vector.zero()`:
  2563. * Returns a new vector `(0, 0, 0)`.
  2564. * `vector.copy(v)`:
  2565. * Returns a copy of the vector `v`.
  2566. * `vector.from_string(s[, init])`:
  2567. * Returns `v, np`, where `v` is a vector read from the given string `s` and
  2568. `np` is the next position in the string after the vector.
  2569. * Returns `nil` on failure.
  2570. * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
  2571. spaces, leaving away commas and adding an additional comma to the end
  2572. is allowed.
  2573. * `init`: If given starts looking for the vector at this string index.
  2574. * `vector.to_string(v)`:
  2575. * Returns a string of the form `"(x, y, z)"`.
  2576. * `tostring(v)` does the same.
  2577. * `vector.direction(p1, p2)`:
  2578. * Returns a vector of length 1 with direction `p1` to `p2`.
  2579. * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
  2580. * `vector.distance(p1, p2)`:
  2581. * Returns zero or a positive number, the distance between `p1` and `p2`.
  2582. * `vector.length(v)`:
  2583. * Returns zero or a positive number, the length of vector `v`.
  2584. * `vector.normalize(v)`:
  2585. * Returns a vector of length 1 with direction of vector `v`.
  2586. * If `v` has zero length, returns `(0, 0, 0)`.
  2587. * `vector.floor(v)`:
  2588. * Returns a vector, each dimension rounded down.
  2589. * `vector.round(v)`:
  2590. * Returns a vector, each dimension rounded to nearest integer.
  2591. * At a multiple of 0.5, rounds away from zero.
  2592. * `vector.apply(v, func)`:
  2593. * Returns a vector where the function `func` has been applied to each
  2594. component.
  2595. * `vector.combine(v, w, func)`:
  2596. * Returns a vector where the function `func` has combined both components of `v` and `w`
  2597. for each component
  2598. * `vector.equals(v1, v2)`:
  2599. * Returns a boolean, `true` if the vectors are identical.
  2600. * `vector.sort(v1, v2)`:
  2601. * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
  2602. * `vector.angle(v1, v2)`:
  2603. * Returns the angle between `v1` and `v2` in radians.
  2604. * `vector.dot(v1, v2)`:
  2605. * Returns the dot product of `v1` and `v2`.
  2606. * `vector.cross(v1, v2)`:
  2607. * Returns the cross product of `v1` and `v2`.
  2608. * `vector.offset(v, x, y, z)`:
  2609. * Returns the sum of the vectors `v` and `(x, y, z)`.
  2610. * `vector.check(v)`:
  2611. * Returns a boolean value indicating whether `v` is a real vector, eg. created
  2612. by a `vector.*` function.
  2613. * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
  2614. For the following functions `x` can be either a vector or a number:
  2615. * `vector.add(v, x)`:
  2616. * Returns a vector.
  2617. * If `x` is a vector: Returns the sum of `v` and `x`.
  2618. * If `x` is a number: Adds `x` to each component of `v`.
  2619. * `vector.subtract(v, x)`:
  2620. * Returns a vector.
  2621. * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
  2622. * If `x` is a number: Subtracts `x` from each component of `v`.
  2623. * `vector.multiply(v, s)`:
  2624. * Returns a scaled vector.
  2625. * Deprecated: If `s` is a vector: Returns the Schur product.
  2626. * `vector.divide(v, s)`:
  2627. * Returns a scaled vector.
  2628. * Deprecated: If `s` is a vector: Returns the Schur quotient.
  2629. Operators
  2630. ---------
  2631. Operators can be used if all of the involved vectors have metatables:
  2632. * `v1 == v2`:
  2633. * Returns whether `v1` and `v2` are identical.
  2634. * `-v`:
  2635. * Returns the additive inverse of v.
  2636. * `v1 + v2`:
  2637. * Returns the sum of both vectors.
  2638. * Note: `+` can not be used together with scalars.
  2639. * `v1 - v2`:
  2640. * Returns the difference of `v1` subtracted by `v2`.
  2641. * Note: `-` can not be used together with scalars.
  2642. * `v * s` or `s * v`:
  2643. * Returns `v` scaled by `s`.
  2644. * `v / s`:
  2645. * Returns `v` scaled by `1 / s`.
  2646. Rotation-related functions
  2647. --------------------------
  2648. For the following functions `a` is an angle in radians and `r` is a rotation
  2649. vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
  2650. angles in radians.
  2651. * `vector.rotate(v, r)`:
  2652. * Applies the rotation `r` to `v` and returns the result.
  2653. * `vector.rotate(vector.new(0, 0, 1), r)` and
  2654. `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
  2655. forward and up relative to an entity's rotation `r`.
  2656. * `vector.rotate_around_axis(v1, v2, a)`:
  2657. * Returns `v1` rotated around axis `v2` by `a` radians according to
  2658. the right hand rule.
  2659. * `vector.dir_to_rotation(direction[, up])`:
  2660. * Returns a rotation vector for `direction` pointing forward using `up`
  2661. as the up vector.
  2662. * If `up` is omitted, the roll of the returned vector defaults to zero.
  2663. * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
  2664. Further helpers
  2665. ---------------
  2666. There are more helper functions involving vectors, but they are listed elsewhere
  2667. because they only work on specific sorts of vectors or involve things that are not
  2668. vectors.
  2669. For example:
  2670. * `minetest.hash_node_position` (Only works on node positions.)
  2671. * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
  2672. Helper functions
  2673. ================
  2674. * `dump2(obj, name, dumped)`: returns a string which makes `obj`
  2675. human-readable, handles reference loops.
  2676. * `obj`: arbitrary variable
  2677. * `name`: string, default: `"_"`
  2678. * `dumped`: table, default: `{}`
  2679. * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
  2680. * `obj`: arbitrary variable
  2681. * `dumped`: table, default: `{}`
  2682. * `math.hypot(x, y)`
  2683. * Get the hypotenuse of a triangle with legs x and y.
  2684. Useful for distance calculation.
  2685. * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
  2686. * Get the sign of a number.
  2687. * tolerance: number, default: `0.0`
  2688. * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
  2689. `0` is returned.
  2690. * `math.factorial(x)`: returns the factorial of `x`
  2691. * `math.round(x)`: Returns `x` rounded to the nearest integer.
  2692. * At a multiple of 0.5, rounds away from zero.
  2693. * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
  2694. * `separator`: string, default: `","`
  2695. * `include_empty`: boolean, default: `false`
  2696. * `max_splits`: number, if it's negative, splits aren't limited,
  2697. default: `-1`
  2698. * `sep_is_pattern`: boolean, it specifies whether separator is a plain
  2699. string or a pattern (regex), default: `false`
  2700. * e.g. `"a,b":split","` returns `{"a","b"}`
  2701. * `string:trim()`: returns the string without whitespace pre- and suffixes
  2702. * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
  2703. * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
  2704. * Adds newlines to the string to keep it within the specified character
  2705. limit
  2706. * Note that the returned lines may be longer than the limit since it only
  2707. splits at word borders.
  2708. * `limit`: number, maximal amount of characters in one line
  2709. * `as_table`: boolean, if set to true, a table of lines instead of a string
  2710. is returned, default: `false`
  2711. * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
  2712. * `pos`: table {x=X, y=Y, z=Z}
  2713. * Converts the position `pos` to a human-readable, printable string
  2714. * `decimal_places`: number, if specified, the x, y and z values of
  2715. the position are rounded to the given decimal place.
  2716. * `minetest.string_to_pos(string)`: returns a position or `nil`
  2717. * Same but in reverse.
  2718. * If the string can't be parsed to a position, nothing is returned.
  2719. * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions
  2720. * Converts a string representing an area box into two positions
  2721. * `minetest.formspec_escape(string)`: returns a string
  2722. * escapes the characters "[", "]", "\", "," and ";", which can not be used
  2723. in formspecs.
  2724. * `minetest.is_yes(arg)`
  2725. * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
  2726. * `minetest.is_nan(arg)`
  2727. * returns true when the passed number represents NaN.
  2728. * `minetest.get_us_time()`
  2729. * returns time with microsecond precision. May not return wall time.
  2730. * `table.copy(table)`: returns a table
  2731. * returns a deep copy of `table`
  2732. * `table.indexof(list, val)`: returns the smallest numerical index containing
  2733. the value `val` in the table `list`. Non-numerical indices are ignored.
  2734. If `val` could not be found, `-1` is returned. `list` must not have
  2735. negative indices.
  2736. * `table.insert_all(table, other_table)`:
  2737. * Appends all values in `other_table` to `table` - uses `#table + 1` to
  2738. find new indices.
  2739. * `table.key_value_swap(t)`: returns a table with keys and values swapped
  2740. * If multiple keys in `t` map to the same value, it is unspecified which
  2741. value maps to that key.
  2742. * `table.shuffle(table, [from], [to], [random_func])`:
  2743. * Shuffles elements `from` to `to` in `table` in place
  2744. * `from` defaults to `1`
  2745. * `to` defaults to `#table`
  2746. * `random_func` defaults to `math.random`. This function receives two
  2747. integers as arguments and should return a random integer inclusively
  2748. between them.
  2749. * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
  2750. position.
  2751. * returns the exact position on the surface of a pointed node
  2752. * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
  2753. Simulates an item that digs a node.
  2754. Returns a table with the following fields:
  2755. * `diggable`: `true` if node can be dug, `false` otherwise.
  2756. * `time`: Time it would take to dig the node.
  2757. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2758. `time` and `wear` are meaningless if node's not diggable
  2759. Parameters:
  2760. * `groups`: Table of the node groups of the node that would be dug
  2761. * `tool_capabilities`: Tool capabilities table of the item
  2762. * `wear`: Amount of wear the tool starts with (default: 0)
  2763. * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
  2764. Simulates an item that punches an object.
  2765. Returns a table with the following fields:
  2766. * `hp`: How much damage the punch would cause (between -65535 and 65535).
  2767. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2768. Parameters:
  2769. * `groups`: Damage groups of the object
  2770. * `tool_capabilities`: Tool capabilities table of the item
  2771. * `time_from_last_punch`: time in seconds since last punch action
  2772. * `wear`: Amount of wear the item starts with (default: 0)
  2773. Translations
  2774. ============
  2775. Texts can be translated client-side with the help of `minetest.translate` and
  2776. translation files.
  2777. Translating a string
  2778. --------------------
  2779. Two functions are provided to translate strings: `minetest.translate` and
  2780. `minetest.get_translator`.
  2781. * `minetest.get_translator(textdomain)` is a simple wrapper around
  2782. `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
  2783. equivalent to `minetest.translate(textdomain, str, ...)`.
  2784. It is intended to be used in the following way, so that it avoids verbose
  2785. repetitions of `minetest.translate`:
  2786. local S = minetest.get_translator(textdomain)
  2787. S(str, ...)
  2788. As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
  2789. * `minetest.translate(textdomain, str, ...)` translates the string `str` with
  2790. the given `textdomain` for disambiguation. The textdomain must match the
  2791. textdomain specified in the translation file in order to get the string
  2792. translated. This can be used so that a string is translated differently in
  2793. different contexts.
  2794. It is advised to use the name of the mod as textdomain whenever possible, to
  2795. avoid clashes with other mods.
  2796. This function must be given a number of arguments equal to the number of
  2797. arguments the translated string expects.
  2798. Arguments are literal strings -- they will not be translated, so if you want
  2799. them to be, they need to come as outputs of `minetest.translate` as well.
  2800. For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
  2801. by the translation of "Red". We can do the following:
  2802. local S = minetest.get_translator()
  2803. S("@1 Wool", S("Red"))
  2804. This will be displayed as "Red Wool" on old clients and on clients that do
  2805. not have localization enabled. However, if we have for instance a translation
  2806. file named `wool.fr.tr` containing the following:
  2807. @1 Wool=Laine @1
  2808. Red=Rouge
  2809. this will be displayed as "Laine Rouge" on clients with a French locale.
  2810. Operations on translated strings
  2811. --------------------------------
  2812. The output of `minetest.translate` is a string, with escape sequences adding
  2813. additional information to that string so that it can be translated on the
  2814. different clients. In particular, you can't expect operations like string.length
  2815. to work on them like you would expect them to, or string.gsub to work in the
  2816. expected manner. However, string concatenation will still work as expected
  2817. (note that you should only use this for things like formspecs; do not translate
  2818. sentences by breaking them into parts; arguments should be used instead), and
  2819. operations such as `minetest.colorize` which are also concatenation.
  2820. Translation file format
  2821. -----------------------
  2822. A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
  2823. it corresponds to. It must be put into the `locale` subdirectory of the mod.
  2824. The file should be a text file, with the following format:
  2825. * Lines beginning with `# textdomain:` (the space is significant) can be used
  2826. to specify the text domain of all following translations in the file.
  2827. * All other empty lines or lines beginning with `#` are ignored.
  2828. * Other lines should be in the format `original=translated`. Both `original`
  2829. and `translated` can contain escape sequences beginning with `@` to insert
  2830. arguments, literal `@`, `=` or newline (See [Escapes] below).
  2831. There must be no extraneous whitespace around the `=` or at the beginning or
  2832. the end of the line.
  2833. Escapes
  2834. -------
  2835. Strings that need to be translated can contain several escapes, preceded by `@`.
  2836. * `@@` acts as a literal `@`.
  2837. * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
  2838. string that will be inlined when translated. Due to how translations are
  2839. implemented, the original translation string **must** have its arguments in
  2840. increasing order, without gaps or repetitions, starting from 1.
  2841. * `@=` acts as a literal `=`. It is not required in strings given to
  2842. `minetest.translate`, but is in translation files to avoid being confused
  2843. with the `=` separating the original from the translation.
  2844. * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
  2845. As with `@=`, this escape is not required in strings given to
  2846. `minetest.translate`, but is in translation files.
  2847. * `@n` acts as a literal newline as well.
  2848. Server side translations
  2849. ------------------------
  2850. On some specific cases, server translation could be useful. For example, filter
  2851. a list on labels and send results to client. A method is supplied to achieve
  2852. that:
  2853. `minetest.get_translated_string(lang_code, string)`: Translates `string` using
  2854. translations for `lang_code` language. It gives the same result as if the string
  2855. was translated by the client.
  2856. The `lang_code` to use for a given player can be retrieved from
  2857. the table returned by `minetest.get_player_information(name)`.
  2858. IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
  2859. You do not need to use this to get translated strings to show up on the client.
  2860. Perlin noise
  2861. ============
  2862. Perlin noise creates a continuously-varying value depending on the input values.
  2863. Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
  2864. The result is used during map generation to create the terrain shape, vary heat
  2865. and humidity to distribute biomes, vary the density of decorations or vary the
  2866. structure of ores.
  2867. Structure of perlin noise
  2868. -------------------------
  2869. An 'octave' is a simple noise generator that outputs a value between -1 and 1.
  2870. The smooth wavy noise it generates has a single characteristic scale, almost
  2871. like a 'wavelength', so on its own does not create fine detail.
  2872. Due to this perlin noise combines several octaves to create variation on
  2873. multiple scales. Each additional octave has a smaller 'wavelength' than the
  2874. previous.
  2875. This combination results in noise varying very roughly between -2.0 and 2.0 and
  2876. with an average value of 0.0, so `scale` and `offset` are then used to multiply
  2877. and offset the noise variation.
  2878. The final perlin noise variation is created as follows:
  2879. noise = offset + scale * (octave1 +
  2880. octave2 * persistence +
  2881. octave3 * persistence ^ 2 +
  2882. octave4 * persistence ^ 3 +
  2883. ...)
  2884. Noise Parameters
  2885. ----------------
  2886. Noise Parameters are commonly called `NoiseParams`.
  2887. ### `offset`
  2888. After the multiplication by `scale` this is added to the result and is the final
  2889. step in creating the noise value.
  2890. Can be positive or negative.
  2891. ### `scale`
  2892. Once all octaves have been combined, the result is multiplied by this.
  2893. Can be positive or negative.
  2894. ### `spread`
  2895. For octave1, this is roughly the change of input value needed for a very large
  2896. variation in the noise value generated by octave1. It is almost like a
  2897. 'wavelength' for the wavy noise variation.
  2898. Each additional octave has a 'wavelength' that is smaller than the previous
  2899. octave, to create finer detail. `spread` will therefore roughly be the typical
  2900. size of the largest structures in the final noise variation.
  2901. `spread` is a vector with values for x, y, z to allow the noise variation to be
  2902. stretched or compressed in the desired axes.
  2903. Values are positive numbers.
  2904. ### `seed`
  2905. This is a whole number that determines the entire pattern of the noise
  2906. variation. Altering it enables different noise patterns to be created.
  2907. With other parameters equal, different seeds produce different noise patterns
  2908. and identical seeds produce identical noise patterns.
  2909. For this parameter you can randomly choose any whole number. Usually it is
  2910. preferable for this to be different from other seeds, but sometimes it is useful
  2911. to be able to create identical noise patterns.
  2912. In some noise APIs the world seed is added to the seed specified in noise
  2913. parameters. This is done to make the resulting noise pattern vary in different
  2914. worlds, and be 'world-specific'.
  2915. ### `octaves`
  2916. The number of simple noise generators that are combined.
  2917. A whole number, 1 or more.
  2918. Each additional octave adds finer detail to the noise but also increases the
  2919. noise calculation load.
  2920. 3 is a typical minimum for a high quality, complex and natural-looking noise
  2921. variation. 1 octave has a slight 'gridlike' appearance.
  2922. Choose the number of octaves according to the `spread` and `lacunarity`, and the
  2923. size of the finest detail you require. For example:
  2924. if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
  2925. nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
  2926. 512, 256, 128, 64, 32, 16 nodes.
  2927. Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
  2928. ### `persistence`
  2929. Each additional octave has an amplitude that is the amplitude of the previous
  2930. octave multiplied by `persistence`, to reduce the amplitude of finer details,
  2931. as is often helpful and natural to do so.
  2932. Since this controls the balance of fine detail to large-scale detail
  2933. `persistence` can be thought of as the 'roughness' of the noise.
  2934. A positive or negative non-zero number, often between 0.3 and 1.0.
  2935. A common medium value is 0.5, such that each octave has half the amplitude of
  2936. the previous octave.
  2937. This may need to be tuned when altering `lacunarity`; when doing so consider
  2938. that a common medium value is 1 / lacunarity.
  2939. ### `lacunarity`
  2940. Each additional octave has a 'wavelength' that is the 'wavelength' of the
  2941. previous octave multiplied by 1 / lacunarity, to create finer detail.
  2942. 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
  2943. A positive number no smaller than 1.0.
  2944. Values below 2.0 create higher quality noise at the expense of requiring more
  2945. octaves to cover a paticular range of 'wavelengths'.
  2946. ### `flags`
  2947. Leave this field unset for no special handling.
  2948. Currently supported are `defaults`, `eased` and `absvalue`:
  2949. #### `defaults`
  2950. Specify this if you would like to keep auto-selection of eased/not-eased while
  2951. specifying some other flags.
  2952. #### `eased`
  2953. Maps noise gradient values onto a quintic S-curve before performing
  2954. interpolation. This results in smooth, rolling noise.
  2955. Disable this (`noeased`) for sharp-looking noise with a slightly gridded
  2956. appearence.
  2957. If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
  2958. not eased.
  2959. Easing a 3D noise significantly increases the noise calculation load, so use
  2960. with restraint.
  2961. #### `absvalue`
  2962. The absolute value of each octave's noise variation is used when combining the
  2963. octaves. The final perlin noise variation is created as follows:
  2964. noise = offset + scale * (abs(octave1) +
  2965. abs(octave2) * persistence +
  2966. abs(octave3) * persistence ^ 2 +
  2967. abs(octave4) * persistence ^ 3 +
  2968. ...)
  2969. ### Format example
  2970. For 2D or 3D perlin noise or perlin noise maps:
  2971. np_terrain = {
  2972. offset = 0,
  2973. scale = 1,
  2974. spread = {x = 500, y = 500, z = 500},
  2975. seed = 571347,
  2976. octaves = 5,
  2977. persistence = 0.63,
  2978. lacunarity = 2.0,
  2979. flags = "defaults, absvalue",
  2980. }
  2981. For 2D noise the Z component of `spread` is still defined but is ignored.
  2982. A single noise parameter table can be used for 2D or 3D noise.
  2983. Ores
  2984. ====
  2985. Ore types
  2986. ---------
  2987. These tell in what manner the ore is generated.
  2988. All default ores are of the uniformly-distributed scatter type.
  2989. ### `scatter`
  2990. Randomly chooses a location and generates a cluster of ore.
  2991. If `noise_params` is specified, the ore will be placed if the 3D perlin noise
  2992. at that point is greater than the `noise_threshold`, giving the ability to
  2993. create a non-equal distribution of ore.
  2994. ### `sheet`
  2995. Creates a sheet of ore in a blob shape according to the 2D perlin noise
  2996. described by `noise_params` and `noise_threshold`. This is essentially an
  2997. improved version of the so-called "stratus" ore seen in some unofficial mods.
  2998. This sheet consists of vertical columns of uniform randomly distributed height,
  2999. varying between the inclusive range `column_height_min` and `column_height_max`.
  3000. If `column_height_min` is not specified, this parameter defaults to 1.
  3001. If `column_height_max` is not specified, this parameter defaults to `clust_size`
  3002. for reverse compatibility. New code should prefer `column_height_max`.
  3003. The `column_midpoint_factor` parameter controls the position of the column at
  3004. which ore emanates from.
  3005. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
  3006. equally starting from each direction.
  3007. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
  3008. this parameter is not specified, the default is 0.5.
  3009. The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
  3010. ore type.
  3011. ### `puff`
  3012. Creates a sheet of ore in a cloud-like puff shape.
  3013. As with the `sheet` ore type, the size and shape of puffs are described by
  3014. `noise_params` and `noise_threshold` and are placed at random vertical
  3015. positions within the currently generated chunk.
  3016. The vertical top and bottom displacement of each puff are determined by the
  3017. noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
  3018. ### `blob`
  3019. Creates a deformed sphere of ore according to 3d perlin noise described by
  3020. `noise_params`. The maximum size of the blob is `clust_size`, and
  3021. `clust_scarcity` has the same meaning as with the `scatter` type.
  3022. ### `vein`
  3023. Creates veins of ore varying in density by according to the intersection of two
  3024. instances of 3d perlin noise with different seeds, both described by
  3025. `noise_params`.
  3026. `random_factor` varies the influence random chance has on placement of an ore
  3027. inside the vein, which is `1` by default. Note that modifying this parameter
  3028. may require adjusting `noise_threshold`.
  3029. The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
  3030. by this ore type.
  3031. This ore type is difficult to control since it is sensitive to small changes.
  3032. The following is a decent set of parameters to work from:
  3033. noise_params = {
  3034. offset = 0,
  3035. scale = 3,
  3036. spread = {x=200, y=200, z=200},
  3037. seed = 5390,
  3038. octaves = 4,
  3039. persistence = 0.5,
  3040. lacunarity = 2.0,
  3041. flags = "eased",
  3042. },
  3043. noise_threshold = 1.6
  3044. **WARNING**: Use this ore type *very* sparingly since it is ~200x more
  3045. computationally expensive than any other ore.
  3046. ### `stratum`
  3047. Creates a single undulating ore stratum that is continuous across mapchunk
  3048. borders and horizontally spans the world.
  3049. The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
  3050. the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
  3051. defines the stratum's vertical thickness (in units of nodes). Due to being
  3052. continuous across mapchunk borders the stratum's vertical thickness is
  3053. unlimited.
  3054. If the noise parameter `noise_params` is omitted the ore will occur from y_min
  3055. to y_max in a simple horizontal stratum.
  3056. A parameter `stratum_thickness` can be provided instead of the noise parameter
  3057. `np_stratum_thickness`, to create a constant thickness.
  3058. Leaving out one or both noise parameters makes the ore generation less
  3059. intensive, useful when adding multiple strata.
  3060. `y_min` and `y_max` define the limits of the ore generation and for performance
  3061. reasons should be set as close together as possible but without clipping the
  3062. stratum's Y variation.
  3063. Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
  3064. solid-ore stratum would require a `clust_scarcity` of 1.
  3065. The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
  3066. `random_factor` are ignored by this ore type.
  3067. Ore attributes
  3068. --------------
  3069. See section [Flag Specifier Format].
  3070. Currently supported flags:
  3071. `puff_cliffs`, `puff_additive_composition`.
  3072. ### `puff_cliffs`
  3073. If set, puff ore generation will not taper down large differences in
  3074. displacement when approaching the edge of a puff. This flag has no effect for
  3075. ore types other than `puff`.
  3076. ### `puff_additive_composition`
  3077. By default, when noise described by `np_puff_top` or `np_puff_bottom` results
  3078. in a negative displacement, the sub-column at that point is not generated. With
  3079. this attribute set, puff ore generation will instead generate the absolute
  3080. difference in noise displacement values. This flag has no effect for ore types
  3081. other than `puff`.
  3082. Decoration types
  3083. ================
  3084. The varying types of decorations that can be placed.
  3085. `simple`
  3086. --------
  3087. Creates a 1 times `H` times 1 column of a specified node (or a random node from
  3088. a list, if a decoration list is specified). Can specify a certain node it must
  3089. spawn next to, such as water or lava, for example. Can also generate a
  3090. decoration of random height between a specified lower and upper bound.
  3091. This type of decoration is intended for placement of grass, flowers, cacti,
  3092. papyri, waterlilies and so on.
  3093. `schematic`
  3094. -----------
  3095. Copies a box of `MapNodes` from a specified schematic file (or raw description).
  3096. Can specify a probability of a node randomly appearing when placed.
  3097. This decoration type is intended to be used for multi-node sized discrete
  3098. structures, such as trees, cave spikes, rocks, and so on.
  3099. Schematics
  3100. ==========
  3101. Schematic specifier
  3102. --------------------
  3103. A schematic specifier identifies a schematic by either a filename to a
  3104. Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  3105. in the form of a table. This table specifies the following fields:
  3106. * The `size` field is a 3D vector containing the dimensions of the provided
  3107. schematic. (required field)
  3108. * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
  3109. sets the probability of a particular horizontal slice of the schematic being
  3110. placed. (optional field)
  3111. `ypos` = 0 for the lowest horizontal slice of a schematic.
  3112. The default of `prob` is 255.
  3113. * The `data` field is a flat table of MapNode tables making up the schematic,
  3114. in the order of `[z [y [x]]]`. (required field)
  3115. Each MapNode table contains:
  3116. * `name`: the name of the map node to place (required)
  3117. * `prob` (alias `param1`): the probability of this node being placed
  3118. (default: 255)
  3119. * `param2`: the raw param2 value of the node being placed onto the map
  3120. (default: 0)
  3121. * `force_place`: boolean representing if the node should forcibly overwrite
  3122. any previous contents (default: false)
  3123. About probability values:
  3124. * A probability value of `0` or `1` means that node will never appear
  3125. (0% chance).
  3126. * A probability value of `254` or `255` means the node will always appear
  3127. (100% chance).
  3128. * If the probability value `p` is greater than `1`, then there is a
  3129. `(p / 256 * 100)` percent chance that node will appear when the schematic is
  3130. placed on the map.
  3131. Schematic attributes
  3132. --------------------
  3133. See section [Flag Specifier Format].
  3134. Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
  3135. `force_placement`.
  3136. * `place_center_x`: Placement of this decoration is centered along the X axis.
  3137. * `place_center_y`: Placement of this decoration is centered along the Y axis.
  3138. * `place_center_z`: Placement of this decoration is centered along the Z axis.
  3139. * `force_placement`: Schematic nodes other than "ignore" will replace existing
  3140. nodes.
  3141. Lua Voxel Manipulator
  3142. =====================
  3143. About VoxelManip
  3144. ----------------
  3145. VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
  3146. facility. The purpose of this object is for fast, low-level, bulk access to
  3147. reading and writing Map content. As such, setting map nodes through VoxelManip
  3148. will lack many of the higher level features and concepts you may be used to
  3149. with other methods of setting nodes. For example, nodes will not have their
  3150. construction and destruction callbacks run, and no rollback information is
  3151. logged.
  3152. It is important to note that VoxelManip is designed for speed, and *not* ease
  3153. of use or flexibility. If your mod requires a map manipulation facility that
  3154. will handle 100% of all edge cases, or the use of high level node placement
  3155. features, perhaps `minetest.set_node()` is better suited for the job.
  3156. In addition, VoxelManip might not be faster, or could even be slower, for your
  3157. specific use case. VoxelManip is most effective when setting large areas of map
  3158. at once - for example, if only setting a 3x3x3 node area, a
  3159. `minetest.set_node()` loop may be more optimal. Always profile code using both
  3160. methods of map manipulation to determine which is most appropriate for your
  3161. usage.
  3162. A recent simple test of setting cubic areas showed that `minetest.set_node()`
  3163. is faster than a VoxelManip for a 3x3x3 node cube or smaller.
  3164. Using VoxelManip
  3165. ----------------
  3166. A VoxelManip object can be created any time using either:
  3167. `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
  3168. If the optional position parameters are present for either of these routines,
  3169. the specified region will be pre-loaded into the VoxelManip object on creation.
  3170. Otherwise, the area of map you wish to manipulate must first be loaded into the
  3171. VoxelManip object using `VoxelManip:read_from_map()`.
  3172. Note that `VoxelManip:read_from_map()` returns two position vectors. The region
  3173. formed by these positions indicate the minimum and maximum (respectively)
  3174. positions of the area actually loaded in the VoxelManip, which may be larger
  3175. than the area requested. For convenience, the loaded area coordinates can also
  3176. be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
  3177. Now that the VoxelManip object is populated with map data, your mod can fetch a
  3178. copy of this data using either of two methods. `VoxelManip:get_node_at()`,
  3179. which retrieves an individual node in a MapNode formatted table at the position
  3180. requested is the simplest method to use, but also the slowest.
  3181. Nodes in a VoxelManip object may also be read in bulk to a flat array table
  3182. using:
  3183. * `VoxelManip:get_data()` for node content (in Content ID form, see section
  3184. [Content IDs]),
  3185. * `VoxelManip:get_light_data()` for node light levels, and
  3186. * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
  3187. See section [Flat array format] for more details.
  3188. It is very important to understand that the tables returned by any of the above
  3189. three functions represent a snapshot of the VoxelManip's internal state at the
  3190. time of the call. This copy of the data will not magically update itself if
  3191. another function modifies the internal VoxelManip state.
  3192. Any functions that modify a VoxelManip's contents work on the VoxelManip's
  3193. internal state unless otherwise explicitly stated.
  3194. Once the bulk data has been edited to your liking, the internal VoxelManip
  3195. state can be set using:
  3196. * `VoxelManip:set_data()` for node content (in Content ID form, see section
  3197. [Content IDs]),
  3198. * `VoxelManip:set_light_data()` for node light levels, and
  3199. * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
  3200. The parameter to each of the above three functions can use any table at all in
  3201. the same flat array format as produced by `get_data()` etc. and is not required
  3202. to be a table retrieved from `get_data()`.
  3203. Once the internal VoxelManip state has been modified to your liking, the
  3204. changes can be committed back to the map by calling `VoxelManip:write_to_map()`
  3205. ### Flat array format
  3206. Let
  3207. `Nx = p2.X - p1.X + 1`,
  3208. `Ny = p2.Y - p1.Y + 1`, and
  3209. `Nz = p2.Z - p1.Z + 1`.
  3210. Then, for a loaded region of p1..p2, this array ranges from `1` up to and
  3211. including the value of the expression `Nx * Ny * Nz`.
  3212. Positions offset from p1 are present in the array with the format of:
  3213. [
  3214. (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
  3215. (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
  3216. ...
  3217. (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
  3218. (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
  3219. ...
  3220. (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
  3221. ...
  3222. (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
  3223. ]
  3224. and the array index for a position p contained completely in p1..p2 is:
  3225. `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
  3226. Note that this is the same "flat 3D array" format as
  3227. `PerlinNoiseMap:get3dMap_flat()`.
  3228. VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
  3229. of the index for a single point in a flat VoxelManip array.
  3230. ### Content IDs
  3231. A Content ID is a unique integer identifier for a specific node type.
  3232. These IDs are used by VoxelManip in place of the node name string for
  3233. `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
  3234. `minetest.get_content_id()` to look up the Content ID for the specified node
  3235. name, and `minetest.get_name_from_content_id()` to look up the node name string
  3236. for a given Content ID.
  3237. After registration of a node, its Content ID will remain the same throughout
  3238. execution of the mod.
  3239. Note that the node being queried needs to have already been been registered.
  3240. The following builtin node types have their Content IDs defined as constants:
  3241. * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
  3242. * `minetest.CONTENT_AIR`: ID for "air" nodes
  3243. * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
  3244. ### Mapgen VoxelManip objects
  3245. Inside of `on_generated()` callbacks, it is possible to retrieve the same
  3246. VoxelManip object used by the core's Map Generator (commonly abbreviated
  3247. Mapgen). Most of the rules previously described still apply but with a few
  3248. differences:
  3249. * The Mapgen VoxelManip object is retrieved using:
  3250. `minetest.get_mapgen_object("voxelmanip")`
  3251. * This VoxelManip object already has the region of map just generated loaded
  3252. into it; it's not necessary to call `VoxelManip:read_from_map()` before using
  3253. a Mapgen VoxelManip.
  3254. * The `on_generated()` callbacks of some mods may place individual nodes in the
  3255. generated area using non-VoxelManip map modification methods. Because the
  3256. same Mapgen VoxelManip object is passed through each `on_generated()`
  3257. callback, it becomes necessary for the Mapgen VoxelManip object to maintain
  3258. consistency with the current map state. For this reason, calling any of the
  3259. following functions:
  3260. `minetest.add_node()`, `minetest.set_node()`, or `minetest.swap_node()`
  3261. will also update the Mapgen VoxelManip object's internal state active on the
  3262. current thread.
  3263. * After modifying the Mapgen VoxelManip object's internal buffer, it may be
  3264. necessary to update lighting information using either:
  3265. `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
  3266. ### Other API functions operating on a VoxelManip
  3267. If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
  3268. `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
  3269. flowing. It is recommended to call this function only after having written all
  3270. buffered data back to the VoxelManip object, save for special situations where
  3271. the modder desires to only have certain liquid nodes begin flowing.
  3272. The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
  3273. will generate all registered decorations and ores throughout the full area
  3274. inside of the specified VoxelManip object.
  3275. `minetest.place_schematic_on_vmanip()` is otherwise identical to
  3276. `minetest.place_schematic()`, except instead of placing the specified schematic
  3277. directly on the map at the specified position, it will place the schematic
  3278. inside the VoxelManip.
  3279. ### Notes
  3280. * Attempting to read data from a VoxelManip object before map is read will
  3281. result in a zero-length array table for `VoxelManip:get_data()`, and an
  3282. "ignore" node at any position for `VoxelManip:get_node_at()`.
  3283. * If either a region of map has not yet been generated or is out-of-bounds of
  3284. the map, that region is filled with "ignore" nodes.
  3285. * Other mods, or the core itself, could possibly modify the area of map
  3286. currently loaded into a VoxelManip object. With the exception of Mapgen
  3287. VoxelManips (see above section), the internal buffers are not updated. For
  3288. this reason, it is strongly encouraged to complete the usage of a particular
  3289. VoxelManip object in the same callback it had been created.
  3290. * If a VoxelManip object will be used often, such as in an `on_generated()`
  3291. callback, consider passing a file-scoped table as the optional parameter to
  3292. `VoxelManip:get_data()`, which serves as a static buffer the function can use
  3293. to write map data to instead of returning a new table each call. This greatly
  3294. enhances performance by avoiding unnecessary memory allocations.
  3295. Methods
  3296. -------
  3297. * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
  3298. containing the region formed by `p1` and `p2`.
  3299. * returns actual emerged `pmin`, actual emerged `pmax`
  3300. * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
  3301. the map.
  3302. * **important**: data must be set using `VoxelManip:set_data()` before
  3303. calling this.
  3304. * if `light` is true, then lighting is automatically recalculated.
  3305. The default value is true.
  3306. If `light` is false, no light calculations happen, and you should correct
  3307. all modified blocks with `minetest.fix_light()` as soon as possible.
  3308. Keep in mind that modifying the map where light is incorrect can cause
  3309. more lighting bugs.
  3310. * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
  3311. the `VoxelManip` at that position
  3312. * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
  3313. that position.
  3314. * `get_data([buffer])`: Retrieves the node content data loaded into the
  3315. `VoxelManip` object.
  3316. * returns raw node data in the form of an array of node content IDs
  3317. * if the param `buffer` is present, this table will be used to store the
  3318. result instead.
  3319. * `set_data(data)`: Sets the data contents of the `VoxelManip` object
  3320. * `update_map()`: Does nothing, kept for compatibility.
  3321. * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
  3322. a uniform value.
  3323. * `light` is a table, `{day=<0...15>, night=<0...15>}`
  3324. * To be used only by a `VoxelManip` object from
  3325. `minetest.get_mapgen_object`.
  3326. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3327. area if left out.
  3328. * `get_light_data()`: Gets the light data read into the `VoxelManip` object
  3329. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3330. `255`.
  3331. * Each value is the bitwise combination of day and night light values
  3332. (`0` to `15` each).
  3333. * `light = day + (night * 16)`
  3334. * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
  3335. in the `VoxelManip`.
  3336. * expects lighting data in the same format that `get_light_data()` returns
  3337. * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
  3338. `VoxelManip` object.
  3339. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3340. `255`.
  3341. * If the param `buffer` is present, this table will be used to store the
  3342. result instead.
  3343. * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
  3344. the `VoxelManip`.
  3345. * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the
  3346. `VoxelManip`.
  3347. * To be used only by a `VoxelManip` object from
  3348. `minetest.get_mapgen_object`.
  3349. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3350. area if left out or nil. For almost all uses these should be left out
  3351. or nil to use the default.
  3352. * `propagate_shadow` is an optional boolean deciding whether shadows in a
  3353. generated mapchunk above are propagated down into the mapchunk, defaults
  3354. to `true` if left out.
  3355. * `update_liquids()`: Update liquid flow
  3356. * `was_modified()`: Returns `true` or `false` if the data in the voxel
  3357. manipulator had been modified since the last read from map, due to a call to
  3358. `minetest.set_data()` on the loaded area elsewhere.
  3359. * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
  3360. `VoxelArea`
  3361. -----------
  3362. A helper class for voxel areas.
  3363. It can be created via `VoxelArea:new{MinEdge = pmin, MaxEdge = pmax}`.
  3364. The coordinates are *inclusive*, like most other things in Minetest.
  3365. ### Methods
  3366. * `getExtent()`: returns a 3D vector containing the size of the area formed by
  3367. `MinEdge` and `MaxEdge`.
  3368. * `getVolume()`: returns the volume of the area formed by `MinEdge` and
  3369. `MaxEdge`.
  3370. * `index(x, y, z)`: returns the index of an absolute position in a flat array
  3371. starting at `1`.
  3372. * `x`, `y` and `z` must be integers to avoid an incorrect index result.
  3373. * The position (x, y, z) is not checked for being inside the area volume,
  3374. being outside can cause an incorrect index result.
  3375. * Useful for things like `VoxelManip`, raw Schematic specifiers,
  3376. `PerlinNoiseMap:get2d`/`3dMap`, and so on.
  3377. * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
  3378. * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
  3379. is not checked for being inside the area volume.
  3380. * `position(i)`: returns the absolute position vector corresponding to index
  3381. `i`.
  3382. * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
  3383. `MinEdge` and `MaxEdge`.
  3384. * `containsp(p)`: same as above, except takes a vector
  3385. * `containsi(i)`: same as above, except takes an index `i`
  3386. * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
  3387. indices.
  3388. * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
  3389. `[z [y [x]]]`.
  3390. * `iterp(minp, maxp)`: same as above, except takes a vector
  3391. ### Y stride and z stride of a flat array
  3392. For a particular position in a voxel area, whose flat array index is known,
  3393. it is often useful to know the index of a neighboring or nearby position.
  3394. The table below shows the changes of index required for 1 node movements along
  3395. the axes in a voxel area:
  3396. Movement Change of index
  3397. +x +1
  3398. -x -1
  3399. +y +ystride
  3400. -y -ystride
  3401. +z +zstride
  3402. -z -zstride
  3403. If, for example:
  3404. local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
  3405. The values of `ystride` and `zstride` can be obtained using `area.ystride` and
  3406. `area.zstride`.
  3407. Mapgen objects
  3408. ==============
  3409. A mapgen object is a construct used in map generation. Mapgen objects can be
  3410. used by an `on_generate` callback to speed up operations by avoiding
  3411. unnecessary recalculations, these can be retrieved using the
  3412. `minetest.get_mapgen_object()` function. If the requested Mapgen object is
  3413. unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
  3414. callback, `nil` is returned.
  3415. The following Mapgen objects are currently available:
  3416. ### `voxelmanip`
  3417. This returns three values; the `VoxelManip` object to be used, minimum and
  3418. maximum emerged position, in that order. All mapgens support this object.
  3419. ### `heightmap`
  3420. Returns an array containing the y coordinates of the ground levels of nodes in
  3421. the most recently generated chunk by the current mapgen.
  3422. ### `biomemap`
  3423. Returns an array containing the biome IDs of nodes in the most recently
  3424. generated chunk by the current mapgen.
  3425. ### `heatmap`
  3426. Returns an array containing the temperature values of nodes in the most
  3427. recently generated chunk by the current mapgen.
  3428. ### `humiditymap`
  3429. Returns an array containing the humidity values of nodes in the most recently
  3430. generated chunk by the current mapgen.
  3431. ### `gennotify`
  3432. Returns a table mapping requested generation notification types to arrays of
  3433. positions at which the corresponding generated structures are located within
  3434. the current chunk. To set the capture of positions of interest to be recorded
  3435. on generate, use `minetest.set_gen_notify()`.
  3436. For decorations, the returned positions are the ground surface 'place_on'
  3437. nodes, not the decorations themselves. A 'simple' type decoration is often 1
  3438. node above the returned position and possibly displaced by 'place_offset_y'.
  3439. Possible fields of the table returned are:
  3440. * `dungeon`
  3441. * `temple`
  3442. * `cave_begin`
  3443. * `cave_end`
  3444. * `large_cave_begin`
  3445. * `large_cave_end`
  3446. * `decoration`
  3447. Decorations have a key in the format of `"decoration#id"`, where `id` is the
  3448. numeric unique decoration ID as returned by `minetest.get_decoration_id`.
  3449. Registered entities
  3450. ===================
  3451. Functions receive a "luaentity" as `self`:
  3452. * It has the member `.name`, which is the registered name `("mod:thing")`
  3453. * It has the member `.object`, which is an `ObjectRef` pointing to the object
  3454. * The original prototype stuff is visible directly via a metatable
  3455. Callbacks:
  3456. * `on_activate(self, staticdata, dtime_s)`
  3457. * Called when the object is instantiated.
  3458. * `dtime_s` is the time passed since the object was unloaded, which can be
  3459. used for updating the entity state.
  3460. * `on_deactivate(self)
  3461. * Called when the object is about to get removed or unloaded.
  3462. * `on_step(self, dtime)`
  3463. * Called on every server tick, after movement and collision processing.
  3464. `dtime` is usually 0.1 seconds, as per the `dedicated_server_step` setting
  3465. in `minetest.conf`.
  3466. * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
  3467. * Called when somebody punches the object.
  3468. * Note that you probably want to handle most punches using the automatic
  3469. armor group system.
  3470. * `puncher`: an `ObjectRef` (can be `nil`)
  3471. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3472. (can be `nil`).
  3473. * `tool_capabilities`: capability table of used item (can be `nil`)
  3474. * `dir`: unit vector of direction of punch. Always defined. Points from the
  3475. puncher to the punched.
  3476. * `damage`: damage that will be done to entity.
  3477. * Can return `true` to prevent the default damage mechanism.
  3478. * `on_death(self, killer)`
  3479. * Called when the object dies.
  3480. * `killer`: an `ObjectRef` (can be `nil`)
  3481. * `on_rightclick(self, clicker)`
  3482. * Called when `clicker` pressed the 'place/use' key while pointing
  3483. to the object (not neccessarily an actual rightclick)
  3484. * `clicker`: an `ObjectRef` (may or may not be a player)
  3485. * `on_attach_child(self, child)`
  3486. * `child`: an `ObjectRef` of the child that attaches
  3487. * `on_detach_child(self, child)`
  3488. * `child`: an `ObjectRef` of the child that detaches
  3489. * `on_detach(self, parent)`
  3490. * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
  3491. * This happens before the parent object is removed from the world
  3492. * `get_staticdata(self)`
  3493. * Should return a string that will be passed to `on_activate` when the
  3494. object is instantiated the next time.
  3495. L-system trees
  3496. ==============
  3497. Tree definition
  3498. ---------------
  3499. treedef={
  3500. axiom, --string initial tree axiom
  3501. rules_a, --string rules set A
  3502. rules_b, --string rules set B
  3503. rules_c, --string rules set C
  3504. rules_d, --string rules set D
  3505. trunk, --string trunk node name
  3506. leaves, --string leaves node name
  3507. leaves2, --string secondary leaves node name
  3508. leaves2_chance,--num chance (0-100) to replace leaves with leaves2
  3509. angle, --num angle in deg
  3510. iterations, --num max # of iterations, usually 2 -5
  3511. random_level, --num factor to lower nr of iterations, usually 0 - 3
  3512. trunk_type, --string single/double/crossed) type of trunk: 1 node,
  3513. -- 2x2 nodes or 3x3 in cross shape
  3514. thin_branches, --boolean true -> use thin (1 node) branches
  3515. fruit, --string fruit node name
  3516. fruit_chance, --num chance (0-100) to replace leaves with fruit node
  3517. seed, --num random seed, if no seed is provided, the engine
  3518. will create one.
  3519. }
  3520. Key for special L-System symbols used in axioms
  3521. -----------------------------------------------
  3522. * `G`: move forward one unit with the pen up
  3523. * `F`: move forward one unit with the pen down drawing trunks and branches
  3524. * `f`: move forward one unit with the pen down drawing leaves (100% chance)
  3525. * `T`: move forward one unit with the pen down drawing trunks only
  3526. * `R`: move forward one unit with the pen down placing fruit
  3527. * `A`: replace with rules set A
  3528. * `B`: replace with rules set B
  3529. * `C`: replace with rules set C
  3530. * `D`: replace with rules set D
  3531. * `a`: replace with rules set A, chance 90%
  3532. * `b`: replace with rules set B, chance 80%
  3533. * `c`: replace with rules set C, chance 70%
  3534. * `d`: replace with rules set D, chance 60%
  3535. * `+`: yaw the turtle right by `angle` parameter
  3536. * `-`: yaw the turtle left by `angle` parameter
  3537. * `&`: pitch the turtle down by `angle` parameter
  3538. * `^`: pitch the turtle up by `angle` parameter
  3539. * `/`: roll the turtle to the right by `angle` parameter
  3540. * `*`: roll the turtle to the left by `angle` parameter
  3541. * `[`: save in stack current state info
  3542. * `]`: recover from stack state info
  3543. Example
  3544. -------
  3545. Spawn a small apple tree:
  3546. pos = {x=230,y=20,z=4}
  3547. apple_tree={
  3548. axiom="FFFFFAFFBF",
  3549. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  3550. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  3551. trunk="default:tree",
  3552. leaves="default:leaves",
  3553. angle=30,
  3554. iterations=2,
  3555. random_level=0,
  3556. trunk_type="single",
  3557. thin_branches=true,
  3558. fruit_chance=10,
  3559. fruit="default:apple"
  3560. }
  3561. minetest.spawn_tree(pos,apple_tree)
  3562. 'minetest' namespace reference
  3563. ==============================
  3564. Utilities
  3565. ---------
  3566. * `minetest.get_current_modname()`: returns the currently loading mod's name,
  3567. when loading a mod.
  3568. * `minetest.get_modpath(modname)`: returns the directory path for a mod,
  3569. e.g. `"/home/user/.minetest/usermods/modname"`.
  3570. * Returns nil if the mod is not enabled or does not exist (not installed).
  3571. * Works regardless of whether the mod has been loaded yet.
  3572. * Useful for loading additional `.lua` modules or static data from a mod,
  3573. or checking if a mod is enabled.
  3574. * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
  3575. * Does not include disabled mods, even if they are installed.
  3576. * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
  3577. * Useful for storing custom data
  3578. * `minetest.is_singleplayer()`
  3579. * `minetest.features`: Table containing API feature flags
  3580. {
  3581. glasslike_framed = true, -- 0.4.7
  3582. nodebox_as_selectionbox = true, -- 0.4.7
  3583. get_all_craft_recipes_works = true, -- 0.4.7
  3584. -- The transparency channel of textures can optionally be used on
  3585. -- nodes (0.4.7)
  3586. use_texture_alpha = true,
  3587. -- Tree and grass ABMs are no longer done from C++ (0.4.8)
  3588. no_legacy_abms = true,
  3589. -- Texture grouping is possible using parentheses (0.4.11)
  3590. texture_names_parens = true,
  3591. -- Unique Area ID for AreaStore:insert_area (0.4.14)
  3592. area_store_custom_ids = true,
  3593. -- add_entity supports passing initial staticdata to on_activate
  3594. -- (0.4.16)
  3595. add_entity_with_staticdata = true,
  3596. -- Chat messages are no longer predicted (0.4.16)
  3597. no_chat_message_prediction = true,
  3598. -- The transparency channel of textures can optionally be used on
  3599. -- objects (ie: players and lua entities) (5.0.0)
  3600. object_use_texture_alpha = true,
  3601. -- Object selectionbox is settable independently from collisionbox
  3602. -- (5.0.0)
  3603. object_independent_selectionbox = true,
  3604. -- Specifies whether binary data can be uploaded or downloaded using
  3605. -- the HTTP API (5.1.0)
  3606. httpfetch_binary_data = true,
  3607. -- Whether formspec_version[<version>] may be used (5.1.0)
  3608. formspec_version_element = true,
  3609. -- Whether AreaStore's IDs are kept on save/load (5.1.0)
  3610. area_store_persistent_ids = true,
  3611. -- Whether minetest.find_path is functional (5.2.0)
  3612. pathfinder_works = true,
  3613. -- Whether Collision info is available to an objects' on_step (5.3.0)
  3614. object_step_has_moveresult = true,
  3615. -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
  3616. direct_velocity_on_players = true,
  3617. -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
  3618. use_texture_alpha_string_modes = true,
  3619. -- degrotate param2 rotates in units of 1.5° instead of 2°
  3620. -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
  3621. degrotate_240_steps = true,
  3622. -- ABM supports min_y and max_y fields in definition (5.5.0)
  3623. abm_min_max_y = true,
  3624. -- dynamic_add_media supports passing a table with options (5.5.0)
  3625. dynamic_add_media_table = true,
  3626. -- allows get_sky to return a table instead of separate values (5.6.0)
  3627. get_sky_as_table = true,
  3628. }
  3629. * `minetest.has_feature(arg)`: returns `boolean, missing_features`
  3630. * `arg`: string or table in format `{foo=true, bar=true}`
  3631. * `missing_features`: `{foo=true, bar=true}`
  3632. * `minetest.get_player_information(player_name)`: Table containing information
  3633. about a player. Example return value:
  3634. {
  3635. address = "127.0.0.1", -- IP address of client
  3636. ip_version = 4, -- IPv4 / IPv6
  3637. connection_uptime = 200, -- seconds since client connected
  3638. protocol_version = 32, -- protocol version used by client
  3639. formspec_version = 2, -- supported formspec version
  3640. lang_code = "fr" -- Language code used for translation
  3641. -- the following keys can be missing if no stats have been collected yet
  3642. min_rtt = 0.01, -- minimum round trip time
  3643. max_rtt = 0.2, -- maximum round trip time
  3644. avg_rtt = 0.02, -- average round trip time
  3645. min_jitter = 0.01, -- minimum packet time jitter
  3646. max_jitter = 0.5, -- maximum packet time jitter
  3647. avg_jitter = 0.03, -- average packet time jitter
  3648. -- the following information is available in a debug build only!!!
  3649. -- DO NOT USE IN MODS
  3650. --ser_vers = 26, -- serialization version used by client
  3651. --major = 0, -- major version number
  3652. --minor = 4, -- minor version number
  3653. --patch = 10, -- patch version number
  3654. --vers_string = "0.4.9-git", -- full version string
  3655. --state = "Active" -- current client state
  3656. }
  3657. * `minetest.mkdir(path)`: returns success.
  3658. * Creates a directory specified by `path`, creating parent directories
  3659. if they don't exist.
  3660. * `minetest.rmdir(path, recursive)`: returns success.
  3661. * Removes a directory specified by `path`.
  3662. * If `recursive` is set to `true`, the directory is recursively removed.
  3663. Otherwise, the directory will only be removed if it is empty.
  3664. * Returns true on success, false on failure.
  3665. * `minetest.cpdir(source, destination)`: returns success.
  3666. * Copies a directory specified by `path` to `destination`
  3667. * Any files in `destination` will be overwritten if they already exist.
  3668. * Returns true on success, false on failure.
  3669. * `minetest.mvdir(source, destination)`: returns success.
  3670. * Moves a directory specified by `path` to `destination`.
  3671. * If the `destination` is a non-empty directory, then the move will fail.
  3672. * Returns true on success, false on failure.
  3673. * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
  3674. * is_dir is one of:
  3675. * nil: return all entries,
  3676. * true: return only subdirectory names, or
  3677. * false: return only file names.
  3678. * `minetest.safe_file_write(path, content)`: returns boolean indicating success
  3679. * Replaces contents of file at path with new contents in a safe (atomic)
  3680. way. Use this instead of below code when writing e.g. database files:
  3681. `local f = io.open(path, "wb"); f:write(content); f:close()`
  3682. * `minetest.get_version()`: returns a table containing components of the
  3683. engine version. Components:
  3684. * `project`: Name of the project, eg, "Minetest"
  3685. * `string`: Simple version, eg, "1.2.3-dev"
  3686. * `hash`: Full git version (only set if available),
  3687. eg, "1.2.3-dev-01234567-dirty".
  3688. Use this for informational purposes only. The information in the returned
  3689. table does not represent the capabilities of the engine, nor is it
  3690. reliable or verifiable. Compatible forks will have a different name and
  3691. version entirely. To check for the presence of engine features, test
  3692. whether the functions exported by the wanted features exist. For example:
  3693. `if minetest.check_for_falling then ... end`.
  3694. * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
  3695. * `data`: string of data to hash
  3696. * `raw`: return raw bytes instead of hex digits, default: false
  3697. * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
  3698. ColorString. If the ColorSpec is invalid, returns `nil`.
  3699. * `colorspec`: The ColorSpec to convert
  3700. * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
  3701. string of four bytes in an RGBA layout, returned as a string.
  3702. * `colorspec`: The ColorSpec to convert
  3703. * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
  3704. image and return it in string form.
  3705. * `width`: Width of the image
  3706. * `height`: Height of the image
  3707. * `data`: Image data, one of:
  3708. * array table of ColorSpec, length must be width*height
  3709. * string with raw RGBA pixels, length must be width*height*4
  3710. * `compression`: Optional zlib compression level, number in range 0 to 9.
  3711. The data is one-dimensional, starting in the upper left corner of the image
  3712. and laid out in scanlines going from left to right, then top to bottom.
  3713. Please note that it's not safe to use string.char to generate raw data,
  3714. use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
  3715. The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
  3716. You may use this to procedurally generate textures during server init.
  3717. Logging
  3718. -------
  3719. * `minetest.debug(...)`
  3720. * Equivalent to `minetest.log(table.concat({...}, "\t"))`
  3721. * `minetest.log([level,] text)`
  3722. * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
  3723. `"info"`, or `"verbose"`. Default is `"none"`.
  3724. Registration functions
  3725. ----------------------
  3726. Call these functions only at load time!
  3727. ### Environment
  3728. * `minetest.register_node(name, node definition)`
  3729. * `minetest.register_craftitem(name, item definition)`
  3730. * `minetest.register_tool(name, item definition)`
  3731. * `minetest.override_item(name, redefinition)`
  3732. * Overrides fields of an item registered with register_node/tool/craftitem.
  3733. * Note: Item must already be defined, (opt)depend on the mod defining it.
  3734. * Example: `minetest.override_item("default:mese",
  3735. {light_source=minetest.LIGHT_MAX})`
  3736. * `minetest.unregister_item(name)`
  3737. * Unregisters the item from the engine, and deletes the entry with key
  3738. `name` from `minetest.registered_items` and from the associated item table
  3739. according to its nature: `minetest.registered_nodes`, etc.
  3740. * `minetest.register_entity(name, entity definition)`
  3741. * `minetest.register_abm(abm definition)`
  3742. * `minetest.register_lbm(lbm definition)`
  3743. * `minetest.register_alias(alias, original_name)`
  3744. * Also use this to set the 'mapgen aliases' needed in a game for the core
  3745. mapgens. See [Mapgen aliases] section above.
  3746. * `minetest.register_alias_force(alias, original_name)`
  3747. * `minetest.register_ore(ore definition)`
  3748. * Returns an integer object handle uniquely identifying the registered
  3749. ore on success.
  3750. * The order of ore registrations determines the order of ore generation.
  3751. * `minetest.register_biome(biome definition)`
  3752. * Returns an integer object handle uniquely identifying the registered
  3753. biome on success. To get the biome ID, use `minetest.get_biome_id`.
  3754. * `minetest.unregister_biome(name)`
  3755. * Unregisters the biome from the engine, and deletes the entry with key
  3756. `name` from `minetest.registered_biomes`.
  3757. * Warning: This alters the biome to biome ID correspondences, so any
  3758. decorations or ores using the 'biomes' field must afterwards be cleared
  3759. and re-registered.
  3760. * `minetest.register_decoration(decoration definition)`
  3761. * Returns an integer object handle uniquely identifying the registered
  3762. decoration on success. To get the decoration ID, use
  3763. `minetest.get_decoration_id`.
  3764. * The order of decoration registrations determines the order of decoration
  3765. generation.
  3766. * `minetest.register_schematic(schematic definition)`
  3767. * Returns an integer object handle uniquely identifying the registered
  3768. schematic on success.
  3769. * If the schematic is loaded from a file, the `name` field is set to the
  3770. filename.
  3771. * If the function is called when loading the mod, and `name` is a relative
  3772. path, then the current mod path will be prepended to the schematic
  3773. filename.
  3774. * `minetest.clear_registered_biomes()`
  3775. * Clears all biomes currently registered.
  3776. * Warning: Clearing and re-registering biomes alters the biome to biome ID
  3777. correspondences, so any decorations or ores using the 'biomes' field must
  3778. afterwards be cleared and re-registered.
  3779. * `minetest.clear_registered_decorations()`
  3780. * Clears all decorations currently registered.
  3781. * `minetest.clear_registered_ores()`
  3782. * Clears all ores currently registered.
  3783. * `minetest.clear_registered_schematics()`
  3784. * Clears all schematics currently registered.
  3785. ### Gameplay
  3786. * `minetest.register_craft(recipe)`
  3787. * Check recipe table syntax for different types below.
  3788. * `minetest.clear_craft(recipe)`
  3789. * Will erase existing craft based either on output item or on input recipe.
  3790. * Specify either output or input only. If you specify both, input will be
  3791. ignored. For input use the same recipe table syntax as for
  3792. `minetest.register_craft(recipe)`. For output specify only the item,
  3793. without a quantity.
  3794. * Returns false if no erase candidate could be found, otherwise returns true.
  3795. * **Warning**! The type field ("shaped", "cooking" or any other) will be
  3796. ignored if the recipe contains output. Erasing is then done independently
  3797. from the crafting method.
  3798. * `minetest.register_chatcommand(cmd, chatcommand definition)`
  3799. * `minetest.override_chatcommand(name, redefinition)`
  3800. * Overrides fields of a chatcommand registered with `register_chatcommand`.
  3801. * `minetest.unregister_chatcommand(name)`
  3802. * Unregisters a chatcommands registered with `register_chatcommand`.
  3803. * `minetest.register_privilege(name, definition)`
  3804. * `definition` can be a description or a definition table (see [Privilege
  3805. definition]).
  3806. * If it is a description, the priv will be granted to singleplayer and admin
  3807. by default.
  3808. * To allow players with `basic_privs` to grant, see the `basic_privs`
  3809. minetest.conf setting.
  3810. * `minetest.register_authentication_handler(authentication handler definition)`
  3811. * Registers an auth handler that overrides the builtin one.
  3812. * This function can be called by a single mod once only.
  3813. Global callback registration functions
  3814. --------------------------------------
  3815. Call these functions only at load time!
  3816. * `minetest.register_globalstep(function(dtime))`
  3817. * Called every server step, usually interval of 0.1s
  3818. * `minetest.register_on_mods_loaded(function())`
  3819. * Called after mods have finished loading and before the media is cached or the
  3820. aliases handled.
  3821. * `minetest.register_on_shutdown(function())`
  3822. * Called before server shutdown
  3823. * **Warning**: If the server terminates abnormally (i.e. crashes), the
  3824. registered callbacks **will likely not be run**. Data should be saved at
  3825. semi-frequent intervals as well as on server shutdown.
  3826. * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
  3827. * Called when a node has been placed
  3828. * If return `true` no item is taken from `itemstack`
  3829. * `placer` may be any valid ObjectRef or nil.
  3830. * **Not recommended**; use `on_construct` or `after_place_node` in node
  3831. definition whenever possible.
  3832. * `minetest.register_on_dignode(function(pos, oldnode, digger))`
  3833. * Called when a node has been dug.
  3834. * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
  3835. definition whenever possible.
  3836. * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
  3837. * Called when a node is punched
  3838. * `minetest.register_on_generated(function(minp, maxp, blockseed))`
  3839. * Called after generating a piece of world. Modifying nodes inside the area
  3840. is a bit faster than usually.
  3841. * `minetest.register_on_newplayer(function(ObjectRef))`
  3842. * Called when a new player enters the world for the first time
  3843. * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
  3844. * Called when a player is punched
  3845. * Note: This callback is invoked even if the punched player is dead.
  3846. * `player`: ObjectRef - Player that was punched
  3847. * `hitter`: ObjectRef - Player that hit
  3848. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3849. (can be nil).
  3850. * `tool_capabilities`: Capability table of used item (can be nil)
  3851. * `dir`: Unit vector of direction of punch. Always defined. Points from
  3852. the puncher to the punched.
  3853. * `damage`: Number that represents the damage calculated by the engine
  3854. * should return `true` to prevent the default damage mechanism
  3855. * `minetest.register_on_rightclickplayer(function(player, clicker))`
  3856. * Called when the 'place/use' key was used while pointing a player
  3857. (not neccessarily an actual rightclick)
  3858. * `player`: ObjectRef - Player that is acted upon
  3859. * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
  3860. * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
  3861. * Called when the player gets damaged or healed
  3862. * `player`: ObjectRef of the player
  3863. * `hp_change`: the amount of change. Negative when it is damage.
  3864. * `reason`: a PlayerHPChangeReason table.
  3865. * The `type` field will have one of the following values:
  3866. * `set_hp`: A mod or the engine called `set_hp` without
  3867. giving a type - use this for custom damage types.
  3868. * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
  3869. * `fall`
  3870. * `node_damage`: `damage_per_second` from a neighbouring node.
  3871. `reason.node` will hold the node name or nil.
  3872. * `drown`
  3873. * `respawn`
  3874. * Any of the above types may have additional fields from mods.
  3875. * `reason.from` will be `mod` or `engine`.
  3876. * `modifier`: when true, the function should return the actual `hp_change`.
  3877. Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
  3878. Modifiers can return true as a second argument to stop the execution of further functions.
  3879. Non-modifiers receive the final HP change calculated by the modifiers.
  3880. * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
  3881. * Called when a player dies
  3882. * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
  3883. * `minetest.register_on_respawnplayer(function(ObjectRef))`
  3884. * Called when player is to be respawned
  3885. * Called _before_ repositioning of player occurs
  3886. * return true in func to disable regular player placement
  3887. * `minetest.register_on_prejoinplayer(function(name, ip))`
  3888. * Called when a client connects to the server, prior to authentication
  3889. * If it returns a string, the client is disconnected with that string as
  3890. reason.
  3891. * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
  3892. * Called when a player joins the game
  3893. * `last_login`: The timestamp of the previous login, or nil if player is new
  3894. * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
  3895. * Called when a player leaves the game
  3896. * `timed_out`: True for timeout, false for other reasons.
  3897. * `minetest.register_on_authplayer(function(name, ip, is_success))`
  3898. * Called when a client attempts to log into an account.
  3899. * `name`: The name of the account being authenticated.
  3900. * `ip`: The IP address of the client
  3901. * `is_success`: Whether the client was successfully authenticated
  3902. * For newly registered accounts, `is_success` will always be true
  3903. * `minetest.register_on_auth_fail(function(name, ip))`
  3904. * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
  3905. * `minetest.register_on_cheat(function(ObjectRef, cheat))`
  3906. * Called when a player cheats
  3907. * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
  3908. * `moved_too_fast`
  3909. * `interacted_too_far`
  3910. * `interacted_with_self`
  3911. * `interacted_while_dead`
  3912. * `finished_unknown_dig`
  3913. * `dug_unbreakable`
  3914. * `dug_too_fast`
  3915. * `minetest.register_on_chat_message(function(name, message))`
  3916. * Called always when a player says something
  3917. * Return `true` to mark the message as handled, which means that it will
  3918. not be sent to other players.
  3919. * `minetest.register_on_chatcommand(function(name, command, params))`
  3920. * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
  3921. is checked to see if the command exists, but after the input is parsed.
  3922. * Return `true` to mark the command as handled, which means that the default
  3923. handlers will be prevented.
  3924. * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
  3925. * Called when the server received input from `player` in a formspec with
  3926. the given `formname`. Specifically, this is called on any of the
  3927. following events:
  3928. * a button was pressed,
  3929. * Enter was pressed while the focus was on a text field
  3930. * a checkbox was toggled,
  3931. * something was selected in a dropdown list,
  3932. * a different tab was selected,
  3933. * selection was changed in a textlist or table,
  3934. * an entry was double-clicked in a textlist or table,
  3935. * a scrollbar was moved, or
  3936. * the form was actively closed by the player.
  3937. * Fields are sent for formspec elements which define a field. `fields`
  3938. is a table containing each formspecs element value (as string), with
  3939. the `name` parameter as index for each. The value depends on the
  3940. formspec element type:
  3941. * `animated_image`: Returns the index of the current frame.
  3942. * `button` and variants: If pressed, contains the user-facing button
  3943. text as value. If not pressed, is `nil`
  3944. * `field`, `textarea` and variants: Text in the field
  3945. * `dropdown`: Either the index or value, depending on the `index event`
  3946. dropdown argument.
  3947. * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
  3948. * `checkbox`: `"true"` if checked, `"false"` if unchecked
  3949. * `textlist`: See `minetest.explode_textlist_event`
  3950. * `table`: See `minetest.explode_table_event`
  3951. * `scrollbar`: See `minetest.explode_scrollbar_event`
  3952. * Special case: `["quit"]="true"` is sent when the user actively
  3953. closed the form by mouse click, keypress or through a button_exit[]
  3954. element.
  3955. * Special case: `["key_enter"]="true"` is sent when the user pressed
  3956. the Enter key and the focus was either nowhere (causing the formspec
  3957. to be closed) or on a button. If the focus was on a text field,
  3958. additionally, the index `key_enter_field` contains the name of the
  3959. text field. See also: `field_close_on_enter`.
  3960. * Newest functions are called first
  3961. * If function returns `true`, remaining functions are not called
  3962. * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
  3963. * Called when `player` crafts something
  3964. * `itemstack` is the output
  3965. * `old_craft_grid` contains the recipe (Note: the one in the inventory is
  3966. cleared).
  3967. * `craft_inv` is the inventory with the crafting grid
  3968. * Return either an `ItemStack`, to replace the output, or `nil`, to not
  3969. modify it.
  3970. * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
  3971. * The same as before, except that it is called before the player crafts, to
  3972. make craft prediction, and it should not change anything.
  3973. * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
  3974. * Determines how much of a stack may be taken, put or moved to a
  3975. player inventory.
  3976. * `player` (type `ObjectRef`) is the player who modified the inventory
  3977. `inventory` (type `InvRef`).
  3978. * List of possible `action` (string) values and their
  3979. `inventory_info` (table) contents:
  3980. * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  3981. * `put`: `{listname=string, index=number, stack=ItemStack}`
  3982. * `take`: Same as `put`
  3983. * Return a numeric value to limit the amount of items to be taken, put or
  3984. moved. A value of `-1` for `take` will make the source stack infinite.
  3985. * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
  3986. * Called after a take, put or move event from/to/in a player inventory
  3987. * Function arguments: see `minetest.register_allow_player_inventory_action`
  3988. * Does not accept or handle any return value.
  3989. * `minetest.register_on_protection_violation(function(pos, name))`
  3990. * Called by `builtin` and mods when a player violates protection at a
  3991. position (eg, digs a node or punches a protected entity).
  3992. * The registered functions can be called using
  3993. `minetest.record_protection_violation`.
  3994. * The provided function should check that the position is protected by the
  3995. mod calling this function before it prints a message, if it does, to
  3996. allow for multiple protection mods.
  3997. * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
  3998. * Called when an item is eaten, by `minetest.item_eat`
  3999. * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
  4000. * `minetest.register_on_priv_grant(function(name, granter, priv))`
  4001. * Called when `granter` grants the priv `priv` to `name`.
  4002. * Note that the callback will be called twice if it's done by a player,
  4003. once with granter being the player name, and again with granter being nil.
  4004. * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
  4005. * Called when `revoker` revokes the priv `priv` from `name`.
  4006. * Note that the callback will be called twice if it's done by a player,
  4007. once with revoker being the player name, and again with revoker being nil.
  4008. * `minetest.register_can_bypass_userlimit(function(name, ip))`
  4009. * Called when `name` user connects with `ip`.
  4010. * Return `true` to by pass the player limit
  4011. * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
  4012. * Called when an incoming mod channel message is received
  4013. * You should have joined some channels to receive events.
  4014. * If message comes from a server mod, `sender` field is an empty string.
  4015. * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
  4016. * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
  4017. engine's liquid transformation process.
  4018. * `pos_list` is an array of all modified positions.
  4019. * `node_list` is an array of the old node that was previously at the position
  4020. with the corresponding index in pos_list.
  4021. Setting-related
  4022. ---------------
  4023. * `minetest.settings`: Settings object containing all of the settings from the
  4024. main config file (`minetest.conf`).
  4025. * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
  4026. parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
  4027. Authentication
  4028. --------------
  4029. * `minetest.string_to_privs(str[, delim])`:
  4030. * Converts string representation of privs into table form
  4031. * `delim`: String separating the privs. Defaults to `","`.
  4032. * Returns `{ priv1 = true, ... }`
  4033. * `minetest.privs_to_string(privs[, delim])`:
  4034. * Returns the string representation of `privs`
  4035. * `delim`: String to delimit privs. Defaults to `","`.
  4036. * `minetest.get_player_privs(name) -> {priv1=true,...}`
  4037. * `minetest.check_player_privs(player_or_name, ...)`:
  4038. returns `bool, missing_privs`
  4039. * A quickhand for checking privileges.
  4040. * `player_or_name`: Either a Player object or the name of a player.
  4041. * `...` is either a list of strings, e.g. `"priva", "privb"` or
  4042. a table, e.g. `{ priva = true, privb = true }`.
  4043. * `minetest.check_password_entry(name, entry, password)`
  4044. * Returns true if the "password entry" for a player with name matches given
  4045. password, false otherwise.
  4046. * The "password entry" is the password representation generated by the
  4047. engine as returned as part of a `get_auth()` call on the auth handler.
  4048. * Only use this function for making it possible to log in via password from
  4049. external protocols such as IRC, other uses are frowned upon.
  4050. * `minetest.get_password_hash(name, raw_password)`
  4051. * Convert a name-password pair to a password hash that Minetest can use.
  4052. * The returned value alone is not a good basis for password checks based
  4053. on comparing the password hash in the database with the password hash
  4054. from the function, with an externally provided password, as the hash
  4055. in the db might use the new SRP verifier format.
  4056. * For this purpose, use `minetest.check_password_entry` instead.
  4057. * `minetest.get_player_ip(name)`: returns an IP address string for the player
  4058. `name`.
  4059. * The player needs to be online for this to be successful.
  4060. * `minetest.get_auth_handler()`: Return the currently active auth handler
  4061. * See the [Authentication handler definition]
  4062. * Use this to e.g. get the authentication data for a player:
  4063. `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  4064. * `minetest.notify_authentication_modified(name)`
  4065. * Must be called by the authentication handler for privilege changes.
  4066. * `name`: string; if omitted, all auth data should be considered modified
  4067. * `minetest.set_player_password(name, password_hash)`: Set password hash of
  4068. player `name`.
  4069. * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
  4070. `name`.
  4071. * `minetest.auth_reload()`
  4072. * See `reload()` in authentication handler definition
  4073. `minetest.set_player_password`, `minetest.set_player_privs`,
  4074. `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
  4075. handler.
  4076. Chat
  4077. ----
  4078. * `minetest.chat_send_all(text)`
  4079. * `minetest.chat_send_player(name, text)`
  4080. * `minetest.format_chat_message(name, message)`
  4081. * Used by the server to format a chat message, based on the setting `chat_message_format`.
  4082. Refer to the documentation of the setting for a list of valid placeholders.
  4083. * Takes player name and message, and returns the formatted string to be sent to players.
  4084. * Can be redefined by mods if required, for things like colored names or messages.
  4085. * **Only** the first occurrence of each placeholder will be replaced.
  4086. Environment access
  4087. ------------------
  4088. * `minetest.set_node(pos, node)`
  4089. * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
  4090. * Set node at position `pos`
  4091. * `node`: table `{name=string, param1=number, param2=number}`
  4092. * If param1 or param2 is omitted, it's set to `0`.
  4093. * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
  4094. * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
  4095. * Set node on all positions set in the first argument.
  4096. * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
  4097. * For node specification or position syntax see `minetest.set_node` call
  4098. * Faster than set_node due to single call, but still considerably slower
  4099. than Lua Voxel Manipulators (LVM) for large numbers of nodes.
  4100. Unlike LVMs, this will call node callbacks. It also allows setting nodes
  4101. in spread out positions which would cause LVMs to waste memory.
  4102. For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
  4103. times faster.
  4104. * `minetest.swap_node(pos, node)`
  4105. * Set node at position, but don't remove metadata
  4106. * `minetest.remove_node(pos)`
  4107. * By default it does the same as `minetest.set_node(pos, {name="air"})`
  4108. * `minetest.get_node(pos)`
  4109. * Returns the node at the given position as table in the format
  4110. `{name="node_name", param1=0, param2=0}`,
  4111. returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
  4112. * `minetest.get_node_or_nil(pos)`
  4113. * Same as `get_node` but returns `nil` for unloaded areas.
  4114. * `minetest.get_node_light(pos, timeofday)`
  4115. * Gets the light value at the given position. Note that the light value
  4116. "inside" the node at the given position is returned, so you usually want
  4117. to get the light value of a neighbor.
  4118. * `pos`: The position where to measure the light.
  4119. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4120. * Returns a number between `0` and `15` or `nil`
  4121. * `nil` is returned e.g. when the map isn't loaded at `pos`
  4122. * `minetest.get_natural_light(pos[, timeofday])`
  4123. * Figures out the sunlight (or moonlight) value at pos at the given time of
  4124. day.
  4125. * `pos`: The position of the node
  4126. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4127. * Returns a number between `0` and `15` or `nil`
  4128. * This function tests 203 nodes in the worst case, which happens very
  4129. unlikely
  4130. * `minetest.get_artificial_light(param1)`
  4131. * Calculates the artificial light (light from e.g. torches) value from the
  4132. `param1` value.
  4133. * `param1`: The param1 value of a `paramtype = "light"` node.
  4134. * Returns a number between `0` and `15`
  4135. * Currently it's the same as `math.floor(param1 / 16)`, except that it
  4136. ensures compatibility.
  4137. * `minetest.place_node(pos, node)`
  4138. * Place node with the same effects that a player would cause
  4139. * `minetest.dig_node(pos)`
  4140. * Dig node with the same effects that a player would cause
  4141. * Returns `true` if successful, `false` on failure (e.g. protected location)
  4142. * `minetest.punch_node(pos)`
  4143. * Punch node with the same effects that a player would cause
  4144. * `minetest.spawn_falling_node(pos)`
  4145. * Change node into falling node
  4146. * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
  4147. * `minetest.find_nodes_with_meta(pos1, pos2)`
  4148. * Get a table of positions of nodes that have metadata within a region
  4149. {pos1, pos2}.
  4150. * `minetest.get_meta(pos)`
  4151. * Get a `NodeMetaRef` at that position
  4152. * `minetest.get_node_timer(pos)`
  4153. * Get `NodeTimerRef`
  4154. * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
  4155. position.
  4156. * Returns `ObjectRef`, or `nil` if failed
  4157. * `minetest.add_item(pos, item)`: Spawn item
  4158. * Returns `ObjectRef`, or `nil` if failed
  4159. * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
  4160. * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  4161. ObjectRefs.
  4162. * `radius`: using an euclidean metric
  4163. * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
  4164. ObjectRefs.
  4165. * `pos1` and `pos2` are the min and max positions of the area to search.
  4166. * `minetest.set_timeofday(val)`
  4167. * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
  4168. * `minetest.get_timeofday()`
  4169. * `minetest.get_gametime()`: returns the time, in seconds, since the world was
  4170. created.
  4171. * `minetest.get_day_count()`: returns number days elapsed since world was
  4172. created.
  4173. * accounts for time changes.
  4174. * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
  4175. pos or `nil`.
  4176. * `radius`: using a maximum metric
  4177. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4178. * `search_center` is an optional boolean (default: `false`)
  4179. If true `pos` is also checked for the nodes
  4180. * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
  4181. * `pos1` and `pos2` are the min and max positions of the area to search.
  4182. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4183. * If `grouped` is true the return value is a table indexed by node name
  4184. which contains lists of positions.
  4185. * If `grouped` is false or absent the return values are as follows:
  4186. first value: Table with all node positions
  4187. second value: Table with the count of each node with the node name
  4188. as index
  4189. * Area volume is limited to 4,096,000 nodes
  4190. * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
  4191. list of positions.
  4192. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4193. * Return value: Table with all node positions with a node air above
  4194. * Area volume is limited to 4,096,000 nodes
  4195. * `minetest.get_perlin(noiseparams)`
  4196. * Return world-specific perlin noise.
  4197. * The actual seed used is the noiseparams seed plus the world seed.
  4198. * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
  4199. * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
  4200. * Return world-specific perlin noise.
  4201. * `minetest.get_voxel_manip([pos1, pos2])`
  4202. * Return voxel manipulator object.
  4203. * Loads the manipulator from the map if positions are passed.
  4204. * `minetest.set_gen_notify(flags, {deco_ids})`
  4205. * Set the types of on-generate notifications that should be collected.
  4206. * `flags` is a flag field with the available flags:
  4207. * dungeon
  4208. * temple
  4209. * cave_begin
  4210. * cave_end
  4211. * large_cave_begin
  4212. * large_cave_end
  4213. * decoration
  4214. * The second parameter is a list of IDs of decorations which notification
  4215. is requested for.
  4216. * `minetest.get_gen_notify()`
  4217. * Returns a flagstring and a table with the `deco_id`s.
  4218. * `minetest.get_decoration_id(decoration_name)`
  4219. * Returns the decoration ID number for the provided decoration name string,
  4220. or `nil` on failure.
  4221. * `minetest.get_mapgen_object(objectname)`
  4222. * Return requested mapgen object if available (see [Mapgen objects])
  4223. * `minetest.get_heat(pos)`
  4224. * Returns the heat at the position, or `nil` on failure.
  4225. * `minetest.get_humidity(pos)`
  4226. * Returns the humidity at the position, or `nil` on failure.
  4227. * `minetest.get_biome_data(pos)`
  4228. * Returns a table containing:
  4229. * `biome` the biome id of the biome at that position
  4230. * `heat` the heat at the position
  4231. * `humidity` the humidity at the position
  4232. * Or returns `nil` on failure.
  4233. * `minetest.get_biome_id(biome_name)`
  4234. * Returns the biome id, as used in the biomemap Mapgen object and returned
  4235. by `minetest.get_biome_data(pos)`, for a given biome_name string.
  4236. * `minetest.get_biome_name(biome_id)`
  4237. * Returns the biome name string for the provided biome id, or `nil` on
  4238. failure.
  4239. * If no biomes have been registered, such as in mgv6, returns `default`.
  4240. * `minetest.get_mapgen_params()`
  4241. * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
  4242. * Returns a table containing:
  4243. * `mgname`
  4244. * `seed`
  4245. * `chunksize`
  4246. * `water_level`
  4247. * `flags`
  4248. * `minetest.set_mapgen_params(MapgenParams)`
  4249. * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
  4250. instead.
  4251. * Set map generation parameters.
  4252. * Function cannot be called after the registration period; only
  4253. initialization and `on_mapgen_init`.
  4254. * Takes a table as an argument with the fields:
  4255. * `mgname`
  4256. * `seed`
  4257. * `chunksize`
  4258. * `water_level`
  4259. * `flags`
  4260. * Leave field unset to leave that parameter unchanged.
  4261. * `flags` contains a comma-delimited string of flags to set, or if the
  4262. prefix `"no"` is attached, clears instead.
  4263. * `flags` is in the same format and has the same options as `mg_flags` in
  4264. `minetest.conf`.
  4265. * `minetest.get_mapgen_setting(name)`
  4266. * Gets the *active* mapgen setting (or nil if none exists) in string
  4267. format with the following order of precedence:
  4268. 1) Settings loaded from map_meta.txt or overrides set during mod
  4269. execution.
  4270. 2) Settings set by mods without a metafile override
  4271. 3) Settings explicitly set in the user config file, minetest.conf
  4272. 4) Settings set as the user config default
  4273. * `minetest.get_mapgen_setting_noiseparams(name)`
  4274. * Same as above, but returns the value as a NoiseParams table if the
  4275. setting `name` exists and is a valid NoiseParams.
  4276. * `minetest.set_mapgen_setting(name, value, [override_meta])`
  4277. * Sets a mapgen param to `value`, and will take effect if the corresponding
  4278. mapgen setting is not already present in map_meta.txt.
  4279. * `override_meta` is an optional boolean (default: `false`). If this is set
  4280. to true, the setting will become the active setting regardless of the map
  4281. metafile contents.
  4282. * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
  4283. * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
  4284. * Same as above, except value is a NoiseParams table.
  4285. * `minetest.set_noiseparams(name, noiseparams, set_default)`
  4286. * Sets the noiseparams setting of `name` to the noiseparams table specified
  4287. in `noiseparams`.
  4288. * `set_default` is an optional boolean (default: `true`) that specifies
  4289. whether the setting should be applied to the default config or current
  4290. active config.
  4291. * `minetest.get_noiseparams(name)`
  4292. * Returns a table of the noiseparams for name.
  4293. * `minetest.generate_ores(vm, pos1, pos2)`
  4294. * Generate all registered ores within the VoxelManip `vm` and in the area
  4295. from `pos1` to `pos2`.
  4296. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4297. * `minetest.generate_decorations(vm, pos1, pos2)`
  4298. * Generate all registered decorations within the VoxelManip `vm` and in the
  4299. area from `pos1` to `pos2`.
  4300. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4301. * `minetest.clear_objects([options])`
  4302. * Clear all objects in the environment
  4303. * Takes an optional table as an argument with the field `mode`.
  4304. * mode = `"full"` : Load and go through every mapblock, clearing
  4305. objects (default).
  4306. * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
  4307. clear objects in unloaded mapblocks only when the
  4308. mapblocks are next activated.
  4309. * `minetest.load_area(pos1[, pos2])`
  4310. * Load the mapblocks containing the area from `pos1` to `pos2`.
  4311. `pos2` defaults to `pos1` if not specified.
  4312. * This function does not trigger map generation.
  4313. * `minetest.emerge_area(pos1, pos2, [callback], [param])`
  4314. * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
  4315. asynchronously fetched from memory, loaded from disk, or if inexistent,
  4316. generates them.
  4317. * If `callback` is a valid Lua function, this will be called for each block
  4318. emerged.
  4319. * The function signature of callback is:
  4320. `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
  4321. * `blockpos` is the *block* coordinates of the block that had been
  4322. emerged.
  4323. * `action` could be one of the following constant values:
  4324. * `minetest.EMERGE_CANCELLED`
  4325. * `minetest.EMERGE_ERRORED`
  4326. * `minetest.EMERGE_FROM_MEMORY`
  4327. * `minetest.EMERGE_FROM_DISK`
  4328. * `minetest.EMERGE_GENERATED`
  4329. * `calls_remaining` is the number of callbacks to be expected after
  4330. this one.
  4331. * `param` is the user-defined parameter passed to emerge_area (or
  4332. nil if the parameter was absent).
  4333. * `minetest.delete_area(pos1, pos2)`
  4334. * delete all mapblocks in the area from pos1 to pos2, inclusive
  4335. * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
  4336. * Checks if there is anything other than air between pos1 and pos2.
  4337. * Returns false if something is blocking the sight.
  4338. * Returns the position of the blocking node when `false`
  4339. * `pos1`: First position
  4340. * `pos2`: Second position
  4341. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
  4342. * Creates a `Raycast` object.
  4343. * `pos1`: start of the ray
  4344. * `pos2`: end of the ray
  4345. * `objects`: if false, only nodes will be returned. Default is `true`.
  4346. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  4347. returned. Default is `false`.
  4348. * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
  4349. * returns table containing path that can be walked on
  4350. * returns a table of 3D points representing a path from `pos1` to `pos2` or
  4351. `nil` on failure.
  4352. * Reasons for failure:
  4353. * No path exists at all
  4354. * No path exists within `searchdistance` (see below)
  4355. * Start or end pos is buried in land
  4356. * `pos1`: start position
  4357. * `pos2`: end position
  4358. * `searchdistance`: maximum distance from the search positions to search in.
  4359. In detail: Path must be completely inside a cuboid. The minimum
  4360. `searchdistance` of 1 will confine search between `pos1` and `pos2`.
  4361. Larger values will increase the size of this cuboid in all directions
  4362. * `max_jump`: maximum height difference to consider walkable
  4363. * `max_drop`: maximum height difference to consider droppable
  4364. * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
  4365. Difference between `"A*"` and `"A*_noprefetch"` is that
  4366. `"A*"` will pre-calculate the cost-data, the other will calculate it
  4367. on-the-fly
  4368. * `minetest.spawn_tree (pos, {treedef})`
  4369. * spawns L-system tree at given `pos` with definition in `treedef` table
  4370. * `minetest.transforming_liquid_add(pos)`
  4371. * add node to liquid flow update queue
  4372. * `minetest.get_node_max_level(pos)`
  4373. * get max available level for leveled node
  4374. * `minetest.get_node_level(pos)`
  4375. * get level of leveled node (water, snow)
  4376. * `minetest.set_node_level(pos, level)`
  4377. * set level of leveled node, default `level` equals `1`
  4378. * if `totallevel > maxlevel`, returns rest (`total-max`).
  4379. * `minetest.add_node_level(pos, level)`
  4380. * increase level of leveled node by level, default `level` equals `1`
  4381. * if `totallevel > maxlevel`, returns rest (`total-max`)
  4382. * `level` must be between -127 and 127
  4383. * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
  4384. * resets the light in a cuboid-shaped part of
  4385. the map and removes lighting bugs.
  4386. * Loads the area if it is not loaded.
  4387. * `pos1` is the corner of the cuboid with the least coordinates
  4388. (in node coordinates), inclusive.
  4389. * `pos2` is the opposite corner of the cuboid, inclusive.
  4390. * The actual updated cuboid might be larger than the specified one,
  4391. because only whole map blocks can be updated.
  4392. The actual updated area consists of those map blocks that intersect
  4393. with the given cuboid.
  4394. * However, the neighborhood of the updated area might change
  4395. as well, as light can spread out of the cuboid, also light
  4396. might be removed.
  4397. * returns `false` if the area is not fully generated,
  4398. `true` otherwise
  4399. * `minetest.check_single_for_falling(pos)`
  4400. * causes an unsupported `group:falling_node` node to fall and causes an
  4401. unattached `group:attached_node` node to fall.
  4402. * does not spread these updates to neighbours.
  4403. * `minetest.check_for_falling(pos)`
  4404. * causes an unsupported `group:falling_node` node to fall and causes an
  4405. unattached `group:attached_node` node to fall.
  4406. * spread these updates to neighbours and can cause a cascade
  4407. of nodes to fall.
  4408. * `minetest.get_spawn_level(x, z)`
  4409. * Returns a player spawn y co-ordinate for the provided (x, z)
  4410. co-ordinates, or `nil` for an unsuitable spawn point.
  4411. * For most mapgens a 'suitable spawn point' is one with y between
  4412. `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
  4413. so `nil` will be returned for many (x, z) co-ordinates.
  4414. * The spawn level returned is for a player spawn in unmodified terrain.
  4415. * The spawn level is intentionally above terrain level to cope with
  4416. full-node biome 'dust' nodes.
  4417. Mod channels
  4418. ------------
  4419. You can find mod channels communication scheme in `doc/mod_channels.png`.
  4420. * `minetest.mod_channel_join(channel_name)`
  4421. * Server joins channel `channel_name`, and creates it if necessary. You
  4422. should listen for incoming messages with
  4423. `minetest.register_on_modchannel_message`
  4424. Inventory
  4425. ---------
  4426. `minetest.get_inventory(location)`: returns an `InvRef`
  4427. * `location` = e.g.
  4428. * `{type="player", name="celeron55"}`
  4429. * `{type="node", pos={x=, y=, z=}}`
  4430. * `{type="detached", name="creative"}`
  4431. * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
  4432. an `InvRef`.
  4433. * `callbacks`: See [Detached inventory callbacks]
  4434. * `player_name`: Make detached inventory available to one player
  4435. exclusively, by default they will be sent to every player (even if not
  4436. used).
  4437. Note that this parameter is mostly just a workaround and will be removed
  4438. in future releases.
  4439. * Creates a detached inventory. If it already exists, it is cleared.
  4440. * `minetest.remove_detached_inventory(name)`
  4441. * Returns a `boolean` indicating whether the removal succeeded.
  4442. * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
  4443. returns leftover ItemStack or nil to indicate no inventory change
  4444. * See `minetest.item_eat` and `minetest.register_on_item_eat`
  4445. Formspec
  4446. --------
  4447. * `minetest.show_formspec(playername, formname, formspec)`
  4448. * `playername`: name of player to show formspec
  4449. * `formname`: name passed to `on_player_receive_fields` callbacks.
  4450. It should follow the `"modname:<whatever>"` naming convention
  4451. * `formspec`: formspec to display
  4452. * `minetest.close_formspec(playername, formname)`
  4453. * `playername`: name of player to close formspec
  4454. * `formname`: has to exactly match the one given in `show_formspec`, or the
  4455. formspec will not close.
  4456. * calling `show_formspec(playername, formname, "")` is equal to this
  4457. expression.
  4458. * to close a formspec regardless of the formname, call
  4459. `minetest.close_formspec(playername, "")`.
  4460. **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  4461. * `minetest.formspec_escape(string)`: returns a string
  4462. * escapes the characters "[", "]", "\", "," and ";", which can not be used
  4463. in formspecs.
  4464. * `minetest.explode_table_event(string)`: returns a table
  4465. * returns e.g. `{type="CHG", row=1, column=2}`
  4466. * `type` is one of:
  4467. * `"INV"`: no row selected
  4468. * `"CHG"`: selected
  4469. * `"DCL"`: double-click
  4470. * `minetest.explode_textlist_event(string)`: returns a table
  4471. * returns e.g. `{type="CHG", index=1}`
  4472. * `type` is one of:
  4473. * `"INV"`: no row selected
  4474. * `"CHG"`: selected
  4475. * `"DCL"`: double-click
  4476. * `minetest.explode_scrollbar_event(string)`: returns a table
  4477. * returns e.g. `{type="CHG", value=500}`
  4478. * `type` is one of:
  4479. * `"INV"`: something failed
  4480. * `"CHG"`: has been changed
  4481. * `"VAL"`: not changed
  4482. Item handling
  4483. -------------
  4484. * `minetest.inventorycube(img1, img2, img3)`
  4485. * Returns a string for making an image of a cube (useful as an item image)
  4486. * `minetest.get_pointed_thing_position(pointed_thing, above)`
  4487. * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
  4488. does not refer to a node or entity.
  4489. * If the optional `above` parameter is true and the `pointed_thing` refers
  4490. to a node, then it will return the `above` position of the `pointed_thing`.
  4491. * `minetest.dir_to_facedir(dir, is6d)`
  4492. * Convert a vector to a facedir value, used in `param2` for
  4493. `paramtype2="facedir"`.
  4494. * passing something non-`nil`/`false` for the optional second parameter
  4495. causes it to take the y component into account.
  4496. * `minetest.facedir_to_dir(facedir)`
  4497. * Convert a facedir back into a vector aimed directly out the "back" of a
  4498. node.
  4499. * `minetest.dir_to_wallmounted(dir)`
  4500. * Convert a vector to a wallmounted value, used for
  4501. `paramtype2="wallmounted"`.
  4502. * `minetest.wallmounted_to_dir(wallmounted)`
  4503. * Convert a wallmounted value back into a vector aimed directly out the
  4504. "back" of a node.
  4505. * `minetest.dir_to_yaw(dir)`
  4506. * Convert a vector into a yaw (angle)
  4507. * `minetest.yaw_to_dir(yaw)`
  4508. * Convert yaw (angle) to a vector
  4509. * `minetest.is_colored_paramtype(ptype)`
  4510. * Returns a boolean. Returns `true` if the given `paramtype2` contains
  4511. color information (`color`, `colorwallmounted` or `colorfacedir`).
  4512. * `minetest.strip_param2_color(param2, paramtype2)`
  4513. * Removes everything but the color information from the
  4514. given `param2` value.
  4515. * Returns `nil` if the given `paramtype2` does not contain color
  4516. information.
  4517. * `minetest.get_node_drops(node, toolname)`
  4518. * Returns list of itemstrings that are dropped by `node` when dug
  4519. with the item `toolname` (not limited to tools).
  4520. * `node`: node as table or node name
  4521. * `toolname`: name of the item used to dig (can be `nil`)
  4522. * `minetest.get_craft_result(input)`: returns `output, decremented_input`
  4523. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4524. * `input.width` = for example `3`
  4525. * `input.items` = for example
  4526. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4527. * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
  4528. * `output.time` = a number, if unsuccessful: `0`
  4529. * `output.replacements` = List of replacement `ItemStack`s that couldn't be
  4530. placed in `decremented_input.items`. Replacements can be placed in
  4531. `decremented_input` if the stack of the replaced item has a count of 1.
  4532. * `decremented_input` = like `input`
  4533. * `minetest.get_craft_recipe(output)`: returns input
  4534. * returns last registered recipe for output item (node)
  4535. * `output` is a node or item type such as `"default:torch"`
  4536. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4537. * `input.width` = for example `3`
  4538. * `input.items` = for example
  4539. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4540. * `input.items` = `nil` if no recipe found
  4541. * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
  4542. * returns indexed table with all registered recipes for query item (node)
  4543. or `nil` if no recipe was found.
  4544. * recipe entry table:
  4545. * `method`: 'normal' or 'cooking' or 'fuel'
  4546. * `width`: 0-3, 0 means shapeless recipe
  4547. * `items`: indexed [1-9] table with recipe items
  4548. * `output`: string with item name and quantity
  4549. * Example query for `"default:gold_ingot"` will return table:
  4550. {
  4551. [1]={method = "cooking", width = 3, output = "default:gold_ingot",
  4552. items = {1 = "default:gold_lump"}},
  4553. [2]={method = "normal", width = 1, output = "default:gold_ingot 9",
  4554. items = {1 = "default:goldblock"}}
  4555. }
  4556. * `minetest.handle_node_drops(pos, drops, digger)`
  4557. * `drops`: list of itemstrings
  4558. * Handles drops from nodes after digging: Default action is to put them
  4559. into digger's inventory.
  4560. * Can be overridden to get different functionality (e.g. dropping items on
  4561. ground)
  4562. * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
  4563. string.
  4564. * Creates an item string which contains palette index information
  4565. for hardware colorization. You can use the returned string
  4566. as an output in a craft recipe.
  4567. * `item`: the item stack which becomes colored. Can be in string,
  4568. table and native form.
  4569. * `palette_index`: this index is added to the item stack
  4570. * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
  4571. * Creates an item string which contains static color information
  4572. for hardware colorization. Use this method if you wish to colorize
  4573. an item that does not own a palette. You can use the returned string
  4574. as an output in a craft recipe.
  4575. * `item`: the item stack which becomes colored. Can be in string,
  4576. table and native form.
  4577. * `colorstring`: the new color of the item stack
  4578. Rollback
  4579. --------
  4580. * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
  4581. returns `{{actor, pos, time, oldnode, newnode}, ...}`
  4582. * Find who has done something to a node, or near a node
  4583. * `actor`: `"player:<name>"`, also `"liquid"`.
  4584. * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
  4585. `boolean, log_messages`.
  4586. * Revert latest actions of someone
  4587. * `actor`: `"player:<name>"`, also `"liquid"`.
  4588. Defaults for the `on_place` and `on_drop` item definition functions
  4589. -------------------------------------------------------------------
  4590. * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
  4591. * Place item as a node
  4592. * `param2` overrides `facedir` and wallmounted `param2`
  4593. * `prevent_after_place`: if set to `true`, `after_place_node` is not called
  4594. for the newly placed node to prevent a callback and placement loop
  4595. * returns `itemstack, position`
  4596. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4597. * `minetest.item_place_object(itemstack, placer, pointed_thing)`
  4598. * Place item as-is
  4599. * returns the leftover itemstack
  4600. * **Note**: This function is deprecated and will never be called.
  4601. * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
  4602. * Wrapper that calls `minetest.item_place_node` if appropriate
  4603. * Calls `on_rightclick` of `pointed_thing.under` if defined instead
  4604. * **Note**: is not called when wielded item overrides `on_place`
  4605. * `param2` overrides facedir and wallmounted `param2`
  4606. * returns `itemstack, position`
  4607. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4608. * `minetest.item_drop(itemstack, dropper, pos)`
  4609. * Drop the item
  4610. * returns the leftover itemstack
  4611. * `minetest.item_eat(hp_change[, replace_with_item])`
  4612. * Returns `function(itemstack, user, pointed_thing)` as a
  4613. function wrapper for `minetest.do_item_eat`.
  4614. * `replace_with_item` is the itemstring which is added to the inventory.
  4615. If the player is eating a stack, then replace_with_item goes to a
  4616. different spot.
  4617. Defaults for the `on_punch` and `on_dig` node definition callbacks
  4618. ------------------------------------------------------------------
  4619. * `minetest.node_punch(pos, node, puncher, pointed_thing)`
  4620. * Calls functions registered by `minetest.register_on_punchnode()`
  4621. * `minetest.node_dig(pos, node, digger)`
  4622. * Checks if node can be dug, puts item into inventory, removes node
  4623. * Calls functions registered by `minetest.registered_on_dignodes()`
  4624. Sounds
  4625. ------
  4626. * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
  4627. * `spec` is a `SimpleSoundSpec`
  4628. * `parameters` is a sound parameter table
  4629. * `ephemeral` is a boolean (default: false)
  4630. Ephemeral sounds will not return a handle and can't be stopped or faded.
  4631. It is recommend to use this for short sounds that happen in response to
  4632. player actions (e.g. door closing).
  4633. * `minetest.sound_stop(handle)`
  4634. * `handle` is a handle returned by `minetest.sound_play`
  4635. * `minetest.sound_fade(handle, step, gain)`
  4636. * `handle` is a handle returned by `minetest.sound_play`
  4637. * `step` determines how fast a sound will fade.
  4638. The gain will change by this much per second,
  4639. until it reaches the target gain.
  4640. Note: Older versions used a signed step. This is deprecated, but old
  4641. code will still work. (the client uses abs(step) to correct it)
  4642. * `gain` the target gain for the fade.
  4643. Fading to zero will delete the sound.
  4644. Timing
  4645. ------
  4646. * `minetest.after(time, func, ...)` : returns job table to use as below.
  4647. * Call the function `func` after `time` seconds, may be fractional
  4648. * Optional: Variable number of arguments that are passed to `func`
  4649. * `job:cancel()`
  4650. * Cancels the job function from being called
  4651. Async environment
  4652. -----------------
  4653. The engine allows you to submit jobs to be ran in an isolated environment
  4654. concurrently with normal server operation.
  4655. A job consists of a function to be ran in the async environment, any amount of
  4656. arguments (will be serialized) and a callback that will be called with the return
  4657. value of the job function once it is finished.
  4658. The async environment does *not* have access to the map, entities, players or any
  4659. globals defined in the 'usual' environment. Consequently, functions like
  4660. `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
  4661. Arguments and return values passed through this can contain certain userdata
  4662. objects that will be seamlessly copied (not shared) to the async environment.
  4663. This allows you easy interoperability for delegating work to jobs.
  4664. * `minetest.handle_async(func, callback, ...)`:
  4665. * Queue the function `func` to be ran in an async environment.
  4666. Note that there are multiple persistent workers and any of them may
  4667. end up running a given job. The engine will scale the amount of
  4668. worker threads automatically.
  4669. * When `func` returns the callback is called (in the normal environment)
  4670. with all of the return values as arguments.
  4671. * Optional: Variable number of arguments that are passed to `func`
  4672. * `minetest.register_async_dofile(path)`:
  4673. * Register a path to a Lua file to be imported when an async environment
  4674. is initialized. You can use this to preload code which you can then call
  4675. later using `minetest.handle_async()`.
  4676. ### List of APIs available in an async environment
  4677. Classes:
  4678. * `ItemStack`
  4679. * `PerlinNoise`
  4680. * `PerlinNoiseMap`
  4681. * `PseudoRandom`
  4682. * `PcgRandom`
  4683. * `SecureRandom`
  4684. * `VoxelArea`
  4685. * `VoxelManip`
  4686. * only if transferred into environment; can't read/write to map
  4687. * `Settings`
  4688. Class instances that can be transferred between environments:
  4689. * `ItemStack`
  4690. * `PerlinNoise`
  4691. * `PerlinNoiseMap`
  4692. * `VoxelManip`
  4693. Functions:
  4694. * Standalone helpers such as logging, filesystem, encoding,
  4695. hashing or compression APIs
  4696. * `minetest.request_insecure_environment` (same restrictions apply)
  4697. Variables:
  4698. * `minetest.settings`
  4699. * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
  4700. `registered_craftitems` and `registered_aliases`
  4701. * with all functions and userdata values replaced by `true`, calling any
  4702. callbacks here is obviously not possible
  4703. Server
  4704. ------
  4705. * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
  4706. server shutdown. Will display `message` to clients.
  4707. * `reconnect` == true displays a reconnect button
  4708. * `delay` adds an optional delay (in seconds) before shutdown.
  4709. Negative delay cancels the current active shutdown.
  4710. Zero delay triggers an immediate shutdown.
  4711. * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
  4712. * `minetest.get_server_status(name, joined)`
  4713. * Returns the server status string when a player joins or when the command
  4714. `/status` is called. Returns `nil` or an empty string when the message is
  4715. disabled.
  4716. * `joined`: Boolean value, indicates whether the function was called when
  4717. a player joined.
  4718. * This function may be overwritten by mods to customize the status message.
  4719. * `minetest.get_server_uptime()`: returns the server uptime in seconds
  4720. * `minetest.get_server_max_lag()`: returns the current maximum lag
  4721. of the server in seconds or nil if server is not fully loaded yet
  4722. * `minetest.remove_player(name)`: remove player from database (if they are not
  4723. connected).
  4724. * As auth data is not removed, minetest.player_exists will continue to
  4725. return true. Call the below method as well if you want to remove auth
  4726. data too.
  4727. * Returns a code (0: successful, 1: no such player, 2: player is connected)
  4728. * `minetest.remove_player_auth(name)`: remove player authentication data
  4729. * Returns boolean indicating success (false if player nonexistant)
  4730. * `minetest.dynamic_add_media(options, callback)`
  4731. * `options`: table containing the following parameters
  4732. * `filepath`: path to a media file on the filesystem
  4733. * `to_player`: name of the player the media should be sent to instead of
  4734. all players (optional)
  4735. * `ephemeral`: boolean that marks the media as ephemeral,
  4736. it will not be cached on the client (optional, default false)
  4737. * `callback`: function with arguments `name`, which is a player name
  4738. * Pushes the specified media file to client(s). (details below)
  4739. The file must be a supported image, sound or model format.
  4740. Dynamically added media is not persisted between server restarts.
  4741. * Returns false on error, true if the request was accepted
  4742. * The given callback will be called for every player as soon as the
  4743. media is available on the client.
  4744. * Details/Notes:
  4745. * If `ephemeral`=false and `to_player` is unset the file is added to the media
  4746. sent to clients on startup, this means the media will appear even on
  4747. old clients if they rejoin the server.
  4748. * If `ephemeral`=false the file must not be modified, deleted, moved or
  4749. renamed after calling this function.
  4750. * Regardless of any use of `ephemeral`, adding media files with the same
  4751. name twice is not possible/guaranteed to work. An exception to this is the
  4752. use of `to_player` to send the same, already existent file to multiple
  4753. chosen players.
  4754. * Clients will attempt to fetch files added this way via remote media,
  4755. this can make transfer of bigger files painless (if set up). Nevertheless
  4756. it is advised not to use dynamic media for big media files.
  4757. Bans
  4758. ----
  4759. * `minetest.get_ban_list()`: returns a list of all bans formatted as string
  4760. * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
  4761. IP address or name formatted as string
  4762. * `minetest.ban_player(name)`: ban the IP of a currently connected player
  4763. * Returns boolean indicating success
  4764. * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
  4765. IP address or name
  4766. * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
  4767. reason.
  4768. * Returns boolean indicating success (false if player nonexistant)
  4769. * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
  4770. optional reason, this will not prefix with 'Kicked: ' like kick_player.
  4771. If no reason is given, it will default to 'Disconnected.'
  4772. * Returns boolean indicating success (false if player nonexistant)
  4773. Particles
  4774. ---------
  4775. * `minetest.add_particle(particle definition)`
  4776. * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
  4777. expirationtime, size, collisiondetection, texture, playername)`
  4778. * `minetest.add_particlespawner(particlespawner definition)`
  4779. * Add a `ParticleSpawner`, an object that spawns an amount of particles
  4780. over `time` seconds.
  4781. * Returns an `id`, and -1 if adding didn't succeed
  4782. * Deprecated: `minetest.add_particlespawner(amount, time,
  4783. minpos, maxpos,
  4784. minvel, maxvel,
  4785. minacc, maxacc,
  4786. minexptime, maxexptime,
  4787. minsize, maxsize,
  4788. collisiondetection, texture, playername)`
  4789. * `minetest.delete_particlespawner(id, player)`
  4790. * Delete `ParticleSpawner` with `id` (return value from
  4791. `minetest.add_particlespawner`).
  4792. * If playername is specified, only deletes on the player's client,
  4793. otherwise on all clients.
  4794. Schematics
  4795. ----------
  4796. * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
  4797. * Create a schematic from the volume of map specified by the box formed by
  4798. p1 and p2.
  4799. * Apply the specified probability and per-node force-place to the specified
  4800. nodes according to the `probability_list`.
  4801. * `probability_list` is an array of tables containing two fields, `pos`
  4802. and `prob`.
  4803. * `pos` is the 3D vector specifying the absolute coordinates of the
  4804. node being modified,
  4805. * `prob` is an integer value from `0` to `255` that encodes
  4806. probability and per-node force-place. Probability has levels
  4807. 0-127, then 128 may be added to encode per-node force-place.
  4808. For probability stated as 0-255, divide by 2 and round down to
  4809. get values 0-127, then add 128 to apply per-node force-place.
  4810. * If there are two or more entries with the same pos value, the
  4811. last entry is used.
  4812. * If `pos` is not inside the box formed by `p1` and `p2`, it is
  4813. ignored.
  4814. * If `probability_list` equals `nil`, no probabilities are applied.
  4815. * Apply the specified probability to the specified horizontal slices
  4816. according to the `slice_prob_list`.
  4817. * `slice_prob_list` is an array of tables containing two fields, `ypos`
  4818. and `prob`.
  4819. * `ypos` indicates the y position of the slice with a probability
  4820. applied, the lowest slice being `ypos = 0`.
  4821. * If slice probability list equals `nil`, no slice probabilities
  4822. are applied.
  4823. * Saves schematic in the Minetest Schematic format to filename.
  4824. * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
  4825. * Place the schematic specified by schematic (see [Schematic specifier]) at
  4826. `pos`.
  4827. * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
  4828. * If the `rotation` parameter is omitted, the schematic is not rotated.
  4829. * `replacements` = `{["old_name"] = "convert_to", ...}`
  4830. * `force_placement` is a boolean indicating whether nodes other than `air`
  4831. and `ignore` are replaced by the schematic.
  4832. * Returns nil if the schematic could not be loaded.
  4833. * **Warning**: Once you have loaded a schematic from a file, it will be
  4834. cached. Future calls will always use the cached version and the
  4835. replacement list defined for it, regardless of whether the file or the
  4836. replacement list parameter have changed. The only way to load the file
  4837. anew is to restart the server.
  4838. * `flags` is a flag field with the available flags:
  4839. * place_center_x
  4840. * place_center_y
  4841. * place_center_z
  4842. * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
  4843. * This function is analogous to minetest.place_schematic, but places a
  4844. schematic onto the specified VoxelManip object `vmanip` instead of the
  4845. map.
  4846. * Returns false if any part of the schematic was cut-off due to the
  4847. VoxelManip not containing the full area required, and true if the whole
  4848. schematic was able to fit.
  4849. * Returns nil if the schematic could not be loaded.
  4850. * After execution, any external copies of the VoxelManip contents are
  4851. invalidated.
  4852. * `flags` is a flag field with the available flags:
  4853. * place_center_x
  4854. * place_center_y
  4855. * place_center_z
  4856. * `minetest.serialize_schematic(schematic, format, options)`
  4857. * Return the serialized schematic specified by schematic
  4858. (see [Schematic specifier])
  4859. * in the `format` of either "mts" or "lua".
  4860. * "mts" - a string containing the binary MTS data used in the MTS file
  4861. format.
  4862. * "lua" - a string containing Lua code representing the schematic in table
  4863. format.
  4864. * `options` is a table containing the following optional parameters:
  4865. * If `lua_use_comments` is true and `format` is "lua", the Lua code
  4866. generated will have (X, Z) position comments for every X row
  4867. generated in the schematic data for easier reading.
  4868. * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
  4869. the Lua code generated will use that number of spaces as indentation
  4870. instead of a tab character.
  4871. * `minetest.read_schematic(schematic, options)`
  4872. * Returns a Lua table representing the schematic (see: [Schematic specifier])
  4873. * `schematic` is the schematic to read (see: [Schematic specifier])
  4874. * `options` is a table containing the following optional parameters:
  4875. * `write_yslice_prob`: string value:
  4876. * `none`: no `write_yslice_prob` table is inserted,
  4877. * `low`: only probabilities that are not 254 or 255 are written in
  4878. the `write_ylisce_prob` table,
  4879. * `all`: write all probabilities to the `write_yslice_prob` table.
  4880. * The default for this option is `all`.
  4881. * Any invalid value will be interpreted as `all`.
  4882. HTTP Requests
  4883. -------------
  4884. * `minetest.request_http_api()`:
  4885. * returns `HTTPApiTable` containing http functions if the calling mod has
  4886. been granted access by being listed in the `secure.http_mods` or
  4887. `secure.trusted_mods` setting, otherwise returns `nil`.
  4888. * The returned table contains the functions `fetch`, `fetch_async` and
  4889. `fetch_async_get` described below.
  4890. * Only works at init time and must be called from the mod's main scope
  4891. (not from a function).
  4892. * Function only exists if minetest server was built with cURL support.
  4893. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
  4894. A LOCAL VARIABLE!**
  4895. * `HTTPApiTable.fetch(HTTPRequest req, callback)`
  4896. * Performs given request asynchronously and calls callback upon completion
  4897. * callback: `function(HTTPRequestResult res)`
  4898. * Use this HTTP function if you are unsure, the others are for advanced use
  4899. * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
  4900. * Performs given request asynchronously and returns handle for
  4901. `HTTPApiTable.fetch_async_get`
  4902. * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
  4903. * Return response data for given asynchronous HTTP request
  4904. Storage API
  4905. -----------
  4906. * `minetest.get_mod_storage()`:
  4907. * returns reference to mod private `StorageRef`
  4908. * must be called during mod load time
  4909. Misc.
  4910. -----
  4911. * `minetest.get_connected_players()`: returns list of `ObjectRefs`
  4912. * `minetest.is_player(obj)`: boolean, whether `obj` is a player
  4913. * `minetest.player_exists(name)`: boolean, whether player exists
  4914. (regardless of online status)
  4915. * `minetest.hud_replace_builtin(name, hud_definition)`
  4916. * Replaces definition of a builtin hud element
  4917. * `name`: `"breath"` or `"health"`
  4918. * `hud_definition`: definition to replace builtin definition
  4919. * `minetest.send_join_message(player_name)`
  4920. * This function can be overridden by mods to change the join message.
  4921. * `minetest.send_leave_message(player_name, timed_out)`
  4922. * This function can be overridden by mods to change the leave message.
  4923. * `minetest.hash_node_position(pos)`: returns an 48-bit integer
  4924. * `pos`: table {x=number, y=number, z=number},
  4925. * Gives a unique hash number for a node position (16+16+16=48bit)
  4926. * `minetest.get_position_from_hash(hash)`: returns a position
  4927. * Inverse transform of `minetest.hash_node_position`
  4928. * `minetest.get_item_group(name, group)`: returns a rating
  4929. * Get rating of a group of an item. (`0` means: not in group)
  4930. * `minetest.get_node_group(name, group)`: returns a rating
  4931. * Deprecated: An alias for the former.
  4932. * `minetest.raillike_group(name)`: returns a rating
  4933. * Returns rating of the connect_to_raillike group corresponding to name
  4934. * If name is not yet the name of a connect_to_raillike group, a new group
  4935. id is created, with that name.
  4936. * `minetest.get_content_id(name)`: returns an integer
  4937. * Gets the internal content ID of `name`
  4938. * `minetest.get_name_from_content_id(content_id)`: returns a string
  4939. * Gets the name of the content with that content ID
  4940. * `minetest.parse_json(string[, nullvalue])`: returns something
  4941. * Convert a string containing JSON data into the Lua equivalent
  4942. * `nullvalue`: returned in place of the JSON null; defaults to `nil`
  4943. * On success returns a table, a string, a number, a boolean or `nullvalue`
  4944. * On failure outputs an error message and returns `nil`
  4945. * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
  4946. * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
  4947. message.
  4948. * Convert a Lua table into a JSON string
  4949. * styled: Outputs in a human-readable format if this is set, defaults to
  4950. false.
  4951. * Unserializable things like functions and userdata will cause an error.
  4952. * **Warning**: JSON is more strict than the Lua table format.
  4953. 1. You can only use strings and positive integers of at least one as
  4954. keys.
  4955. 2. You can not mix string and integer keys.
  4956. This is due to the fact that JSON has two distinct array and object
  4957. values.
  4958. * Example: `write_json({10, {a = false}})`,
  4959. returns `'[10, {"a": false}]'`
  4960. * `minetest.serialize(table)`: returns a string
  4961. * Convert a table containing tables, strings, numbers, booleans and `nil`s
  4962. into string form readable by `minetest.deserialize`
  4963. * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
  4964. * `minetest.deserialize(string[, safe])`: returns a table
  4965. * Convert a string returned by `minetest.serialize` into a table
  4966. * `string` is loaded in an empty sandbox environment.
  4967. * Will load functions if safe is false or omitted. Although these functions
  4968. cannot directly access the global environment, they could bypass this
  4969. restriction with maliciously crafted Lua bytecode if mod security is
  4970. disabled.
  4971. * This function should not be used on untrusted data, regardless of the
  4972. value of `safe`. It is fine to serialize then deserialize user-provided
  4973. data, but directly providing user input to deserialize is always unsafe.
  4974. * Example: `deserialize('return { ["foo"] = "bar" }')`,
  4975. returns `{foo="bar"}`
  4976. * Example: `deserialize('print("foo")')`, returns `nil`
  4977. (function call fails), returns
  4978. `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
  4979. * `minetest.compress(data, method, ...)`: returns `compressed_data`
  4980. * Compress a string of data.
  4981. * `method` is a string identifying the compression method to be used.
  4982. * Supported compression methods:
  4983. * Deflate (zlib): `"deflate"`
  4984. * `...` indicates method-specific arguments. Currently defined arguments
  4985. are:
  4986. * Deflate: `level` - Compression level, `0`-`9` or `nil`.
  4987. * `minetest.decompress(compressed_data, method, ...)`: returns data
  4988. * Decompress a string of data (using ZLib).
  4989. * See documentation on `minetest.compress()` for supported compression
  4990. methods.
  4991. * `...` indicates method-specific arguments. Currently, no methods use this
  4992. * `minetest.rgba(red, green, blue[, alpha])`: returns a string
  4993. * Each argument is a 8 Bit unsigned integer
  4994. * Returns the ColorString from rgb or rgba values
  4995. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
  4996. * `minetest.encode_base64(string)`: returns string encoded in base64
  4997. * Encodes a string in base64.
  4998. * `minetest.decode_base64(string)`: returns string or nil on failure
  4999. * Padding characters are only supported starting at version 5.4.0, where
  5000. 5.5.0 and newer perform proper checks.
  5001. * Decodes a string encoded in base64.
  5002. * `minetest.is_protected(pos, name)`: returns boolean
  5003. * Returning `true` restricts the player `name` from modifying (i.e. digging,
  5004. placing) the node at position `pos`.
  5005. * `name` will be `""` for non-players or unknown players.
  5006. * This function should be overridden by protection mods. It is highly
  5007. recommended to grant access to players with the `protection_bypass` privilege.
  5008. * Cache and call the old version of this function if the position is
  5009. not protected by the mod. This will allow using multiple protection mods.
  5010. * Example:
  5011. local old_is_protected = minetest.is_protected
  5012. function minetest.is_protected(pos, name)
  5013. if mymod:position_protected_from(pos, name) then
  5014. return true
  5015. end
  5016. return old_is_protected(pos, name)
  5017. end
  5018. * `minetest.record_protection_violation(pos, name)`
  5019. * This function calls functions registered with
  5020. `minetest.register_on_protection_violation`.
  5021. * `minetest.is_creative_enabled(name)`: returns boolean
  5022. * Returning `true` means that Creative Mode is enabled for player `name`.
  5023. * `name` will be `""` for non-players or if the player is unknown.
  5024. * This function should be overridden by Creative Mode-related mods to
  5025. implement a per-player Creative Mode.
  5026. * By default, this function returns `true` if the setting
  5027. `creative_mode` is `true` and `false` otherwise.
  5028. * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
  5029. * Returns the position of the first node that `player_name` may not modify
  5030. in the specified cuboid between `pos1` and `pos2`.
  5031. * Returns `false` if no protections were found.
  5032. * Applies `is_protected()` to a 3D lattice of points in the defined volume.
  5033. The points are spaced evenly throughout the volume and have a spacing
  5034. similar to, but no larger than, `interval`.
  5035. * All corners and edges of the defined volume are checked.
  5036. * `interval` defaults to 4.
  5037. * `interval` should be carefully chosen and maximised to avoid an excessive
  5038. number of points being checked.
  5039. * Like `minetest.is_protected`, this function may be extended or
  5040. overwritten by mods to provide a faster implementation to check the
  5041. cuboid for intersections.
  5042. * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
  5043. orient_flags, prevent_after_place])`
  5044. * Attempt to predict the desired orientation of the facedir-capable node
  5045. defined by `itemstack`, and place it accordingly (on-wall, on the floor,
  5046. or hanging from the ceiling).
  5047. * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
  5048. stacks are handled normally.
  5049. * `orient_flags`: Optional table containing extra tweaks to the placement code:
  5050. * `invert_wall`: if `true`, place wall-orientation on the ground and
  5051. ground-orientation on the wall.
  5052. * `force_wall` : if `true`, always place the node in wall orientation.
  5053. * `force_ceiling`: if `true`, always place on the ceiling.
  5054. * `force_floor`: if `true`, always place the node on the floor.
  5055. * `force_facedir`: if `true`, forcefully reset the facedir to north
  5056. when placing on the floor or ceiling.
  5057. * The first four options are mutually-exclusive; the last in the list
  5058. takes precedence over the first.
  5059. * `prevent_after_place` is directly passed to `minetest.item_place_node`
  5060. * Returns the new itemstack after placement
  5061. * `minetest.rotate_node(itemstack, placer, pointed_thing)`
  5062. * calls `rotate_and_place()` with `infinitestacks` set according to the state
  5063. of the creative mode setting, checks for "sneak" to set the `invert_wall`
  5064. parameter and `prevent_after_place` set to `true`.
  5065. * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
  5066. tool_capabilities, dir, distance, damage)`
  5067. * Returns the amount of knockback applied on the punched player.
  5068. * Arguments are equivalent to `register_on_punchplayer`, except the following:
  5069. * `distance`: distance between puncher and punched player
  5070. * This function can be overriden by mods that wish to modify this behaviour.
  5071. * You may want to cache and call the old function to allow multiple mods to
  5072. change knockback behaviour.
  5073. * `minetest.forceload_block(pos[, transient])`
  5074. * forceloads the position `pos`.
  5075. * returns `true` if area could be forceloaded
  5076. * If `transient` is `false` or absent, the forceload will be persistent
  5077. (saved between server runs). If `true`, the forceload will be transient
  5078. (not saved between server runs).
  5079. * `minetest.forceload_free_block(pos[, transient])`
  5080. * stops forceloading the position `pos`
  5081. * If `transient` is `false` or absent, frees a persistent forceload.
  5082. If `true`, frees a transient forceload.
  5083. * `minetest.compare_block_status(pos, condition)`
  5084. * Checks whether the mapblock at positition `pos` is in the wanted condition.
  5085. * `condition` may be one of the following values:
  5086. * `"unknown"`: not in memory
  5087. * `"emerging"`: in the queue for loading from disk or generating
  5088. * `"loaded"`: in memory but inactive (no ABMs are executed)
  5089. * `"active"`: in memory and active
  5090. * Other values are reserved for future functionality extensions
  5091. * Return value, the comparison status:
  5092. * `false`: Mapblock does not fulfil the wanted condition
  5093. * `true`: Mapblock meets the requirement
  5094. * `nil`: Unsupported `condition` value
  5095. * `minetest.request_insecure_environment()`: returns an environment containing
  5096. insecure functions if the calling mod has been listed as trusted in the
  5097. `secure.trusted_mods` setting or security is disabled, otherwise returns
  5098. `nil`.
  5099. * Only works at init time and must be called from the mod's main scope
  5100. (ie: the init.lua of the mod, not from another Lua file or within a function).
  5101. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
  5102. IT IN A LOCAL VARIABLE!**
  5103. * `minetest.global_exists(name)`
  5104. * Checks if a global variable has been set, without triggering a warning.
  5105. Global objects
  5106. --------------
  5107. * `minetest.env`: `EnvRef` of the server environment and world.
  5108. * Any function in the minetest namespace can be called using the syntax
  5109. `minetest.env:somefunction(somearguments)`
  5110. instead of `minetest.somefunction(somearguments)`
  5111. * Deprecated, but support is not to be dropped soon
  5112. Global tables
  5113. -------------
  5114. ### Registered definition tables
  5115. * `minetest.registered_items`
  5116. * Map of registered items, indexed by name
  5117. * `minetest.registered_nodes`
  5118. * Map of registered node definitions, indexed by name
  5119. * `minetest.registered_craftitems`
  5120. * Map of registered craft item definitions, indexed by name
  5121. * `minetest.registered_tools`
  5122. * Map of registered tool definitions, indexed by name
  5123. * `minetest.registered_entities`
  5124. * Map of registered entity prototypes, indexed by name
  5125. * Values in this table may be modified directly.
  5126. Note: changes to initial properties will only affect entities spawned afterwards,
  5127. as they are only read when spawning.
  5128. * `minetest.object_refs`
  5129. * Map of object references, indexed by active object id
  5130. * `minetest.luaentities`
  5131. * Map of Lua entities, indexed by active object id
  5132. * `minetest.registered_abms`
  5133. * List of ABM definitions
  5134. * `minetest.registered_lbms`
  5135. * List of LBM definitions
  5136. * `minetest.registered_aliases`
  5137. * Map of registered aliases, indexed by name
  5138. * `minetest.registered_ores`
  5139. * Map of registered ore definitions, indexed by the `name` field.
  5140. * If `name` is nil, the key is the object handle returned by
  5141. `minetest.register_ore`.
  5142. * `minetest.registered_biomes`
  5143. * Map of registered biome definitions, indexed by the `name` field.
  5144. * If `name` is nil, the key is the object handle returned by
  5145. `minetest.register_biome`.
  5146. * `minetest.registered_decorations`
  5147. * Map of registered decoration definitions, indexed by the `name` field.
  5148. * If `name` is nil, the key is the object handle returned by
  5149. `minetest.register_decoration`.
  5150. * `minetest.registered_schematics`
  5151. * Map of registered schematic definitions, indexed by the `name` field.
  5152. * If `name` is nil, the key is the object handle returned by
  5153. `minetest.register_schematic`.
  5154. * `minetest.registered_chatcommands`
  5155. * Map of registered chat command definitions, indexed by name
  5156. * `minetest.registered_privileges`
  5157. * Map of registered privilege definitions, indexed by name
  5158. * Registered privileges can be modified directly in this table.
  5159. ### Registered callback tables
  5160. All callbacks registered with [Global callback registration functions] are added
  5161. to corresponding `minetest.registered_*` tables.
  5162. Class reference
  5163. ===============
  5164. Sorted alphabetically.
  5165. `AreaStore`
  5166. -----------
  5167. AreaStore is a data structure to calculate intersections of 3D cuboid volumes
  5168. and points. The `data` field (string) may be used to store and retrieve any
  5169. mod-relevant information to the specified area.
  5170. Despite its name, mods must take care of persisting AreaStore data. They may
  5171. use the provided load and write functions for this.
  5172. ### Methods
  5173. * `AreaStore(type_name)`
  5174. * Returns a new AreaStore instance
  5175. * `type_name`: optional, forces the internally used API.
  5176. * Possible values: `"LibSpatial"` (default).
  5177. * When other values are specified, or SpatialIndex is not available,
  5178. the custom Minetest functions are used.
  5179. * `get_area(id, include_corners, include_data)`
  5180. * Returns the area information about the specified ID.
  5181. * Returned values are either of these:
  5182. nil -- Area not found
  5183. true -- Without `include_corners` and `include_data`
  5184. {
  5185. min = pos, max = pos -- `include_corners == true`
  5186. data = string -- `include_data == true`
  5187. }
  5188. * `get_areas_for_pos(pos, include_corners, include_data)`
  5189. * Returns all areas as table, indexed by the area ID.
  5190. * Table values: see `get_area`.
  5191. * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
  5192. * Returns all areas that contain all nodes inside the area specified by`
  5193. `corner1 and `corner2` (inclusive).
  5194. * `accept_overlap`: if `true`, areas are returned that have nodes in
  5195. common (intersect) with the specified area.
  5196. * Returns the same values as `get_areas_for_pos`.
  5197. * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
  5198. * Returns the new area's ID, or nil if the insertion failed.
  5199. * The (inclusive) positions `corner1` and `corner2` describe the area.
  5200. * `data` is a string stored with the area.
  5201. * `id` (optional): will be used as the internal area ID if it is an unique
  5202. number between 0 and 2^32-2.
  5203. * `reserve(count)`
  5204. * Requires SpatialIndex, no-op function otherwise.
  5205. * Reserves resources for `count` many contained areas to improve
  5206. efficiency when working with many area entries. Additional areas can still
  5207. be inserted afterwards at the usual complexity.
  5208. * `remove_area(id)`: removes the area with the given id from the store, returns
  5209. success.
  5210. * `set_cache_params(params)`: sets params for the included prefiltering cache.
  5211. Calling invalidates the cache, so that its elements have to be newly
  5212. generated.
  5213. * `params` is a table with the following fields:
  5214. enabled = boolean, -- Whether to enable, default true
  5215. block_radius = int, -- The radius (in nodes) of the areas the cache
  5216. -- generates prefiltered lists for, minimum 16,
  5217. -- default 64
  5218. limit = int, -- The cache size, minimum 20, default 1000
  5219. * `to_string()`: Experimental. Returns area store serialized as a (binary)
  5220. string.
  5221. * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
  5222. a file.
  5223. * `from_string(str)`: Experimental. Deserializes string and loads it into the
  5224. AreaStore.
  5225. Returns success and, optionally, an error message.
  5226. * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
  5227. from a file.
  5228. `InvRef`
  5229. --------
  5230. An `InvRef` is a reference to an inventory.
  5231. ### Methods
  5232. * `is_empty(listname)`: return `true` if list is empty
  5233. * `get_size(listname)`: get size of a list
  5234. * `set_size(listname, size)`: set size of a list
  5235. * returns `false` on error (e.g. invalid `listname` or `size`)
  5236. * `get_width(listname)`: get width of a list
  5237. * `set_width(listname, width)`: set width of list; currently used for crafting
  5238. * `get_stack(listname, i)`: get a copy of stack index `i` in list
  5239. * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
  5240. * `get_list(listname)`: return full list (list of `ItemStack`s)
  5241. * `set_list(listname, list)`: set full list (size will not change)
  5242. * `get_lists()`: returns table that maps listnames to inventory lists
  5243. * `set_lists(lists)`: sets inventory lists (size will not change)
  5244. * `add_item(listname, stack)`: add item somewhere in list, returns leftover
  5245. `ItemStack`.
  5246. * `room_for_item(listname, stack):` returns `true` if the stack of items
  5247. can be fully added to the list
  5248. * `contains_item(listname, stack, [match_meta])`: returns `true` if
  5249. the stack of items can be fully taken from the list.
  5250. If `match_meta` is false, only the items' names are compared
  5251. (default: `false`).
  5252. * `remove_item(listname, stack)`: take as many items as specified from the
  5253. list, returns the items that were actually removed (as an `ItemStack`)
  5254. -- note that any item metadata is ignored, so attempting to remove a specific
  5255. unique item this way will likely remove the wrong one -- to do that use
  5256. `set_stack` with an empty `ItemStack`.
  5257. * `get_location()`: returns a location compatible to
  5258. `minetest.get_inventory(location)`.
  5259. * returns `{type="undefined"}` in case location is not known
  5260. ### Callbacks
  5261. Detached & nodemeta inventories provide the following callbacks for move actions:
  5262. #### Before
  5263. The `allow_*` callbacks return how many items can be moved.
  5264. * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
  5265. * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
  5266. * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
  5267. #### After
  5268. The `on_*` callbacks are called after the items have been placed in the inventories.
  5269. * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
  5270. * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
  5271. * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
  5272. #### Swapping
  5273. When a player tries to put an item to a place where another item is, the items are *swapped*.
  5274. This means that all callbacks will be called twice (once for each action).
  5275. `ItemStack`
  5276. -----------
  5277. An `ItemStack` is a stack of items.
  5278. It can be created via `ItemStack(x)`, where x is an `ItemStack`,
  5279. an itemstring, a table or `nil`.
  5280. ### Methods
  5281. * `is_empty()`: returns `true` if stack is empty.
  5282. * `get_name()`: returns item name (e.g. `"default:stone"`).
  5283. * `set_name(item_name)`: returns a boolean indicating whether the item was
  5284. cleared.
  5285. * `get_count()`: Returns number of items on the stack.
  5286. * `set_count(count)`: returns a boolean indicating whether the item was cleared
  5287. * `count`: number, unsigned 16 bit integer
  5288. * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
  5289. * `set_wear(wear)`: returns boolean indicating whether item was cleared
  5290. * `wear`: number, unsigned 16 bit integer
  5291. * `get_meta()`: returns ItemStackMetaRef. See section for more details
  5292. * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
  5293. stack).
  5294. * `set_metadata(metadata)`: (DEPRECATED) Returns true.
  5295. * `get_description()`: returns the description shown in inventory list tooltips.
  5296. * The engine uses this when showing item descriptions in tooltips.
  5297. * Fields for finding the description, in order:
  5298. * `description` in item metadata (See [Item Metadata].)
  5299. * `description` in item definition
  5300. * item name
  5301. * `get_short_description()`: returns the short description or nil.
  5302. * Unlike the description, this does not include new lines.
  5303. * Fields for finding the short description, in order:
  5304. * `short_description` in item metadata (See [Item Metadata].)
  5305. * `short_description` in item definition
  5306. * first line of the description (From item meta or def, see `get_description()`.)
  5307. * Returns nil if none of the above are set
  5308. * `clear()`: removes all items from the stack, making it empty.
  5309. * `replace(item)`: replace the contents of this stack.
  5310. * `item` can also be an itemstring or table.
  5311. * `to_string()`: returns the stack in itemstring form.
  5312. * `to_table()`: returns the stack in Lua table form.
  5313. * `get_stack_max()`: returns the maximum size of the stack (depends on the
  5314. item).
  5315. * `get_free_space()`: returns `get_stack_max() - get_count()`.
  5316. * `is_known()`: returns `true` if the item name refers to a defined item type.
  5317. * `get_definition()`: returns the item definition table.
  5318. * `get_tool_capabilities()`: returns the digging properties of the item,
  5319. or those of the hand if none are defined for this item type
  5320. * `add_wear(amount)`
  5321. * Increases wear by `amount` if the item is a tool, otherwise does nothing
  5322. * `amount`: number, integer
  5323. * `add_item(item)`: returns leftover `ItemStack`
  5324. * Put some item or stack onto this stack
  5325. * `item_fits(item)`: returns `true` if item or stack can be fully added to
  5326. this one.
  5327. * `take_item(n)`: returns taken `ItemStack`
  5328. * Take (and remove) up to `n` items from this stack
  5329. * `n`: number, default: `1`
  5330. * `peek_item(n)`: returns taken `ItemStack`
  5331. * Copy (don't remove) up to `n` items from this stack
  5332. * `n`: number, default: `1`
  5333. `ItemStackMetaRef`
  5334. ------------------
  5335. ItemStack metadata: reference extra data and functionality stored in a stack.
  5336. Can be obtained via `item:get_meta()`.
  5337. ### Methods
  5338. * All methods in MetaDataRef
  5339. * `set_tool_capabilities([tool_capabilities])`
  5340. * Overrides the item's tool capabilities
  5341. * A nil value will clear the override data and restore the original
  5342. behavior.
  5343. `MetaDataRef`
  5344. -------------
  5345. Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
  5346. and [`PlayerMetaRef`].
  5347. ### Methods
  5348. * `contains(key)`: Returns true if key present, otherwise false.
  5349. * Returns `nil` when the MetaData is inexistent.
  5350. * `get(key)`: Returns `nil` if key not present, else the stored string.
  5351. * `set_string(key, value)`: Value of `""` will delete the key.
  5352. * `get_string(key)`: Returns `""` if key not present.
  5353. * `set_int(key, value)`
  5354. * `get_int(key)`: Returns `0` if key not present.
  5355. * `set_float(key, value)`
  5356. * `get_float(key)`: Returns `0` if key not present.
  5357. * `to_table()`: returns `nil` or a table with keys:
  5358. * `fields`: key-value storage
  5359. * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
  5360. * `from_table(nil or {})`
  5361. * Any non-table value will clear the metadata
  5362. * See [Node Metadata] for an example
  5363. * returns `true` on success
  5364. * `equals(other)`
  5365. * returns `true` if this metadata has the same key-value pairs as `other`
  5366. `ModChannel`
  5367. ------------
  5368. An interface to use mod channels on client and server
  5369. ### Methods
  5370. * `leave()`: leave the mod channel.
  5371. * Server leaves channel `channel_name`.
  5372. * No more incoming or outgoing messages can be sent to this channel from
  5373. server mods.
  5374. * This invalidate all future object usage.
  5375. * Ensure you set mod_channel to nil after that to free Lua resources.
  5376. * `is_writeable()`: returns true if channel is writeable and mod can send over
  5377. it.
  5378. * `send_all(message)`: Send `message` though the mod channel.
  5379. * If mod channel is not writeable or invalid, message will be dropped.
  5380. * Message size is limited to 65535 characters by protocol.
  5381. `NodeMetaRef`
  5382. -------------
  5383. Node metadata: reference extra data and functionality stored in a node.
  5384. Can be obtained via `minetest.get_meta(pos)`.
  5385. ### Methods
  5386. * All methods in MetaDataRef
  5387. * `get_inventory()`: returns `InvRef`
  5388. * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
  5389. This will prevent them from being sent to the client. Note that the "private"
  5390. status will only be remembered if an associated key-value pair exists,
  5391. meaning it's best to call this when initializing all other meta (e.g.
  5392. `on_construct`).
  5393. `NodeTimerRef`
  5394. --------------
  5395. Node Timers: a high resolution persistent per-node timer.
  5396. Can be gotten via `minetest.get_node_timer(pos)`.
  5397. ### Methods
  5398. * `set(timeout,elapsed)`
  5399. * set a timer's state
  5400. * `timeout` is in seconds, and supports fractional values (0.1 etc)
  5401. * `elapsed` is in seconds, and supports fractional values (0.1 etc)
  5402. * will trigger the node's `on_timer` function after `(timeout - elapsed)`
  5403. seconds.
  5404. * `start(timeout)`
  5405. * start a timer
  5406. * equivalent to `set(timeout,0)`
  5407. * `stop()`
  5408. * stops the timer
  5409. * `get_timeout()`: returns current timeout in seconds
  5410. * if `timeout` equals `0`, timer is inactive
  5411. * `get_elapsed()`: returns current elapsed time in seconds
  5412. * the node's `on_timer` function will be called after `(timeout - elapsed)`
  5413. seconds.
  5414. * `is_started()`: returns boolean state of timer
  5415. * returns `true` if timer is started, otherwise `false`
  5416. `ObjectRef`
  5417. -----------
  5418. Moving things in the game are generally these.
  5419. This is basically a reference to a C++ `ServerActiveObject`.
  5420. ### Advice on handling `ObjectRefs`
  5421. When you receive an `ObjectRef` as a callback argument or from another API
  5422. function, it is possible to store the reference somewhere and keep it around.
  5423. It will keep functioning until the object is unloaded or removed.
  5424. However, doing this is **NOT** recommended as there is (intentionally) no method
  5425. to test if a previously acquired `ObjectRef` is still valid.
  5426. Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
  5427. Lua back to the engine.
  5428. Doing so is much less error-prone and you will never need to wonder if the
  5429. object you are working with still exists.
  5430. ### Methods
  5431. * `get_pos()`: returns `{x=num, y=num, z=num}`
  5432. * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
  5433. * `get_velocity()`: returns the velocity, a vector.
  5434. * `add_velocity(vel)`
  5435. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5436. * In comparison to using get_velocity, adding the velocity and then using
  5437. set_velocity, add_velocity is supposed to avoid synchronization problems.
  5438. Additionally, players also do not support set_velocity.
  5439. * If a player:
  5440. * Does not apply during free_move.
  5441. * Note that since the player speed is normalized at each move step,
  5442. increasing e.g. Y velocity beyond what would usually be achieved
  5443. (see: physics overrides) will cause existing X/Z velocity to be reduced.
  5444. * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
  5445. pressing the jump key (assuming default settings)
  5446. * `move_to(pos, continuous=false)`
  5447. * Does an interpolated move for Lua entities for visually smooth transitions.
  5448. * If `continuous` is true, the Lua entity will not be moved to the current
  5449. position before starting the interpolated move.
  5450. * For players this does the same as `set_pos`,`continuous` is ignored.
  5451. * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
  5452. * `puncher` = another `ObjectRef`,
  5453. * `time_from_last_punch` = time since last punch action of the puncher
  5454. * `direction`: can be `nil`
  5455. * `right_click(clicker)`; `clicker` is another `ObjectRef`
  5456. * `get_hp()`: returns number of health points
  5457. * `set_hp(hp, reason)`: set number of health points
  5458. * See reason in register_on_player_hpchange
  5459. * Is limited to the range of 0 ... 65535 (2^16 - 1)
  5460. * For players: HP are also limited by `hp_max` specified in the player's
  5461. object properties
  5462. * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
  5463. * `get_wield_list()`: returns the name of the inventory list the wielded item
  5464. is in.
  5465. * `get_wield_index()`: returns the index of the wielded item
  5466. * `get_wielded_item()`: returns an `ItemStack`
  5467. * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
  5468. successful.
  5469. * `set_armor_groups({group1=rating, group2=rating, ...})`
  5470. * `get_armor_groups()`: returns a table with the armor group ratings
  5471. * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
  5472. * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
  5473. * `frame_speed`: number, default: `15.0`
  5474. * `frame_blend`: number, default: `0.0`
  5475. * `frame_loop`: boolean, default: `true`
  5476. * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
  5477. `frame_loop`.
  5478. * `set_animation_frame_speed(frame_speed)`
  5479. * `frame_speed`: number, default: `15.0`
  5480. * `set_attach(parent[, bone, position, rotation, forced_visible])`
  5481. * `bone`: string. Default is `""`, the root bone
  5482. * `position`: `{x=num, y=num, z=num}`, relative, default `{x=0, y=0, z=0}`
  5483. * `rotation`: `{x=num, y=num, z=num}` = Rotation on each axis, in degrees.
  5484. Default `{x=0, y=0, z=0}`
  5485. * `forced_visible`: Boolean to control whether the attached entity
  5486. should appear in first person. Default `false`.
  5487. * This command may fail silently (do nothing) when it would result
  5488. in circular attachments.
  5489. * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
  5490. or nil if it isn't attached.
  5491. * `get_children()`: returns a list of ObjectRefs that are attached to the
  5492. object.
  5493. * `set_detach()`
  5494. * `set_bone_position([bone, position, rotation])`
  5495. * `bone`: string. Default is `""`, the root bone
  5496. * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
  5497. * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
  5498. * `get_bone_position(bone)`: returns position and rotation of the bone
  5499. * `set_properties(object property table)`
  5500. * `get_properties()`: returns object property table
  5501. * `is_player()`: returns true for players, false otherwise
  5502. * `get_nametag_attributes()`
  5503. * returns a table with the attributes of the nametag of an object
  5504. * {
  5505. text = "",
  5506. color = {a=0..255, r=0..255, g=0..255, b=0..255},
  5507. bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
  5508. }
  5509. * `set_nametag_attributes(attributes)`
  5510. * sets the attributes of the nametag of an object
  5511. * `attributes`:
  5512. {
  5513. text = "My Nametag",
  5514. color = ColorSpec,
  5515. -- ^ Text color
  5516. bgcolor = ColorSpec or false,
  5517. -- ^ Sets background color of nametag
  5518. -- `false` will cause the background to be set automatically based on user settings
  5519. -- Default: false
  5520. }
  5521. #### Lua entity only (no-op for other objects)
  5522. * `remove()`: remove object
  5523. * The object is removed after returning from Lua. However the `ObjectRef`
  5524. itself instantly becomes unusable with all further method calls having
  5525. no effect and returning `nil`.
  5526. * `set_velocity(vel)`
  5527. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5528. * `set_acceleration(acc)`
  5529. * `acc` is a vector
  5530. * `get_acceleration()`: returns the acceleration, a vector
  5531. * `set_rotation(rot)`
  5532. * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
  5533. and Z is roll (bank).
  5534. * `get_rotation()`: returns the rotation, a vector (radians)
  5535. * `set_yaw(yaw)`: sets the yaw in radians (heading).
  5536. * `get_yaw()`: returns number in radians
  5537. * `set_texture_mod(mod)`
  5538. * Set a texture modifier to the base texture, for sprites and meshes.
  5539. * When calling `set_texture_mod` again, the previous one is discarded.
  5540. * `mod` the texture modifier. See [Texture modifiers].
  5541. * `get_texture_mod()` returns current texture modifier
  5542. * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
  5543. * Specifies and starts a sprite animation
  5544. * Animations iterate along the frame `y` position.
  5545. * `start_frame`: {x=column number, y=row number}, the coordinate of the
  5546. first frame, default: `{x=0, y=0}`
  5547. * `num_frames`: Total frames in the texture, default: `1`
  5548. * `framelength`: Time per animated frame in seconds, default: `0.2`
  5549. * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
  5550. position according to the view direction. default: `false`.
  5551. * First column: subject facing the camera
  5552. * Second column: subject looking to the left
  5553. * Third column: subject backing the camera
  5554. * Fourth column: subject looking to the right
  5555. * Fifth column: subject viewed from above
  5556. * Sixth column: subject viewed from below
  5557. * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
  5558. * `get_luaentity()`
  5559. #### Player only (no-op for other objects)
  5560. * `get_player_name()`: returns `""` if is not a player
  5561. * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
  5562. table {x, y, z} representing the player's instantaneous velocity in nodes/s
  5563. * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
  5564. * `get_look_dir()`: get camera direction as a unit vector
  5565. * `get_look_vertical()`: pitch in radians
  5566. * Angle ranges between -pi/2 and pi/2, which are straight up and down
  5567. respectively.
  5568. * `get_look_horizontal()`: yaw in radians
  5569. * Angle is counter-clockwise from the +z direction.
  5570. * `set_look_vertical(radians)`: sets look pitch
  5571. * radians: Angle from looking forward, where positive is downwards.
  5572. * `set_look_horizontal(radians)`: sets look yaw
  5573. * radians: Angle from the +z direction, where positive is counter-clockwise.
  5574. * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
  5575. `get_look_vertical`.
  5576. * Angle ranges between -pi/2 and pi/2, which are straight down and up
  5577. respectively.
  5578. * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
  5579. `get_look_horizontal`.
  5580. * Angle is counter-clockwise from the +x direction.
  5581. * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
  5582. `set_look_vertical`.
  5583. * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
  5584. `set_look_horizontal`.
  5585. * `get_breath()`: returns player's breath
  5586. * `set_breath(value)`: sets player's breath
  5587. * values:
  5588. * `0`: player is drowning
  5589. * max: bubbles bar is not shown
  5590. * See [Object properties] for more information
  5591. * Is limited to range 0 ... 65535 (2^16 - 1)
  5592. * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
  5593. * `fov`: FOV value.
  5594. * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
  5595. Defaults to `false`.
  5596. * `transition_time`: If defined, enables smooth FOV transition.
  5597. Interpreted as the time (in seconds) to reach target FOV.
  5598. If set to 0, FOV change is instantaneous. Defaults to 0.
  5599. * Set `fov` to 0 to clear FOV override.
  5600. * `get_fov()`: Returns the following:
  5601. * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
  5602. * Boolean indicating whether the FOV value is a multiplier.
  5603. * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
  5604. * `set_attribute(attribute, value)`: DEPRECATED, use get_meta() instead
  5605. * Sets an extra attribute with value on player.
  5606. * `value` must be a string, or a number which will be converted to a
  5607. string.
  5608. * If `value` is `nil`, remove attribute from player.
  5609. * `get_attribute(attribute)`: DEPRECATED, use get_meta() instead
  5610. * Returns value (a string) for extra attribute.
  5611. * Returns `nil` if no attribute found.
  5612. * `get_meta()`: Returns a PlayerMetaRef.
  5613. * `set_inventory_formspec(formspec)`
  5614. * Redefine player's inventory form
  5615. * Should usually be called in `on_joinplayer`
  5616. * If `formspec` is `""`, the player's inventory is disabled.
  5617. * `get_inventory_formspec()`: returns a formspec string
  5618. * `set_formspec_prepend(formspec)`:
  5619. * the formspec string will be added to every formspec shown to the user,
  5620. except for those with a no_prepend[] tag.
  5621. * This should be used to set style elements such as background[] and
  5622. bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
  5623. * Only affects formspecs shown after this is called.
  5624. * `get_formspec_prepend(formspec)`: returns a formspec string.
  5625. * `get_player_control()`: returns table with player pressed keys
  5626. * The table consists of fields with the following boolean values
  5627. representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
  5628. `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
  5629. * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
  5630. and exist only to preserve backwards compatibility.
  5631. * Returns an empty table `{}` if the object is not a player.
  5632. * `get_player_control_bits()`: returns integer with bit packed player pressed
  5633. keys.
  5634. * Bits:
  5635. * 0 - up
  5636. * 1 - down
  5637. * 2 - left
  5638. * 3 - right
  5639. * 4 - jump
  5640. * 5 - aux1
  5641. * 6 - sneak
  5642. * 7 - dig
  5643. * 8 - place
  5644. * 9 - zoom
  5645. * Returns `0` (no bits set) if the object is not a player.
  5646. * `set_physics_override(override_table)`
  5647. * `override_table` is a table with the following fields:
  5648. * `speed`: multiplier to default walking speed value (default: `1`)
  5649. * `jump`: multiplier to default jump value (default: `1`)
  5650. * `gravity`: multiplier to default gravity value (default: `1`)
  5651. * `sneak`: whether player can sneak (default: `true`)
  5652. * `sneak_glitch`: whether player can use the new move code replications
  5653. of the old sneak side-effects: sneak ladders and 2 node sneak jump
  5654. (default: `false`)
  5655. * `new_move`: use new move/sneak code. When `false` the exact old code
  5656. is used for the specific old sneak behaviour (default: `true`)
  5657. * `get_physics_override()`: returns the table given to `set_physics_override`
  5658. * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
  5659. number on success
  5660. * `hud_remove(id)`: remove the HUD element of the specified id
  5661. * `hud_change(id, stat, value)`: change a value of a previously added HUD
  5662. element.
  5663. * element `stat` values:
  5664. `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
  5665. * `hud_get(id)`: gets the HUD element definition structure of the specified ID
  5666. * `hud_set_flags(flags)`: sets specified HUD flags of player.
  5667. * `flags`: A table with the following fields set to boolean values
  5668. * `hotbar`
  5669. * `healthbar`
  5670. * `crosshair`
  5671. * `wielditem`
  5672. * `breathbar`
  5673. * `minimap`: Modifies the client's permission to view the minimap.
  5674. The client may locally elect to not view the minimap.
  5675. * `minimap_radar`: is only usable when `minimap` is true
  5676. * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
  5677. This includes map seed, player position, look direction, the pointed node and block bounds.
  5678. Does not affect players with the `debug` privilege.
  5679. * If a flag equals `nil`, the flag is not modified
  5680. * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
  5681. * See `hud_set_flags` for a list of flags that can be toggled.
  5682. * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
  5683. * `count`: number of items, must be between `1` and `32`
  5684. * `hud_get_hotbar_itemcount`: returns number of visible items
  5685. * `hud_set_hotbar_image(texturename)`
  5686. * sets background image for hotbar
  5687. * `hud_get_hotbar_image`: returns texturename
  5688. * `hud_set_hotbar_selected_image(texturename)`
  5689. * sets image for selected item of hotbar
  5690. * `hud_get_hotbar_selected_image`: returns texturename
  5691. * `set_minimap_modes({mode, mode, ...}, selected_mode)`
  5692. * Overrides the available minimap modes (and toggle order), and changes the
  5693. selected mode.
  5694. * `mode` is a table consisting of up to four fields:
  5695. * `type`: Available type:
  5696. * `off`: Minimap off
  5697. * `surface`: Minimap in surface mode
  5698. * `radar`: Minimap in radar mode
  5699. * `texture`: Texture to be displayed instead of terrain map
  5700. (texture is centered around 0,0 and can be scaled).
  5701. Texture size is limited to 512 x 512 pixel.
  5702. * `label`: Optional label to display on minimap mode toggle
  5703. The translation must be handled within the mod.
  5704. * `size`: Sidelength or diameter, in number of nodes, of the terrain
  5705. displayed in minimap
  5706. * `texture`: Only for texture type, name of the texture to display
  5707. * `scale`: Only for texture type, scale of the texture map in nodes per
  5708. pixel (for example a `scale` of 2 means each pixel represents a 2x2
  5709. nodes square)
  5710. * `selected_mode` is the mode index to be selected after modes have been changed
  5711. (0 is the first mode).
  5712. * `set_sky(sky_parameters)`
  5713. * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
  5714. whether `set_sky` accepts this format. Check the legacy format otherwise.
  5715. * Passing no arguments resets the sky to its default values.
  5716. * `sky_parameters` is a table with the following optional fields:
  5717. * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
  5718. (default: `#ffffff`)
  5719. * `type`: Available types:
  5720. * `"regular"`: Uses 0 textures, `base_color` ignored
  5721. * `"skybox"`: Uses 6 textures, `base_color` used as fog.
  5722. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
  5723. (default: `"regular"`)
  5724. * `textures`: A table containing up to six textures in the following
  5725. order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
  5726. * `clouds`: Boolean for whether clouds appear. (default: `true`)
  5727. * `sky_color`: A table used in `"regular"` type only, containing the
  5728. following values (alpha is ignored):
  5729. * `day_sky`: ColorSpec, for the top half of the sky during the day.
  5730. (default: `#61b5f5`)
  5731. * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
  5732. (default: `#90d3f6`)
  5733. * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
  5734. (default: `#b4bafa`)
  5735. The resulting sky color will be a darkened version of the ColorSpec.
  5736. Warning: The darkening of the ColorSpec is subject to change.
  5737. * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
  5738. (default: `#bac1f0`)
  5739. The resulting sky color will be a darkened version of the ColorSpec.
  5740. Warning: The darkening of the ColorSpec is subject to change.
  5741. * `night_sky`: ColorSpec, for the top half of the sky during the night.
  5742. (default: `#006bff`)
  5743. The resulting sky color will be a dark version of the ColorSpec.
  5744. Warning: The darkening of the ColorSpec is subject to change.
  5745. * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
  5746. (default: `#4090ff`)
  5747. The resulting sky color will be a dark version of the ColorSpec.
  5748. Warning: The darkening of the ColorSpec is subject to change.
  5749. * `indoors`: ColorSpec, for when you're either indoors or underground.
  5750. (default: `#646464`)
  5751. * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
  5752. at sunrise and sunset. (default: `#f47d1d`)
  5753. * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
  5754. at sunrise and sunset. (default: `#7f99cc`)
  5755. * `fog_tint_type`: string, changes which mode the directional fog
  5756. abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
  5757. `"default"` uses the classic Minetest sun and moon tinting.
  5758. Will use tonemaps, if set to `"default"`. (default: `"default"`)
  5759. * `set_sky(base_color, type, {texture names}, clouds)`
  5760. * Deprecated. Use `set_sky(sky_parameters)`
  5761. * `base_color`: ColorSpec, defaults to white
  5762. * `type`: Available types:
  5763. * `"regular"`: Uses 0 textures, `bgcolor` ignored
  5764. * `"skybox"`: Uses 6 textures, `bgcolor` used
  5765. * `"plain"`: Uses 0 textures, `bgcolor` used
  5766. * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
  5767. `"plain"` custom skyboxes (default: `true`)
  5768. * `get_sky(as_table)`:
  5769. * `as_table`: boolean that determines whether the deprecated version of this
  5770. function is being used.
  5771. * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
  5772. * Deprecated: `false` or `nil` returns base_color, type, table of textures,
  5773. clouds.
  5774. * `get_sky_color()`:
  5775. * Deprecated: Use `get_sky(as_table)` instead.
  5776. * returns a table with the `sky_color` parameters as in `set_sky`.
  5777. * `set_sun(sun_parameters)`:
  5778. * Passing no arguments resets the sun to its default values.
  5779. * `sun_parameters` is a table with the following optional fields:
  5780. * `visible`: Boolean for whether the sun is visible.
  5781. (default: `true`)
  5782. * `texture`: A regular texture for the sun. Setting to `""`
  5783. will re-enable the mesh sun. (default: "sun.png", if it exists)
  5784. * `tonemap`: A 512x1 texture containing the tonemap for the sun
  5785. (default: `"sun_tonemap.png"`)
  5786. * `sunrise`: A regular texture for the sunrise texture.
  5787. (default: `"sunrisebg.png"`)
  5788. * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
  5789. (default: `true`)
  5790. * `scale`: Float controlling the overall size of the sun. (default: `1`)
  5791. * `get_sun()`: returns a table with the current sun parameters as in
  5792. `set_sun`.
  5793. * `set_moon(moon_parameters)`:
  5794. * Passing no arguments resets the moon to its default values.
  5795. * `moon_parameters` is a table with the following optional fields:
  5796. * `visible`: Boolean for whether the moon is visible.
  5797. (default: `true`)
  5798. * `texture`: A regular texture for the moon. Setting to `""`
  5799. will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
  5800. Note: Relative to the sun, the moon texture is rotated by 180°.
  5801. You can use the `^[transformR180` texture modifier to achieve the same orientation.
  5802. * `tonemap`: A 512x1 texture containing the tonemap for the moon
  5803. (default: `"moon_tonemap.png"`)
  5804. * `scale`: Float controlling the overall size of the moon (default: `1`)
  5805. * `get_moon()`: returns a table with the current moon parameters as in
  5806. `set_moon`.
  5807. * `set_stars(star_parameters)`:
  5808. * Passing no arguments resets stars to their default values.
  5809. * `star_parameters` is a table with the following optional fields:
  5810. * `visible`: Boolean for whether the stars are visible.
  5811. (default: `true`)
  5812. * `count`: Integer number to set the number of stars in
  5813. the skybox. Only applies to `"skybox"` and `"regular"` sky types.
  5814. (default: `1000`)
  5815. * `star_color`: ColorSpec, sets the colors of the stars,
  5816. alpha channel is used to set overall star brightness.
  5817. (default: `#ebebff69`)
  5818. * `scale`: Float controlling the overall size of the stars (default: `1`)
  5819. * `get_stars()`: returns a table with the current stars parameters as in
  5820. `set_stars`.
  5821. * `set_clouds(cloud_parameters)`: set cloud parameters
  5822. * Passing no arguments resets clouds to their default values.
  5823. * `cloud_parameters` is a table with the following optional fields:
  5824. * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
  5825. * `color`: basic cloud color with alpha channel, ColorSpec
  5826. (default `#fff0f0e5`).
  5827. * `ambient`: cloud color lower bound, use for a "glow at night" effect.
  5828. ColorSpec (alpha ignored, default `#000000`)
  5829. * `height`: cloud height, i.e. y of cloud base (default per conf,
  5830. usually `120`)
  5831. * `thickness`: cloud thickness in nodes (default `16`)
  5832. * `speed`: 2D cloud speed + direction in nodes per second
  5833. (default `{x=0, z=-2}`).
  5834. * `get_clouds()`: returns a table with the current cloud parameters as in
  5835. `set_clouds`.
  5836. * `override_day_night_ratio(ratio or nil)`
  5837. * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
  5838. amount.
  5839. * `nil`: Disables override, defaulting to sunlight based on day-night cycle
  5840. * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
  5841. * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
  5842. set animation for player model in third person view.
  5843. * Every animation equals to a `{x=starting frame, y=ending frame}` table.
  5844. * `frame_speed` sets the animations frame speed. Default is 30.
  5845. * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
  5846. `frame_speed`.
  5847. * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
  5848. camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
  5849. * in first person view
  5850. * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
  5851. * `get_eye_offset()`: returns first and third person offsets.
  5852. * `send_mapblock(blockpos)`:
  5853. * Sends a server-side loaded mapblock to the player.
  5854. * Returns `false` if failed.
  5855. * Resource intensive - use sparsely
  5856. * To get blockpos, integer divide pos by 16
  5857. * `set_lighting(light_definition)`: sets lighting for the player
  5858. * `light_definition` is a table with the following optional fields:
  5859. * `shadows` is a table that controls ambient shadows
  5860. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
  5861. * `get_lighting()`: returns the current state of lighting for the player.
  5862. * Result is a table with the same fields as `light_definition` in `set_lighting`.
  5863. `PcgRandom`
  5864. -----------
  5865. A 32-bit pseudorandom number generator.
  5866. Uses PCG32, an algorithm of the permuted congruential generator family,
  5867. offering very strong randomness.
  5868. It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
  5869. ### Methods
  5870. * `next()`: return next integer random number [`-2147483648`...`2147483647`]
  5871. * `next(min, max)`: return next integer random number [`min`...`max`]
  5872. * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
  5873. random number [`min`...`max`].
  5874. * This is only a rough approximation of a normal distribution with:
  5875. * `mean = (max - min) / 2`, and
  5876. * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
  5877. * Increasing `num_trials` improves accuracy of the approximation
  5878. `PerlinNoise`
  5879. -------------
  5880. A perlin noise generator.
  5881. It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
  5882. For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
  5883. plus the world seed, to create world-specific noise.
  5884. `PerlinNoise(noiseparams)`
  5885. `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
  5886. `minetest.get_perlin(noiseparams)`
  5887. `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
  5888. ### Methods
  5889. * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
  5890. * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
  5891. `PerlinNoiseMap`
  5892. ----------------
  5893. A fast, bulk perlin noise generator.
  5894. It can be created via `PerlinNoiseMap(noiseparams, size)` or
  5895. `minetest.get_perlin_map(noiseparams, size)`.
  5896. For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
  5897. plus the world seed, to create world-specific noise.
  5898. Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
  5899. for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
  5900. `nil` is returned).
  5901. For each of the functions with an optional `buffer` parameter: If `buffer` is
  5902. not nil, this table will be used to store the result instead of creating a new
  5903. table.
  5904. ### Methods
  5905. * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
  5906. with values starting at `pos={x=,y=}`
  5907. * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
  5908. 3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
  5909. * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
  5910. array of 2D noise with values starting at `pos={x=,y=}`
  5911. * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
  5912. * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
  5913. is stored internally.
  5914. * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
  5915. is stored internally.
  5916. * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
  5917. returns a slice of the most recently computed noise results. The result slice
  5918. begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
  5919. E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
  5920. offset y = 20:
  5921. `noisevals = noise:get_map_slice({y=20}, {y=2})`
  5922. It is important to note that `slice_offset` offset coordinates begin at 1,
  5923. and are relative to the starting position of the most recently calculated
  5924. noise.
  5925. To grab a single vertical column of noise starting at map coordinates
  5926. x = 1023, y=1000, z = 1000:
  5927. `noise:calc_3d_map({x=1000, y=1000, z=1000})`
  5928. `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
  5929. `PlayerMetaRef`
  5930. ---------------
  5931. Player metadata.
  5932. Uses the same method of storage as the deprecated player attribute API, so
  5933. data there will also be in player meta.
  5934. Can be obtained using `player:get_meta()`.
  5935. ### Methods
  5936. * All methods in MetaDataRef
  5937. `PseudoRandom`
  5938. --------------
  5939. A 16-bit pseudorandom number generator.
  5940. Uses a well-known LCG algorithm introduced by K&R.
  5941. It can be created via `PseudoRandom(seed)`.
  5942. ### Methods
  5943. * `next()`: return next integer random number [`0`...`32767`]
  5944. * `next(min, max)`: return next integer random number [`min`...`max`]
  5945. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
  5946. due to the simple implementation making bad distribution otherwise.
  5947. `Raycast`
  5948. ---------
  5949. A raycast on the map. It works with selection boxes.
  5950. Can be used as an iterator in a for loop as:
  5951. local ray = Raycast(...)
  5952. for pointed_thing in ray do
  5953. ...
  5954. end
  5955. The map is loaded as the ray advances. If the map is modified after the
  5956. `Raycast` is created, the changes may or may not have an effect on the object.
  5957. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  5958. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  5959. * `pos1`: start of the ray
  5960. * `pos2`: end of the ray
  5961. * `objects`: if false, only nodes will be returned. Default is true.
  5962. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  5963. returned. Default is false.
  5964. ### Methods
  5965. * `next()`: returns a `pointed_thing` with exact pointing location
  5966. * Returns the next thing pointed by the ray or nil.
  5967. `SecureRandom`
  5968. --------------
  5969. Interface for the operating system's crypto-secure PRNG.
  5970. It can be created via `SecureRandom()`. The constructor returns nil if a
  5971. secure random device cannot be found on the system.
  5972. ### Methods
  5973. * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
  5974. random bytes, as a string.
  5975. `Settings`
  5976. ----------
  5977. An interface to read config files in the format of `minetest.conf`.
  5978. It can be created via `Settings(filename)`.
  5979. ### Methods
  5980. * `get(key)`: returns a value
  5981. * `get_bool(key, [default])`: returns a boolean
  5982. * `default` is the value returned if `key` is not found.
  5983. * Returns `nil` if `key` is not found and `default` not specified.
  5984. * `get_np_group(key)`: returns a NoiseParams table
  5985. * `get_flags(key)`:
  5986. * Returns `{flag = true/false, ...}` according to the set flags.
  5987. * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
  5988. flags like `mgv5_spflags`.
  5989. * `set(key, value)`
  5990. * Setting names can't contain whitespace or any of `="{}#`.
  5991. * Setting values can't contain the sequence `\n"""`.
  5992. * Setting names starting with "secure." can't be set on the main settings
  5993. object (`minetest.settings`).
  5994. * `set_bool(key, value)`
  5995. * See documentation for set() above.
  5996. * `set_np_group(key, value)`
  5997. * `value` is a NoiseParams table.
  5998. * Also, see documentation for set() above.
  5999. * `remove(key)`: returns a boolean (`true` for success)
  6000. * `get_names()`: returns `{key1,...}`
  6001. * `write()`: returns a boolean (`true` for success)
  6002. * Writes changes to file.
  6003. * `to_table()`: returns `{[key1]=value1,...}`
  6004. ### Format
  6005. The settings have the format `key = value`. Example:
  6006. foo = example text
  6007. bar = """
  6008. Multiline
  6009. value
  6010. """
  6011. `StorageRef`
  6012. ------------
  6013. Mod metadata: per mod metadata, saved automatically.
  6014. Can be obtained via `minetest.get_mod_storage()` during load time.
  6015. WARNING: This storage backend is incaptable to save raw binary data due
  6016. to restrictions of JSON.
  6017. ### Methods
  6018. * All methods in MetaDataRef
  6019. Definition tables
  6020. =================
  6021. Object properties
  6022. -----------------
  6023. Used by `ObjectRef` methods. Part of an Entity definition.
  6024. These properties are not persistent, but are applied automatically to the
  6025. corresponding Lua entity using the given registration fields.
  6026. Player properties need to be saved manually.
  6027. {
  6028. hp_max = 1,
  6029. -- For players only. Defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
  6030. breath_max = 0,
  6031. -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
  6032. zoom_fov = 0.0,
  6033. -- For players only. Zoom FOV in degrees.
  6034. -- Note that zoom loads and/or generates world beyond the server's
  6035. -- maximum send and generate distances, so acts like a telescope.
  6036. -- Smaller zoom_fov values increase the distance loaded/generated.
  6037. -- Defaults to 15 in creative mode, 0 in survival mode.
  6038. -- zoom_fov = 0 disables zooming for the player.
  6039. eye_height = 1.625,
  6040. -- For players only. Camera height above feet position in nodes.
  6041. -- Defaults to 1.625.
  6042. physical = true,
  6043. -- Collide with `walkable` nodes.
  6044. collide_with_objects = true,
  6045. -- Collide with other objects if physical = true
  6046. collisionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5}, -- Default
  6047. selectionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
  6048. -- Selection box uses collision box dimensions when not set.
  6049. -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
  6050. -- object position.
  6051. pointable = true,
  6052. -- Overrides selection box when false
  6053. visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
  6054. -- "cube" is a node-sized cube.
  6055. -- "sprite" is a flat texture always facing the player.
  6056. -- "upright_sprite" is a vertical flat texture.
  6057. -- "mesh" uses the defined mesh model.
  6058. -- "wielditem" is used for dropped items.
  6059. -- (see builtin/game/item_entity.lua).
  6060. -- For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
  6061. -- If the item has a 'wield_image' the object will be an extrusion of
  6062. -- that, otherwise:
  6063. -- If 'itemname' is a cubic node or nodebox the object will appear
  6064. -- identical to 'itemname'.
  6065. -- If 'itemname' is a plantlike node the object will be an extrusion
  6066. -- of its texture.
  6067. -- Otherwise for non-node items, the object will be an extrusion of
  6068. -- 'inventory_image'.
  6069. -- If 'itemname' contains a ColorString or palette index (e.g. from
  6070. -- `minetest.itemstring_with_palette()`), the entity will inherit the color.
  6071. -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
  6072. visual_size = {x = 1, y = 1, z = 1},
  6073. -- Multipliers for the visual size. If `z` is not specified, `x` will be used
  6074. -- to scale the entity along both horizontal axes.
  6075. mesh = "model.obj",
  6076. -- File name of mesh when using "mesh" visual
  6077. textures = {},
  6078. -- Number of required textures depends on visual.
  6079. -- "cube" uses 6 textures just like a node, but all 6 must be defined.
  6080. -- "sprite" uses 1 texture.
  6081. -- "upright_sprite" uses 2 textures: {front, back}.
  6082. -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
  6083. -- "mesh" requires one texture for each mesh buffer/material (in order)
  6084. colors = {},
  6085. -- Number of required colors depends on visual
  6086. use_texture_alpha = false,
  6087. -- Use texture's alpha channel.
  6088. -- Excludes "upright_sprite" and "wielditem".
  6089. -- Note: currently causes visual issues when viewed through other
  6090. -- semi-transparent materials such as water.
  6091. spritediv = {x = 1, y = 1},
  6092. -- Used with spritesheet textures for animation and/or frame selection
  6093. -- according to position relative to player.
  6094. -- Defines the number of columns and rows in the spritesheet:
  6095. -- {columns, rows}.
  6096. initial_sprite_basepos = {x = 0, y = 0},
  6097. -- Used with spritesheet textures.
  6098. -- Defines the {column, row} position of the initially used frame in the
  6099. -- spritesheet.
  6100. is_visible = true,
  6101. -- If false, object is invisible and can't be pointed.
  6102. makes_footstep_sound = false,
  6103. -- If true, is able to make footstep sounds of nodes
  6104. -- (see node sound definition for details).
  6105. automatic_rotate = 0,
  6106. -- Set constant rotation in radians per second, positive or negative.
  6107. -- Object rotates along the local Y-axis, and works with set_rotation.
  6108. -- Set to 0 to disable constant rotation.
  6109. stepheight = 0,
  6110. -- If positive number, object will climb upwards when it moves
  6111. -- horizontally against a `walkable` node, if the height difference
  6112. -- is within `stepheight`.
  6113. automatic_face_movement_dir = 0.0,
  6114. -- Automatically set yaw to movement direction, offset in degrees.
  6115. -- 'false' to disable.
  6116. automatic_face_movement_max_rotation_per_sec = -1,
  6117. -- Limit automatic rotation to this value in degrees per second.
  6118. -- No limit if value <= 0.
  6119. backface_culling = true,
  6120. -- Set to false to disable backface_culling for model
  6121. glow = 0,
  6122. -- Add this much extra lighting when calculating texture color.
  6123. -- Value < 0 disables light's effect on texture color.
  6124. -- For faking self-lighting, UI style entities, or programmatic coloring
  6125. -- in mods.
  6126. nametag = "",
  6127. -- The name to display on the head of the object. By default empty.
  6128. -- If the object is a player, a nil or empty nametag is replaced by the player's name.
  6129. -- For all other objects, a nil or empty string removes the nametag.
  6130. -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
  6131. nametag_color = <ColorSpec>,
  6132. -- Sets text color of nametag
  6133. nametag_bgcolor = <ColorSpec>,
  6134. -- Sets background color of nametag
  6135. -- `false` will cause the background to be set automatically based on user settings.
  6136. -- Default: false
  6137. infotext = "",
  6138. -- Same as infotext for nodes. Empty by default
  6139. static_save = true,
  6140. -- If false, never save this object statically. It will simply be
  6141. -- deleted when the block gets unloaded.
  6142. -- The get_staticdata() callback is never called then.
  6143. -- Defaults to 'true'.
  6144. damage_texture_modifier = "^[brighten",
  6145. -- Texture modifier to be applied for a short duration when object is hit
  6146. shaded = true,
  6147. -- Setting this to 'false' disables diffuse lighting of entity
  6148. show_on_minimap = false,
  6149. -- Defaults to true for players, false for other entities.
  6150. -- If set to true the entity will show as a marker on the minimap.
  6151. }
  6152. Entity definition
  6153. -----------------
  6154. Used by `minetest.register_entity`.
  6155. {
  6156. initial_properties = {
  6157. visual = "mesh",
  6158. mesh = "boats_boat.obj",
  6159. ...,
  6160. },
  6161. -- A table of object properties, see the `Object properties` section.
  6162. -- Object properties being read directly from the entity definition
  6163. -- table is deprecated. Define object properties in this
  6164. -- `initial_properties` table instead.
  6165. on_activate = function(self, staticdata, dtime_s),
  6166. on_step = function(self, dtime, moveresult),
  6167. -- Called every server step
  6168. -- dtime: Elapsed time
  6169. -- moveresult: Table with collision info (only available if physical=true)
  6170. on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir),
  6171. on_rightclick = function(self, clicker),
  6172. get_staticdata = function(self),
  6173. -- Called sometimes; the string returned is passed to on_activate when
  6174. -- the entity is re-activated from static state
  6175. _custom_field = whatever,
  6176. -- You can define arbitrary member variables here (see Item definition
  6177. -- for more info) by using a '_' prefix
  6178. }
  6179. Collision info passed to `on_step` (`moveresult` argument):
  6180. {
  6181. touching_ground = boolean,
  6182. collides = boolean,
  6183. standing_on_object = boolean,
  6184. collisions = {
  6185. {
  6186. type = string, -- "node" or "object",
  6187. axis = string, -- "x", "y" or "z"
  6188. node_pos = vector, -- if type is "node"
  6189. object = ObjectRef, -- if type is "object"
  6190. old_velocity = vector,
  6191. new_velocity = vector,
  6192. },
  6193. ...
  6194. }
  6195. -- `collisions` does not contain data of unloaded mapblock collisions
  6196. -- or when the velocity changes are negligibly small
  6197. }
  6198. ABM (ActiveBlockModifier) definition
  6199. ------------------------------------
  6200. Used by `minetest.register_abm`.
  6201. {
  6202. label = "Lava cooling",
  6203. -- Descriptive label for profiling purposes (optional).
  6204. -- Definitions with identical labels will be listed as one.
  6205. nodenames = {"default:lava_source"},
  6206. -- Apply `action` function to these nodes.
  6207. -- `group:groupname` can also be used here.
  6208. neighbors = {"default:water_source", "default:water_flowing"},
  6209. -- Only apply `action` to nodes that have one of, or any
  6210. -- combination of, these neighbors.
  6211. -- If left out or empty, any neighbor will do.
  6212. -- `group:groupname` can also be used here.
  6213. interval = 1.0,
  6214. -- Operation interval in seconds
  6215. chance = 1,
  6216. -- Chance of triggering `action` per-node per-interval is 1.0 / this
  6217. -- value
  6218. min_y = -32768,
  6219. max_y = 32767,
  6220. -- min and max height levels where ABM will be processed
  6221. -- can be used to reduce CPU usage
  6222. catch_up = true,
  6223. -- If true, catch-up behaviour is enabled: The `chance` value is
  6224. -- temporarily reduced when returning to an area to simulate time lost
  6225. -- by the area being unattended. Note that the `chance` value can often
  6226. -- be reduced to 1.
  6227. action = function(pos, node, active_object_count, active_object_count_wider),
  6228. -- Function triggered for each qualifying node.
  6229. -- `active_object_count` is number of active objects in the node's
  6230. -- mapblock.
  6231. -- `active_object_count_wider` is number of active objects in the node's
  6232. -- mapblock plus all 26 neighboring mapblocks. If any neighboring
  6233. -- mapblocks are unloaded an estmate is calculated for them based on
  6234. -- loaded mapblocks.
  6235. }
  6236. LBM (LoadingBlockModifier) definition
  6237. -------------------------------------
  6238. Used by `minetest.register_lbm`.
  6239. A loading block modifier (LBM) is used to define a function that is called for
  6240. specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
  6241. gets loaded.
  6242. {
  6243. label = "Upgrade legacy doors",
  6244. -- Descriptive label for profiling purposes (optional).
  6245. -- Definitions with identical labels will be listed as one.
  6246. name = "modname:replace_legacy_door",
  6247. nodenames = {"default:lava_source"},
  6248. -- List of node names to trigger the LBM on.
  6249. -- Also non-registered nodes will work.
  6250. -- Groups (as of group:groupname) will work as well.
  6251. run_at_every_load = false,
  6252. -- Whether to run the LBM's action every time a block gets loaded,
  6253. -- and not only the first time the block gets loaded after the LBM
  6254. -- was introduced.
  6255. action = function(pos, node),
  6256. }
  6257. Tile definition
  6258. ---------------
  6259. * `"image.png"`
  6260. * `{name="image.png", animation={Tile Animation definition}}`
  6261. * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
  6262. * backface culling enabled by default for most nodes
  6263. * align style determines whether the texture will be rotated with the node
  6264. or kept aligned with its surroundings. "user" means that client
  6265. setting will be used, similar to `glasslike_framed_optional`.
  6266. Note: supported by solid nodes and nodeboxes only.
  6267. * scale is used to make texture span several (exactly `scale`) nodes,
  6268. instead of just one, in each direction. Works for world-aligned
  6269. textures only.
  6270. Note that as the effect is applied on per-mapblock basis, `16` should
  6271. be equally divisible by `scale` or you may get wrong results.
  6272. * `{name="image.png", color=ColorSpec}`
  6273. * the texture's color will be multiplied with this color.
  6274. * the tile's color overrides the owning node's color in all cases.
  6275. * deprecated, yet still supported field names:
  6276. * `image` (name)
  6277. Tile animation definition
  6278. -------------------------
  6279. {
  6280. type = "vertical_frames",
  6281. aspect_w = 16,
  6282. -- Width of a frame in pixels
  6283. aspect_h = 16,
  6284. -- Height of a frame in pixels
  6285. length = 3.0,
  6286. -- Full loop length
  6287. }
  6288. {
  6289. type = "sheet_2d",
  6290. frames_w = 5,
  6291. -- Width in number of frames
  6292. frames_h = 3,
  6293. -- Height in number of frames
  6294. frame_length = 0.5,
  6295. -- Length of a single frame
  6296. }
  6297. Item definition
  6298. ---------------
  6299. Used by `minetest.register_node`, `minetest.register_craftitem`, and
  6300. `minetest.register_tool`.
  6301. {
  6302. description = "Steel Axe",
  6303. -- Can contain new lines. "\n" has to be used as new line character.
  6304. -- See also: `get_description` in [`ItemStack`]
  6305. short_description = "Steel Axe",
  6306. -- Must not contain new lines.
  6307. -- Defaults to nil.
  6308. -- Use an [`ItemStack`] to get the short description, eg:
  6309. -- ItemStack(itemname):get_short_description()
  6310. groups = {},
  6311. -- key = name, value = rating; rating = 1..3.
  6312. -- If rating not applicable, use 1.
  6313. -- e.g. {wool = 1, fluffy = 3}
  6314. -- {soil = 2, outerspace = 1, crumbly = 1}
  6315. -- {bendy = 2, snappy = 1},
  6316. -- {hard = 1, metal = 1, spikes = 1}
  6317. inventory_image = "default_tool_steelaxe.png",
  6318. inventory_overlay = "overlay.png",
  6319. -- An overlay which does not get colorized
  6320. wield_image = "",
  6321. wield_overlay = "",
  6322. palette = "",
  6323. -- An image file containing the palette of a node.
  6324. -- You can set the currently used color as the "palette_index" field of
  6325. -- the item stack metadata.
  6326. -- The palette is always stretched to fit indices between 0 and 255, to
  6327. -- ensure compatibility with "colorfacedir" and "colorwallmounted" nodes.
  6328. color = "0xFFFFFFFF",
  6329. -- The color of the item. The palette overrides this.
  6330. wield_scale = {x = 1, y = 1, z = 1},
  6331. -- The default value of 99 may be configured by
  6332. -- users using the setting "default_stack_max"
  6333. stack_max = 99,
  6334. range = 4.0,
  6335. liquids_pointable = false,
  6336. -- If true, item points to all liquid nodes (`liquidtype ~= "none"`),
  6337. -- even those for which `pointable = false`
  6338. light_source = 0,
  6339. -- When used for nodes: Defines amount of light emitted by node.
  6340. -- Otherwise: Defines texture glow when viewed as a dropped item
  6341. -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
  6342. -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
  6343. -- behavior.
  6344. -- See "Tool Capabilities" section for an example including explanation
  6345. tool_capabilities = {
  6346. full_punch_interval = 1.0,
  6347. max_drop_level = 0,
  6348. groupcaps = {
  6349. -- For example:
  6350. choppy = {times = {[1] = 2.50, [2] = 1.40, [3] = 1.00},
  6351. uses = 20, maxlevel = 2},
  6352. },
  6353. damage_groups = {groupname = damage},
  6354. -- Damage values must be between -32768 and 32767 (2^15)
  6355. punch_attack_uses = nil,
  6356. -- Amount of uses this tool has for attacking players and entities
  6357. -- by punching them (0 = infinite uses).
  6358. -- For compatibility, this is automatically set from the first
  6359. -- suitable groupcap using the forumla "uses * 3^(maxlevel - 1)".
  6360. -- It is recommend to set this explicitly instead of relying on the
  6361. -- fallback behavior.
  6362. },
  6363. node_placement_prediction = nil,
  6364. -- If nil and item is node, prediction is made automatically.
  6365. -- If nil and item is not a node, no prediction is made.
  6366. -- If "" and item is anything, no prediction is made.
  6367. -- Otherwise should be name of node which the client immediately places
  6368. -- on ground when the player places the item. Server will always update
  6369. -- actual result to client in a short moment.
  6370. node_dig_prediction = "air",
  6371. -- if "", no prediction is made.
  6372. -- if "air", node is removed.
  6373. -- Otherwise should be name of node which the client immediately places
  6374. -- upon digging. Server will always update actual result shortly.
  6375. sound = {
  6376. -- Definition of items sounds to be played at various events.
  6377. -- All fields in this table are optional.
  6378. breaks = <SimpleSoundSpec>,
  6379. -- When tool breaks due to wear. Ignored for non-tools
  6380. eat = <SimpleSoundSpec>,
  6381. -- When item is eaten with `minetest.do_item_eat`
  6382. },
  6383. on_place = function(itemstack, placer, pointed_thing),
  6384. -- When the 'place' key was pressed with the item in hand
  6385. -- and a node was pointed at.
  6386. -- Shall place item and return the leftover itemstack
  6387. -- or nil to not modify the inventory.
  6388. -- The placer may be any ObjectRef or nil.
  6389. -- default: minetest.item_place
  6390. on_secondary_use = function(itemstack, user, pointed_thing),
  6391. -- Same as on_place but called when not pointing at a node.
  6392. -- Function must return either nil if inventory shall not be modified,
  6393. -- or an itemstack to replace the original itemstack.
  6394. -- The user may be any ObjectRef or nil.
  6395. -- default: nil
  6396. on_drop = function(itemstack, dropper, pos),
  6397. -- Shall drop item and return the leftover itemstack.
  6398. -- The dropper may be any ObjectRef or nil.
  6399. -- default: minetest.item_drop
  6400. on_use = function(itemstack, user, pointed_thing),
  6401. -- default: nil
  6402. -- When user pressed the 'punch/mine' key with the item in hand.
  6403. -- Function must return either nil if inventory shall not be modified,
  6404. -- or an itemstack to replace the original itemstack.
  6405. -- e.g. itemstack:take_item(); return itemstack
  6406. -- Otherwise, the function is free to do what it wants.
  6407. -- The user may be any ObjectRef or nil.
  6408. -- The default functions handle regular use cases.
  6409. after_use = function(itemstack, user, node, digparams),
  6410. -- default: nil
  6411. -- If defined, should return an itemstack and will be called instead of
  6412. -- wearing out the item (if tool). If returns nil, does nothing.
  6413. -- If after_use doesn't exist, it is the same as:
  6414. -- function(itemstack, user, node, digparams)
  6415. -- itemstack:add_wear(digparams.wear)
  6416. -- return itemstack
  6417. -- end
  6418. -- The user may be any ObjectRef or nil.
  6419. _custom_field = whatever,
  6420. -- Add your own custom fields. By convention, all custom field names
  6421. -- should start with `_` to avoid naming collisions with future engine
  6422. -- usage.
  6423. }
  6424. Node definition
  6425. ---------------
  6426. Used by `minetest.register_node`.
  6427. {
  6428. -- <all fields allowed in item definitions>,
  6429. drawtype = "normal", -- See "Node drawtypes"
  6430. visual_scale = 1.0,
  6431. -- Supported for drawtypes "plantlike", "signlike", "torchlike",
  6432. -- "firelike", "mesh", "nodebox", "allfaces".
  6433. -- For plantlike and firelike, the image will start at the bottom of the
  6434. -- node. For torchlike, the image will start at the surface to which the
  6435. -- node "attaches". For the other drawtypes the image will be centered
  6436. -- on the node.
  6437. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6438. -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
  6439. -- Old field name was 'tile_images'.
  6440. -- List can be shortened to needed length.
  6441. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6442. -- Same as `tiles`, but these textures are drawn on top of the base
  6443. -- tiles. You can use this to colorize only specific parts of your
  6444. -- texture. If the texture name is an empty string, that overlay is not
  6445. -- drawn. Since such tiles are drawn twice, it is not recommended to use
  6446. -- overlays on very common nodes.
  6447. special_tiles = {tile definition 1, Tile definition 2},
  6448. -- Special textures of node; used rarely.
  6449. -- Old field name was 'special_materials'.
  6450. -- List can be shortened to needed length.
  6451. color = ColorSpec,
  6452. -- The node's original color will be multiplied with this color.
  6453. -- If the node has a palette, then this setting only has an effect in
  6454. -- the inventory and on the wield item.
  6455. use_texture_alpha = ...,
  6456. -- Specifies how the texture's alpha channel will be used for rendering.
  6457. -- possible values:
  6458. -- * "opaque": Node is rendered opaque regardless of alpha channel
  6459. -- * "clip": A given pixel is either fully see-through or opaque
  6460. -- depending on the alpha channel being below/above 50% in value
  6461. -- * "blend": The alpha channel specifies how transparent a given pixel
  6462. -- of the rendered node is
  6463. -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
  6464. -- "clip" otherwise.
  6465. -- If set to a boolean value (deprecated): true either sets it to blend
  6466. -- or clip, false sets it to clip or opaque mode depending on the drawtype.
  6467. palette = "palette.png",
  6468. -- The node's `param2` is used to select a pixel from the image.
  6469. -- Pixels are arranged from left to right and from top to bottom.
  6470. -- The node's color will be multiplied with the selected pixel's color.
  6471. -- Tiles can override this behavior.
  6472. -- Only when `paramtype2` supports palettes.
  6473. post_effect_color = "green#0F",
  6474. -- Screen tint if player is inside node, see "ColorSpec"
  6475. paramtype = "none", -- See "Nodes"
  6476. paramtype2 = "none", -- See "Nodes"
  6477. place_param2 = nil, -- Force value for param2 when player places node
  6478. is_ground_content = true,
  6479. -- If false, the cave generator and dungeon generator will not carve
  6480. -- through this node.
  6481. -- Specifically, this stops mod-added nodes being removed by caves and
  6482. -- dungeons when those generate in a neighbor mapchunk and extend out
  6483. -- beyond the edge of that mapchunk.
  6484. sunlight_propagates = false,
  6485. -- If true, sunlight will go infinitely through this node
  6486. walkable = true, -- If true, objects collide with node
  6487. pointable = true, -- If true, can be pointed at
  6488. diggable = true, -- If false, can never be dug
  6489. climbable = false, -- If true, can be climbed on (ladder)
  6490. move_resistance = 0,
  6491. -- Slows down movement of players through this node (max. 7).
  6492. -- If this is nil, it will be equal to liquid_viscosity.
  6493. -- Note: If liquid movement physics apply to the node
  6494. -- (see `liquid_move_physics`), the movement speed will also be
  6495. -- affected by the `movement_liquid_*` settings.
  6496. buildable_to = false, -- If true, placed nodes can replace this node
  6497. floodable = false,
  6498. -- If true, liquids flow into and replace this node.
  6499. -- Warning: making a liquid node 'floodable' will cause problems.
  6500. liquidtype = "none", -- specifies liquid flowing physics
  6501. -- * "none": no liquid flowing physics
  6502. -- * "source": spawns flowing liquid nodes at all 4 sides and below;
  6503. -- recommended drawtype: "liquid".
  6504. -- * "flowing": spawned from source, spawns more flowing liquid nodes
  6505. -- around it until `liquid_range` is reached;
  6506. -- will drain out without a source;
  6507. -- recommended drawtype: "flowingliquid".
  6508. -- If it's "source" or "flowing" and `liquid_range > 0`, then
  6509. -- both `liquid_alternative_*` fields must be specified
  6510. liquid_alternative_flowing = "", -- Flowing version of source liquid
  6511. liquid_alternative_source = "", -- Source version of flowing liquid
  6512. liquid_viscosity = 0,
  6513. -- Controls speed at which the liquid spreads/flows (max. 7).
  6514. -- 0 is fastest, 7 is slowest.
  6515. -- By default, this also slows down movement of players inside the node
  6516. -- (can be overridden using `move_resistance`)
  6517. liquid_renewable = true,
  6518. -- If true, a new liquid source can be created by placing two or more
  6519. -- sources nearby
  6520. liquid_move_physics = nil, -- specifies movement physics if inside node
  6521. -- * false: No liquid movement physics apply.
  6522. -- * true: Enables liquid movement physics. Enables things like
  6523. -- ability to "swim" up/down, sinking slowly if not moving,
  6524. -- smoother speed change when falling into, etc. The `movement_liquid_*`
  6525. -- settings apply.
  6526. -- * nil: Will be treated as true if `liquidype ~= "none"`
  6527. -- and as false otherwise.
  6528. -- Default: nil
  6529. leveled = 0,
  6530. -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
  6531. -- Allows defining the nodebox height without using param2.
  6532. -- The nodebox height is 'leveled' / 64 nodes.
  6533. -- The maximum value of 'leveled' is `leveled_max`.
  6534. leveled_max = 127,
  6535. -- Maximum value for `leveled` (0-127), enforced in
  6536. -- `minetest.set_node_level` and `minetest.add_node_level`.
  6537. -- Values above 124 might causes collision detection issues.
  6538. liquid_range = 8,
  6539. -- Maximum distance that flowing liquid nodes can spread around
  6540. -- source on flat land;
  6541. -- maximum = 8; set to 0 to disable liquid flow
  6542. drowning = 0,
  6543. -- Player will take this amount of damage if no bubbles are left
  6544. damage_per_second = 0,
  6545. -- If player is inside node, this damage is caused
  6546. node_box = {type="regular"}, -- See "Node boxes"
  6547. connects_to = nodenames,
  6548. -- Used for nodebox nodes with the type == "connected".
  6549. -- Specifies to what neighboring nodes connections will be drawn.
  6550. -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
  6551. connect_sides = { "top", "bottom", "front", "left", "back", "right" },
  6552. -- Tells connected nodebox nodes to connect only to these sides of this
  6553. -- node
  6554. mesh = "model.obj",
  6555. -- File name of mesh when using "mesh" drawtype
  6556. selection_box = {
  6557. type = "fixed",
  6558. fixed = {
  6559. {-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
  6560. -- Node box format: see [Node boxes]
  6561. },
  6562. },
  6563. -- Custom selection box definition. Multiple boxes can be defined.
  6564. -- If "nodebox" drawtype is used and selection_box is nil, then node_box
  6565. -- definition is used for the selection box.
  6566. collision_box = {
  6567. type = "fixed",
  6568. fixed = {
  6569. {-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
  6570. -- Node box format: see [Node boxes]
  6571. },
  6572. },
  6573. -- Custom collision box definition. Multiple boxes can be defined.
  6574. -- If "nodebox" drawtype is used and collision_box is nil, then node_box
  6575. -- definition is used for the collision box.
  6576. -- Support maps made in and before January 2012
  6577. legacy_facedir_simple = false,
  6578. legacy_wallmounted = false,
  6579. waving = 0,
  6580. -- Valid for drawtypes:
  6581. -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
  6582. -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
  6583. -- 2 - wave node like leaves (whole node moves side-to-side)
  6584. -- 3 - wave node like liquids (whole node moves up and down)
  6585. -- Not all models will properly wave.
  6586. -- plantlike drawtype can only wave like plants.
  6587. -- allfaces_optional drawtype can only wave like leaves.
  6588. -- liquid, flowingliquid drawtypes can only wave like liquids.
  6589. sounds = {
  6590. -- Definition of node sounds to be played at various events.
  6591. -- All fields in this table are optional.
  6592. footstep = <SimpleSoundSpec>,
  6593. -- If walkable, played when object walks on it. If node is
  6594. -- climbable or a liquid, played when object moves through it
  6595. dig = <SimpleSoundSpec> or "__group",
  6596. -- While digging node.
  6597. -- If `"__group"`, then the sound will be
  6598. -- `default_dig_<groupname>`, where `<groupname>` is the
  6599. -- name of the item's digging group with the fastest digging time.
  6600. -- In case of a tie, one of the sounds will be played (but we
  6601. -- cannot predict which one)
  6602. -- Default value: `"__group"`
  6603. dug = <SimpleSoundSpec>,
  6604. -- Node was dug
  6605. place = <SimpleSoundSpec>,
  6606. -- Node was placed. Also played after falling
  6607. place_failed = <SimpleSoundSpec>,
  6608. -- When node placement failed.
  6609. -- Note: This happens if the _built-in_ node placement failed.
  6610. -- This sound will still be played if the node is placed in the
  6611. -- `on_place` callback manually.
  6612. fall = <SimpleSoundSpec>,
  6613. -- When node starts to fall or is detached
  6614. },
  6615. drop = "",
  6616. -- Name of dropped item when dug.
  6617. -- Default dropped item is the node itself.
  6618. -- Using a table allows multiple items, drop chances and item filtering.
  6619. -- Item filtering by string matching is deprecated.
  6620. drop = {
  6621. max_items = 1,
  6622. -- Maximum number of item lists to drop.
  6623. -- The entries in 'items' are processed in order. For each:
  6624. -- Item filtering is applied, chance of drop is applied, if both are
  6625. -- successful the entire item list is dropped.
  6626. -- Entry processing continues until the number of dropped item lists
  6627. -- equals 'max_items'.
  6628. -- Therefore, entries should progress from low to high drop chance.
  6629. items = {
  6630. -- Entry examples.
  6631. {
  6632. -- 1 in 1000 chance of dropping a diamond.
  6633. -- Default rarity is '1'.
  6634. rarity = 1000,
  6635. items = {"default:diamond"},
  6636. },
  6637. {
  6638. -- Only drop if using an item whose name is identical to one
  6639. -- of these.
  6640. tools = {"default:shovel_mese", "default:shovel_diamond"},
  6641. rarity = 5,
  6642. items = {"default:dirt"},
  6643. -- Whether all items in the dropped item list inherit the
  6644. -- hardware coloring palette color from the dug node.
  6645. -- Default is 'false'.
  6646. inherit_color = true,
  6647. },
  6648. {
  6649. -- Only drop if using an item whose name contains
  6650. -- "default:shovel_" (this item filtering by string matching
  6651. -- is deprecated, use tool_groups instead).
  6652. tools = {"~default:shovel_"},
  6653. rarity = 2,
  6654. -- The item list dropped.
  6655. items = {"default:sand", "default:desert_sand"},
  6656. },
  6657. {
  6658. -- Only drop if using an item in the "magicwand" group, or
  6659. -- an item that is in both the "pickaxe" and the "lucky"
  6660. -- groups.
  6661. tool_groups = {
  6662. "magicwand",
  6663. {"pickaxe", "lucky"}
  6664. },
  6665. items = {"default:coal_lump"},
  6666. },
  6667. },
  6668. },
  6669. on_construct = function(pos),
  6670. -- Node constructor; called after adding node.
  6671. -- Can set up metadata and stuff like that.
  6672. -- Not called for bulk node placement (i.e. schematics and VoxelManip).
  6673. -- default: nil
  6674. on_destruct = function(pos),
  6675. -- Node destructor; called before removing node.
  6676. -- Not called for bulk node placement.
  6677. -- default: nil
  6678. after_destruct = function(pos, oldnode),
  6679. -- Node destructor; called after removing node.
  6680. -- Not called for bulk node placement.
  6681. -- default: nil
  6682. on_flood = function(pos, oldnode, newnode),
  6683. -- Called when a liquid (newnode) is about to flood oldnode, if it has
  6684. -- `floodable = true` in the nodedef. Not called for bulk node placement
  6685. -- (i.e. schematics and VoxelManip) or air nodes. If return true the
  6686. -- node is not flooded, but on_flood callback will most likely be called
  6687. -- over and over again every liquid update interval.
  6688. -- Default: nil
  6689. -- Warning: making a liquid node 'floodable' will cause problems.
  6690. preserve_metadata = function(pos, oldnode, oldmeta, drops),
  6691. -- Called when oldnode is about be converted to an item, but before the
  6692. -- node is deleted from the world or the drops are added. This is
  6693. -- generally the result of either the node being dug or an attached node
  6694. -- becoming detached.
  6695. -- oldmeta is the NodeMetaRef of the oldnode before deletion.
  6696. -- drops is a table of ItemStacks, so any metadata to be preserved can
  6697. -- be added directly to one or more of the dropped items. See
  6698. -- "ItemStackMetaRef".
  6699. -- default: nil
  6700. after_place_node = function(pos, placer, itemstack, pointed_thing),
  6701. -- Called after constructing node when node was placed using
  6702. -- minetest.item_place_node / minetest.place_node.
  6703. -- If return true no item is taken from itemstack.
  6704. -- `placer` may be any valid ObjectRef or nil.
  6705. -- default: nil
  6706. after_dig_node = function(pos, oldnode, oldmetadata, digger),
  6707. -- oldmetadata is in table format.
  6708. -- Called after destructing node when node was dug using
  6709. -- minetest.node_dig / minetest.dig_node.
  6710. -- default: nil
  6711. can_dig = function(pos, [player]),
  6712. -- Returns true if node can be dug, or false if not.
  6713. -- default: nil
  6714. on_punch = function(pos, node, puncher, pointed_thing),
  6715. -- default: minetest.node_punch
  6716. -- Called when puncher (an ObjectRef) punches the node at pos.
  6717. -- By default calls minetest.register_on_punchnode callbacks.
  6718. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
  6719. -- default: nil
  6720. -- Called when clicker (an ObjectRef) used the 'place/build' key
  6721. -- (not neccessarily an actual rightclick)
  6722. -- while pointing at the node at pos with 'node' being the node table.
  6723. -- itemstack will hold clicker's wielded item.
  6724. -- Shall return the leftover itemstack.
  6725. -- Note: pointed_thing can be nil, if a mod calls this function.
  6726. -- This function does not get triggered by clients <=0.4.16 if the
  6727. -- "formspec" node metadata field is set.
  6728. on_dig = function(pos, node, digger),
  6729. -- default: minetest.node_dig
  6730. -- By default checks privileges, wears out item (if tool) and removes node.
  6731. -- return true if the node was dug successfully, false otherwise.
  6732. -- Deprecated: returning nil is the same as returning true.
  6733. on_timer = function(pos, elapsed),
  6734. -- default: nil
  6735. -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
  6736. -- elapsed is the total time passed since the timer was started.
  6737. -- return true to run the timer for another cycle with the same timeout
  6738. -- value.
  6739. on_receive_fields = function(pos, formname, fields, sender),
  6740. -- fields = {name1 = value1, name2 = value2, ...}
  6741. -- Called when an UI form (e.g. sign text input) returns data.
  6742. -- See minetest.register_on_player_receive_fields for more info.
  6743. -- default: nil
  6744. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  6745. -- Called when a player wants to move items inside the inventory.
  6746. -- Return value: number of items allowed to move.
  6747. allow_metadata_inventory_put = function(pos, listname, index, stack, player),
  6748. -- Called when a player wants to put something into the inventory.
  6749. -- Return value: number of items allowed to put.
  6750. -- Return value -1: Allow and don't modify item count in inventory.
  6751. allow_metadata_inventory_take = function(pos, listname, index, stack, player),
  6752. -- Called when a player wants to take something out of the inventory.
  6753. -- Return value: number of items allowed to take.
  6754. -- Return value -1: Allow and don't modify item count in inventory.
  6755. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  6756. on_metadata_inventory_put = function(pos, listname, index, stack, player),
  6757. on_metadata_inventory_take = function(pos, listname, index, stack, player),
  6758. -- Called after the actual action has happened, according to what was
  6759. -- allowed.
  6760. -- No return value.
  6761. on_blast = function(pos, intensity),
  6762. -- intensity: 1.0 = mid range of regular TNT.
  6763. -- If defined, called when an explosion touches the node, instead of
  6764. -- removing the node.
  6765. mod_origin = "modname",
  6766. -- stores which mod actually registered a node
  6767. -- if it can not find a source, returns "??"
  6768. -- useful for getting what mod truly registered something
  6769. -- example: if a node is registered as ":othermodname:nodename",
  6770. -- nodename will show "othermodname", but mod_orgin will say "modname"
  6771. }
  6772. Crafting recipes
  6773. ----------------
  6774. Used by `minetest.register_craft`.
  6775. ### Shaped
  6776. {
  6777. output = "default:pick_stone",
  6778. recipe = {
  6779. {"default:cobble", "default:cobble", "default:cobble"},
  6780. {"", "default:stick", ""},
  6781. {"", "default:stick", ""}, -- Also groups; e.g. "group:crumbly"
  6782. },
  6783. replacements = <list of item pairs>,
  6784. -- replacements: replace one input item with another item on crafting
  6785. -- (optional).
  6786. }
  6787. ### Shapeless
  6788. {
  6789. type = "shapeless",
  6790. output = "mushrooms:mushroom_stew",
  6791. recipe = {
  6792. "mushrooms:bowl",
  6793. "mushrooms:mushroom_brown",
  6794. "mushrooms:mushroom_red",
  6795. },
  6796. replacements = <list of item pairs>,
  6797. }
  6798. ### Tool repair
  6799. {
  6800. type = "toolrepair",
  6801. additional_wear = -0.02, -- multiplier of 65536
  6802. }
  6803. Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
  6804. group. Player can put 2 equal tools in the craft grid to get one "repaired" tool
  6805. back.
  6806. The wear of the output is determined by the wear of both tools, plus a
  6807. 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
  6808. you want `additional_wear` to be negative.
  6809. The formula used to calculate the resulting wear is:
  6810. 65536 - ( (65536 - tool_1_wear) + (65536 - tool_2_wear) + 65536 * additional_wear )
  6811. The result is rounded and can't be lower than 0. If the result is 65536 or higher,
  6812. no crafting is possible.
  6813. ### Cooking
  6814. {
  6815. type = "cooking",
  6816. output = "default:glass",
  6817. recipe = "default:sand",
  6818. cooktime = 3,
  6819. }
  6820. ### Furnace fuel
  6821. {
  6822. type = "fuel",
  6823. recipe = "bucket:bucket_lava",
  6824. burntime = 60,
  6825. replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
  6826. }
  6827. Ore definition
  6828. --------------
  6829. Used by `minetest.register_ore`.
  6830. See [Ores] section above for essential information.
  6831. {
  6832. ore_type = "scatter",
  6833. ore = "default:stone_with_coal",
  6834. ore_param2 = 3,
  6835. -- Facedir rotation. Default is 0 (unchanged rotation)
  6836. wherein = "default:stone",
  6837. -- A list of nodenames is supported too
  6838. clust_scarcity = 8 * 8 * 8,
  6839. -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
  6840. -- If the desired average distance between ores is 'd', set this to
  6841. -- d * d * d.
  6842. clust_num_ores = 8,
  6843. -- Number of ores in a cluster
  6844. clust_size = 3,
  6845. -- Size of the bounding box of the cluster.
  6846. -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
  6847. -- nodes are coal ore.
  6848. y_min = -31000,
  6849. y_max = 64,
  6850. -- Lower and upper limits for ore
  6851. flags = "",
  6852. -- Attributes for the ore generation, see 'Ore attributes' section above
  6853. noise_threshold = 0.5,
  6854. -- If noise is above this threshold, ore is placed. Not needed for a
  6855. -- uniform distribution.
  6856. noise_params = {
  6857. offset = 0,
  6858. scale = 1,
  6859. spread = {x = 100, y = 100, z = 100},
  6860. seed = 23,
  6861. octaves = 3,
  6862. persistence = 0.7
  6863. },
  6864. -- NoiseParams structure describing one of the perlin noises used for
  6865. -- ore distribution.
  6866. -- Needed by "sheet", "puff", "blob" and "vein" ores.
  6867. -- Omit from "scatter" ore for a uniform ore distribution.
  6868. -- Omit from "stratum" ore for a simple horizontal strata from y_min to
  6869. -- y_max.
  6870. biomes = {"desert", "rainforest"},
  6871. -- List of biomes in which this ore occurs.
  6872. -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
  6873. -- being used does not support biomes.
  6874. -- Can be a list of (or a single) biome names, IDs, or definitions.
  6875. -- Type-specific parameters
  6876. -- sheet
  6877. column_height_min = 1,
  6878. column_height_max = 16,
  6879. column_midpoint_factor = 0.5,
  6880. -- puff
  6881. np_puff_top = {
  6882. offset = 4,
  6883. scale = 2,
  6884. spread = {x = 100, y = 100, z = 100},
  6885. seed = 47,
  6886. octaves = 3,
  6887. persistence = 0.7
  6888. },
  6889. np_puff_bottom = {
  6890. offset = 4,
  6891. scale = 2,
  6892. spread = {x = 100, y = 100, z = 100},
  6893. seed = 11,
  6894. octaves = 3,
  6895. persistence = 0.7
  6896. },
  6897. -- vein
  6898. random_factor = 1.0,
  6899. -- stratum
  6900. np_stratum_thickness = {
  6901. offset = 8,
  6902. scale = 4,
  6903. spread = {x = 100, y = 100, z = 100},
  6904. seed = 17,
  6905. octaves = 3,
  6906. persistence = 0.7
  6907. },
  6908. stratum_thickness = 8,
  6909. }
  6910. Biome definition
  6911. ----------------
  6912. Used by `minetest.register_biome`.
  6913. The maximum number of biomes that can be used is 65535. However, using an
  6914. excessive number of biomes will slow down map generation. Depending on desired
  6915. performance and computing power the practical limit is much lower.
  6916. {
  6917. name = "tundra",
  6918. node_dust = "default:snow",
  6919. -- Node dropped onto upper surface after all else is generated
  6920. node_top = "default:dirt_with_snow",
  6921. depth_top = 1,
  6922. -- Node forming surface layer of biome and thickness of this layer
  6923. node_filler = "default:permafrost",
  6924. depth_filler = 3,
  6925. -- Node forming lower layer of biome and thickness of this layer
  6926. node_stone = "default:bluestone",
  6927. -- Node that replaces all stone nodes between roughly y_min and y_max.
  6928. node_water_top = "default:ice",
  6929. depth_water_top = 10,
  6930. -- Node forming a surface layer in seawater with the defined thickness
  6931. node_water = "",
  6932. -- Node that replaces all seawater nodes not in the surface layer
  6933. node_river_water = "default:ice",
  6934. -- Node that replaces river water in mapgens that use
  6935. -- default:river_water
  6936. node_riverbed = "default:gravel",
  6937. depth_riverbed = 2,
  6938. -- Node placed under river water and thickness of this layer
  6939. node_cave_liquid = "default:lava_source",
  6940. node_cave_liquid = {"default:water_source", "default:lava_source"},
  6941. -- Nodes placed inside 50% of the medium size caves.
  6942. -- Multiple nodes can be specified, each cave will use a randomly
  6943. -- chosen node from the list.
  6944. -- If this field is left out or 'nil', cave liquids fall back to
  6945. -- classic behaviour of lava and water distributed using 3D noise.
  6946. -- For no cave liquid, specify "air".
  6947. node_dungeon = "default:cobble",
  6948. -- Node used for primary dungeon structure.
  6949. -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
  6950. -- alias, if that is also absent, dungeon nodes fall back to the biome
  6951. -- 'node_stone'.
  6952. -- If present, the following two nodes are also used.
  6953. node_dungeon_alt = "default:mossycobble",
  6954. -- Node used for randomly-distributed alternative structure nodes.
  6955. -- If alternative structure nodes are not wanted leave this absent for
  6956. -- performance reasons.
  6957. node_dungeon_stair = "stairs:stair_cobble",
  6958. -- Node used for dungeon stairs.
  6959. -- If absent, stairs fall back to 'node_dungeon'.
  6960. y_max = 31000,
  6961. y_min = 1,
  6962. -- Upper and lower limits for biome.
  6963. -- Alternatively you can use xyz limits as shown below.
  6964. max_pos = {x = 31000, y = 128, z = 31000},
  6965. min_pos = {x = -31000, y = 9, z = -31000},
  6966. -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
  6967. -- Biome is limited to a cuboid defined by these positions.
  6968. -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
  6969. -- 31000 in 'max_pos'.
  6970. vertical_blend = 8,
  6971. -- Vertical distance in nodes above 'y_max' over which the biome will
  6972. -- blend with the biome above.
  6973. -- Set to 0 for no vertical blend. Defaults to 0.
  6974. heat_point = 0,
  6975. humidity_point = 50,
  6976. -- Characteristic temperature and humidity for the biome.
  6977. -- These values create 'biome points' on a voronoi diagram with heat and
  6978. -- humidity as axes. The resulting voronoi cells determine the
  6979. -- distribution of the biomes.
  6980. -- Heat and humidity have average values of 50, vary mostly between
  6981. -- 0 and 100 but can exceed these values.
  6982. }
  6983. Decoration definition
  6984. ---------------------
  6985. See [Decoration types]. Used by `minetest.register_decoration`.
  6986. {
  6987. deco_type = "simple",
  6988. place_on = "default:dirt_with_grass",
  6989. -- Node (or list of nodes) that the decoration can be placed on
  6990. sidelen = 8,
  6991. -- Size of the square divisions of the mapchunk being generated.
  6992. -- Determines the resolution of noise variation if used.
  6993. -- If the chunk size is not evenly divisible by sidelen, sidelen is made
  6994. -- equal to the chunk size.
  6995. fill_ratio = 0.02,
  6996. -- The value determines 'decorations per surface node'.
  6997. -- Used only if noise_params is not specified.
  6998. -- If >= 10.0 complete coverage is enabled and decoration placement uses
  6999. -- a different and much faster method.
  7000. noise_params = {
  7001. offset = 0,
  7002. scale = 0.45,
  7003. spread = {x = 100, y = 100, z = 100},
  7004. seed = 354,
  7005. octaves = 3,
  7006. persistence = 0.7,
  7007. lacunarity = 2.0,
  7008. flags = "absvalue"
  7009. },
  7010. -- NoiseParams structure describing the perlin noise used for decoration
  7011. -- distribution.
  7012. -- A noise value is calculated for each square division and determines
  7013. -- 'decorations per surface node' within each division.
  7014. -- If the noise value >= 10.0 complete coverage is enabled and
  7015. -- decoration placement uses a different and much faster method.
  7016. biomes = {"Oceanside", "Hills", "Plains"},
  7017. -- List of biomes in which this decoration occurs. Occurs in all biomes
  7018. -- if this is omitted, and ignored if the Mapgen being used does not
  7019. -- support biomes.
  7020. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7021. y_min = -31000,
  7022. y_max = 31000,
  7023. -- Lower and upper limits for decoration.
  7024. -- These parameters refer to the Y co-ordinate of the 'place_on' node.
  7025. spawn_by = "default:water",
  7026. -- Node (or list of nodes) that the decoration only spawns next to.
  7027. -- Checks two horizontal planes of 8 neighbouring nodes (including
  7028. -- diagonal neighbours), one plane level with the 'place_on' node and a
  7029. -- plane one node above that.
  7030. num_spawn_by = 1,
  7031. -- Number of spawn_by nodes that must be surrounding the decoration
  7032. -- position to occur.
  7033. -- If absent or -1, decorations occur next to any nodes.
  7034. flags = "liquid_surface, force_placement, all_floors, all_ceilings",
  7035. -- Flags for all decoration types.
  7036. -- "liquid_surface": Instead of placement on the highest solid surface
  7037. -- in a mapchunk column, placement is on the highest liquid surface.
  7038. -- Placement is disabled if solid nodes are found above the liquid
  7039. -- surface.
  7040. -- "force_placement": Nodes other than "air" and "ignore" are replaced
  7041. -- by the decoration.
  7042. -- "all_floors", "all_ceilings": Instead of placement on the highest
  7043. -- surface in a mapchunk the decoration is placed on all floor and/or
  7044. -- ceiling surfaces, for example in caves and dungeons.
  7045. -- Ceiling decorations act as an inversion of floor decorations so the
  7046. -- effect of 'place_offset_y' is inverted.
  7047. -- Y-slice probabilities do not function correctly for ceiling
  7048. -- schematic decorations as the behaviour is unchanged.
  7049. -- If a single decoration registration has both flags the floor and
  7050. -- ceiling decorations will be aligned vertically.
  7051. ----- Simple-type parameters
  7052. decoration = "default:grass",
  7053. -- The node name used as the decoration.
  7054. -- If instead a list of strings, a randomly selected node from the list
  7055. -- is placed as the decoration.
  7056. height = 1,
  7057. -- Decoration height in nodes.
  7058. -- If height_max is not 0, this is the lower limit of a randomly
  7059. -- selected height.
  7060. height_max = 0,
  7061. -- Upper limit of the randomly selected height.
  7062. -- If absent, the parameter 'height' is used as a constant.
  7063. param2 = 0,
  7064. -- Param2 value of decoration nodes.
  7065. -- If param2_max is not 0, this is the lower limit of a randomly
  7066. -- selected param2.
  7067. param2_max = 0,
  7068. -- Upper limit of the randomly selected param2.
  7069. -- If absent, the parameter 'param2' is used as a constant.
  7070. place_offset_y = 0,
  7071. -- Y offset of the decoration base node relative to the standard base
  7072. -- node position.
  7073. -- Can be positive or negative. Default is 0.
  7074. -- Effect is inverted for "all_ceilings" decorations.
  7075. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7076. -- to the 'place_on' node.
  7077. ----- Schematic-type parameters
  7078. schematic = "foobar.mts",
  7079. -- If schematic is a string, it is the filepath relative to the current
  7080. -- working directory of the specified Minetest schematic file.
  7081. -- Could also be the ID of a previously registered schematic.
  7082. schematic = {
  7083. size = {x = 4, y = 6, z = 4},
  7084. data = {
  7085. {name = "default:cobble", param1 = 255, param2 = 0},
  7086. {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
  7087. {name = "air", param1 = 255, param2 = 0},
  7088. ...
  7089. },
  7090. yslice_prob = {
  7091. {ypos = 2, prob = 128},
  7092. {ypos = 5, prob = 64},
  7093. ...
  7094. },
  7095. },
  7096. -- Alternative schematic specification by supplying a table. The fields
  7097. -- size and data are mandatory whereas yslice_prob is optional.
  7098. -- See 'Schematic specifier' for details.
  7099. replacements = {["oldname"] = "convert_to", ...},
  7100. flags = "place_center_x, place_center_y, place_center_z",
  7101. -- Flags for schematic decorations. See 'Schematic attributes'.
  7102. rotation = "90",
  7103. -- Rotation can be "0", "90", "180", "270", or "random"
  7104. place_offset_y = 0,
  7105. -- If the flag 'place_center_y' is set this parameter is ignored.
  7106. -- Y offset of the schematic base node layer relative to the 'place_on'
  7107. -- node.
  7108. -- Can be positive or negative. Default is 0.
  7109. -- Effect is inverted for "all_ceilings" decorations.
  7110. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7111. -- to the 'place_on' node.
  7112. }
  7113. Chat command definition
  7114. -----------------------
  7115. Used by `minetest.register_chatcommand`.
  7116. {
  7117. params = "<name> <privilege>", -- Short parameter description
  7118. description = "Remove privilege from player", -- Full description
  7119. privs = {privs=true}, -- Require the "privs" privilege to run
  7120. func = function(name, param),
  7121. -- Called when command is run. Returns boolean success and text output.
  7122. -- Special case: The help message is shown to the player if `func`
  7123. -- returns false without a text output.
  7124. }
  7125. Note that in params, use of symbols is as follows:
  7126. * `<>` signifies a placeholder to be replaced when the command is used. For
  7127. example, when a player name is needed: `<name>`
  7128. * `[]` signifies param is optional and not required when the command is used.
  7129. For example, if you require param1 but param2 is optional:
  7130. `<param1> [<param2>]`
  7131. * `|` signifies exclusive or. The command requires one param from the options
  7132. provided. For example: `<param1> | <param2>`
  7133. * `()` signifies grouping. For example, when param1 and param2 are both
  7134. required, or only param3 is required: `(<param1> <param2>) | <param3>`
  7135. Privilege definition
  7136. --------------------
  7137. Used by `minetest.register_privilege`.
  7138. {
  7139. description = "",
  7140. -- Privilege description
  7141. give_to_singleplayer = true,
  7142. -- Whether to grant the privilege to singleplayer.
  7143. give_to_admin = true,
  7144. -- Whether to grant the privilege to the server admin.
  7145. -- Uses value of 'give_to_singleplayer' by default.
  7146. on_grant = function(name, granter_name),
  7147. -- Called when given to player 'name' by 'granter_name'.
  7148. -- 'granter_name' will be nil if the priv was granted by a mod.
  7149. on_revoke = function(name, revoker_name),
  7150. -- Called when taken from player 'name' by 'revoker_name'.
  7151. -- 'revoker_name' will be nil if the priv was revoked by a mod.
  7152. -- Note that the above two callbacks will be called twice if a player is
  7153. -- responsible, once with the player name, and then with a nil player
  7154. -- name.
  7155. -- Return true in the above callbacks to stop register_on_priv_grant or
  7156. -- revoke being called.
  7157. }
  7158. Detached inventory callbacks
  7159. ----------------------------
  7160. Used by `minetest.create_detached_inventory`.
  7161. {
  7162. allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7163. -- Called when a player wants to move items inside the inventory.
  7164. -- Return value: number of items allowed to move.
  7165. allow_put = function(inv, listname, index, stack, player),
  7166. -- Called when a player wants to put something into the inventory.
  7167. -- Return value: number of items allowed to put.
  7168. -- Return value -1: Allow and don't modify item count in inventory.
  7169. allow_take = function(inv, listname, index, stack, player),
  7170. -- Called when a player wants to take something out of the inventory.
  7171. -- Return value: number of items allowed to take.
  7172. -- Return value -1: Allow and don't modify item count in inventory.
  7173. on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7174. on_put = function(inv, listname, index, stack, player),
  7175. on_take = function(inv, listname, index, stack, player),
  7176. -- Called after the actual action has happened, according to what was
  7177. -- allowed.
  7178. -- No return value.
  7179. }
  7180. HUD Definition
  7181. --------------
  7182. See [HUD] section.
  7183. Used by `Player:hud_add`. Returned by `Player:hud_get`.
  7184. {
  7185. hud_elem_type = "image", -- See HUD element types
  7186. -- Type of element, can be "image", "text", "statbar", "inventory",
  7187. -- "compass" or "minimap"
  7188. position = {x=0.5, y=0.5},
  7189. -- Left corner position of element
  7190. name = "<name>",
  7191. scale = {x = 2, y = 2},
  7192. text = "<text>",
  7193. text2 = "<text>",
  7194. number = 2,
  7195. item = 3,
  7196. -- Selected item in inventory. 0 for no item selected.
  7197. direction = 0,
  7198. -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  7199. alignment = {x=0, y=0},
  7200. offset = {x=0, y=0},
  7201. size = { x=100, y=100 },
  7202. -- Size of element in pixels
  7203. z_index = 0,
  7204. -- Z index : lower z-index HUDs are displayed behind higher z-index HUDs
  7205. style = 0,
  7206. -- For "text" elements sets font style: bitfield with 1 = bold, 2 = italic, 4 = monospace
  7207. }
  7208. Particle definition
  7209. -------------------
  7210. Used by `minetest.add_particle`.
  7211. {
  7212. pos = {x=0, y=0, z=0},
  7213. velocity = {x=0, y=0, z=0},
  7214. acceleration = {x=0, y=0, z=0},
  7215. -- Spawn particle at pos with velocity and acceleration
  7216. expirationtime = 1,
  7217. -- Disappears after expirationtime seconds
  7218. size = 1,
  7219. -- Scales the visual size of the particle texture.
  7220. -- If `node` is set, size can be set to 0 to spawn a randomly-sized
  7221. -- particle (just like actual node dig particles).
  7222. collisiondetection = false,
  7223. -- If true collides with `walkable` nodes and, depending on the
  7224. -- `object_collision` field, objects too.
  7225. collision_removal = false,
  7226. -- If true particle is removed when it collides.
  7227. -- Requires collisiondetection = true to have any effect.
  7228. object_collision = false,
  7229. -- If true particle collides with objects that are defined as
  7230. -- `physical = true,` and `collide_with_objects = true,`.
  7231. -- Requires collisiondetection = true to have any effect.
  7232. vertical = false,
  7233. -- If true faces player using y axis only
  7234. texture = "image.png",
  7235. -- The texture of the particle
  7236. playername = "singleplayer",
  7237. -- Optional, if specified spawns particle only on the player's client
  7238. animation = {Tile Animation definition},
  7239. -- Optional, specifies how to animate the particle texture
  7240. glow = 0
  7241. -- Optional, specify particle self-luminescence in darkness.
  7242. -- Values 0-14.
  7243. node = {name = "ignore", param2 = 0},
  7244. -- Optional, if specified the particle will have the same appearance as
  7245. -- node dig particles for the given node.
  7246. -- `texture` and `animation` will be ignored if this is set.
  7247. node_tile = 0,
  7248. -- Optional, only valid in combination with `node`
  7249. -- If set to a valid number 1-6, specifies the tile from which the
  7250. -- particle texture is picked.
  7251. -- Otherwise, the default behavior is used. (currently: any random tile)
  7252. }
  7253. `ParticleSpawner` definition
  7254. ----------------------------
  7255. Used by `minetest.add_particlespawner`.
  7256. {
  7257. amount = 1,
  7258. -- Number of particles spawned over the time period `time`.
  7259. time = 1,
  7260. -- Lifespan of spawner in seconds.
  7261. -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
  7262. -- a per-second basis.
  7263. minpos = {x=0, y=0, z=0},
  7264. maxpos = {x=0, y=0, z=0},
  7265. minvel = {x=0, y=0, z=0},
  7266. maxvel = {x=0, y=0, z=0},
  7267. minacc = {x=0, y=0, z=0},
  7268. maxacc = {x=0, y=0, z=0},
  7269. minexptime = 1,
  7270. maxexptime = 1,
  7271. minsize = 1,
  7272. maxsize = 1,
  7273. -- The particles' properties are random values between the min and max
  7274. -- values.
  7275. -- applies to: pos, velocity, acceleration, expirationtime, size
  7276. -- If `node` is set, min and maxsize can be set to 0 to spawn
  7277. -- randomly-sized particles (just like actual node dig particles).
  7278. collisiondetection = false,
  7279. -- If true collide with `walkable` nodes and, depending on the
  7280. -- `object_collision` field, objects too.
  7281. collision_removal = false,
  7282. -- If true particles are removed when they collide.
  7283. -- Requires collisiondetection = true to have any effect.
  7284. object_collision = false,
  7285. -- If true particles collide with objects that are defined as
  7286. -- `physical = true,` and `collide_with_objects = true,`.
  7287. -- Requires collisiondetection = true to have any effect.
  7288. attached = ObjectRef,
  7289. -- If defined, particle positions, velocities and accelerations are
  7290. -- relative to this object's position and yaw
  7291. vertical = false,
  7292. -- If true face player using y axis only
  7293. texture = "image.png",
  7294. -- The texture of the particle
  7295. playername = "singleplayer",
  7296. -- Optional, if specified spawns particles only on the player's client
  7297. animation = {Tile Animation definition},
  7298. -- Optional, specifies how to animate the particles' texture
  7299. glow = 0
  7300. -- Optional, specify particle self-luminescence in darkness.
  7301. -- Values 0-14.
  7302. node = {name = "ignore", param2 = 0},
  7303. -- Optional, if specified the particles will have the same appearance as
  7304. -- node dig particles for the given node.
  7305. -- `texture` and `animation` will be ignored if this is set.
  7306. node_tile = 0,
  7307. -- Optional, only valid in combination with `node`
  7308. -- If set to a valid number 1-6, specifies the tile from which the
  7309. -- particle texture is picked.
  7310. -- Otherwise, the default behavior is used. (currently: any random tile)
  7311. }
  7312. `HTTPRequest` definition
  7313. ------------------------
  7314. Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
  7315. {
  7316. url = "http://example.org",
  7317. timeout = 10,
  7318. -- Timeout for request to be completed in seconds. Default depends on engine settings.
  7319. method = "GET", "POST", "PUT" or "DELETE"
  7320. -- The http method to use. Defaults to "GET".
  7321. data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
  7322. -- Data for the POST, PUT or DELETE request.
  7323. -- Accepts both a string and a table. If a table is specified, encodes
  7324. -- table as x-www-form-urlencoded key-value pairs.
  7325. user_agent = "ExampleUserAgent",
  7326. -- Optional, if specified replaces the default minetest user agent with
  7327. -- given string
  7328. extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
  7329. -- Optional, if specified adds additional headers to the HTTP request.
  7330. -- You must make sure that the header strings follow HTTP specification
  7331. -- ("Key: Value").
  7332. multipart = boolean
  7333. -- Optional, if true performs a multipart HTTP request.
  7334. -- Default is false.
  7335. -- Post only, data must be array
  7336. post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
  7337. -- Deprecated, use `data` instead. Forces `method = "POST"`.
  7338. }
  7339. `HTTPRequestResult` definition
  7340. ------------------------------
  7341. Passed to `HTTPApiTable.fetch` callback. Returned by
  7342. `HTTPApiTable.fetch_async_get`.
  7343. {
  7344. completed = true,
  7345. -- If true, the request has finished (either succeeded, failed or timed
  7346. -- out)
  7347. succeeded = true,
  7348. -- If true, the request was successful
  7349. timeout = false,
  7350. -- If true, the request timed out
  7351. code = 200,
  7352. -- HTTP status code
  7353. data = "response"
  7354. }
  7355. Authentication handler definition
  7356. ---------------------------------
  7357. Used by `minetest.register_authentication_handler`.
  7358. {
  7359. get_auth = function(name),
  7360. -- Get authentication data for existing player `name` (`nil` if player
  7361. -- doesn't exist).
  7362. -- Returns following structure:
  7363. -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
  7364. create_auth = function(name, password),
  7365. -- Create new auth data for player `name`.
  7366. -- Note that `password` is not plain-text but an arbitrary
  7367. -- representation decided by the engine.
  7368. delete_auth = function(name),
  7369. -- Delete auth data of player `name`.
  7370. -- Returns boolean indicating success (false if player is nonexistent).
  7371. set_password = function(name, password),
  7372. -- Set password of player `name` to `password`.
  7373. -- Auth data should be created if not present.
  7374. set_privileges = function(name, privileges),
  7375. -- Set privileges of player `name`.
  7376. -- `privileges` is in table form, auth data should be created if not
  7377. -- present.
  7378. reload = function(),
  7379. -- Reload authentication data from the storage location.
  7380. -- Returns boolean indicating success.
  7381. record_login = function(name),
  7382. -- Called when player joins, used for keeping track of last_login
  7383. iterate = function(),
  7384. -- Returns an iterator (use with `for` loops) for all player names
  7385. -- currently in the auth database
  7386. }
  7387. Bit Library
  7388. -----------
  7389. Functions: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
  7390. See http://bitop.luajit.org/ for advanced information.