lua_api.txt 269 KB

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