2
0

lua_api.txt 367 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034
  1. Minetest Lua Modding API Reference
  2. ==================================
  3. * More information at <http://www.minetest.net/>
  4. * Developer Wiki: <http://dev.minetest.net/>
  5. * (Unofficial) Minetest Modding Book by rubenwardy: <https://rubenwardy.com/minetest_modding_book/>
  6. Introduction
  7. ------------
  8. Content and functionality can be added to Minetest using Lua scripting
  9. in run-time loaded mods.
  10. A mod is a self-contained bunch of scripts, textures and other related
  11. things, which is loaded by and interfaces with Minetest.
  12. Mods are contained and ran solely on the server side. Definitions and media
  13. files are automatically transferred to the client.
  14. If you see a deficiency in the API, feel free to attempt to add the
  15. functionality in the engine and API, and to document it here.
  16. Programming in Lua
  17. ------------------
  18. If you have any difficulty in understanding this, please read
  19. [Programming in Lua](http://www.lua.org/pil/).
  20. Startup
  21. -------
  22. Mods are loaded during server startup from the mod load paths by running
  23. the `init.lua` scripts in a shared environment.
  24. Paths
  25. -----
  26. * `RUN_IN_PLACE=1` (Windows release, local build)
  27. * `$path_user`: `<build directory>`
  28. * `$path_share`: `<build directory>`
  29. * `RUN_IN_PLACE=0`: (Linux release)
  30. * `$path_share`:
  31. * Linux: `/usr/share/minetest`
  32. * Windows: `<install directory>/minetest-0.4.x`
  33. * `$path_user`:
  34. * Linux: `$HOME/.minetest`
  35. * Windows: `C:/users/<user>/AppData/minetest` (maybe)
  36. Games
  37. =====
  38. Games are looked up from:
  39. * `$path_share/games/<gameid>/`
  40. * `$path_user/games/<gameid>/`
  41. Where `<gameid>` is unique to each game.
  42. The game directory can contain the following files:
  43. * `game.conf`, with the following keys:
  44. * `name`: Required, a human readable title to address the game, e.g. `name = Minetest`.
  45. * `description`: Short description to be shown in the content tab
  46. * `allowed_mapgens = <comma-separated mapgens>`
  47. e.g. `allowed_mapgens = v5,v6,flat`
  48. Mapgens not in this list are removed from the list of mapgens for the
  49. game.
  50. If not specified, all mapgens are allowed.
  51. * `disallowed_mapgens = <comma-separated mapgens>`
  52. e.g. `disallowed_mapgens = v5,v6,flat`
  53. These mapgens are removed from the list of mapgens for the game.
  54. When both `allowed_mapgens` and `disallowed_mapgens` are
  55. specified, `allowed_mapgens` is applied before
  56. `disallowed_mapgens`.
  57. * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
  58. e.g. `disallowed_mapgen_settings = mgv5_spflags`
  59. These mapgen settings are hidden for this game in the world creation
  60. dialog and game start menu. Add `seed` to hide the seed input field.
  61. * `disabled_settings = <comma-separated settings>`
  62. e.g. `disabled_settings = enable_damage, creative_mode`
  63. These settings are hidden for this game in the "Start game" tab
  64. and will be initialized as `false` when the game is started.
  65. Prepend a setting name with an exclamation mark to initialize it to `true`
  66. (this does not work for `enable_server`).
  67. Only these settings are supported:
  68. `enable_damage`, `creative_mode`, `enable_server`.
  69. * `author`: The author of the game. It only appears when downloaded from
  70. ContentDB.
  71. * `release`: Ignore this: Should only ever be set by ContentDB, as it is
  72. an internal ID used to track versions.
  73. * `minetest.conf`:
  74. Used to set default settings when running this game.
  75. * `settingtypes.txt`:
  76. In the same format as the one in builtin.
  77. This settingtypes.txt will be parsed by the menu and the settings will be
  78. displayed in the "Games" category in the advanced settings tab.
  79. * If the game contains a folder called `textures` the server will load it as a
  80. texturepack, overriding mod textures.
  81. Any server texturepack will override mod textures and the game texturepack.
  82. Menu images
  83. -----------
  84. Games can provide custom main menu images. They are put inside a `menu`
  85. directory inside the game directory.
  86. The images are named `$identifier.png`, where `$identifier` is one of
  87. `overlay`, `background`, `footer`, `header`.
  88. If you want to specify multiple images for one identifier, add additional
  89. images named like `$identifier.$n.png`, with an ascending number $n starting
  90. with 1, and a random image will be chosen from the provided ones.
  91. Menu music
  92. -----------
  93. Games can provide custom main menu music. They are put inside a `menu`
  94. directory inside the game directory.
  95. The music files are named `theme.ogg`.
  96. If you want to specify multiple music files for one game, add additional
  97. images named like `theme.$n.ogg`, with an ascending number $n starting
  98. with 1 (max 10), and a random music file will be chosen from the provided ones.
  99. Mods
  100. ====
  101. Mod load path
  102. -------------
  103. Paths are relative to the directories listed in the [Paths] section above.
  104. * `games/<gameid>/mods/`
  105. * `mods/`
  106. * `worlds/<worldname>/worldmods/`
  107. World-specific games
  108. --------------------
  109. It is possible to include a game in a world; in this case, no mods or
  110. games are loaded or checked from anywhere else.
  111. This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
  112. directory exists.
  113. Mods should then be placed in `<worldname>/game/mods/`.
  114. Modpacks
  115. --------
  116. Mods can be put in a subdirectory, if the parent directory, which otherwise
  117. should be a mod, contains a file named `modpack.conf`.
  118. The file is a key-value store of modpack details.
  119. * `name`: The modpack name. Allows Minetest to determine the modpack name even
  120. if the folder is wrongly named.
  121. * `description`: Description of mod to be shown in the Mods tab of the main
  122. menu.
  123. * `author`: The author of the modpack. It only appears when downloaded from
  124. ContentDB.
  125. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  126. internal ID used to track versions.
  127. * `title`: A human-readable title to address the modpack.
  128. Note: to support 0.4.x, please also create an empty modpack.txt file.
  129. Mod directory structure
  130. -----------------------
  131. mods
  132. ├── modname
  133. │   ├── mod.conf
  134. │   ├── screenshot.png
  135. │   ├── settingtypes.txt
  136. │   ├── init.lua
  137. │   ├── models
  138. │   ├── textures
  139. │   │   ├── modname_stuff.png
  140. │   │   ├── modname_stuff_normal.png
  141. │   │   ├── modname_something_else.png
  142. │   │   ├── subfolder_foo
  143. │   │   │ ├── modname_more_stuff.png
  144. │   │   │ └── another_subfolder
  145. │   │   └── bar_subfolder
  146. │   ├── sounds
  147. │   ├── media
  148. │   ├── locale
  149. │   └── <custom data>
  150. └── another
  151. ### modname
  152. The location of this directory can be fetched by using
  153. `minetest.get_modpath(modname)`.
  154. ### mod.conf
  155. A `Settings` file that provides meta information about the mod.
  156. * `name`: The mod name. Allows Minetest to determine the mod name even if the
  157. folder is wrongly named.
  158. * `description`: Description of mod to be shown in the Mods tab of the main
  159. menu.
  160. * `depends`: A comma separated list of dependencies. These are mods that must be
  161. loaded before this mod.
  162. * `optional_depends`: A comma separated list of optional dependencies.
  163. Like a dependency, but no error if the mod doesn't exist.
  164. * `author`: The author of the mod. It only appears when downloaded from
  165. ContentDB.
  166. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  167. internal ID used to track versions.
  168. * `title`: A human-readable title to address the mod.
  169. Note: to support 0.4.x, please also provide depends.txt.
  170. ### `screenshot.png`
  171. A screenshot shown in the mod manager within the main menu. It should
  172. have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
  173. ### `depends.txt`
  174. **Deprecated:** you should use mod.conf instead.
  175. This file is used if there are no dependencies in mod.conf.
  176. List of mods that have to be loaded before loading this mod.
  177. A single line contains a single modname.
  178. Optional dependencies can be defined by appending a question mark
  179. to a single modname. This means that if the specified mod
  180. is missing, it does not prevent this mod from being loaded.
  181. ### `description.txt`
  182. **Deprecated:** you should use mod.conf instead.
  183. This file is used if there is no description in mod.conf.
  184. A file containing a description to be shown in the Mods tab of the main menu.
  185. ### `settingtypes.txt`
  186. The format is documented in `builtin/settingtypes.txt`.
  187. It is parsed by the main menu settings dialogue to list mod-specific
  188. settings in the "Mods" category.
  189. ### `init.lua`
  190. The main Lua script. Running this script should register everything it
  191. wants to register. Subsequent execution depends on minetest calling the
  192. registered callbacks.
  193. `minetest.settings` can be used to read custom or existing settings at load
  194. time, if necessary. (See [`Settings`])
  195. ### `textures`, `sounds`, `media`, `models`, `locale`
  196. Media files (textures, sounds, whatever) that will be transferred to the
  197. client and will be available for use by the mod and translation files for
  198. the clients (see [Translations]).
  199. It is suggested to use the folders for the purpose they are thought for,
  200. eg. put textures into `textures`, translation files into `locale`,
  201. models for entities or meshnodes into `models` et cetera.
  202. These folders and subfolders can contain subfolders.
  203. Subfolders with names starting with `_` or `.` are ignored.
  204. If a subfolder contains a media file with the same name as a media file
  205. in one of its parents, the parent's file is used.
  206. Although it is discouraged, a mod can overwrite a media file of any mod that it
  207. depends on by supplying a file with an equal name.
  208. Naming conventions
  209. ------------------
  210. Registered names should generally be in this format:
  211. modname:<whatever>
  212. `<whatever>` can have these characters:
  213. a-zA-Z0-9_
  214. This is to prevent conflicting names from corrupting maps and is
  215. enforced by the mod loader.
  216. Registered names can be overridden by prefixing the name with `:`. This can
  217. be used for overriding the registrations of some other mod.
  218. The `:` prefix can also be used for maintaining backwards compatibility.
  219. ### Example
  220. In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
  221. So the name should be `experimental:tnt`.
  222. Any mod can redefine `experimental:tnt` by using the name
  223. :experimental:tnt
  224. when registering it. That mod is required to have `experimental` as a
  225. dependency.
  226. Aliases
  227. =======
  228. Aliases of itemnames can be added by using
  229. `minetest.register_alias(alias, original_name)` or
  230. `minetest.register_alias_force(alias, original_name)`.
  231. This adds an alias `alias` for the item called `original_name`.
  232. From now on, you can use `alias` to refer to the item `original_name`.
  233. The only difference between `minetest.register_alias` and
  234. `minetest.register_alias_force` is that if an item named `alias` already exists,
  235. `minetest.register_alias` will do nothing while
  236. `minetest.register_alias_force` will unregister it.
  237. This can be used for maintaining backwards compatibility.
  238. This can also set quick access names for things, e.g. if
  239. you have an item called `epiclylongmodname:stuff`, you could do
  240. minetest.register_alias("stuff", "epiclylongmodname:stuff")
  241. and be able to use `/giveme stuff`.
  242. Mapgen aliases
  243. --------------
  244. In a game, a certain number of these must be set to tell core mapgens which
  245. of the game's nodes are to be used for core mapgen generation. For example:
  246. minetest.register_alias("mapgen_stone", "default:stone")
  247. ### Aliases for non-V6 mapgens
  248. #### Essential aliases
  249. * mapgen_stone
  250. * mapgen_water_source
  251. * mapgen_river_water_source
  252. `mapgen_river_water_source` is required for mapgens with sloping rivers where
  253. it is necessary to have a river liquid node with a short `liquid_range` and
  254. `liquid_renewable = false` to avoid flooding.
  255. #### Optional aliases
  256. * mapgen_lava_source
  257. Fallback lava node used if cave liquids are not defined in biome definitions.
  258. Deprecated for non-V6 mapgens, define cave liquids in biome definitions instead.
  259. * mapgen_cobble
  260. Fallback node used if dungeon nodes are not defined in biome definitions.
  261. Deprecated for non-V6 mapgens, define dungeon nodes in biome definitions instead.
  262. ### Aliases needed for Mapgen V6
  263. * mapgen_stone
  264. * mapgen_water_source
  265. * mapgen_lava_source
  266. * mapgen_dirt
  267. * mapgen_dirt_with_grass
  268. * mapgen_sand
  269. * mapgen_gravel
  270. * mapgen_desert_stone
  271. * mapgen_desert_sand
  272. * mapgen_dirt_with_snow
  273. * mapgen_snowblock
  274. * mapgen_snow
  275. * mapgen_ice
  276. * mapgen_tree
  277. * mapgen_leaves
  278. * mapgen_apple
  279. * mapgen_jungletree
  280. * mapgen_jungleleaves
  281. * mapgen_junglegrass
  282. * mapgen_pine_tree
  283. * mapgen_pine_needles
  284. * mapgen_cobble
  285. * mapgen_stair_cobble
  286. * mapgen_mossycobble
  287. * mapgen_stair_desert_stone
  288. ### Setting the node used in Mapgen Singlenode
  289. By default the world is filled with air nodes. To set a different node use, for
  290. example:
  291. minetest.register_alias("mapgen_singlenode", "default:stone")
  292. Textures
  293. ========
  294. Mods should generally prefix their textures with `modname_`, e.g. given
  295. the mod name `foomod`, a texture could be called:
  296. foomod_foothing.png
  297. Textures are referred to by their complete name, or alternatively by
  298. stripping out the file extension:
  299. * e.g. `foomod_foothing.png`
  300. * e.g. `foomod_foothing`
  301. Texture modifiers
  302. -----------------
  303. There are various texture modifiers that can be used
  304. to let the client generate textures on-the-fly.
  305. The modifiers are applied directly in sRGB colorspace,
  306. i.e. without gamma-correction.
  307. ### Texture overlaying
  308. Textures can be overlaid by putting a `^` between them.
  309. Example:
  310. default_dirt.png^default_grass_side.png
  311. `default_grass_side.png` is overlaid over `default_dirt.png`.
  312. The texture with the lower resolution will be automatically upscaled to
  313. the higher resolution texture.
  314. ### Texture grouping
  315. Textures can be grouped together by enclosing them in `(` and `)`.
  316. Example: `cobble.png^(thing1.png^thing2.png)`
  317. A texture for `thing1.png^thing2.png` is created and the resulting
  318. texture is overlaid on top of `cobble.png`.
  319. ### Escaping
  320. Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
  321. passing complex texture names as arguments. Escaping is done with backslash and
  322. is required for `^` and `:`.
  323. Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
  324. The lower 50 percent of `color.png^[mask:trans.png` are overlaid
  325. on top of `cobble.png`.
  326. ### Advanced texture modifiers
  327. #### Crack
  328. * `[crack:<n>:<p>`
  329. * `[cracko:<n>:<p>`
  330. * `[crack:<t>:<n>:<p>`
  331. * `[cracko:<t>:<n>:<p>`
  332. Parameters:
  333. * `<t>`: tile count (in each direction)
  334. * `<n>`: animation frame count
  335. * `<p>`: current animation frame
  336. Draw a step of the crack animation on the texture.
  337. `crack` draws it normally, while `cracko` lays it over, keeping transparent
  338. pixels intact.
  339. Example:
  340. default_cobble.png^[crack:10:1
  341. #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
  342. * `<w>`: width
  343. * `<h>`: height
  344. * `<x>`: x position
  345. * `<y>`: y position
  346. * `<file>`: texture to combine
  347. Creates a texture of size `<w>` times `<h>` and blits the listed files to their
  348. specified coordinates.
  349. Example:
  350. [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
  351. #### `[resize:<w>x<h>`
  352. Resizes the texture to the given dimensions.
  353. Example:
  354. default_sandstone.png^[resize:16x16
  355. #### `[opacity:<r>`
  356. Makes the base image transparent according to the given ratio.
  357. `r` must be between 0 (transparent) and 255 (opaque).
  358. Example:
  359. default_sandstone.png^[opacity:127
  360. #### `[invert:<mode>`
  361. Inverts the given channels of the base image.
  362. Mode may contain the characters "r", "g", "b", "a".
  363. Only the channels that are mentioned in the mode string will be inverted.
  364. Example:
  365. default_apple.png^[invert:rgb
  366. #### `[brighten`
  367. Brightens the texture.
  368. Example:
  369. tnt_tnt_side.png^[brighten
  370. #### `[noalpha`
  371. Makes the texture completely opaque.
  372. Example:
  373. default_leaves.png^[noalpha
  374. #### `[makealpha:<r>,<g>,<b>`
  375. Convert one color to transparency.
  376. Example:
  377. default_cobble.png^[makealpha:128,128,128
  378. #### `[transform<t>`
  379. * `<t>`: transformation(s) to apply
  380. Rotates and/or flips the image.
  381. `<t>` can be a number (between 0 and 7) or a transform name.
  382. Rotations are counter-clockwise.
  383. 0 I identity
  384. 1 R90 rotate by 90 degrees
  385. 2 R180 rotate by 180 degrees
  386. 3 R270 rotate by 270 degrees
  387. 4 FX flip X
  388. 5 FXR90 flip X then rotate by 90 degrees
  389. 6 FY flip Y
  390. 7 FYR90 flip Y then rotate by 90 degrees
  391. Example:
  392. default_stone.png^[transformFXR90
  393. #### `[inventorycube{<top>{<left>{<right>`
  394. Escaping does not apply here and `^` is replaced by `&` in texture names
  395. instead.
  396. Create an inventory cube texture using the side textures.
  397. Example:
  398. [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
  399. Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
  400. `dirt.png^grass_side.png` textures
  401. #### `[lowpart:<percent>:<file>`
  402. Blit the lower `<percent>`% part of `<file>` on the texture.
  403. Example:
  404. base.png^[lowpart:25:overlay.png
  405. #### `[verticalframe:<t>:<n>`
  406. * `<t>`: animation frame count
  407. * `<n>`: current animation frame
  408. Crops the texture to a frame of a vertical animation.
  409. Example:
  410. default_torch_animated.png^[verticalframe:16:8
  411. #### `[mask:<file>`
  412. Apply a mask to the base image.
  413. The mask is applied using binary AND.
  414. #### `[sheet:<w>x<h>:<x>,<y>`
  415. Retrieves a tile at position x,y from the base image
  416. which it assumes to be a tilesheet with dimensions w,h.
  417. #### `[colorize:<color>:<ratio>`
  418. Colorize the textures with the given color.
  419. `<color>` is specified as a `ColorString`.
  420. `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
  421. it is an int, then it specifies how far to interpolate between the
  422. colors where 0 is only the texture color and 255 is only `<color>`. If
  423. omitted, the alpha of `<color>` will be used as the ratio. If it is
  424. the word "`alpha`", then each texture pixel will contain the RGB of
  425. `<color>` and the alpha of `<color>` multiplied by the alpha of the
  426. texture pixel.
  427. #### `[multiply:<color>`
  428. Multiplies texture colors with the given color.
  429. `<color>` is specified as a `ColorString`.
  430. Result is more like what you'd expect if you put a color on top of another
  431. color, meaning white surfaces get a lot of your new color while black parts
  432. don't change very much.
  433. #### `[png:<base64>`
  434. Embed a base64 encoded PNG image in the texture string.
  435. You can produce a valid string for this by calling
  436. `minetest.encode_base64(minetest.encode_png(tex))`,
  437. refer to the documentation of these functions for details.
  438. You can use this to send disposable images such as captchas
  439. to individual clients, or render things that would be too
  440. expensive to compose with `[combine:`.
  441. IMPORTANT: Avoid sending large images this way.
  442. This is not a replacement for asset files, do not use it to do anything
  443. that you could instead achieve by just using a file.
  444. In particular consider `minetest.dynamic_add_media` and test whether
  445. using other texture modifiers could result in a shorter string than
  446. embedding a whole image, this may vary by use case.
  447. Hardware coloring
  448. -----------------
  449. The goal of hardware coloring is to simplify the creation of
  450. colorful nodes. If your textures use the same pattern, and they only
  451. differ in their color (like colored wool blocks), you can use hardware
  452. coloring instead of creating and managing many texture files.
  453. All of these methods use color multiplication (so a white-black texture
  454. with red coloring will result in red-black color).
  455. ### Static coloring
  456. This method is useful if you wish to create nodes/items with
  457. the same texture, in different colors, each in a new node/item definition.
  458. #### Global color
  459. When you register an item or node, set its `color` field (which accepts a
  460. `ColorSpec`) to the desired color.
  461. An `ItemStack`'s static color can be overwritten by the `color` metadata
  462. field. If you set that field to a `ColorString`, that color will be used.
  463. #### Tile color
  464. Each tile may have an individual static color, which overwrites every
  465. other coloring method. To disable the coloring of a face,
  466. set its color to white (because multiplying with white does nothing).
  467. You can set the `color` property of the tiles in the node's definition
  468. if the tile is in table format.
  469. ### Palettes
  470. For nodes and items which can have many colors, a palette is more
  471. suitable. A palette is a texture, which can contain up to 256 pixels.
  472. Each pixel is one possible color for the node/item.
  473. You can register one node/item, which can have up to 256 colors.
  474. #### Palette indexing
  475. When using palettes, you always provide a pixel index for the given
  476. node or `ItemStack`. The palette is read from left to right and from
  477. top to bottom. If the palette has less than 256 pixels, then it is
  478. stretched to contain exactly 256 pixels (after arranging the pixels
  479. to one line). The indexing starts from 0.
  480. Examples:
  481. * 16x16 palette, index = 0: the top left corner
  482. * 16x16 palette, index = 4: the fifth pixel in the first row
  483. * 16x16 palette, index = 16: the pixel below the top left corner
  484. * 16x16 palette, index = 255: the bottom right corner
  485. * 2 (width) x 4 (height) palette, index = 31: the top left corner.
  486. The palette has 8 pixels, so each pixel is stretched to 32 pixels,
  487. to ensure the total 256 pixels.
  488. * 2x4 palette, index = 32: the top right corner
  489. * 2x4 palette, index = 63: the top right corner
  490. * 2x4 palette, index = 64: the pixel below the top left corner
  491. #### Using palettes with items
  492. When registering an item, set the item definition's `palette` field to
  493. a texture. You can also use texture modifiers.
  494. The `ItemStack`'s color depends on the `palette_index` field of the
  495. stack's metadata. `palette_index` is an integer, which specifies the
  496. index of the pixel to use.
  497. #### Linking palettes with nodes
  498. When registering a node, set the item definition's `palette` field to
  499. a texture. You can also use texture modifiers.
  500. The node's color depends on its `param2`, so you also must set an
  501. appropriate `paramtype2`:
  502. * `paramtype2 = "color"` for nodes which use their full `param2` for
  503. palette indexing. These nodes can have 256 different colors.
  504. The palette should contain 256 pixels.
  505. * `paramtype2 = "colorwallmounted"` for nodes which use the first
  506. five bits (most significant) of `param2` for palette indexing.
  507. The remaining three bits are describing rotation, as in `wallmounted`
  508. paramtype2. Division by 8 yields the palette index (without stretching the
  509. palette). These nodes can have 32 different colors, and the palette
  510. should contain 32 pixels.
  511. Examples:
  512. * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
  513. pixel will be picked from the palette.
  514. * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
  515. pixel will be picked from the palette.
  516. * `paramtype2 = "colorfacedir"` for nodes which use the first
  517. three bits of `param2` for palette indexing. The remaining
  518. five bits are describing rotation, as in `facedir` paramtype2.
  519. Division by 32 yields the palette index (without stretching the
  520. palette). These nodes can have 8 different colors, and the
  521. palette should contain 8 pixels.
  522. Examples:
  523. * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
  524. first (= 0 + 1) pixel will be picked from the palette.
  525. * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
  526. second (= 1 + 1) pixel will be picked from the palette.
  527. To colorize a node on the map, set its `param2` value (according
  528. to the node's paramtype2).
  529. ### Conversion between nodes in the inventory and on the map
  530. Static coloring is the same for both cases, there is no need
  531. for conversion.
  532. If the `ItemStack`'s metadata contains the `color` field, it will be
  533. lost on placement, because nodes on the map can only use palettes.
  534. If the `ItemStack`'s metadata contains the `palette_index` field, it is
  535. automatically transferred between node and item forms by the engine,
  536. when a player digs or places a colored node.
  537. You can disable this feature by setting the `drop` field of the node
  538. to itself (without metadata).
  539. To transfer the color to a special drop, you need a drop table.
  540. Example:
  541. minetest.register_node("mod:stone", {
  542. description = "Stone",
  543. tiles = {"default_stone.png"},
  544. paramtype2 = "color",
  545. palette = "palette.png",
  546. drop = {
  547. items = {
  548. -- assume that mod:cobblestone also has the same palette
  549. {items = {"mod:cobblestone"}, inherit_color = true },
  550. }
  551. }
  552. })
  553. ### Colored items in craft recipes
  554. Craft recipes only support item strings, but fortunately item strings
  555. can also contain metadata. Example craft recipe registration:
  556. minetest.register_craft({
  557. output = minetest.itemstring_with_palette("wool:block", 3),
  558. type = "shapeless",
  559. recipe = {
  560. "wool:block",
  561. "dye:red",
  562. },
  563. })
  564. To set the `color` field, you can use `minetest.itemstring_with_color`.
  565. Metadata field filtering in the `recipe` field are not supported yet,
  566. so the craft output is independent of the color of the ingredients.
  567. Soft texture overlay
  568. --------------------
  569. Sometimes hardware coloring is not enough, because it affects the
  570. whole tile. Soft texture overlays were added to Minetest to allow
  571. the dynamic coloring of only specific parts of the node's texture.
  572. For example a grass block may have colored grass, while keeping the
  573. dirt brown.
  574. These overlays are 'soft', because unlike texture modifiers, the layers
  575. are not merged in the memory, but they are simply drawn on top of each
  576. other. This allows different hardware coloring, but also means that
  577. tiles with overlays are drawn slower. Using too much overlays might
  578. cause FPS loss.
  579. For inventory and wield images you can specify overlays which
  580. hardware coloring does not modify. You have to set `inventory_overlay`
  581. and `wield_overlay` fields to an image name.
  582. To define a node overlay, simply set the `overlay_tiles` field of the node
  583. definition. These tiles are defined in the same way as plain tiles:
  584. they can have a texture name, color etc.
  585. To skip one face, set that overlay tile to an empty string.
  586. Example (colored grass block):
  587. minetest.register_node("default:dirt_with_grass", {
  588. description = "Dirt with Grass",
  589. -- Regular tiles, as usual
  590. -- The dirt tile disables palette coloring
  591. tiles = {{name = "default_grass.png"},
  592. {name = "default_dirt.png", color = "white"}},
  593. -- Overlay tiles: define them in the same style
  594. -- The top and bottom tile does not have overlay
  595. overlay_tiles = {"", "",
  596. {name = "default_grass_side.png"}},
  597. -- Global color, used in inventory
  598. color = "green",
  599. -- Palette in the world
  600. paramtype2 = "color",
  601. palette = "default_foilage.png",
  602. })
  603. Sounds
  604. ======
  605. Only Ogg Vorbis files are supported.
  606. For positional playing of sounds, only single-channel (mono) files are
  607. supported. Otherwise OpenAL will play them non-positionally.
  608. Mods should generally prefix their sounds with `modname_`, e.g. given
  609. the mod name "`foomod`", a sound could be called:
  610. foomod_foosound.ogg
  611. Sounds are referred to by their name with a dot, a single digit and the
  612. file extension stripped out. When a sound is played, the actual sound file
  613. is chosen randomly from the matching sounds.
  614. When playing the sound `foomod_foosound`, the sound is chosen randomly
  615. from the available ones of the following files:
  616. * `foomod_foosound.ogg`
  617. * `foomod_foosound.0.ogg`
  618. * `foomod_foosound.1.ogg`
  619. * (...)
  620. * `foomod_foosound.9.ogg`
  621. Examples of sound parameter tables:
  622. -- Play locationless on all clients
  623. {
  624. gain = 1.0, -- default
  625. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  626. pitch = 1.0, -- default
  627. }
  628. -- Play locationless to one player
  629. {
  630. to_player = name,
  631. gain = 1.0, -- default
  632. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  633. pitch = 1.0, -- default
  634. }
  635. -- Play locationless to one player, looped
  636. {
  637. to_player = name,
  638. gain = 1.0, -- default
  639. loop = true,
  640. }
  641. -- Play at a location
  642. {
  643. pos = {x = 1, y = 2, z = 3},
  644. gain = 1.0, -- default
  645. max_hear_distance = 32, -- default, uses an euclidean metric
  646. }
  647. -- Play connected to an object, looped
  648. {
  649. object = <an ObjectRef>,
  650. gain = 1.0, -- default
  651. max_hear_distance = 32, -- default, uses an euclidean metric
  652. loop = true,
  653. }
  654. -- Play at a location, heard by anyone *but* the given player
  655. {
  656. pos = {x = 32, y = 0, z = 100},
  657. max_hear_distance = 40,
  658. exclude_player = name,
  659. }
  660. Looped sounds must either be connected to an object or played locationless to
  661. one player using `to_player = name`.
  662. A positional sound will only be heard by players that are within
  663. `max_hear_distance` of the sound position, at the start of the sound.
  664. `exclude_player = name` can be applied to locationless, positional and object-
  665. bound sounds to exclude a single player from hearing them.
  666. `SimpleSoundSpec`
  667. -----------------
  668. Specifies a sound name, gain (=volume) and pitch.
  669. This is either a string or a table.
  670. In string form, you just specify the sound name or
  671. the empty string for no sound.
  672. Table form has the following fields:
  673. * `name`: Sound name
  674. * `gain`: Volume (`1.0` = 100%)
  675. * `pitch`: Pitch (`1.0` = 100%)
  676. `gain` and `pitch` are optional and default to `1.0`.
  677. Examples:
  678. * `""`: No sound
  679. * `{}`: No sound
  680. * `"default_place_node"`: Play e.g. `default_place_node.ogg`
  681. * `{name = "default_place_node"}`: Same as above
  682. * `{name = "default_place_node", gain = 0.5}`: 50% volume
  683. * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
  684. Special sound files
  685. -------------------
  686. These sound files are played back by the engine if provided.
  687. * `player_damage`: Played when the local player takes damage (gain = 0.5)
  688. * `player_falling_damage`: Played when the local player takes
  689. damage by falling (gain = 0.5)
  690. * `player_jump`: Played when the local player jumps
  691. * `default_dig_<groupname>`: Default node digging sound
  692. (see node sound definition for details)
  693. Registered definitions
  694. ======================
  695. Anything added using certain [Registration functions] gets added to one or more
  696. of the global [Registered definition tables].
  697. Note that in some cases you will stumble upon things that are not contained
  698. in these tables (e.g. when a mod has been removed). Always check for
  699. existence before trying to access the fields.
  700. Example:
  701. All nodes register with `minetest.register_node` get added to the table
  702. `minetest.registered_nodes`.
  703. If you want to check the drawtype of a node, you could do:
  704. local function get_nodedef_field(nodename, fieldname)
  705. if not minetest.registered_nodes[nodename] then
  706. return nil
  707. end
  708. return minetest.registered_nodes[nodename][fieldname]
  709. end
  710. local drawtype = get_nodedef_field(nodename, "drawtype")
  711. Nodes
  712. =====
  713. Nodes are the bulk data of the world: cubes and other things that take the
  714. space of a cube. Huge amounts of them are handled efficiently, but they
  715. are quite static.
  716. The definition of a node is stored and can be accessed by using
  717. minetest.registered_nodes[node.name]
  718. See [Registered definitions].
  719. Nodes are passed by value between Lua and the engine.
  720. They are represented by a table:
  721. {name="name", param1=num, param2=num}
  722. `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
  723. them for certain automated functions. If you don't use these functions, you can
  724. use them to store arbitrary values.
  725. Node paramtypes
  726. ---------------
  727. The functions of `param1` and `param2` are determined by certain fields in the
  728. node definition.
  729. The function of `param1` is determined by `paramtype` in node definition.
  730. `param1` is reserved for the engine when `paramtype != "none"`.
  731. * `paramtype = "light"`
  732. * The value stores light with and without sun in its lower and upper 4 bits
  733. respectively.
  734. * Required by a light source node to enable spreading its light.
  735. * Required by the following drawtypes as they determine their visual
  736. brightness from their internal light value:
  737. * torchlike
  738. * signlike
  739. * firelike
  740. * fencelike
  741. * raillike
  742. * nodebox
  743. * mesh
  744. * plantlike
  745. * plantlike_rooted
  746. * `paramtype = "none"`
  747. * `param1` will not be used by the engine and can be used to store
  748. an arbitrary value
  749. The function of `param2` is determined by `paramtype2` in node definition.
  750. `param2` is reserved for the engine when `paramtype2 != "none"`.
  751. * `paramtype2 = "flowingliquid"`
  752. * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
  753. * The liquid level and a flag of the liquid are stored in `param2`
  754. * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
  755. see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
  756. to access/manipulate the content of this field
  757. * Bit 3: If set, liquid is flowing downwards (no graphical effect)
  758. * `paramtype2 = "wallmounted"`
  759. * Supported drawtypes: "torchlike", "signlike", "plantlike",
  760. "plantlike_rooted", "normal", "nodebox", "mesh"
  761. * The rotation of the node is stored in `param2`
  762. * You can make this value by using `minetest.dir_to_wallmounted()`
  763. * Values range 0 - 5
  764. * The value denotes at which direction the node is "mounted":
  765. 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z-
  766. * `paramtype2 = "facedir"`
  767. * Supported drawtypes: "normal", "nodebox", "mesh"
  768. * The rotation of the node is stored in `param2`. Furnaces and chests are
  769. rotated this way. Can be made by using `minetest.dir_to_facedir()`.
  770. * Values range 0 - 23
  771. * facedir / 4 = axis direction:
  772. 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y-
  773. * facedir modulo 4 = rotation around that axis
  774. * `paramtype2 = "leveled"`
  775. * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
  776. * Leveled nodebox:
  777. * The level of the top face of the nodebox is stored in `param2`.
  778. * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
  779. nodeboxes.
  780. * The nodebox height is (`param2` / 64) nodes.
  781. * The maximum accepted value of `param2` is 127.
  782. * Rooted plantlike:
  783. * The height of the 'plantlike' section is stored in `param2`.
  784. * The height is (`param2` / 16) nodes.
  785. * `paramtype2 = "degrotate"`
  786. * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
  787. stored in `param2`.
  788. * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
  789. get the actual rotation in degrees of the node.
  790. * `paramtype2 = "meshoptions"`
  791. * Only valid for "plantlike" drawtype. `param2` encodes the shape and
  792. optional modifiers of the "plant". `param2` is a bitfield.
  793. * Bits 0 to 2 select the shape.
  794. Use only one of the values below:
  795. * 0 = a "x" shaped plant (ordinary plant)
  796. * 1 = a "+" shaped plant (just rotated 45 degrees)
  797. * 2 = a "*" shaped plant with 3 faces instead of 2
  798. * 3 = a "#" shaped plant with 4 faces instead of 2
  799. * 4 = a "#" shaped plant with 4 faces that lean outwards
  800. * 5-7 are unused and reserved for future meshes.
  801. * Bits 3 to 7 are used to enable any number of optional modifiers.
  802. Just add the corresponding value(s) below to `param2`:
  803. * 8 - Makes the plant slightly vary placement horizontally
  804. * 16 - Makes the plant mesh 1.4x larger
  805. * 32 - Moves each face randomly a small bit down (1/8 max)
  806. * values 64 and 128 (bits 6-7) are reserved for future use.
  807. * Example: `param2 = 0` selects a normal "x" shaped plant
  808. * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
  809. * `paramtype2 = "color"`
  810. * `param2` tells which color is picked from the palette.
  811. The palette should have 256 pixels.
  812. * `paramtype2 = "colorfacedir"`
  813. * Same as `facedir`, but with colors.
  814. * The first three bits of `param2` tells which color is picked from the
  815. palette. The palette should have 8 pixels.
  816. * `paramtype2 = "colorwallmounted"`
  817. * Same as `wallmounted`, but with colors.
  818. * The first five bits of `param2` tells which color is picked from the
  819. palette. The palette should have 32 pixels.
  820. * `paramtype2 = "glasslikeliquidlevel"`
  821. * Only valid for "glasslike_framed" or "glasslike_framed_optional"
  822. drawtypes. "glasslike_framed_optional" nodes are only affected if the
  823. "Connected Glass" setting is enabled.
  824. * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
  825. full.
  826. * Bits 6 and 7 modify the appearance of the frame and node faces. One or
  827. both of these values may be added to `param2`:
  828. * 64 - Makes the node not connect with neighbors above or below it.
  829. * 128 - Makes the node not connect with neighbors to its sides.
  830. * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
  831. * `paramtype2 = "colordegrotate"`
  832. * Same as `degrotate`, but with colors.
  833. * The first (most-significant) three bits of `param2` tells which color
  834. is picked from the palette. The palette should have 8 pixels.
  835. * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
  836. * `paramtype2 = "none"`
  837. * `param2` will not be used by the engine and can be used to store
  838. an arbitrary value
  839. Nodes can also contain extra data. See [Node Metadata].
  840. Node drawtypes
  841. --------------
  842. There are a bunch of different looking node types.
  843. Look for examples in `games/devtest` or `games/minetest_game`.
  844. * `normal`
  845. * A node-sized cube.
  846. * `airlike`
  847. * Invisible, uses no texture.
  848. * `liquid`
  849. * The cubic source node for a liquid.
  850. * Faces bordering to the same node are never rendered.
  851. * Connects to node specified in `liquid_alternative_flowing`.
  852. * Use `backface_culling = false` for the tiles you want to make
  853. visible when inside the node.
  854. * `flowingliquid`
  855. * The flowing version of a liquid, appears with various heights and slopes.
  856. * Faces bordering to the same node are never rendered.
  857. * Connects to node specified in `liquid_alternative_source`.
  858. * Node textures are defined with `special_tiles` where the first tile
  859. is for the top and bottom faces and the second tile is for the side
  860. faces.
  861. * `tiles` is used for the item/inventory/wield image rendering.
  862. * Use `backface_culling = false` for the special tiles you want to make
  863. visible when inside the node
  864. * `glasslike`
  865. * Often used for partially-transparent nodes.
  866. * Only external sides of textures are visible.
  867. * `glasslike_framed`
  868. * All face-connected nodes are drawn as one volume within a surrounding
  869. frame.
  870. * The frame appearance is generated from the edges of the first texture
  871. specified in `tiles`. The width of the edges used are 1/16th of texture
  872. size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
  873. * The glass 'shine' (or other desired detail) on each node face is supplied
  874. by the second texture specified in `tiles`.
  875. * `glasslike_framed_optional`
  876. * This switches between the above 2 drawtypes according to the menu setting
  877. 'Connected Glass'.
  878. * `allfaces`
  879. * Often used for partially-transparent nodes.
  880. * External and internal sides of textures are visible.
  881. * `allfaces_optional`
  882. * Often used for leaves nodes.
  883. * This switches between `normal`, `glasslike` and `allfaces` according to
  884. the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
  885. * With 'Simple Leaves' selected, the texture specified in `special_tiles`
  886. is used instead, if present. This allows a visually thicker texture to be
  887. used to compensate for how `glasslike` reduces visual thickness.
  888. * `torchlike`
  889. * A single vertical texture.
  890. * If `paramtype2="[color]wallmounted":
  891. * If placed on top of a node, uses the first texture specified in `tiles`.
  892. * If placed against the underside of a node, uses the second texture
  893. specified in `tiles`.
  894. * If placed on the side of a node, uses the third texture specified in
  895. `tiles` and is perpendicular to that node.
  896. * If `paramtype2="none"`:
  897. * Will be rendered as if placed on top of a node (see
  898. above) and only the first texture is used.
  899. * `signlike`
  900. * A single texture parallel to, and mounted against, the top, underside or
  901. side of a node.
  902. * If `paramtype2="[color]wallmounted", it rotates according to `param2`
  903. * If `paramtype2="none"`, it will always be on the floor.
  904. * `plantlike`
  905. * Two vertical and diagonal textures at right-angles to each other.
  906. * See `paramtype2 = "meshoptions"` above for other options.
  907. * `firelike`
  908. * When above a flat surface, appears as 6 textures, the central 2 as
  909. `plantlike` plus 4 more surrounding those.
  910. * If not above a surface the central 2 do not appear, but the texture
  911. appears against the faces of surrounding nodes if they are present.
  912. * `fencelike`
  913. * A 3D model suitable for a wooden fence.
  914. * One placed node appears as a single vertical post.
  915. * Adjacently-placed nodes cause horizontal bars to appear between them.
  916. * `raillike`
  917. * Often used for tracks for mining carts.
  918. * Requires 4 textures to be specified in `tiles`, in order: Straight,
  919. curved, t-junction, crossing.
  920. * Each placed node automatically switches to a suitable rotated texture
  921. determined by the adjacent `raillike` nodes, in order to create a
  922. continuous track network.
  923. * Becomes a sloping node if placed against stepped nodes.
  924. * `nodebox`
  925. * Often used for stairs and slabs.
  926. * Allows defining nodes consisting of an arbitrary number of boxes.
  927. * See [Node boxes] below for more information.
  928. * `mesh`
  929. * Uses models for nodes.
  930. * Tiles should hold model materials textures.
  931. * Only static meshes are implemented.
  932. * For supported model formats see Irrlicht engine documentation.
  933. * `plantlike_rooted`
  934. * Enables underwater `plantlike` without air bubbles around the nodes.
  935. * Consists of a base cube at the co-ordinates of the node plus a
  936. `plantlike` extension above
  937. * If `paramtype2="leveled", the `plantlike` extension has a height
  938. of `param2 / 16` nodes, otherwise it's the height of 1 node
  939. * If `paramtype2="wallmounted"`, the `plantlike` extension
  940. will be at one of the corresponding 6 sides of the base cube.
  941. Also, the base cube rotates like a `normal` cube would
  942. * The `plantlike` extension visually passes through any nodes above the
  943. base cube without affecting them.
  944. * The base cube texture tiles are defined as normal, the `plantlike`
  945. extension uses the defined special tile, for example:
  946. `special_tiles = {{name = "default_papyrus.png"}},`
  947. `*_optional` drawtypes need less rendering time if deactivated
  948. (always client-side).
  949. Node boxes
  950. ----------
  951. Node selection boxes are defined using "node boxes".
  952. A nodebox is defined as any of:
  953. {
  954. -- A normal cube; the default in most things
  955. type = "regular"
  956. }
  957. {
  958. -- A fixed box (or boxes) (facedir param2 is used, if applicable)
  959. type = "fixed",
  960. fixed = box OR {box1, box2, ...}
  961. }
  962. {
  963. -- A variable height box (or boxes) with the top face position defined
  964. -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
  965. -- by param2.
  966. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
  967. type = "leveled",
  968. fixed = box OR {box1, box2, ...}
  969. }
  970. {
  971. -- A box like the selection box for torches
  972. -- (wallmounted param2 is used, if applicable)
  973. type = "wallmounted",
  974. wall_top = box,
  975. wall_bottom = box,
  976. wall_side = box
  977. }
  978. {
  979. -- A node that has optional boxes depending on neighbouring nodes'
  980. -- presence and type. See also `connects_to`.
  981. type = "connected",
  982. fixed = box OR {box1, box2, ...}
  983. connect_top = box OR {box1, box2, ...}
  984. connect_bottom = box OR {box1, box2, ...}
  985. connect_front = box OR {box1, box2, ...}
  986. connect_left = box OR {box1, box2, ...}
  987. connect_back = box OR {box1, box2, ...}
  988. connect_right = box OR {box1, box2, ...}
  989. -- The following `disconnected_*` boxes are the opposites of the
  990. -- `connect_*` ones above, i.e. when a node has no suitable neighbour
  991. -- on the respective side, the corresponding disconnected box is drawn.
  992. disconnected_top = box OR {box1, box2, ...}
  993. disconnected_bottom = box OR {box1, box2, ...}
  994. disconnected_front = box OR {box1, box2, ...}
  995. disconnected_left = box OR {box1, box2, ...}
  996. disconnected_back = box OR {box1, box2, ...}
  997. disconnected_right = box OR {box1, box2, ...}
  998. disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
  999. disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
  1000. -- neighbours to the sides
  1001. }
  1002. A `box` is defined as:
  1003. {x1, y1, z1, x2, y2, z2}
  1004. A box of a regular node would look like:
  1005. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  1006. To avoid collision issues, keep each value within the range of +/- 1.45.
  1007. This also applies to leveled nodeboxes, where the final height shall not
  1008. exceed this soft limit.
  1009. Map terminology and coordinates
  1010. ===============================
  1011. Nodes, mapblocks, mapchunks
  1012. ---------------------------
  1013. A 'node' is the fundamental cubic unit of a world and appears to a player as
  1014. roughly 1x1x1 meters in size.
  1015. A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
  1016. fundamental region of a world that is stored in the world database, sent to
  1017. clients and handled by many parts of the engine.
  1018. 'mapblock' is preferred terminology to 'block' to help avoid confusion with
  1019. 'node', however 'block' often appears in the API.
  1020. A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
  1021. (80x80x80 nodes) and is the volume of world generated in one operation by
  1022. the map generator.
  1023. The size in mapblocks has been chosen to optimise map generation.
  1024. Coordinates
  1025. -----------
  1026. ### Orientation of axes
  1027. For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
  1028. ### Node coordinates
  1029. Almost all positions used in the API use node coordinates.
  1030. ### Mapblock coordinates
  1031. Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
  1032. specify a particular mapblock.
  1033. For example blockpos (0,0,0) specifies the mapblock that extends from
  1034. node position (0,0,0) to node position (15,15,15).
  1035. #### Converting node position to the containing blockpos
  1036. To calculate the blockpos of the mapblock that contains the node at 'nodepos',
  1037. for each axis:
  1038. * blockpos = math.floor(nodepos / 16)
  1039. #### Converting blockpos to min/max node positions
  1040. To calculate the min/max node positions contained in the mapblock at 'blockpos',
  1041. for each axis:
  1042. * Minimum:
  1043. nodepos = blockpos * 16
  1044. * Maximum:
  1045. nodepos = blockpos * 16 + 15
  1046. HUD
  1047. ===
  1048. HUD element types
  1049. -----------------
  1050. The position field is used for all element types.
  1051. To account for differing resolutions, the position coordinates are the
  1052. percentage of the screen, ranging in value from `0` to `1`.
  1053. The name field is not yet used, but should contain a description of what the
  1054. HUD element represents.
  1055. The `direction` field is the direction in which something is drawn.
  1056. `0` draws from left to right, `1` draws from right to left, `2` draws from
  1057. top to bottom, and `3` draws from bottom to top.
  1058. The `alignment` field specifies how the item will be aligned. It is a table
  1059. where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
  1060. moved to the left/up, and `1` is to the right/down. Fractional values can be
  1061. used.
  1062. The `offset` field specifies a pixel offset from the position. Contrary to
  1063. position, the offset is not scaled to screen size. This allows for some
  1064. precisely positioned items in the HUD.
  1065. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
  1066. factor!
  1067. The `z_index` field specifies the order of HUD elements from back to front.
  1068. Lower z-index elements are displayed behind higher z-index elements. Elements
  1069. with same z-index are displayed in an arbitrary order. Default 0.
  1070. Supports negative values. By convention, the following values are recommended:
  1071. * -400: Graphical effects, such as vignette
  1072. * -300: Name tags, waypoints
  1073. * -200: Wieldhand
  1074. * -100: Things that block the player's view, e.g. masks
  1075. * 0: Default. For standard in-game HUD elements like crosshair, hotbar,
  1076. minimap, builtin statbars, etc.
  1077. * 100: Temporary text messages or notification icons
  1078. * 1000: Full-screen effects such as full-black screen or credits.
  1079. This includes effects that cover the entire screen
  1080. * Other: If your HUD element doesn't fit into any category, pick a number
  1081. between the suggested values
  1082. Below are the specific uses for fields in each type; fields not listed for that
  1083. type are ignored.
  1084. ### `image`
  1085. Displays an image on the HUD.
  1086. * `scale`: The scale of the image, with 1 being the original texture size.
  1087. Only the X coordinate scale is used (positive values).
  1088. Negative values represent that percentage of the screen it
  1089. should take; e.g. `x=-100` means 100% (width).
  1090. * `text`: The name of the texture that is displayed.
  1091. * `alignment`: The alignment of the image.
  1092. * `offset`: offset in pixels from position.
  1093. ### `text`
  1094. Displays text on the HUD.
  1095. * `scale`: Defines the bounding rectangle of the text.
  1096. A value such as `{x=100, y=100}` should work.
  1097. * `text`: The text to be displayed in the HUD element.
  1098. * `number`: An integer containing the RGB value of the color used to draw the
  1099. text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
  1100. * `alignment`: The alignment of the text.
  1101. * `offset`: offset in pixels from position.
  1102. * `size`: size of the text.
  1103. The player-set font size is multiplied by size.x (y value isn't used).
  1104. ### `statbar`
  1105. Displays a horizontal bar made up of half-images with an optional background.
  1106. * `text`: The name of the texture to use.
  1107. * `text2`: Optional texture name to enable a background / "off state"
  1108. texture (useful to visualize the maximal value). Both textures
  1109. must have the same size.
  1110. * `number`: The number of half-textures that are displayed.
  1111. If odd, will end with a vertically center-split texture.
  1112. * `item`: Same as `number` but for the "off state" texture
  1113. * `direction`: To which direction the images will extend to
  1114. * `offset`: offset in pixels from position.
  1115. * `size`: If used, will force full-image size to this value (override texture
  1116. pack image size)
  1117. ### `inventory`
  1118. * `text`: The name of the inventory list to be displayed.
  1119. * `number`: Number of items in the inventory to be displayed.
  1120. * `item`: Position of item that is selected.
  1121. * `direction`
  1122. * `offset`: offset in pixels from position.
  1123. ### `waypoint`
  1124. Displays distance to selected world position.
  1125. * `name`: The name of the waypoint.
  1126. * `text`: Distance suffix. Can be blank.
  1127. * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
  1128. If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
  1129. When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
  1130. `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
  1131. `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
  1132. `precision = n` will show multiples of `1/n`
  1133. * `number:` An integer containing the RGB value of the color used to draw the
  1134. text.
  1135. * `world_pos`: World position of the waypoint.
  1136. * `offset`: offset in pixels from position.
  1137. * `alignment`: The alignment of the waypoint.
  1138. ### `image_waypoint`
  1139. Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
  1140. * `scale`: The scale of the image, with 1 being the original texture size.
  1141. Only the X coordinate scale is used (positive values).
  1142. Negative values represent that percentage of the screen it
  1143. should take; e.g. `x=-100` means 100% (width).
  1144. * `text`: The name of the texture that is displayed.
  1145. * `alignment`: The alignment of the image.
  1146. * `world_pos`: World position of the waypoint.
  1147. * `offset`: offset in pixels from position.
  1148. ### `compass`
  1149. Displays an image oriented or translated according to current heading direction.
  1150. * `size`: The size of this element. Negative values represent percentage
  1151. of the screen; e.g. `x=-100` means 100% (width).
  1152. * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
  1153. * `text`: The name of the texture to use.
  1154. * `alignment`: The alignment of the image.
  1155. * `offset`: Offset in pixels from position.
  1156. * `dir`: How the image is rotated/translated:
  1157. * 0 - Rotate as heading direction
  1158. * 1 - Rotate in reverse direction
  1159. * 2 - Translate as landscape direction
  1160. * 3 - Translate in reverse direction
  1161. If translation is chosen, texture is repeated horizontally to fill the whole element.
  1162. ### `minimap`
  1163. Displays a minimap on the HUD.
  1164. * `size`: Size of the minimap to display. Minimap should be a square to avoid
  1165. distortion.
  1166. * `alignment`: The alignment of the minimap.
  1167. * `offset`: offset in pixels from position.
  1168. Representations of simple things
  1169. ================================
  1170. Vector (ie. a position)
  1171. -----------------------
  1172. vector.new(x, y, z)
  1173. See [Spatial Vectors] for details.
  1174. `pointed_thing`
  1175. ---------------
  1176. * `{type="nothing"}`
  1177. * `{type="node", under=pos, above=pos}`
  1178. * Indicates a pointed node selection box.
  1179. * `under` refers to the node position behind the pointed face.
  1180. * `above` refers to the node position in front of the pointed face.
  1181. * `{type="object", ref=ObjectRef}`
  1182. Exact pointing location (currently only `Raycast` supports these fields):
  1183. * `pointed_thing.intersection_point`: The absolute world coordinates of the
  1184. point on the selection box which is pointed at. May be in the selection box
  1185. if the pointer is in the box too.
  1186. * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
  1187. from 1).
  1188. * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
  1189. selected selection box. This specifies which face is pointed at.
  1190. Is a null vector `vector.zero()` when the pointer is inside the selection box.
  1191. Flag Specifier Format
  1192. =====================
  1193. Flags using the standardized flag specifier format can be specified in either
  1194. of two ways, by string or table.
  1195. The string format is a comma-delimited set of flag names; whitespace and
  1196. unrecognized flag fields are ignored. Specifying a flag in the string sets the
  1197. flag, and specifying a flag prefixed by the string `"no"` explicitly
  1198. clears the flag from whatever the default may be.
  1199. In addition to the standard string flag format, the schematic flags field can
  1200. also be a table of flag names to boolean values representing whether or not the
  1201. flag is set. Additionally, if a field with the flag name prefixed with `"no"`
  1202. is present, mapped to a boolean of any value, the specified flag is unset.
  1203. E.g. A flag field of value
  1204. {place_center_x = true, place_center_y=false, place_center_z=true}
  1205. is equivalent to
  1206. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  1207. which is equivalent to
  1208. "place_center_x, noplace_center_y, place_center_z"
  1209. or even
  1210. "place_center_x, place_center_z"
  1211. since, by default, no schematic attributes are set.
  1212. Items
  1213. =====
  1214. Items are things that can be held by players, dropped in the map and
  1215. stored in inventories.
  1216. Items come in the form of item stacks, which are collections of equal
  1217. items that occupy a single inventory slot.
  1218. Item types
  1219. ----------
  1220. There are three kinds of items: nodes, tools and craftitems.
  1221. * Node: Placeable item form of a node in the world's voxel grid
  1222. * Tool: Has a changable wear property but cannot be stacked
  1223. * Craftitem: Has no special properties
  1224. Every registered node (the voxel in the world) has a corresponding
  1225. item form (the thing in your inventory) that comes along with it.
  1226. This item form can be placed which will create a node in the
  1227. world (by default).
  1228. Both the 'actual' node and its item form share the same identifier.
  1229. For all practical purposes, you can treat the node and its item form
  1230. interchangeably. We usually just say 'node' to the item form of
  1231. the node as well.
  1232. Note the definition of tools is purely technical. The only really
  1233. unique thing about tools is their wear, and that's basically it.
  1234. Beyond that, you can't make any gameplay-relevant assumptions
  1235. about tools or non-tools. It is perfectly valid to register something
  1236. that acts as tool in a gameplay sense as a craftitem, and vice-versa.
  1237. Craftitems can be used for items that neither need to be a node
  1238. nor a tool.
  1239. Amount and wear
  1240. ---------------
  1241. All item stacks have an amount between 0 and 65535. It is 1 by
  1242. default. Tool item stacks can not have an amount greater than 1.
  1243. Tools use a wear (damage) value ranging from 0 to 65535. The
  1244. value 0 is the default and is used for unworn tools. The values
  1245. 1 to 65535 are used for worn tools, where a higher value stands for
  1246. a higher wear. Non-tools technically also have a wear property,
  1247. but it is always 0. There is also a special 'toolrepair' crafting
  1248. recipe that is only available to tools.
  1249. Item formats
  1250. ------------
  1251. Items and item stacks can exist in three formats: Serializes, table format
  1252. and `ItemStack`.
  1253. When an item must be passed to a function, it can usually be in any of
  1254. these formats.
  1255. ### Serialized
  1256. This is called "stackstring" or "itemstring". It is a simple string with
  1257. 1-3 components: the full item identifier, an optional amount and an optional
  1258. wear value. Syntax:
  1259. <identifier> [<amount>[ <wear>]]
  1260. Examples:
  1261. * `"default:apple"`: 1 apple
  1262. * `"default:dirt 5"`: 5 dirt
  1263. * `"default:pick_stone"`: a new stone pickaxe
  1264. * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
  1265. ### Table format
  1266. Examples:
  1267. 5 dirt nodes:
  1268. {name="default:dirt", count=5, wear=0, metadata=""}
  1269. A wooden pick about 1/3 worn out:
  1270. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  1271. An apple:
  1272. {name="default:apple", count=1, wear=0, metadata=""}
  1273. ### `ItemStack`
  1274. A native C++ format with many helper methods. Useful for converting
  1275. between formats. See the [Class reference] section for details.
  1276. Groups
  1277. ======
  1278. In a number of places, there is a group table. Groups define the
  1279. properties of a thing (item, node, armor of entity, tool capabilities)
  1280. in such a way that the engine and other mods can can interact with
  1281. the thing without actually knowing what the thing is.
  1282. Usage
  1283. -----
  1284. Groups are stored in a table, having the group names with keys and the
  1285. group ratings as values. Group ratings are integer values within the
  1286. range [-32767, 32767]. For example:
  1287. -- Default dirt
  1288. groups = {crumbly=3, soil=1}
  1289. -- A more special dirt-kind of thing
  1290. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  1291. Groups always have a rating associated with them. If there is no
  1292. useful meaning for a rating for an enabled group, it shall be `1`.
  1293. When not defined, the rating of a group defaults to `0`. Thus when you
  1294. read groups, you must interpret `nil` and `0` as the same value, `0`.
  1295. You can read the rating of a group for an item or a node by using
  1296. minetest.get_item_group(itemname, groupname)
  1297. Groups of items
  1298. ---------------
  1299. Groups of items can define what kind of an item it is (e.g. wool).
  1300. Groups of nodes
  1301. ---------------
  1302. In addition to the general item things, groups are used to define whether
  1303. a node is destroyable and how long it takes to destroy by a tool.
  1304. Groups of entities
  1305. ------------------
  1306. For entities, groups are, as of now, used only for calculating damage.
  1307. The rating is the percentage of damage caused by items with this damage group.
  1308. See [Entity damage mechanism].
  1309. object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
  1310. object.set_armor_groups({fleshy=30, cracky=80})
  1311. Groups of tool capabilities
  1312. ---------------------------
  1313. Groups in tool capabilities define which groups of nodes and entities they
  1314. are effective towards.
  1315. Groups in crafting recipes
  1316. --------------------------
  1317. An example: Make meat soup from any meat, any water and any bowl:
  1318. {
  1319. output = "food:meat_soup_raw",
  1320. recipe = {
  1321. {"group:meat"},
  1322. {"group:water"},
  1323. {"group:bowl"},
  1324. },
  1325. -- preserve = {"group:bowl"}, -- Not implemented yet (TODO)
  1326. }
  1327. Another example: Make red wool from white wool and red dye:
  1328. {
  1329. type = "shapeless",
  1330. output = "wool:red",
  1331. recipe = {"wool:white", "group:dye,basecolor_red"},
  1332. }
  1333. Special groups
  1334. --------------
  1335. The asterisk `(*)` after a group name describes that there is no engine
  1336. functionality bound to it, and implementation is left up as a suggestion
  1337. to games.
  1338. ### Node and item groups
  1339. * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
  1340. that the item should be hidden in item lists.
  1341. ### Node-only groups
  1342. * `attached_node`: if the node under it is not a walkable block the node will be
  1343. dropped as an item. If the node is wallmounted the wallmounted direction is
  1344. checked.
  1345. * `bouncy`: value is bounce speed in percent
  1346. * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
  1347. connect to each other
  1348. * `dig_immediate`: Player can always pick up node without reducing tool wear
  1349. * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
  1350. * `3`: the node always gets the digging time 0 seconds (torch)
  1351. * `disable_jump`: Player (and possibly other things) cannot jump from node
  1352. or if their feet are in the node. Note: not supported for `new_move = false`
  1353. * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
  1354. the top of this node. There's also an armor group with the same name.
  1355. The final player damage is determined by the following formula:
  1356. damage =
  1357. collision speed
  1358. * ((node_fall_damage_add_percent + 100) / 100) -- node group
  1359. * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
  1360. - (14) -- constant tolerance
  1361. Negative damage values are discarded as no damage.
  1362. * `falling_node`: if there is no walkable block under the node it will fall
  1363. * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
  1364. * `level`: Can be used to give an additional sense of progression in the game.
  1365. * A larger level will cause e.g. a weapon of a lower level make much less
  1366. damage, and get worn out much faster, or not be able to get drops
  1367. from destroyed nodes.
  1368. * `0` is something that is directly accessible at the start of gameplay
  1369. * There is no upper limit
  1370. * See also: `leveldiff` in [Tool Capabilities]
  1371. * `slippery`: Players and items will slide on the node.
  1372. Slipperiness rises steadily with `slippery` value, starting at 1.
  1373. ### Tool-only groups
  1374. * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
  1375. `"toolrepair"` crafting recipe
  1376. ### `ObjectRef` armor groups
  1377. * `immortal`: Skips all damage and breath handling for an object. This group
  1378. will also hide the integrated HUD status bars for players. It is
  1379. automatically set to all players when damage is disabled on the server and
  1380. cannot be reset (subject to change).
  1381. * `fall_damage_add_percent`: Modifies the fall damage suffered by players
  1382. when they hit the ground. It is analog to the node group with the same
  1383. name. See the node group above for the exact calculation.
  1384. * `punch_operable`: For entities; disables the regular damage mechanism for
  1385. players punching it by hand or a non-tool item, so that it can do something
  1386. else than take damage.
  1387. Known damage and digging time defining groups
  1388. ---------------------------------------------
  1389. * `crumbly`: dirt, sand
  1390. * `cracky`: tough but crackable stuff like stone.
  1391. * `snappy`: something that can be cut using things like scissors, shears,
  1392. bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
  1393. * `choppy`: something that can be cut using force; e.g. trees, wooden planks
  1394. * `fleshy`: Living things like animals and the player. This could imply
  1395. some blood effects when hitting.
  1396. * `explody`: Especially prone to explosions
  1397. * `oddly_breakable_by_hand`:
  1398. Can be added to nodes that shouldn't logically be breakable by the
  1399. hand but are. Somewhat similar to `dig_immediate`, but times are more
  1400. like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
  1401. digging speed of an item if it can dig at a faster speed than this
  1402. suggests for the hand.
  1403. Examples of custom groups
  1404. -------------------------
  1405. Item groups are often used for defining, well, _groups of items_.
  1406. * `meat`: any meat-kind of a thing (rating might define the size or healing
  1407. ability or be irrelevant -- it is not defined as of yet)
  1408. * `eatable`: anything that can be eaten. Rating might define HP gain in half
  1409. hearts.
  1410. * `flammable`: can be set on fire. Rating might define the intensity of the
  1411. fire, affecting e.g. the speed of the spreading of an open fire.
  1412. * `wool`: any wool (any origin, any color)
  1413. * `metal`: any metal
  1414. * `weapon`: any weapon
  1415. * `heavy`: anything considerably heavy
  1416. Digging time calculation specifics
  1417. ----------------------------------
  1418. Groups such as `crumbly`, `cracky` and `snappy` are used for this
  1419. purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
  1420. faster digging time.
  1421. The `level` group is used to limit the toughness of nodes an item capable
  1422. of digging can dig and to scale the digging times / damage to a greater extent.
  1423. **Please do understand this**, otherwise you cannot use the system to it's
  1424. full potential.
  1425. Items define their properties by a list of parameters for groups. They
  1426. cannot dig other groups; thus it is important to use a standard bunch of
  1427. groups to enable interaction with items.
  1428. Tool Capabilities
  1429. =================
  1430. 'Tool capabilities' is a property of items that defines two things:
  1431. 1) Which nodes it can dig and how fast
  1432. 2) Which objects it can hurt by punching and by how much
  1433. Tool capabilities are available for all items, not just tools.
  1434. But only tools can receive wear from digging and punching.
  1435. Missing or incomplete tool capabilities will default to the
  1436. player's hand.
  1437. Tool capabilities definition
  1438. ----------------------------
  1439. Tool capabilities define:
  1440. * Full punch interval
  1441. * Maximum drop level
  1442. * For an arbitrary list of node groups:
  1443. * Uses (until the tool breaks)
  1444. * Maximum level (usually `0`, `1`, `2` or `3`)
  1445. * Digging times
  1446. * Damage groups
  1447. * Punch attack uses (until the tool breaks)
  1448. ### Full punch interval
  1449. When used as a weapon, the item will do full damage if this time is spent
  1450. between punches. If e.g. half the time is spent, the item will do half
  1451. damage.
  1452. ### Maximum drop level
  1453. Suggests the maximum level of node, when dug with the item, that will drop
  1454. its useful item. (e.g. iron ore to drop a lump of iron).
  1455. This is not automated; it is the responsibility of the node definition
  1456. to implement this.
  1457. ### Uses (tools only)
  1458. Determines how many uses the tool has when it is used for digging a node,
  1459. of this group, of the maximum level. The maximum supported number of
  1460. uses is 65535. The special number 0 is used for infinite uses.
  1461. For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
  1462. `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
  1463. node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
  1464. * `uses=10, leveldiff=0`: actual uses: 10
  1465. * `uses=10, leveldiff=1`: actual uses: 30
  1466. * `uses=10, leveldiff=2`: actual uses: 90
  1467. For non-tools, this has no effect.
  1468. ### Maximum level
  1469. Tells what is the maximum level of a node of this group that the item will
  1470. be able to dig.
  1471. ### Digging times
  1472. List of digging times for different ratings of the group, for nodes of the
  1473. maximum level.
  1474. For example, as a Lua table, `times={2=2.00, 3=0.70}`. This would
  1475. result in the item to be able to dig nodes that have a rating of `2` or `3`
  1476. for this group, and unable to dig the rating `1`, which is the toughest.
  1477. Unless there is a matching group that enables digging otherwise.
  1478. If the result digging time is 0, a delay of 0.15 seconds is added between
  1479. digging nodes; If the player releases LMB after digging, this delay is set to 0,
  1480. i.e. players can more quickly click the nodes away instead of holding LMB.
  1481. ### Damage groups
  1482. List of damage for groups of entities. See [Entity damage mechanism].
  1483. ### Punch attack uses (tools only)
  1484. Determines how many uses (before breaking) the tool has when dealing damage
  1485. to an object, when the full punch interval (see above) was always
  1486. waited out fully.
  1487. Wear received by the tool is proportional to the time spent, scaled by
  1488. the full punch interval.
  1489. For non-tools, this has no effect.
  1490. Example definition of the capabilities of an item
  1491. -------------------------------------------------
  1492. tool_capabilities = {
  1493. full_punch_interval=1.5,
  1494. max_drop_level=1,
  1495. groupcaps={
  1496. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  1497. }
  1498. damage_groups = {fleshy=2},
  1499. }
  1500. This makes the item capable of digging nodes that fulfil both of these:
  1501. * Have the `crumbly` group
  1502. * Have a `level` group less or equal to `2`
  1503. Table of resulting digging times:
  1504. crumbly 0 1 2 3 4 <- level
  1505. -> 0 - - - - -
  1506. 1 0.80 1.60 1.60 - -
  1507. 2 0.60 1.20 1.20 - -
  1508. 3 0.40 0.80 0.80 - -
  1509. level diff: 2 1 0 -1 -2
  1510. Table of resulting tool uses:
  1511. -> 0 - - - - -
  1512. 1 180 60 20 - -
  1513. 2 180 60 20 - -
  1514. 3 180 60 20 - -
  1515. **Notes**:
  1516. * At `crumbly==0`, the node is not diggable.
  1517. * At `crumbly==3`, the level difference digging time divider kicks in and makes
  1518. easy nodes to be quickly breakable.
  1519. * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
  1520. Entity damage mechanism
  1521. =======================
  1522. Damage calculation:
  1523. damage = 0
  1524. foreach group in cap.damage_groups:
  1525. damage += cap.damage_groups[group]
  1526. * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
  1527. * (object.armor_groups[group] / 100.0)
  1528. -- Where object.armor_groups[group] is 0 for inexistent values
  1529. return damage
  1530. Client predicts damage based on damage groups. Because of this, it is able to
  1531. give an immediate response when an entity is damaged or dies; the response is
  1532. pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
  1533. TODO).
  1534. Currently a smoke puff will appear when an entity dies.
  1535. The group `immortal` completely disables normal damage.
  1536. Entities can define a special armor group, which is `punch_operable`. This
  1537. group disables the regular damage mechanism for players punching it by hand or
  1538. a non-tool item, so that it can do something else than take damage.
  1539. On the Lua side, every punch calls:
  1540. entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
  1541. damage)
  1542. This should never be called directly, because damage is usually not handled by
  1543. the entity itself.
  1544. * `puncher` is the object performing the punch. Can be `nil`. Should never be
  1545. accessed unless absolutely required, to encourage interoperability.
  1546. * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
  1547. * `tool_capabilities` can be `nil`.
  1548. * `direction` is a unit vector, pointing from the source of the punch to
  1549. the punched object.
  1550. * `damage` damage that will be done to entity
  1551. Return value of this function will determine if damage is done by this function
  1552. (retval true) or shall be done by engine (retval false)
  1553. To punch an entity/object in Lua, call:
  1554. object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1555. * Return value is tool wear.
  1556. * Parameters are equal to the above callback.
  1557. * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
  1558. will be automatically filled in based on the location of `puncher`.
  1559. Metadata
  1560. ========
  1561. Node Metadata
  1562. -------------
  1563. The instance of a node in the world normally only contains the three values
  1564. mentioned in [Nodes]. However, it is possible to insert extra data into a node.
  1565. It is called "node metadata"; See `NodeMetaRef`.
  1566. Node metadata contains two things:
  1567. * A key-value store
  1568. * An inventory
  1569. Some of the values in the key-value store are handled specially:
  1570. * `formspec`: Defines an inventory menu that is opened with the
  1571. 'place/use' key. Only works if no `on_rightclick` was
  1572. defined for the node. See also [Formspec].
  1573. * `infotext`: Text shown on the screen when the node is pointed at.
  1574. Line-breaks will be applied automatically.
  1575. If the infotext is very long, it will be truncated.
  1576. Example:
  1577. local meta = minetest.get_meta(pos)
  1578. meta:set_string("formspec",
  1579. "size[8,9]"..
  1580. "list[context;main;0,0;8,4;]"..
  1581. "list[current_player;main;0,5;8,4;]")
  1582. meta:set_string("infotext", "Chest");
  1583. local inv = meta:get_inventory()
  1584. inv:set_size("main", 8*4)
  1585. print(dump(meta:to_table()))
  1586. meta:from_table({
  1587. inventory = {
  1588. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
  1589. [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
  1590. [10] = "", [11] = "", [12] = "", [13] = "",
  1591. [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
  1592. [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
  1593. [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
  1594. [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
  1595. [32] = ""}
  1596. },
  1597. fields = {
  1598. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  1599. infotext = "Chest"
  1600. }
  1601. })
  1602. Item Metadata
  1603. -------------
  1604. Item stacks can store metadata too. See [`ItemStackMetaRef`].
  1605. Item metadata only contains a key-value store.
  1606. Some of the values in the key-value store are handled specially:
  1607. * `description`: Set the item stack's description.
  1608. See also: `get_description` in [`ItemStack`]
  1609. * `short_description`: Set the item stack's short description.
  1610. See also: `get_short_description` in [`ItemStack`]
  1611. * `color`: A `ColorString`, which sets the stack's color.
  1612. * `palette_index`: If the item has a palette, this is used to get the
  1613. current color from the palette.
  1614. * `count_meta`: Replace the displayed count with any string.
  1615. * `count_alignment`: Set the alignment of the displayed count value. This is an
  1616. int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
  1617. 4th bit specify the alignment in y-direction:
  1618. 0 = default, 1 = left / up, 2 = middle, 3 = right / down
  1619. The default currently is the same as right/down.
  1620. Example: 6 = 2 + 1*4 = middle,up
  1621. Example:
  1622. local meta = stack:get_meta()
  1623. meta:set_string("key", "value")
  1624. print(dump(meta:to_table()))
  1625. Example manipulations of "description" and expected output behaviors:
  1626. print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
  1627. print(ItemStack("foobar"):get_description()) --> Unknown Item
  1628. local stack = ItemStack("default:stone")
  1629. stack:get_meta():set_string("description", "Custom description\nAnother line")
  1630. print(stack:get_description()) --> Custom description\nAnother line
  1631. print(stack:get_short_description()) --> Custom description
  1632. stack:get_meta():set_string("short_description", "Short")
  1633. print(stack:get_description()) --> Custom description\nAnother line
  1634. print(stack:get_short_description()) --> Short
  1635. print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
  1636. Formspec
  1637. ========
  1638. Formspec defines a menu. This supports inventories and some of the
  1639. typical widgets like buttons, checkboxes, text input fields, etc.
  1640. It is a string, with a somewhat strange format.
  1641. A formspec is made out of formspec elements, which includes widgets
  1642. like buttons but also can be used to set stuff like background color.
  1643. Many formspec elements have a `name`, which is a unique identifier which
  1644. is used when the server receives user input. You must not use the name
  1645. "quit" for formspec elements.
  1646. Spaces and newlines can be inserted between the blocks, as is used in the
  1647. examples.
  1648. Position and size units are inventory slots unless the new coordinate system
  1649. is enabled. `X` and `Y` position the formspec element relative to the top left
  1650. of the menu or container. `W` and `H` are its width and height values.
  1651. If the new system is enabled, all elements have unified coordinates for all
  1652. elements with no padding or spacing in between. This is highly recommended
  1653. for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
  1654. Coordinates`.
  1655. Inventories with a `player:<name>` inventory location are only sent to the
  1656. player named `<name>`.
  1657. When displaying text which can contain formspec code, e.g. text set by a player,
  1658. use `minetest.formspec_escape`.
  1659. For coloured text you can use `minetest.colorize`.
  1660. Since formspec version 3, elements drawn in the order they are defined. All
  1661. background elements are drawn before all other elements.
  1662. **WARNING**: do _not_ use a element name starting with `key_`; those names are
  1663. reserved to pass key press events to formspec!
  1664. **WARNING**: Minetest allows you to add elements to every single formspec instance
  1665. using `player:set_formspec_prepend()`, which may be the reason backgrounds are
  1666. appearing when you don't expect them to, or why things are styled differently
  1667. to normal. See [`no_prepend[]`] and [Styling Formspecs].
  1668. Examples
  1669. --------
  1670. ### Chest
  1671. size[8,9]
  1672. list[context;main;0,0;8,4;]
  1673. list[current_player;main;0,5;8,4;]
  1674. ### Furnace
  1675. size[8,9]
  1676. list[context;fuel;2,3;1,1;]
  1677. list[context;src;2,1;1,1;]
  1678. list[context;dst;5,1;2,2;]
  1679. list[current_player;main;0,5;8,4;]
  1680. ### Minecraft-like player inventory
  1681. size[8,7.5]
  1682. image[1,0.6;1,2;player.png]
  1683. list[current_player;main;0,3.5;8,4;]
  1684. list[current_player;craft;3,0;3,3;]
  1685. list[current_player;craftpreview;7,1;1,1;]
  1686. Version History
  1687. ---------------
  1688. * Formspec version 1 (pre-5.1.0):
  1689. * (too much)
  1690. * Formspec version 2 (5.1.0):
  1691. * Forced real coordinates
  1692. * background9[]: 9-slice scaling parameters
  1693. * Formspec version 3 (5.2.0):
  1694. * Formspec elements are drawn in the order of definition
  1695. * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
  1696. * box[] and image[] elements enable clipping by default
  1697. * new element: scroll_container[]
  1698. * Formspec version 4 (5.4.0):
  1699. * Allow dropdown indexing events
  1700. * Formspec version 5 (5.5.0):
  1701. * Added padding[] element
  1702. Elements
  1703. --------
  1704. ### `formspec_version[<version>]`
  1705. * Set the formspec version to a certain number. If not specified,
  1706. version 1 is assumed.
  1707. * Must be specified before `size` element.
  1708. * Clients older than this version can neither show newer elements nor display
  1709. elements with new arguments correctly.
  1710. * Available since feature `formspec_version_element`.
  1711. * See also: [Version History]
  1712. ### `size[<W>,<H>,<fixed_size>]`
  1713. * Define the size of the menu in inventory slots
  1714. * `fixed_size`: `true`/`false` (optional)
  1715. * deprecated: `invsize[<W>,<H>;]`
  1716. ### `position[<X>,<Y>]`
  1717. * Must be used after `size` element.
  1718. * Defines the position on the game window of the formspec's `anchor` point.
  1719. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
  1720. for example:
  1721. * [0.0, 0.0] sets the position to the top left corner of the game window.
  1722. * [1.0, 1.0] sets the position to the bottom right of the game window.
  1723. * Defaults to the center of the game window [0.5, 0.5].
  1724. ### `anchor[<X>,<Y>]`
  1725. * Must be used after both `size` and `position` (if present) elements.
  1726. * Defines the location of the anchor point within the formspec.
  1727. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
  1728. for example:
  1729. * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
  1730. * [1.0, 0.0] sets the anchor to the top right of the formspec.
  1731. * Defaults to the center of the formspec [0.5, 0.5].
  1732. * `position` and `anchor` elements need suitable values to avoid a formspec
  1733. extending off the game window due to particular game window sizes.
  1734. ### `padding[<X>,<Y>]`
  1735. * Must be used after the `size`, `position`, and `anchor` elements (if present).
  1736. * Defines how much space is padded around the formspec if the formspec tries to
  1737. increase past the size of the screen and coordinates have to be shrunk.
  1738. * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
  1739. screen), and 0.5 represents half the screen (which forces the coordinate size
  1740. to 0). If negative, the formspec can extend off the edge of the screen.
  1741. * Defaults to [0.05, 0.05].
  1742. ### `no_prepend[]`
  1743. * Must be used after the `size`, `position`, `anchor`, and `padding` elements
  1744. (if present).
  1745. * Disables player:set_formspec_prepend() from applying to this formspec.
  1746. ### `real_coordinates[<bool>]`
  1747. * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
  1748. * When set to true, all following formspec elements will use the new coordinate system.
  1749. * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
  1750. (if present), the form size will use the new coordinate system.
  1751. * **Note**: Formspec prepends are not affected by the coordinates in the main form.
  1752. They must enable it explicitly.
  1753. * For information on converting forms to the new coordinate system, see `Migrating
  1754. to Real Coordinates`.
  1755. ### `container[<X>,<Y>]`
  1756. * Start of a container block, moves all physical elements in the container by
  1757. (X, Y).
  1758. * Must have matching `container_end`
  1759. * Containers can be nested, in which case the offsets are added
  1760. (child containers are relative to parent containers)
  1761. ### `container_end[]`
  1762. * End of a container, following elements are no longer relative to this
  1763. container.
  1764. ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
  1765. * Start of a scroll_container block. All contained elements will ...
  1766. * take the scroll_container coordinate as position origin,
  1767. * be additionally moved by the current value of the scrollbar with the name
  1768. `scrollbar name` times `scroll factor` along the orientation `orientation` and
  1769. * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
  1770. * `orientation`: possible values are `vertical` and `horizontal`.
  1771. * `scroll factor`: optional, defaults to `0.1`.
  1772. * Nesting is possible.
  1773. * Some elements might work a little different if they are in a scroll_container.
  1774. * Note: If you want the scroll_container to actually work, you also need to add a
  1775. scrollbar element with the specified name. Furthermore, it is highly recommended
  1776. to use a scrollbaroptions element on this scrollbar.
  1777. ### `scroll_container_end[]`
  1778. * End of a scroll_container, following elements are no longer bound to this
  1779. container.
  1780. ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
  1781. * Show an inventory list if it has been sent to the client.
  1782. * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
  1783. are moved) while the formspec is open, the formspec element may (but is not guaranteed
  1784. to) adapt to the new inventory list.
  1785. * Item slots are drawn in a grid from left to right, then up to down, ordered
  1786. according to the slot index.
  1787. * `W` and `H` are in inventory slots, not in coordinates.
  1788. * `starting item index` (Optional): The index of the first (upper-left) item to draw.
  1789. Indices start at `0`. Default is `0`.
  1790. * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
  1791. `starting item index`.
  1792. * **Note**: With the new coordinate system, the spacing between inventory
  1793. slots is one-fourth the size of an inventory slot by default. Also see
  1794. [Styling Formspecs] for changing the size of slots and spacing.
  1795. ### `listring[<inventory location>;<list name>]`
  1796. * Allows to create a ring of inventory lists
  1797. * Shift-clicking on items in one element of the ring
  1798. will send them to the next inventory list inside the ring
  1799. * The first occurrence of an element inside the ring will
  1800. determine the inventory where items will be sent to
  1801. ### `listring[]`
  1802. * Shorthand for doing `listring[<inventory location>;<list name>]`
  1803. for the last two inventory lists added by list[...]
  1804. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
  1805. * Sets background color of slots as `ColorString`
  1806. * Sets background color of slots on mouse hovering
  1807. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
  1808. * Sets background color of slots as `ColorString`
  1809. * Sets background color of slots on mouse hovering
  1810. * Sets color of slots border
  1811. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
  1812. * Sets background color of slots as `ColorString`
  1813. * Sets background color of slots on mouse hovering
  1814. * Sets color of slots border
  1815. * Sets default background color of tooltips
  1816. * Sets default font color of tooltips
  1817. ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1818. * Adds tooltip for an element
  1819. * `bgcolor` tooltip background color as `ColorString` (optional)
  1820. * `fontcolor` tooltip font color as `ColorString` (optional)
  1821. ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1822. * Adds tooltip for an area. Other tooltips will take priority when present.
  1823. * `bgcolor` tooltip background color as `ColorString` (optional)
  1824. * `fontcolor` tooltip font color as `ColorString` (optional)
  1825. ### `image[<X>,<Y>;<W>,<H>;<texture name>]`
  1826. * Show an image
  1827. ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>]`
  1828. * Show an animated image. The image is drawn like a "vertical_frames" tile
  1829. animation (See [Tile animation definition]), but uses a frame count/duration
  1830. for simplicity
  1831. * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
  1832. * `texture name`: The image to use.
  1833. * `frame count`: The number of frames animating the image.
  1834. * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
  1835. * `frame start` (Optional): The index of the frame to start on. Default `1`.
  1836. ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
  1837. * Show a mesh model.
  1838. * `name`: Element name that can be used for styling
  1839. * `mesh`: The mesh model to use.
  1840. * `textures`: The mesh textures to use according to the mesh materials.
  1841. Texture names must be separated by commas.
  1842. * `rotation {X,Y}` (Optional): Initial rotation of the camera.
  1843. The axes are euler angles in degrees.
  1844. * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
  1845. * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
  1846. * `frame loop range` (Optional): Range of the animation frames.
  1847. * Defaults to the full range of all available frames.
  1848. * Syntax: `<begin>,<end>`
  1849. * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
  1850. ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
  1851. * Show an inventory image of registered item/node
  1852. ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
  1853. * Sets background color of formspec.
  1854. * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
  1855. of the non-fullscreen and the fullscreen background.
  1856. * `fullscreen` (optional) can be one of the following:
  1857. * `false`: Only the non-fullscreen background color is drawn. (default)
  1858. * `true`: Only the fullscreen background color is drawn.
  1859. * `both`: The non-fullscreen and the fullscreen background color are drawn.
  1860. * `neither`: No background color is drawn.
  1861. * Note: Leave a parameter empty to not modify the value.
  1862. * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
  1863. are not bools are only available since formspec version 3.
  1864. ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
  1865. * Example for formspec 8x4 in 16x resolution: image shall be sized
  1866. 8 times 16px times 4 times 16px.
  1867. ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
  1868. * Example for formspec 8x4 in 16x resolution:
  1869. image shall be sized 8 times 16px times 4 times 16px
  1870. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1871. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1872. ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
  1873. * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
  1874. * Middle is a rect which defines the middle of the 9-slice.
  1875. * `x` - The middle will be x pixels from all sides.
  1876. * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
  1877. * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
  1878. will be added to the width and height of the texture, allowing it to be used as the
  1879. distance from the far end.
  1880. * All numbers in middle are integers.
  1881. * Example for formspec 8x4 in 16x resolution:
  1882. image shall be sized 8 times 16px times 4 times 16px
  1883. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1884. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1885. * Available since formspec version 2
  1886. ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1887. * Textual password style field; will be sent to server when a button is clicked
  1888. * When enter is pressed in field, fields.key_enter_field will be sent with the
  1889. name of this field.
  1890. * With the old coordinate system, fields are a set height, but will be vertically
  1891. centred on `H`. With the new coordinate system, `H` will modify the height.
  1892. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1893. * `label`, if not blank, will be text printed on the top left above the field
  1894. * See `field_close_on_enter` to stop enter closing the formspec
  1895. ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1896. * Textual field; will be sent to server when a button is clicked
  1897. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1898. the name of this field.
  1899. * With the old coordinate system, fields are a set height, but will be vertically
  1900. centred on `H`. With the new coordinate system, `H` will modify the height.
  1901. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1902. * `label`, if not blank, will be text printed on the top left above the field
  1903. * `default` is the default value of the field
  1904. * `default` may contain variable references such as `${text}` which
  1905. will fill the value from the metadata value `text`
  1906. * **Note**: no extra text or more than a single variable is supported ATM.
  1907. * See `field_close_on_enter` to stop enter closing the formspec
  1908. ### `field[<name>;<label>;<default>]`
  1909. * As above, but without position/size units
  1910. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1911. the name of this field.
  1912. * Special field for creating simple forms, such as sign text input
  1913. * Must be used without a `size[]` element
  1914. * A "Proceed" button will be added automatically
  1915. * See `field_close_on_enter` to stop enter closing the formspec
  1916. ### `field_close_on_enter[<name>;<close_on_enter>]`
  1917. * <name> is the name of the field
  1918. * if <close_on_enter> is false, pressing enter in the field will submit the
  1919. form but not close it.
  1920. * defaults to true when not specified (ie: no tag for a field)
  1921. ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1922. * Same as fields above, but with multi-line input
  1923. * If the text overflows, a vertical scrollbar is added.
  1924. * If the name is empty, the textarea is read-only and
  1925. the background is not shown, which corresponds to a multi-line label.
  1926. ### `label[<X>,<Y>;<label>]`
  1927. * The label formspec element displays the text set in `label`
  1928. at the specified position.
  1929. * **Note**: If the new coordinate system is enabled, labels are
  1930. positioned from the center of the text, not the top.
  1931. * The text is displayed directly without automatic line breaking,
  1932. so label should not be used for big text chunks. Newlines can be
  1933. used to make labels multiline.
  1934. * **Note**: With the new coordinate system, newlines are spaced with
  1935. half a coordinate. With the old system, newlines are spaced 2/5 of
  1936. an inventory slot.
  1937. ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
  1938. * Displays a static formatted text with hyperlinks.
  1939. * **Note**: This element is currently unstable and subject to change.
  1940. * `x`, `y`, `w` and `h` work as per field
  1941. * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
  1942. * `text` is the formatted text using `Markup Language` described below.
  1943. ### `vertlabel[<X>,<Y>;<label>]`
  1944. * Textual label drawn vertically
  1945. * `label` is the text on the label
  1946. * **Note**: If the new coordinate system is enabled, vertlabels are
  1947. positioned from the center of the text, not the left.
  1948. ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1949. * Clickable button. When clicked, fields will be sent.
  1950. * With the old coordinate system, buttons are a set height, but will be vertically
  1951. centred on `H`. With the new coordinate system, `H` will modify the height.
  1952. * `label` is the text on the button
  1953. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1954. * `texture name` is the filename of an image
  1955. * **Note**: Height is supported on both the old and new coordinate systems
  1956. for image_buttons.
  1957. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
  1958. * `texture name` is the filename of an image
  1959. * `noclip=true` means the image button doesn't need to be within specified
  1960. formsize.
  1961. * `drawborder`: draw button border or not
  1962. * `pressed texture name` is the filename of an image on pressed state
  1963. ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
  1964. * `item name` is the registered name of an item/node
  1965. * The item description will be used as the tooltip. This can be overridden with
  1966. a tooltip element.
  1967. ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1968. * When clicked, fields will be sent and the form will quit.
  1969. * Same as `button` in all other respects.
  1970. ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  1971. * When clicked, fields will be sent and the form will quit.
  1972. * Same as `image_button` in all other respects.
  1973. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
  1974. * Scrollable item list showing arbitrary text elements
  1975. * `name` fieldname sent to server on doubleclick value is current selected
  1976. element.
  1977. * `listelements` can be prepended by #color in hexadecimal format RRGGBB
  1978. (only).
  1979. * if you want a listelement to start with "#" write "##".
  1980. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
  1981. * Scrollable itemlist showing arbitrary text elements
  1982. * `name` fieldname sent to server on doubleclick value is current selected
  1983. element.
  1984. * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
  1985. * if you want a listelement to start with "#" write "##"
  1986. * Index to be selected within textlist
  1987. * `true`/`false`: draw transparent background
  1988. * See also `minetest.explode_textlist_event`
  1989. (main menu: `core.explode_textlist_event`).
  1990. ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  1991. * Show a tab**header** at specific position (ignores formsize)
  1992. * `X` and `Y`: position of the tabheader
  1993. * *Note*: Width and height are automatically chosen with this syntax
  1994. * `name` fieldname data is transferred to Lua
  1995. * `caption 1`...: name shown on top of tab
  1996. * `current_tab`: index of selected tab 1...
  1997. * `transparent` (optional): if true, tabs are semi-transparent
  1998. * `draw_border` (optional): if true, draw a thin line at tab base
  1999. ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2000. * Show a tab**header** at specific position (ignores formsize)
  2001. * **Important note**: This syntax for tabheaders can only be used with the
  2002. new coordinate system.
  2003. * `X` and `Y`: position of the tabheader
  2004. * `H`: height of the tabheader. Width is automatically determined with this syntax.
  2005. * `name` fieldname data is transferred to Lua
  2006. * `caption 1`...: name shown on top of tab
  2007. * `current_tab`: index of selected tab 1...
  2008. * `transparent` (optional): show transparent
  2009. * `draw_border` (optional): draw border
  2010. ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2011. * Show a tab**header** at specific position (ignores formsize)
  2012. * **Important note**: This syntax for tabheaders can only be used with the
  2013. new coordinate system.
  2014. * `X` and `Y`: position of the tabheader
  2015. * `W` and `H`: width and height of the tabheader
  2016. * `name` fieldname data is transferred to Lua
  2017. * `caption 1`...: name shown on top of tab
  2018. * `current_tab`: index of selected tab 1...
  2019. * `transparent` (optional): show transparent
  2020. * `draw_border` (optional): draw border
  2021. ### `box[<X>,<Y>;<W>,<H>;<color>]`
  2022. * Simple colored box
  2023. * `color` is color specified as a `ColorString`.
  2024. If the alpha component is left blank, the box will be semitransparent.
  2025. If the color is not specified, the box will use the options specified by
  2026. its style. If the color is specified, all styling options will be ignored.
  2027. ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2028. * Show a dropdown field
  2029. * **Important note**: There are two different operation modes:
  2030. 1. handle directly on change (only changed dropdown is submitted)
  2031. 2. read the value on pressing a button (all dropdown values are available)
  2032. * `X` and `Y`: position of the dropdown
  2033. * `W`: width of the dropdown. Height is automatically chosen with this syntax.
  2034. * Fieldname data is transferred to Lua
  2035. * Items to be shown in dropdown
  2036. * Index of currently selected dropdown item
  2037. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2038. event field value for selected items.
  2039. * `true`: Selected item index
  2040. * `false` (default): Selected item value
  2041. ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2042. * Show a dropdown field
  2043. * **Important note**: This syntax for dropdowns can only be used with the
  2044. new coordinate system.
  2045. * **Important note**: There are two different operation modes:
  2046. 1. handle directly on change (only changed dropdown is submitted)
  2047. 2. read the value on pressing a button (all dropdown values are available)
  2048. * `X` and `Y`: position of the dropdown
  2049. * `W` and `H`: width and height of the dropdown
  2050. * Fieldname data is transferred to Lua
  2051. * Items to be shown in dropdown
  2052. * Index of currently selected dropdown item
  2053. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2054. event field value for selected items.
  2055. * `true`: Selected item index
  2056. * `false` (default): Selected item value
  2057. ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
  2058. * Show a checkbox
  2059. * `name` fieldname data is transferred to Lua
  2060. * `label` to be shown left of checkbox
  2061. * `selected` (optional): `true`/`false`
  2062. * **Note**: If the new coordinate system is enabled, checkboxes are
  2063. positioned from the center of the checkbox, not the top.
  2064. ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
  2065. * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
  2066. * There are two ways to use it:
  2067. 1. handle the changed event (only changed scrollbar is available)
  2068. 2. read the value on pressing a button (all scrollbars are available)
  2069. * `orientation`: `vertical`/`horizontal`. Default horizontal.
  2070. * Fieldname data is transferred to Lua
  2071. * Value of this trackbar is set to (`0`-`1000`) by default
  2072. * See also `minetest.explode_scrollbar_event`
  2073. (main menu: `core.explode_scrollbar_event`).
  2074. ### `scrollbaroptions[opt1;opt2;...]`
  2075. * Sets options for all following `scrollbar[]` elements
  2076. * `min=<int>`
  2077. * Sets scrollbar minimum value, defaults to `0`.
  2078. * `max=<int>`
  2079. * Sets scrollbar maximum value, defaults to `1000`.
  2080. If the max is equal to the min, the scrollbar will be disabled.
  2081. * `smallstep=<int>`
  2082. * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
  2083. scrolled.
  2084. * If this is set to a negative number, the value will be reset to `10`.
  2085. * `largestep=<int>`
  2086. * Sets scrollbar step value used by page up and page down.
  2087. * If this is set to a negative number, the value will be reset to `100`.
  2088. * `thumbsize=<int>`
  2089. * Sets size of the thumb on the scrollbar. Size is calculated in the number of
  2090. units the thumb spans out of the range of the scrollbar values.
  2091. * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
  2092. would span a tenth of the scrollbar space.
  2093. * If this is set to zero or less, the value will be reset to `1`.
  2094. * `arrows=<show/hide/default>`
  2095. * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
  2096. when the scrollbar gets too small, but shows them otherwise.
  2097. ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
  2098. * Show scrollable table using options defined by the previous `tableoptions[]`
  2099. * Displays cells as defined by the previous `tablecolumns[]`
  2100. * `name`: fieldname sent to server on row select or doubleclick
  2101. * `cell 1`...`cell n`: cell contents given in row-major order
  2102. * `selected idx`: index of row to be selected within table (first row = `1`)
  2103. * See also `minetest.explode_table_event`
  2104. (main menu: `core.explode_table_event`).
  2105. ### `tableoptions[<opt 1>;<opt 2>;...]`
  2106. * Sets options for `table[]`
  2107. * `color=#RRGGBB`
  2108. * default text color (`ColorString`), defaults to `#FFFFFF`
  2109. * `background=#RRGGBB`
  2110. * table background color (`ColorString`), defaults to `#000000`
  2111. * `border=<true/false>`
  2112. * should the table be drawn with a border? (default: `true`)
  2113. * `highlight=#RRGGBB`
  2114. * highlight background color (`ColorString`), defaults to `#466432`
  2115. * `highlight_text=#RRGGBB`
  2116. * highlight text color (`ColorString`), defaults to `#FFFFFF`
  2117. * `opendepth=<value>`
  2118. * all subtrees up to `depth < value` are open (default value = `0`)
  2119. * only useful when there is a column of type "tree"
  2120. ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
  2121. * Sets columns for `table[]`
  2122. * Types: `text`, `image`, `color`, `indent`, `tree`
  2123. * `text`: show cell contents as text
  2124. * `image`: cell contents are an image index, use column options to define
  2125. images.
  2126. * `color`: cell contents are a ColorString and define color of following
  2127. cell.
  2128. * `indent`: cell contents are a number and define indentation of following
  2129. cell.
  2130. * `tree`: same as indent, but user can open and close subtrees
  2131. (treeview-like).
  2132. * Column options:
  2133. * `align=<value>`
  2134. * for `text` and `image`: content alignment within cells.
  2135. Available values: `left` (default), `center`, `right`, `inline`
  2136. * `width=<value>`
  2137. * for `text` and `image`: minimum width in em (default: `0`)
  2138. * for `indent` and `tree`: indent width in em (default: `1.5`)
  2139. * `padding=<value>`: padding left of the column, in em (default `0.5`).
  2140. Exception: defaults to 0 for indent columns
  2141. * `tooltip=<value>`: tooltip text (default: empty)
  2142. * `image` column options:
  2143. * `0=<value>` sets image for image index 0
  2144. * `1=<value>` sets image for image index 1
  2145. * `2=<value>` sets image for image index 2
  2146. * and so on; defined indices need not be contiguous empty or
  2147. non-numeric cells are treated as `0`.
  2148. * `color` column options:
  2149. * `span=<value>`: number of following columns to affect
  2150. (default: infinite).
  2151. ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2152. * Set the style for the element(s) matching `selector` by name.
  2153. * `selector` can be one of:
  2154. * `<name>` - An element name. Includes `*`, which represents every element.
  2155. * `<name>:<state>` - An element name, a colon, and one or more states.
  2156. * `state` is a list of states separated by the `+` character.
  2157. * If a state is provided, the style will only take effect when the element is in that state.
  2158. * All provided states must be active for the style to apply.
  2159. * Note: this **must** be before the element is defined.
  2160. * See [Styling Formspecs].
  2161. ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2162. * Set the style for the element(s) matching `selector` by type.
  2163. * `selector` can be one of:
  2164. * `<type>` - An element type. Includes `*`, which represents every element.
  2165. * `<type>:<state>` - An element type, a colon, and one or more states.
  2166. * `state` is a list of states separated by the `+` character.
  2167. * If a state is provided, the style will only take effect when the element is in that state.
  2168. * All provided states must be active for the style to apply.
  2169. * See [Styling Formspecs].
  2170. ### `set_focus[<name>;<force>]`
  2171. * Sets the focus to the element with the same `name` parameter.
  2172. * **Note**: This element must be placed before the element it focuses.
  2173. * `force` (optional, default `false`): By default, focus is not applied for
  2174. re-sent formspecs with the same name so that player-set focus is kept.
  2175. `true` sets the focus to the specified element for every sent formspec.
  2176. * The following elements have the ability to be focused:
  2177. * checkbox
  2178. * button
  2179. * button_exit
  2180. * image_button
  2181. * image_button_exit
  2182. * item_image_button
  2183. * table
  2184. * textlist
  2185. * dropdown
  2186. * field
  2187. * pwdfield
  2188. * textarea
  2189. * scrollbar
  2190. Migrating to Real Coordinates
  2191. -----------------------------
  2192. In the old system, positions included padding and spacing. Padding is a gap between
  2193. the formspec window edges and content, and spacing is the gaps between items. For
  2194. example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
  2195. and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
  2196. in the new coordinate system from scratch.
  2197. To recreate an old layout with padding, you'll need to pass the positions and sizes
  2198. through the following formula to re-introduce padding:
  2199. ```
  2200. pos = (oldpos + 1)*spacing + padding
  2201. where
  2202. padding = 3/8
  2203. spacing = 5/4
  2204. ```
  2205. You'll need to change the `size[]` tag like this:
  2206. ```
  2207. size = (oldsize-1)*spacing + padding*2 + 1
  2208. ```
  2209. A few elements had random offsets in the old system. Here is a table which shows these
  2210. offsets when migrating:
  2211. | Element | Position | Size | Notes
  2212. |---------|------------|---------|-------
  2213. | box | +0.3, +0.1 | 0, -0.4 |
  2214. | button | | | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
  2215. | list | | | Spacing is now 0.25 for both directions, meaning lists will be taller in height
  2216. | label | 0, +0.3 | | The first line of text is now positioned centered exactly at the position specified
  2217. Styling Formspecs
  2218. -----------------
  2219. Formspec elements can be themed using the style elements:
  2220. style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
  2221. style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
  2222. style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
  2223. style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
  2224. Where a prop is:
  2225. property_name=property_value
  2226. For example:
  2227. style_type[button;bgcolor=#006699]
  2228. style[world_delete;bgcolor=red;textcolor=yellow]
  2229. button[4,3.95;2.6,1;world_delete;Delete]
  2230. A name/type can optionally be a comma separated list of names/types, like so:
  2231. world_delete,world_create,world_configure
  2232. button,image_button
  2233. A `*` type can be used to select every element in the formspec.
  2234. Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
  2235. world_delete:hovered+pressed
  2236. button:pressed
  2237. States allow you to apply styles in response to changes in the element, instead of applying at all times.
  2238. Setting a property to nothing will reset it to the default value. For example:
  2239. style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
  2240. style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
  2241. ### Supported Element Types
  2242. Some types may inherit styles from parent types.
  2243. * animated_image, inherits from image
  2244. * box
  2245. * button
  2246. * button_exit, inherits from button
  2247. * checkbox
  2248. * dropdown
  2249. * field
  2250. * image
  2251. * image_button
  2252. * item_image_button
  2253. * label
  2254. * list
  2255. * model
  2256. * pwdfield, inherits from field
  2257. * scrollbar
  2258. * tabheader
  2259. * table
  2260. * textarea
  2261. * textlist
  2262. * vertlabel, inherits from label
  2263. ### Valid Properties
  2264. * animated_image
  2265. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2266. * box
  2267. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2268. * Defaults to false in formspec_version version 3 or higher
  2269. * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
  2270. * Single value (e.g. `#FF0`): All corners/borders.
  2271. * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
  2272. top and bottom,left and right.
  2273. * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
  2274. * These work similarly to CSS borders.
  2275. * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
  2276. * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
  2277. * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
  2278. negative, the border will extend inside the box, whereas positive extends outside
  2279. the box. A width of zero results in no border; this is default.
  2280. * button, button_exit, image_button, item_image_button
  2281. * alpha - boolean, whether to draw alpha in bgimg. Default true.
  2282. * bgcolor - color, sets button tint.
  2283. * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
  2284. * This is deprecated, use states instead.
  2285. * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
  2286. * This is deprecated, use states instead.
  2287. * bgimg - standard background image. Defaults to none.
  2288. * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
  2289. * This is deprecated, use states instead.
  2290. * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
  2291. See background9[] documentation for more details. This property also pads the
  2292. button's content when set.
  2293. * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
  2294. * This is deprecated, use states instead.
  2295. * font - Sets font type. This is a comma separated list of options. Valid options:
  2296. * Main font type options. These cannot be combined with each other:
  2297. * `normal`: Default font
  2298. * `mono`: Monospaced font
  2299. * Font modification options. If used without a main font type, `normal` is used:
  2300. * `bold`: Makes font bold.
  2301. * `italic`: Makes font italic.
  2302. Default `normal`.
  2303. * font_size - Sets font size. Default is user-set. Can have multiple values:
  2304. * `<number>`: Sets absolute font size to `number`.
  2305. * `+<number>`/`-<number>`: Offsets default font size by `number` points.
  2306. * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
  2307. * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
  2308. * content_offset - 2d vector, shifts the position of the button's content without resizing it.
  2309. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2310. * padding - rect, adds space between the edges of the button and the content. This value is
  2311. relative to bgimg_middle.
  2312. * sound - a sound to be played when triggered.
  2313. * textcolor - color, default white.
  2314. * checkbox
  2315. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2316. * sound - a sound to be played when triggered.
  2317. * dropdown
  2318. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2319. * sound - a sound to be played when the entry is changed.
  2320. * field, pwdfield, textarea
  2321. * border - set to false to hide the textbox background and border. Default true.
  2322. * font - Sets font type. See button `font` property for more information.
  2323. * font_size - Sets font size. See button `font_size` property for more information.
  2324. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2325. * textcolor - color. Default white.
  2326. * model
  2327. * bgcolor - color, sets background color.
  2328. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2329. * Default to false in formspec_version version 3 or higher
  2330. * image
  2331. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2332. * Default to false in formspec_version version 3 or higher
  2333. * item_image
  2334. * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
  2335. * label, vertlabel
  2336. * font - Sets font type. See button `font` property for more information.
  2337. * font_size - Sets font size. See button `font_size` property for more information.
  2338. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2339. * list
  2340. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2341. * size - 2d vector, sets the size of inventory slots in coordinates.
  2342. * spacing - 2d vector, sets the space between inventory slots in coordinates.
  2343. * image_button (additional properties)
  2344. * fgimg - standard image. Defaults to none.
  2345. * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
  2346. * This is deprecated, use states instead.
  2347. * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
  2348. * This is deprecated, use states instead.
  2349. * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
  2350. * sound - a sound to be played when triggered.
  2351. * scrollbar
  2352. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2353. * tabheader
  2354. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2355. * sound - a sound to be played when a different tab is selected.
  2356. * textcolor - color. Default white.
  2357. * table, textlist
  2358. * font - Sets font type. See button `font` property for more information.
  2359. * font_size - Sets font size. See button `font_size` property for more information.
  2360. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2361. ### Valid States
  2362. * *all elements*
  2363. * default - Equivalent to providing no states
  2364. * button, button_exit, image_button, item_image_button
  2365. * hovered - Active when the mouse is hovering over the element
  2366. * pressed - Active when the button is pressed
  2367. Markup Language
  2368. ---------------
  2369. Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
  2370. The markup language is currently unstable and subject to change. Use with caution.
  2371. Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
  2372. Tags can have attributes, in that case, attributes are in the opening tag in
  2373. form of a key/value separated with equal signs. Attribute values should not be quoted.
  2374. If you want to insert a literal greater-than sign or a backslash into the text,
  2375. you must escape it by preceding it with a backslash.
  2376. These are the technically basic tags but see below for usual tags. Base tags are:
  2377. `<style color=... font=... size=...>...</style>`
  2378. Changes the style of the text.
  2379. * `color`: Text color. Given color is a `colorspec`.
  2380. * `size`: Text size.
  2381. * `font`: Text font (`mono` or `normal`).
  2382. `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
  2383. Sets global style.
  2384. Global only styles:
  2385. * `background`: Text background, a `colorspec` or `none`.
  2386. * `margin`: Page margins in pixel.
  2387. * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
  2388. Inheriting styles (affects child elements):
  2389. * `color`: Default text color. Given color is a `colorspec`.
  2390. * `hovercolor`: Color of <action> tags when mouse is over.
  2391. * `size`: Default text size.
  2392. * `font`: Default text font (`mono` or `normal`).
  2393. * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
  2394. This tag needs to be placed only once as it changes the global settings of the
  2395. text. Anyway, if several tags are placed, each changed will be made in the order
  2396. tags appear.
  2397. `<tag name=... color=... hovercolor=... font=... size=...>`
  2398. Defines or redefines tag style. This can be used to define new tags.
  2399. * `name`: Name of the tag to define or change.
  2400. * `color`: Text color. Given color is a `colorspec`.
  2401. * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
  2402. * `size`: Text size.
  2403. * `font`: Text font (`mono` or `normal`).
  2404. Following tags are the usual tags for text layout. They are defined by default.
  2405. Other tags can be added using `<tag ...>` tag.
  2406. `<normal>...</normal>`: Normal size text
  2407. `<big>...</big>`: Big text
  2408. `<bigger>...</bigger>`: Bigger text
  2409. `<center>...</center>`: Centered text
  2410. `<left>...</left>`: Left-aligned text
  2411. `<right>...</right>`: Right-aligned text
  2412. `<justify>...</justify>`: Justified text
  2413. `<mono>...</mono>`: Monospaced font
  2414. `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
  2415. `<action name=...>...</action>`
  2416. Make that text a clickable text triggering an action.
  2417. * `name`: Name of the action (mandatory).
  2418. When clicked, the formspec is send to the server. The value of the text field
  2419. sent to `on_player_receive_fields` will be "action:" concatenated to the action
  2420. name.
  2421. `<img name=... float=... width=... height=...>`
  2422. Draws an image which is present in the client media cache.
  2423. * `name`: Name of the texture (mandatory).
  2424. * `float`: If present, makes the image floating (`left` or `right`).
  2425. * `width`: Force image width instead of taking texture width.
  2426. * `height`: Force image height instead of taking texture height.
  2427. If only width or height given, texture aspect is kept.
  2428. `<item name=... float=... width=... height=... rotate=...>`
  2429. Draws an item image.
  2430. * `name`: Item string of the item to draw (mandatory).
  2431. * `float`: If present, makes the image floating (`left` or `right`).
  2432. * `width`: Item image width.
  2433. * `height`: Item image height.
  2434. * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
  2435. rotation speeds in percent of standard speed (-1000 to 1000). Works only if
  2436. `inventory_items_animations` is set to true.
  2437. * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
  2438. X, Y and Z being angles around each three axes. Works only if
  2439. `inventory_items_animations` is set to true.
  2440. Inventory
  2441. =========
  2442. Inventory locations
  2443. -------------------
  2444. * `"context"`: Selected node metadata (deprecated: `"current_name"`)
  2445. * `"current_player"`: Player to whom the menu is shown
  2446. * `"player:<name>"`: Any player
  2447. * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
  2448. * `"detached:<name>"`: A detached inventory
  2449. Player Inventory lists
  2450. ----------------------
  2451. * `main`: list containing the default inventory
  2452. * `craft`: list containing the craft input
  2453. * `craftpreview`: list containing the craft prediction
  2454. * `craftresult`: list containing the crafted output
  2455. * `hand`: list containing an override for the empty hand
  2456. * Is not created automatically, use `InvRef:set_size`
  2457. * Is only used to enhance the empty hand's tool capabilities
  2458. Colors
  2459. ======
  2460. `ColorString`
  2461. -------------
  2462. `#RGB` defines a color in hexadecimal format.
  2463. `#RGBA` defines a color in hexadecimal format and alpha channel.
  2464. `#RRGGBB` defines a color in hexadecimal format.
  2465. `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
  2466. Named colors are also supported and are equivalent to
  2467. [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
  2468. To specify the value of the alpha channel, append `#A` or `#AA` to the end of
  2469. the color name (e.g. `colorname#08`).
  2470. `ColorSpec`
  2471. -----------
  2472. A ColorSpec specifies a 32-bit color. It can be written in any of the following
  2473. forms:
  2474. * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
  2475. * `colorspec = {a=255, r=0, g=255, b=0}`
  2476. * numerical form: The raw integer value of an ARGB8 quad:
  2477. * `colorspec = 0xFF00FF00`
  2478. * string form: A ColorString (defined above):
  2479. * `colorspec = "green"`
  2480. Escape sequences
  2481. ================
  2482. Most text can contain escape sequences, that can for example color the text.
  2483. There are a few exceptions: tab headers, dropdowns and vertical labels can't.
  2484. The following functions provide escape sequences:
  2485. * `minetest.get_color_escape_sequence(color)`:
  2486. * `color` is a ColorString
  2487. * The escape sequence sets the text color to `color`
  2488. * `minetest.colorize(color, message)`:
  2489. * Equivalent to:
  2490. `minetest.get_color_escape_sequence(color) ..
  2491. message ..
  2492. minetest.get_color_escape_sequence("#ffffff")`
  2493. * `minetest.get_background_escape_sequence(color)`
  2494. * `color` is a ColorString
  2495. * The escape sequence sets the background of the whole text element to
  2496. `color`. Only defined for item descriptions and tooltips.
  2497. * `minetest.strip_foreground_colors(str)`
  2498. * Removes foreground colors added by `get_color_escape_sequence`.
  2499. * `minetest.strip_background_colors(str)`
  2500. * Removes background colors added by `get_background_escape_sequence`.
  2501. * `minetest.strip_colors(str)`
  2502. * Removes all color escape sequences.
  2503. Spatial Vectors
  2504. ===============
  2505. Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
  2506. and has a class to represent them (`vector.*`), which this chapter is about.
  2507. For details on what a spatial vectors is, please refer to Wikipedia:
  2508. https://en.wikipedia.org/wiki/Euclidean_vector.
  2509. Spatial vectors are used for various things, including, but not limited to:
  2510. * any 3D spatial vector (x/y/z-directions)
  2511. * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
  2512. meaning here. Therefore, most vector operations make no sense in this use case.)
  2513. Note that they are *not* used for:
  2514. * n-dimensional vectors where n is not 3 (ie. n=2)
  2515. * arrays of the form `{num, num, num}`
  2516. The API documentation may refer to spatial vectors, as produced by `vector.new`,
  2517. by any of the following notations:
  2518. * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
  2519. * `vector.new(x, y, z)`
  2520. * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
  2521. Compatibility notes
  2522. -------------------
  2523. Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
  2524. Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
  2525. Note: Those old-style vectors can still be found in old mod code. Hence, mod and
  2526. engine APIs still need to be able to cope with them in many places.
  2527. Manually constructed tables are deprecated and highly discouraged. This interface
  2528. should be used to ensure seamless compatibility between mods and the Minetest API.
  2529. This is especially important to callback function parameters and functions overwritten
  2530. by mods.
  2531. Also, though not likely, the internal implementation of a vector might change in
  2532. the future.
  2533. In your own code, or if you define your own API, you can, of course, still use
  2534. other representations of vectors.
  2535. Vectors provided by API functions will provide an instance of this class if not
  2536. stated otherwise. Mods should adapt this for convenience reasons.
  2537. Special properties of the class
  2538. -------------------------------
  2539. Vectors can be indexed with numbers and allow method and operator syntax.
  2540. All these forms of addressing a vector `v` are valid:
  2541. `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
  2542. Note: Prefer letter over number indexing for performance and compatibility reasons.
  2543. Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
  2544. the same as `vector.foo(v, ...)`, apart from deprecated functionality.
  2545. `tostring` is defined for vectors, see `vector.to_string`.
  2546. The metatable that is used for vectors can be accessed via `vector.metatable`.
  2547. Do not modify it!
  2548. All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
  2549. Returned vectors always have a metatable set.
  2550. Common functions and methods
  2551. ----------------------------
  2552. For the following functions (and subchapters),
  2553. `v`, `v1`, `v2` are vectors,
  2554. `p1`, `p2` are position vectors,
  2555. `s` is a scalar (a number),
  2556. vectors are written like this: `(x, y, z)`:
  2557. * `vector.new([a[, b, c]])`:
  2558. * Returns a new vector `(a, b, c)`.
  2559. * Deprecated: `vector.new()` does the same as `vector.zero()` and
  2560. `vector.new(v)` does the same as `vector.copy(v)`
  2561. * `vector.zero()`:
  2562. * Returns a new vector `(0, 0, 0)`.
  2563. * `vector.copy(v)`:
  2564. * Returns a copy of the vector `v`.
  2565. * `vector.from_string(s[, init])`:
  2566. * Returns `v, np`, where `v` is a vector read from the given string `s` and
  2567. `np` is the next position in the string after the vector.
  2568. * Returns `nil` on failure.
  2569. * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
  2570. spaces, leaving away commas and adding an additional comma to the end
  2571. is allowed.
  2572. * `init`: If given starts looking for the vector at this string index.
  2573. * `vector.to_string(v)`:
  2574. * Returns a string of the form `"(x, y, z)"`.
  2575. * `tostring(v)` does the same.
  2576. * `vector.direction(p1, p2)`:
  2577. * Returns a vector of length 1 with direction `p1` to `p2`.
  2578. * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
  2579. * `vector.distance(p1, p2)`:
  2580. * Returns zero or a positive number, the distance between `p1` and `p2`.
  2581. * `vector.length(v)`:
  2582. * Returns zero or a positive number, the length of vector `v`.
  2583. * `vector.normalize(v)`:
  2584. * Returns a vector of length 1 with direction of vector `v`.
  2585. * If `v` has zero length, returns `(0, 0, 0)`.
  2586. * `vector.floor(v)`:
  2587. * Returns a vector, each dimension rounded down.
  2588. * `vector.round(v)`:
  2589. * Returns a vector, each dimension rounded to nearest integer.
  2590. * At a multiple of 0.5, rounds away from zero.
  2591. * `vector.apply(v, func)`:
  2592. * Returns a vector where the function `func` has been applied to each
  2593. component.
  2594. * `vector.combine(v, w, func)`:
  2595. * Returns a vector where the function `func` has combined both components of `v` and `w`
  2596. for each component
  2597. * `vector.equals(v1, v2)`:
  2598. * Returns a boolean, `true` if the vectors are identical.
  2599. * `vector.sort(v1, v2)`:
  2600. * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
  2601. * `vector.angle(v1, v2)`:
  2602. * Returns the angle between `v1` and `v2` in radians.
  2603. * `vector.dot(v1, v2)`:
  2604. * Returns the dot product of `v1` and `v2`.
  2605. * `vector.cross(v1, v2)`:
  2606. * Returns the cross product of `v1` and `v2`.
  2607. * `vector.offset(v, x, y, z)`:
  2608. * Returns the sum of the vectors `v` and `(x, y, z)`.
  2609. * `vector.check(v)`:
  2610. * Returns a boolean value indicating whether `v` is a real vector, eg. created
  2611. by a `vector.*` function.
  2612. * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
  2613. For the following functions `x` can be either a vector or a number:
  2614. * `vector.add(v, x)`:
  2615. * Returns a vector.
  2616. * If `x` is a vector: Returns the sum of `v` and `x`.
  2617. * If `x` is a number: Adds `x` to each component of `v`.
  2618. * `vector.subtract(v, x)`:
  2619. * Returns a vector.
  2620. * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
  2621. * If `x` is a number: Subtracts `x` from each component of `v`.
  2622. * `vector.multiply(v, s)`:
  2623. * Returns a scaled vector.
  2624. * Deprecated: If `s` is a vector: Returns the Schur product.
  2625. * `vector.divide(v, s)`:
  2626. * Returns a scaled vector.
  2627. * Deprecated: If `s` is a vector: Returns the Schur quotient.
  2628. Operators
  2629. ---------
  2630. Operators can be used if all of the involved vectors have metatables:
  2631. * `v1 == v2`:
  2632. * Returns whether `v1` and `v2` are identical.
  2633. * `-v`:
  2634. * Returns the additive inverse of v.
  2635. * `v1 + v2`:
  2636. * Returns the sum of both vectors.
  2637. * Note: `+` can not be used together with scalars.
  2638. * `v1 - v2`:
  2639. * Returns the difference of `v1` subtracted by `v2`.
  2640. * Note: `-` can not be used together with scalars.
  2641. * `v * s` or `s * v`:
  2642. * Returns `v` scaled by `s`.
  2643. * `v / s`:
  2644. * Returns `v` scaled by `1 / s`.
  2645. Rotation-related functions
  2646. --------------------------
  2647. For the following functions `a` is an angle in radians and `r` is a rotation
  2648. vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
  2649. angles in radians.
  2650. * `vector.rotate(v, r)`:
  2651. * Applies the rotation `r` to `v` and returns the result.
  2652. * `vector.rotate(vector.new(0, 0, 1), r)` and
  2653. `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
  2654. forward and up relative to an entity's rotation `r`.
  2655. * `vector.rotate_around_axis(v1, v2, a)`:
  2656. * Returns `v1` rotated around axis `v2` by `a` radians according to
  2657. the right hand rule.
  2658. * `vector.dir_to_rotation(direction[, up])`:
  2659. * Returns a rotation vector for `direction` pointing forward using `up`
  2660. as the up vector.
  2661. * If `up` is omitted, the roll of the returned vector defaults to zero.
  2662. * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
  2663. Further helpers
  2664. ---------------
  2665. There are more helper functions involving vectors, but they are listed elsewhere
  2666. because they only work on specific sorts of vectors or involve things that are not
  2667. vectors.
  2668. For example:
  2669. * `minetest.hash_node_position` (Only works on node positions.)
  2670. * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
  2671. Helper functions
  2672. ================
  2673. * `dump2(obj, name, dumped)`: returns a string which makes `obj`
  2674. human-readable, handles reference loops.
  2675. * `obj`: arbitrary variable
  2676. * `name`: string, default: `"_"`
  2677. * `dumped`: table, default: `{}`
  2678. * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
  2679. * `obj`: arbitrary variable
  2680. * `dumped`: table, default: `{}`
  2681. * `math.hypot(x, y)`
  2682. * Get the hypotenuse of a triangle with legs x and y.
  2683. Useful for distance calculation.
  2684. * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
  2685. * Get the sign of a number.
  2686. * tolerance: number, default: `0.0`
  2687. * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
  2688. `0` is returned.
  2689. * `math.factorial(x)`: returns the factorial of `x`
  2690. * `math.round(x)`: Returns `x` rounded to the nearest integer.
  2691. * At a multiple of 0.5, rounds away from zero.
  2692. * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
  2693. * `separator`: string, default: `","`
  2694. * `include_empty`: boolean, default: `false`
  2695. * `max_splits`: number, if it's negative, splits aren't limited,
  2696. default: `-1`
  2697. * `sep_is_pattern`: boolean, it specifies whether separator is a plain
  2698. string or a pattern (regex), default: `false`
  2699. * e.g. `"a,b":split","` returns `{"a","b"}`
  2700. * `string:trim()`: returns the string without whitespace pre- and suffixes
  2701. * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
  2702. * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
  2703. * Adds newlines to the string to keep it within the specified character
  2704. limit
  2705. * Note that the returned lines may be longer than the limit since it only
  2706. splits at word borders.
  2707. * `limit`: number, maximal amount of characters in one line
  2708. * `as_table`: boolean, if set to true, a table of lines instead of a string
  2709. is returned, default: `false`
  2710. * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
  2711. * `pos`: table {x=X, y=Y, z=Z}
  2712. * Converts the position `pos` to a human-readable, printable string
  2713. * `decimal_places`: number, if specified, the x, y and z values of
  2714. the position are rounded to the given decimal place.
  2715. * `minetest.string_to_pos(string)`: returns a position or `nil`
  2716. * Same but in reverse.
  2717. * If the string can't be parsed to a position, nothing is returned.
  2718. * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions
  2719. * Converts a string representing an area box into two positions
  2720. * `minetest.formspec_escape(string)`: returns a string
  2721. * escapes the characters "[", "]", "\", "," and ";", which can not be used
  2722. in formspecs.
  2723. * `minetest.is_yes(arg)`
  2724. * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
  2725. * `minetest.is_nan(arg)`
  2726. * returns true when the passed number represents NaN.
  2727. * `minetest.get_us_time()`
  2728. * returns time with microsecond precision. May not return wall time.
  2729. * `table.copy(table)`: returns a table
  2730. * returns a deep copy of `table`
  2731. * `table.indexof(list, val)`: returns the smallest numerical index containing
  2732. the value `val` in the table `list`. Non-numerical indices are ignored.
  2733. If `val` could not be found, `-1` is returned. `list` must not have
  2734. negative indices.
  2735. * `table.insert_all(table, other_table)`:
  2736. * Appends all values in `other_table` to `table` - uses `#table + 1` to
  2737. find new indices.
  2738. * `table.key_value_swap(t)`: returns a table with keys and values swapped
  2739. * If multiple keys in `t` map to the same value, it is unspecified which
  2740. value maps to that key.
  2741. * `table.shuffle(table, [from], [to], [random_func])`:
  2742. * Shuffles elements `from` to `to` in `table` in place
  2743. * `from` defaults to `1`
  2744. * `to` defaults to `#table`
  2745. * `random_func` defaults to `math.random`. This function receives two
  2746. integers as arguments and should return a random integer inclusively
  2747. between them.
  2748. * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
  2749. position.
  2750. * returns the exact position on the surface of a pointed node
  2751. * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
  2752. Simulates an item that digs a node.
  2753. Returns a table with the following fields:
  2754. * `diggable`: `true` if node can be dug, `false` otherwise.
  2755. * `time`: Time it would take to dig the node.
  2756. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2757. `time` and `wear` are meaningless if node's not diggable
  2758. Parameters:
  2759. * `groups`: Table of the node groups of the node that would be dug
  2760. * `tool_capabilities`: Tool capabilities table of the item
  2761. * `wear`: Amount of wear the tool starts with (default: 0)
  2762. * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
  2763. Simulates an item that punches an object.
  2764. Returns a table with the following fields:
  2765. * `hp`: How much damage the punch would cause (between -65535 and 65535).
  2766. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2767. Parameters:
  2768. * `groups`: Damage groups of the object
  2769. * `tool_capabilities`: Tool capabilities table of the item
  2770. * `time_from_last_punch`: time in seconds since last punch action
  2771. * `wear`: Amount of wear the item starts with (default: 0)
  2772. Translations
  2773. ============
  2774. Texts can be translated client-side with the help of `minetest.translate` and
  2775. translation files.
  2776. Translating a string
  2777. --------------------
  2778. Two functions are provided to translate strings: `minetest.translate` and
  2779. `minetest.get_translator`.
  2780. * `minetest.get_translator(textdomain)` is a simple wrapper around
  2781. `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
  2782. equivalent to `minetest.translate(textdomain, str, ...)`.
  2783. It is intended to be used in the following way, so that it avoids verbose
  2784. repetitions of `minetest.translate`:
  2785. local S = minetest.get_translator(textdomain)
  2786. S(str, ...)
  2787. As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
  2788. * `minetest.translate(textdomain, str, ...)` translates the string `str` with
  2789. the given `textdomain` for disambiguation. The textdomain must match the
  2790. textdomain specified in the translation file in order to get the string
  2791. translated. This can be used so that a string is translated differently in
  2792. different contexts.
  2793. It is advised to use the name of the mod as textdomain whenever possible, to
  2794. avoid clashes with other mods.
  2795. This function must be given a number of arguments equal to the number of
  2796. arguments the translated string expects.
  2797. Arguments are literal strings -- they will not be translated, so if you want
  2798. them to be, they need to come as outputs of `minetest.translate` as well.
  2799. For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
  2800. by the translation of "Red". We can do the following:
  2801. local S = minetest.get_translator()
  2802. S("@1 Wool", S("Red"))
  2803. This will be displayed as "Red Wool" on old clients and on clients that do
  2804. not have localization enabled. However, if we have for instance a translation
  2805. file named `wool.fr.tr` containing the following:
  2806. @1 Wool=Laine @1
  2807. Red=Rouge
  2808. this will be displayed as "Laine Rouge" on clients with a French locale.
  2809. Operations on translated strings
  2810. --------------------------------
  2811. The output of `minetest.translate` is a string, with escape sequences adding
  2812. additional information to that string so that it can be translated on the
  2813. different clients. In particular, you can't expect operations like string.length
  2814. to work on them like you would expect them to, or string.gsub to work in the
  2815. expected manner. However, string concatenation will still work as expected
  2816. (note that you should only use this for things like formspecs; do not translate
  2817. sentences by breaking them into parts; arguments should be used instead), and
  2818. operations such as `minetest.colorize` which are also concatenation.
  2819. Translation file format
  2820. -----------------------
  2821. A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
  2822. it corresponds to. It must be put into the `locale` subdirectory of the mod.
  2823. The file should be a text file, with the following format:
  2824. * Lines beginning with `# textdomain:` (the space is significant) can be used
  2825. to specify the text domain of all following translations in the file.
  2826. * All other empty lines or lines beginning with `#` are ignored.
  2827. * Other lines should be in the format `original=translated`. Both `original`
  2828. and `translated` can contain escape sequences beginning with `@` to insert
  2829. arguments, literal `@`, `=` or newline (See [Escapes] below).
  2830. There must be no extraneous whitespace around the `=` or at the beginning or
  2831. the end of the line.
  2832. Escapes
  2833. -------
  2834. Strings that need to be translated can contain several escapes, preceded by `@`.
  2835. * `@@` acts as a literal `@`.
  2836. * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
  2837. string that will be inlined when translated. Due to how translations are
  2838. implemented, the original translation string **must** have its arguments in
  2839. increasing order, without gaps or repetitions, starting from 1.
  2840. * `@=` acts as a literal `=`. It is not required in strings given to
  2841. `minetest.translate`, but is in translation files to avoid being confused
  2842. with the `=` separating the original from the translation.
  2843. * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
  2844. As with `@=`, this escape is not required in strings given to
  2845. `minetest.translate`, but is in translation files.
  2846. * `@n` acts as a literal newline as well.
  2847. Server side translations
  2848. ------------------------
  2849. On some specific cases, server translation could be useful. For example, filter
  2850. a list on labels and send results to client. A method is supplied to achieve
  2851. that:
  2852. `minetest.get_translated_string(lang_code, string)`: Translates `string` using
  2853. translations for `lang_code` language. It gives the same result as if the string
  2854. was translated by the client.
  2855. The `lang_code` to use for a given player can be retrieved from
  2856. the table returned by `minetest.get_player_information(name)`.
  2857. IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
  2858. You do not need to use this to get translated strings to show up on the client.
  2859. Perlin noise
  2860. ============
  2861. Perlin noise creates a continuously-varying value depending on the input values.
  2862. Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
  2863. The result is used during map generation to create the terrain shape, vary heat
  2864. and humidity to distribute biomes, vary the density of decorations or vary the
  2865. structure of ores.
  2866. Structure of perlin noise
  2867. -------------------------
  2868. An 'octave' is a simple noise generator that outputs a value between -1 and 1.
  2869. The smooth wavy noise it generates has a single characteristic scale, almost
  2870. like a 'wavelength', so on its own does not create fine detail.
  2871. Due to this perlin noise combines several octaves to create variation on
  2872. multiple scales. Each additional octave has a smaller 'wavelength' than the
  2873. previous.
  2874. This combination results in noise varying very roughly between -2.0 and 2.0 and
  2875. with an average value of 0.0, so `scale` and `offset` are then used to multiply
  2876. and offset the noise variation.
  2877. The final perlin noise variation is created as follows:
  2878. noise = offset + scale * (octave1 +
  2879. octave2 * persistence +
  2880. octave3 * persistence ^ 2 +
  2881. octave4 * persistence ^ 3 +
  2882. ...)
  2883. Noise Parameters
  2884. ----------------
  2885. Noise Parameters are commonly called `NoiseParams`.
  2886. ### `offset`
  2887. After the multiplication by `scale` this is added to the result and is the final
  2888. step in creating the noise value.
  2889. Can be positive or negative.
  2890. ### `scale`
  2891. Once all octaves have been combined, the result is multiplied by this.
  2892. Can be positive or negative.
  2893. ### `spread`
  2894. For octave1, this is roughly the change of input value needed for a very large
  2895. variation in the noise value generated by octave1. It is almost like a
  2896. 'wavelength' for the wavy noise variation.
  2897. Each additional octave has a 'wavelength' that is smaller than the previous
  2898. octave, to create finer detail. `spread` will therefore roughly be the typical
  2899. size of the largest structures in the final noise variation.
  2900. `spread` is a vector with values for x, y, z to allow the noise variation to be
  2901. stretched or compressed in the desired axes.
  2902. Values are positive numbers.
  2903. ### `seed`
  2904. This is a whole number that determines the entire pattern of the noise
  2905. variation. Altering it enables different noise patterns to be created.
  2906. With other parameters equal, different seeds produce different noise patterns
  2907. and identical seeds produce identical noise patterns.
  2908. For this parameter you can randomly choose any whole number. Usually it is
  2909. preferable for this to be different from other seeds, but sometimes it is useful
  2910. to be able to create identical noise patterns.
  2911. In some noise APIs the world seed is added to the seed specified in noise
  2912. parameters. This is done to make the resulting noise pattern vary in different
  2913. worlds, and be 'world-specific'.
  2914. ### `octaves`
  2915. The number of simple noise generators that are combined.
  2916. A whole number, 1 or more.
  2917. Each additional octave adds finer detail to the noise but also increases the
  2918. noise calculation load.
  2919. 3 is a typical minimum for a high quality, complex and natural-looking noise
  2920. variation. 1 octave has a slight 'gridlike' appearance.
  2921. Choose the number of octaves according to the `spread` and `lacunarity`, and the
  2922. size of the finest detail you require. For example:
  2923. if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
  2924. nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
  2925. 512, 256, 128, 64, 32, 16 nodes.
  2926. Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
  2927. ### `persistence`
  2928. Each additional octave has an amplitude that is the amplitude of the previous
  2929. octave multiplied by `persistence`, to reduce the amplitude of finer details,
  2930. as is often helpful and natural to do so.
  2931. Since this controls the balance of fine detail to large-scale detail
  2932. `persistence` can be thought of as the 'roughness' of the noise.
  2933. A positive or negative non-zero number, often between 0.3 and 1.0.
  2934. A common medium value is 0.5, such that each octave has half the amplitude of
  2935. the previous octave.
  2936. This may need to be tuned when altering `lacunarity`; when doing so consider
  2937. that a common medium value is 1 / lacunarity.
  2938. ### `lacunarity`
  2939. Each additional octave has a 'wavelength' that is the 'wavelength' of the
  2940. previous octave multiplied by 1 / lacunarity, to create finer detail.
  2941. 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
  2942. A positive number no smaller than 1.0.
  2943. Values below 2.0 create higher quality noise at the expense of requiring more
  2944. octaves to cover a paticular range of 'wavelengths'.
  2945. ### `flags`
  2946. Leave this field unset for no special handling.
  2947. Currently supported are `defaults`, `eased` and `absvalue`:
  2948. #### `defaults`
  2949. Specify this if you would like to keep auto-selection of eased/not-eased while
  2950. specifying some other flags.
  2951. #### `eased`
  2952. Maps noise gradient values onto a quintic S-curve before performing
  2953. interpolation. This results in smooth, rolling noise.
  2954. Disable this (`noeased`) for sharp-looking noise with a slightly gridded
  2955. appearence.
  2956. If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
  2957. not eased.
  2958. Easing a 3D noise significantly increases the noise calculation load, so use
  2959. with restraint.
  2960. #### `absvalue`
  2961. The absolute value of each octave's noise variation is used when combining the
  2962. octaves. The final perlin noise variation is created as follows:
  2963. noise = offset + scale * (abs(octave1) +
  2964. abs(octave2) * persistence +
  2965. abs(octave3) * persistence ^ 2 +
  2966. abs(octave4) * persistence ^ 3 +
  2967. ...)
  2968. ### Format example
  2969. For 2D or 3D perlin noise or perlin noise maps:
  2970. np_terrain = {
  2971. offset = 0,
  2972. scale = 1,
  2973. spread = {x = 500, y = 500, z = 500},
  2974. seed = 571347,
  2975. octaves = 5,
  2976. persistence = 0.63,
  2977. lacunarity = 2.0,
  2978. flags = "defaults, absvalue",
  2979. }
  2980. For 2D noise the Z component of `spread` is still defined but is ignored.
  2981. A single noise parameter table can be used for 2D or 3D noise.
  2982. Ores
  2983. ====
  2984. Ore types
  2985. ---------
  2986. These tell in what manner the ore is generated.
  2987. All default ores are of the uniformly-distributed scatter type.
  2988. ### `scatter`
  2989. Randomly chooses a location and generates a cluster of ore.
  2990. If `noise_params` is specified, the ore will be placed if the 3D perlin noise
  2991. at that point is greater than the `noise_threshold`, giving the ability to
  2992. create a non-equal distribution of ore.
  2993. ### `sheet`
  2994. Creates a sheet of ore in a blob shape according to the 2D perlin noise
  2995. described by `noise_params` and `noise_threshold`. This is essentially an
  2996. improved version of the so-called "stratus" ore seen in some unofficial mods.
  2997. This sheet consists of vertical columns of uniform randomly distributed height,
  2998. varying between the inclusive range `column_height_min` and `column_height_max`.
  2999. If `column_height_min` is not specified, this parameter defaults to 1.
  3000. If `column_height_max` is not specified, this parameter defaults to `clust_size`
  3001. for reverse compatibility. New code should prefer `column_height_max`.
  3002. The `column_midpoint_factor` parameter controls the position of the column at
  3003. which ore emanates from.
  3004. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
  3005. equally starting from each direction.
  3006. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
  3007. this parameter is not specified, the default is 0.5.
  3008. The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
  3009. ore type.
  3010. ### `puff`
  3011. Creates a sheet of ore in a cloud-like puff shape.
  3012. As with the `sheet` ore type, the size and shape of puffs are described by
  3013. `noise_params` and `noise_threshold` and are placed at random vertical
  3014. positions within the currently generated chunk.
  3015. The vertical top and bottom displacement of each puff are determined by the
  3016. noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
  3017. ### `blob`
  3018. Creates a deformed sphere of ore according to 3d perlin noise described by
  3019. `noise_params`. The maximum size of the blob is `clust_size`, and
  3020. `clust_scarcity` has the same meaning as with the `scatter` type.
  3021. ### `vein`
  3022. Creates veins of ore varying in density by according to the intersection of two
  3023. instances of 3d perlin noise with different seeds, both described by
  3024. `noise_params`.
  3025. `random_factor` varies the influence random chance has on placement of an ore
  3026. inside the vein, which is `1` by default. Note that modifying this parameter
  3027. may require adjusting `noise_threshold`.
  3028. The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
  3029. by this ore type.
  3030. This ore type is difficult to control since it is sensitive to small changes.
  3031. The following is a decent set of parameters to work from:
  3032. noise_params = {
  3033. offset = 0,
  3034. scale = 3,
  3035. spread = {x=200, y=200, z=200},
  3036. seed = 5390,
  3037. octaves = 4,
  3038. persistence = 0.5,
  3039. lacunarity = 2.0,
  3040. flags = "eased",
  3041. },
  3042. noise_threshold = 1.6
  3043. **WARNING**: Use this ore type *very* sparingly since it is ~200x more
  3044. computationally expensive than any other ore.
  3045. ### `stratum`
  3046. Creates a single undulating ore stratum that is continuous across mapchunk
  3047. borders and horizontally spans the world.
  3048. The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
  3049. the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
  3050. defines the stratum's vertical thickness (in units of nodes). Due to being
  3051. continuous across mapchunk borders the stratum's vertical thickness is
  3052. unlimited.
  3053. If the noise parameter `noise_params` is omitted the ore will occur from y_min
  3054. to y_max in a simple horizontal stratum.
  3055. A parameter `stratum_thickness` can be provided instead of the noise parameter
  3056. `np_stratum_thickness`, to create a constant thickness.
  3057. Leaving out one or both noise parameters makes the ore generation less
  3058. intensive, useful when adding multiple strata.
  3059. `y_min` and `y_max` define the limits of the ore generation and for performance
  3060. reasons should be set as close together as possible but without clipping the
  3061. stratum's Y variation.
  3062. Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
  3063. solid-ore stratum would require a `clust_scarcity` of 1.
  3064. The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
  3065. `random_factor` are ignored by this ore type.
  3066. Ore attributes
  3067. --------------
  3068. See section [Flag Specifier Format].
  3069. Currently supported flags:
  3070. `puff_cliffs`, `puff_additive_composition`.
  3071. ### `puff_cliffs`
  3072. If set, puff ore generation will not taper down large differences in
  3073. displacement when approaching the edge of a puff. This flag has no effect for
  3074. ore types other than `puff`.
  3075. ### `puff_additive_composition`
  3076. By default, when noise described by `np_puff_top` or `np_puff_bottom` results
  3077. in a negative displacement, the sub-column at that point is not generated. With
  3078. this attribute set, puff ore generation will instead generate the absolute
  3079. difference in noise displacement values. This flag has no effect for ore types
  3080. other than `puff`.
  3081. Decoration types
  3082. ================
  3083. The varying types of decorations that can be placed.
  3084. `simple`
  3085. --------
  3086. Creates a 1 times `H` times 1 column of a specified node (or a random node from
  3087. a list, if a decoration list is specified). Can specify a certain node it must
  3088. spawn next to, such as water or lava, for example. Can also generate a
  3089. decoration of random height between a specified lower and upper bound.
  3090. This type of decoration is intended for placement of grass, flowers, cacti,
  3091. papyri, waterlilies and so on.
  3092. `schematic`
  3093. -----------
  3094. Copies a box of `MapNodes` from a specified schematic file (or raw description).
  3095. Can specify a probability of a node randomly appearing when placed.
  3096. This decoration type is intended to be used for multi-node sized discrete
  3097. structures, such as trees, cave spikes, rocks, and so on.
  3098. Schematics
  3099. ==========
  3100. Schematic specifier
  3101. --------------------
  3102. A schematic specifier identifies a schematic by either a filename to a
  3103. Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  3104. in the form of a table. This table specifies the following fields:
  3105. * The `size` field is a 3D vector containing the dimensions of the provided
  3106. schematic. (required field)
  3107. * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
  3108. sets the probability of a particular horizontal slice of the schematic being
  3109. placed. (optional field)
  3110. `ypos` = 0 for the lowest horizontal slice of a schematic.
  3111. The default of `prob` is 255.
  3112. * The `data` field is a flat table of MapNode tables making up the schematic,
  3113. in the order of `[z [y [x]]]`. (required field)
  3114. Each MapNode table contains:
  3115. * `name`: the name of the map node to place (required)
  3116. * `prob` (alias `param1`): the probability of this node being placed
  3117. (default: 255)
  3118. * `param2`: the raw param2 value of the node being placed onto the map
  3119. (default: 0)
  3120. * `force_place`: boolean representing if the node should forcibly overwrite
  3121. any previous contents (default: false)
  3122. About probability values:
  3123. * A probability value of `0` or `1` means that node will never appear
  3124. (0% chance).
  3125. * A probability value of `254` or `255` means the node will always appear
  3126. (100% chance).
  3127. * If the probability value `p` is greater than `1`, then there is a
  3128. `(p / 256 * 100)` percent chance that node will appear when the schematic is
  3129. placed on the map.
  3130. Schematic attributes
  3131. --------------------
  3132. See section [Flag Specifier Format].
  3133. Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
  3134. `force_placement`.
  3135. * `place_center_x`: Placement of this decoration is centered along the X axis.
  3136. * `place_center_y`: Placement of this decoration is centered along the Y axis.
  3137. * `place_center_z`: Placement of this decoration is centered along the Z axis.
  3138. * `force_placement`: Schematic nodes other than "ignore" will replace existing
  3139. nodes.
  3140. Lua Voxel Manipulator
  3141. =====================
  3142. About VoxelManip
  3143. ----------------
  3144. VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
  3145. facility. The purpose of this object is for fast, low-level, bulk access to
  3146. reading and writing Map content. As such, setting map nodes through VoxelManip
  3147. will lack many of the higher level features and concepts you may be used to
  3148. with other methods of setting nodes. For example, nodes will not have their
  3149. construction and destruction callbacks run, and no rollback information is
  3150. logged.
  3151. It is important to note that VoxelManip is designed for speed, and *not* ease
  3152. of use or flexibility. If your mod requires a map manipulation facility that
  3153. will handle 100% of all edge cases, or the use of high level node placement
  3154. features, perhaps `minetest.set_node()` is better suited for the job.
  3155. In addition, VoxelManip might not be faster, or could even be slower, for your
  3156. specific use case. VoxelManip is most effective when setting large areas of map
  3157. at once - for example, if only setting a 3x3x3 node area, a
  3158. `minetest.set_node()` loop may be more optimal. Always profile code using both
  3159. methods of map manipulation to determine which is most appropriate for your
  3160. usage.
  3161. A recent simple test of setting cubic areas showed that `minetest.set_node()`
  3162. is faster than a VoxelManip for a 3x3x3 node cube or smaller.
  3163. Using VoxelManip
  3164. ----------------
  3165. A VoxelManip object can be created any time using either:
  3166. `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
  3167. If the optional position parameters are present for either of these routines,
  3168. the specified region will be pre-loaded into the VoxelManip object on creation.
  3169. Otherwise, the area of map you wish to manipulate must first be loaded into the
  3170. VoxelManip object using `VoxelManip:read_from_map()`.
  3171. Note that `VoxelManip:read_from_map()` returns two position vectors. The region
  3172. formed by these positions indicate the minimum and maximum (respectively)
  3173. positions of the area actually loaded in the VoxelManip, which may be larger
  3174. than the area requested. For convenience, the loaded area coordinates can also
  3175. be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
  3176. Now that the VoxelManip object is populated with map data, your mod can fetch a
  3177. copy of this data using either of two methods. `VoxelManip:get_node_at()`,
  3178. which retrieves an individual node in a MapNode formatted table at the position
  3179. requested is the simplest method to use, but also the slowest.
  3180. Nodes in a VoxelManip object may also be read in bulk to a flat array table
  3181. using:
  3182. * `VoxelManip:get_data()` for node content (in Content ID form, see section
  3183. [Content IDs]),
  3184. * `VoxelManip:get_light_data()` for node light levels, and
  3185. * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
  3186. See section [Flat array format] for more details.
  3187. It is very important to understand that the tables returned by any of the above
  3188. three functions represent a snapshot of the VoxelManip's internal state at the
  3189. time of the call. This copy of the data will not magically update itself if
  3190. another function modifies the internal VoxelManip state.
  3191. Any functions that modify a VoxelManip's contents work on the VoxelManip's
  3192. internal state unless otherwise explicitly stated.
  3193. Once the bulk data has been edited to your liking, the internal VoxelManip
  3194. state can be set using:
  3195. * `VoxelManip:set_data()` for node content (in Content ID form, see section
  3196. [Content IDs]),
  3197. * `VoxelManip:set_light_data()` for node light levels, and
  3198. * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
  3199. The parameter to each of the above three functions can use any table at all in
  3200. the same flat array format as produced by `get_data()` etc. and is not required
  3201. to be a table retrieved from `get_data()`.
  3202. Once the internal VoxelManip state has been modified to your liking, the
  3203. changes can be committed back to the map by calling `VoxelManip:write_to_map()`
  3204. ### Flat array format
  3205. Let
  3206. `Nx = p2.X - p1.X + 1`,
  3207. `Ny = p2.Y - p1.Y + 1`, and
  3208. `Nz = p2.Z - p1.Z + 1`.
  3209. Then, for a loaded region of p1..p2, this array ranges from `1` up to and
  3210. including the value of the expression `Nx * Ny * Nz`.
  3211. Positions offset from p1 are present in the array with the format of:
  3212. [
  3213. (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
  3214. (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
  3215. ...
  3216. (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
  3217. (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
  3218. ...
  3219. (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
  3220. ...
  3221. (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
  3222. ]
  3223. and the array index for a position p contained completely in p1..p2 is:
  3224. `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
  3225. Note that this is the same "flat 3D array" format as
  3226. `PerlinNoiseMap:get3dMap_flat()`.
  3227. VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
  3228. of the index for a single point in a flat VoxelManip array.
  3229. ### Content IDs
  3230. A Content ID is a unique integer identifier for a specific node type.
  3231. These IDs are used by VoxelManip in place of the node name string for
  3232. `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
  3233. `minetest.get_content_id()` to look up the Content ID for the specified node
  3234. name, and `minetest.get_name_from_content_id()` to look up the node name string
  3235. for a given Content ID.
  3236. After registration of a node, its Content ID will remain the same throughout
  3237. execution of the mod.
  3238. Note that the node being queried needs to have already been been registered.
  3239. The following builtin node types have their Content IDs defined as constants:
  3240. * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
  3241. * `minetest.CONTENT_AIR`: ID for "air" nodes
  3242. * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
  3243. ### Mapgen VoxelManip objects
  3244. Inside of `on_generated()` callbacks, it is possible to retrieve the same
  3245. VoxelManip object used by the core's Map Generator (commonly abbreviated
  3246. Mapgen). Most of the rules previously described still apply but with a few
  3247. differences:
  3248. * The Mapgen VoxelManip object is retrieved using:
  3249. `minetest.get_mapgen_object("voxelmanip")`
  3250. * This VoxelManip object already has the region of map just generated loaded
  3251. into it; it's not necessary to call `VoxelManip:read_from_map()` before using
  3252. a Mapgen VoxelManip.
  3253. * The `on_generated()` callbacks of some mods may place individual nodes in the
  3254. generated area using non-VoxelManip map modification methods. Because the
  3255. same Mapgen VoxelManip object is passed through each `on_generated()`
  3256. callback, it becomes necessary for the Mapgen VoxelManip object to maintain
  3257. consistency with the current map state. For this reason, calling any of the
  3258. following functions:
  3259. `minetest.add_node()`, `minetest.set_node()`, or `minetest.swap_node()`
  3260. will also update the Mapgen VoxelManip object's internal state active on the
  3261. current thread.
  3262. * After modifying the Mapgen VoxelManip object's internal buffer, it may be
  3263. necessary to update lighting information using either:
  3264. `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
  3265. ### Other API functions operating on a VoxelManip
  3266. If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
  3267. `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
  3268. flowing. It is recommended to call this function only after having written all
  3269. buffered data back to the VoxelManip object, save for special situations where
  3270. the modder desires to only have certain liquid nodes begin flowing.
  3271. The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
  3272. will generate all registered decorations and ores throughout the full area
  3273. inside of the specified VoxelManip object.
  3274. `minetest.place_schematic_on_vmanip()` is otherwise identical to
  3275. `minetest.place_schematic()`, except instead of placing the specified schematic
  3276. directly on the map at the specified position, it will place the schematic
  3277. inside the VoxelManip.
  3278. ### Notes
  3279. * Attempting to read data from a VoxelManip object before map is read will
  3280. result in a zero-length array table for `VoxelManip:get_data()`, and an
  3281. "ignore" node at any position for `VoxelManip:get_node_at()`.
  3282. * If either a region of map has not yet been generated or is out-of-bounds of
  3283. the map, that region is filled with "ignore" nodes.
  3284. * Other mods, or the core itself, could possibly modify the area of map
  3285. currently loaded into a VoxelManip object. With the exception of Mapgen
  3286. VoxelManips (see above section), the internal buffers are not updated. For
  3287. this reason, it is strongly encouraged to complete the usage of a particular
  3288. VoxelManip object in the same callback it had been created.
  3289. * If a VoxelManip object will be used often, such as in an `on_generated()`
  3290. callback, consider passing a file-scoped table as the optional parameter to
  3291. `VoxelManip:get_data()`, which serves as a static buffer the function can use
  3292. to write map data to instead of returning a new table each call. This greatly
  3293. enhances performance by avoiding unnecessary memory allocations.
  3294. Methods
  3295. -------
  3296. * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
  3297. containing the region formed by `p1` and `p2`.
  3298. * returns actual emerged `pmin`, actual emerged `pmax`
  3299. * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
  3300. the map.
  3301. * **important**: data must be set using `VoxelManip:set_data()` before
  3302. calling this.
  3303. * if `light` is true, then lighting is automatically recalculated.
  3304. The default value is true.
  3305. If `light` is false, no light calculations happen, and you should correct
  3306. all modified blocks with `minetest.fix_light()` as soon as possible.
  3307. Keep in mind that modifying the map where light is incorrect can cause
  3308. more lighting bugs.
  3309. * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
  3310. the `VoxelManip` at that position
  3311. * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
  3312. that position.
  3313. * `get_data([buffer])`: Retrieves the node content data loaded into the
  3314. `VoxelManip` object.
  3315. * returns raw node data in the form of an array of node content IDs
  3316. * if the param `buffer` is present, this table will be used to store the
  3317. result instead.
  3318. * `set_data(data)`: Sets the data contents of the `VoxelManip` object
  3319. * `update_map()`: Does nothing, kept for compatibility.
  3320. * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
  3321. a uniform value.
  3322. * `light` is a table, `{day=<0...15>, night=<0...15>}`
  3323. * To be used only by a `VoxelManip` object from
  3324. `minetest.get_mapgen_object`.
  3325. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3326. area if left out.
  3327. * `get_light_data()`: Gets the light data read into the `VoxelManip` object
  3328. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3329. `255`.
  3330. * Each value is the bitwise combination of day and night light values
  3331. (`0` to `15` each).
  3332. * `light = day + (night * 16)`
  3333. * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
  3334. in the `VoxelManip`.
  3335. * expects lighting data in the same format that `get_light_data()` returns
  3336. * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
  3337. `VoxelManip` object.
  3338. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3339. `255`.
  3340. * If the param `buffer` is present, this table will be used to store the
  3341. result instead.
  3342. * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
  3343. the `VoxelManip`.
  3344. * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the
  3345. `VoxelManip`.
  3346. * To be used only by a `VoxelManip` object from
  3347. `minetest.get_mapgen_object`.
  3348. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3349. area if left out or nil. For almost all uses these should be left out
  3350. or nil to use the default.
  3351. * `propagate_shadow` is an optional boolean deciding whether shadows in a
  3352. generated mapchunk above are propagated down into the mapchunk, defaults
  3353. to `true` if left out.
  3354. * `update_liquids()`: Update liquid flow
  3355. * `was_modified()`: Returns `true` or `false` if the data in the voxel
  3356. manipulator had been modified since the last read from map, due to a call to
  3357. `minetest.set_data()` on the loaded area elsewhere.
  3358. * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
  3359. `VoxelArea`
  3360. -----------
  3361. A helper class for voxel areas.
  3362. It can be created via `VoxelArea:new{MinEdge = pmin, MaxEdge = pmax}`.
  3363. The coordinates are *inclusive*, like most other things in Minetest.
  3364. ### Methods
  3365. * `getExtent()`: returns a 3D vector containing the size of the area formed by
  3366. `MinEdge` and `MaxEdge`.
  3367. * `getVolume()`: returns the volume of the area formed by `MinEdge` and
  3368. `MaxEdge`.
  3369. * `index(x, y, z)`: returns the index of an absolute position in a flat array
  3370. starting at `1`.
  3371. * `x`, `y` and `z` must be integers to avoid an incorrect index result.
  3372. * The position (x, y, z) is not checked for being inside the area volume,
  3373. being outside can cause an incorrect index result.
  3374. * Useful for things like `VoxelManip`, raw Schematic specifiers,
  3375. `PerlinNoiseMap:get2d`/`3dMap`, and so on.
  3376. * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
  3377. * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
  3378. is not checked for being inside the area volume.
  3379. * `position(i)`: returns the absolute position vector corresponding to index
  3380. `i`.
  3381. * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
  3382. `MinEdge` and `MaxEdge`.
  3383. * `containsp(p)`: same as above, except takes a vector
  3384. * `containsi(i)`: same as above, except takes an index `i`
  3385. * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
  3386. indices.
  3387. * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
  3388. `[z [y [x]]]`.
  3389. * `iterp(minp, maxp)`: same as above, except takes a vector
  3390. ### Y stride and z stride of a flat array
  3391. For a particular position in a voxel area, whose flat array index is known,
  3392. it is often useful to know the index of a neighboring or nearby position.
  3393. The table below shows the changes of index required for 1 node movements along
  3394. the axes in a voxel area:
  3395. Movement Change of index
  3396. +x +1
  3397. -x -1
  3398. +y +ystride
  3399. -y -ystride
  3400. +z +zstride
  3401. -z -zstride
  3402. If, for example:
  3403. local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
  3404. The values of `ystride` and `zstride` can be obtained using `area.ystride` and
  3405. `area.zstride`.
  3406. Mapgen objects
  3407. ==============
  3408. A mapgen object is a construct used in map generation. Mapgen objects can be
  3409. used by an `on_generate` callback to speed up operations by avoiding
  3410. unnecessary recalculations, these can be retrieved using the
  3411. `minetest.get_mapgen_object()` function. If the requested Mapgen object is
  3412. unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
  3413. callback, `nil` is returned.
  3414. The following Mapgen objects are currently available:
  3415. ### `voxelmanip`
  3416. This returns three values; the `VoxelManip` object to be used, minimum and
  3417. maximum emerged position, in that order. All mapgens support this object.
  3418. ### `heightmap`
  3419. Returns an array containing the y coordinates of the ground levels of nodes in
  3420. the most recently generated chunk by the current mapgen.
  3421. ### `biomemap`
  3422. Returns an array containing the biome IDs of nodes in the most recently
  3423. generated chunk by the current mapgen.
  3424. ### `heatmap`
  3425. Returns an array containing the temperature values of nodes in the most
  3426. recently generated chunk by the current mapgen.
  3427. ### `humiditymap`
  3428. Returns an array containing the humidity values of nodes in the most recently
  3429. generated chunk by the current mapgen.
  3430. ### `gennotify`
  3431. Returns a table mapping requested generation notification types to arrays of
  3432. positions at which the corresponding generated structures are located within
  3433. the current chunk. To set the capture of positions of interest to be recorded
  3434. on generate, use `minetest.set_gen_notify()`.
  3435. For decorations, the returned positions are the ground surface 'place_on'
  3436. nodes, not the decorations themselves. A 'simple' type decoration is often 1
  3437. node above the returned position and possibly displaced by 'place_offset_y'.
  3438. Possible fields of the table returned are:
  3439. * `dungeon`
  3440. * `temple`
  3441. * `cave_begin`
  3442. * `cave_end`
  3443. * `large_cave_begin`
  3444. * `large_cave_end`
  3445. * `decoration`
  3446. Decorations have a key in the format of `"decoration#id"`, where `id` is the
  3447. numeric unique decoration ID as returned by `minetest.get_decoration_id`.
  3448. Registered entities
  3449. ===================
  3450. Functions receive a "luaentity" as `self`:
  3451. * It has the member `.name`, which is the registered name `("mod:thing")`
  3452. * It has the member `.object`, which is an `ObjectRef` pointing to the object
  3453. * The original prototype stuff is visible directly via a metatable
  3454. Callbacks:
  3455. * `on_activate(self, staticdata, dtime_s)`
  3456. * Called when the object is instantiated.
  3457. * `dtime_s` is the time passed since the object was unloaded, which can be
  3458. used for updating the entity state.
  3459. * `on_deactivate(self)
  3460. * Called when the object is about to get removed or unloaded.
  3461. * `on_step(self, dtime)`
  3462. * Called on every server tick, after movement and collision processing.
  3463. `dtime` is usually 0.1 seconds, as per the `dedicated_server_step` setting
  3464. in `minetest.conf`.
  3465. * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
  3466. * Called when somebody punches the object.
  3467. * Note that you probably want to handle most punches using the automatic
  3468. armor group system.
  3469. * `puncher`: an `ObjectRef` (can be `nil`)
  3470. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3471. (can be `nil`).
  3472. * `tool_capabilities`: capability table of used item (can be `nil`)
  3473. * `dir`: unit vector of direction of punch. Always defined. Points from the
  3474. puncher to the punched.
  3475. * `damage`: damage that will be done to entity.
  3476. * Can return `true` to prevent the default damage mechanism.
  3477. * `on_death(self, killer)`
  3478. * Called when the object dies.
  3479. * `killer`: an `ObjectRef` (can be `nil`)
  3480. * `on_rightclick(self, clicker)`
  3481. * Called when `clicker` pressed the 'place/use' key while pointing
  3482. to the object (not neccessarily an actual rightclick)
  3483. * `clicker`: an `ObjectRef` (may or may not be a player)
  3484. * `on_attach_child(self, child)`
  3485. * `child`: an `ObjectRef` of the child that attaches
  3486. * `on_detach_child(self, child)`
  3487. * `child`: an `ObjectRef` of the child that detaches
  3488. * `on_detach(self, parent)`
  3489. * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
  3490. * This happens before the parent object is removed from the world
  3491. * `get_staticdata(self)`
  3492. * Should return a string that will be passed to `on_activate` when the
  3493. object is instantiated the next time.
  3494. L-system trees
  3495. ==============
  3496. Tree definition
  3497. ---------------
  3498. treedef={
  3499. axiom, --string initial tree axiom
  3500. rules_a, --string rules set A
  3501. rules_b, --string rules set B
  3502. rules_c, --string rules set C
  3503. rules_d, --string rules set D
  3504. trunk, --string trunk node name
  3505. leaves, --string leaves node name
  3506. leaves2, --string secondary leaves node name
  3507. leaves2_chance,--num chance (0-100) to replace leaves with leaves2
  3508. angle, --num angle in deg
  3509. iterations, --num max # of iterations, usually 2 -5
  3510. random_level, --num factor to lower nr of iterations, usually 0 - 3
  3511. trunk_type, --string single/double/crossed) type of trunk: 1 node,
  3512. -- 2x2 nodes or 3x3 in cross shape
  3513. thin_branches, --boolean true -> use thin (1 node) branches
  3514. fruit, --string fruit node name
  3515. fruit_chance, --num chance (0-100) to replace leaves with fruit node
  3516. seed, --num random seed, if no seed is provided, the engine
  3517. will create one.
  3518. }
  3519. Key for special L-System symbols used in axioms
  3520. -----------------------------------------------
  3521. * `G`: move forward one unit with the pen up
  3522. * `F`: move forward one unit with the pen down drawing trunks and branches
  3523. * `f`: move forward one unit with the pen down drawing leaves (100% chance)
  3524. * `T`: move forward one unit with the pen down drawing trunks only
  3525. * `R`: move forward one unit with the pen down placing fruit
  3526. * `A`: replace with rules set A
  3527. * `B`: replace with rules set B
  3528. * `C`: replace with rules set C
  3529. * `D`: replace with rules set D
  3530. * `a`: replace with rules set A, chance 90%
  3531. * `b`: replace with rules set B, chance 80%
  3532. * `c`: replace with rules set C, chance 70%
  3533. * `d`: replace with rules set D, chance 60%
  3534. * `+`: yaw the turtle right by `angle` parameter
  3535. * `-`: yaw the turtle left by `angle` parameter
  3536. * `&`: pitch the turtle down by `angle` parameter
  3537. * `^`: pitch the turtle up by `angle` parameter
  3538. * `/`: roll the turtle to the right by `angle` parameter
  3539. * `*`: roll the turtle to the left by `angle` parameter
  3540. * `[`: save in stack current state info
  3541. * `]`: recover from stack state info
  3542. Example
  3543. -------
  3544. Spawn a small apple tree:
  3545. pos = {x=230,y=20,z=4}
  3546. apple_tree={
  3547. axiom="FFFFFAFFBF",
  3548. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  3549. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  3550. trunk="default:tree",
  3551. leaves="default:leaves",
  3552. angle=30,
  3553. iterations=2,
  3554. random_level=0,
  3555. trunk_type="single",
  3556. thin_branches=true,
  3557. fruit_chance=10,
  3558. fruit="default:apple"
  3559. }
  3560. minetest.spawn_tree(pos,apple_tree)
  3561. 'minetest' namespace reference
  3562. ==============================
  3563. Utilities
  3564. ---------
  3565. * `minetest.get_current_modname()`: returns the currently loading mod's name,
  3566. when loading a mod.
  3567. * `minetest.get_modpath(modname)`: returns the directory path for a mod,
  3568. e.g. `"/home/user/.minetest/usermods/modname"`.
  3569. * Returns nil if the mod is not enabled or does not exist (not installed).
  3570. * Works regardless of whether the mod has been loaded yet.
  3571. * Useful for loading additional `.lua` modules or static data from a mod,
  3572. or checking if a mod is enabled.
  3573. * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
  3574. * Does not include disabled mods, even if they are installed.
  3575. * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
  3576. * Useful for storing custom data
  3577. * `minetest.is_singleplayer()`
  3578. * `minetest.features`: Table containing API feature flags
  3579. {
  3580. glasslike_framed = true, -- 0.4.7
  3581. nodebox_as_selectionbox = true, -- 0.4.7
  3582. get_all_craft_recipes_works = true, -- 0.4.7
  3583. -- The transparency channel of textures can optionally be used on
  3584. -- nodes (0.4.7)
  3585. use_texture_alpha = true,
  3586. -- Tree and grass ABMs are no longer done from C++ (0.4.8)
  3587. no_legacy_abms = true,
  3588. -- Texture grouping is possible using parentheses (0.4.11)
  3589. texture_names_parens = true,
  3590. -- Unique Area ID for AreaStore:insert_area (0.4.14)
  3591. area_store_custom_ids = true,
  3592. -- add_entity supports passing initial staticdata to on_activate
  3593. -- (0.4.16)
  3594. add_entity_with_staticdata = true,
  3595. -- Chat messages are no longer predicted (0.4.16)
  3596. no_chat_message_prediction = true,
  3597. -- The transparency channel of textures can optionally be used on
  3598. -- objects (ie: players and lua entities) (5.0.0)
  3599. object_use_texture_alpha = true,
  3600. -- Object selectionbox is settable independently from collisionbox
  3601. -- (5.0.0)
  3602. object_independent_selectionbox = true,
  3603. -- Specifies whether binary data can be uploaded or downloaded using
  3604. -- the HTTP API (5.1.0)
  3605. httpfetch_binary_data = true,
  3606. -- Whether formspec_version[<version>] may be used (5.1.0)
  3607. formspec_version_element = true,
  3608. -- Whether AreaStore's IDs are kept on save/load (5.1.0)
  3609. area_store_persistent_ids = true,
  3610. -- Whether minetest.find_path is functional (5.2.0)
  3611. pathfinder_works = true,
  3612. -- Whether Collision info is available to an objects' on_step (5.3.0)
  3613. object_step_has_moveresult = true,
  3614. -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
  3615. direct_velocity_on_players = true,
  3616. -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
  3617. use_texture_alpha_string_modes = true,
  3618. -- degrotate param2 rotates in units of 1.5° instead of 2°
  3619. -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
  3620. degrotate_240_steps = true,
  3621. -- ABM supports min_y and max_y fields in definition (5.5.0)
  3622. abm_min_max_y = true,
  3623. -- dynamic_add_media supports passing a table with options (5.5.0)
  3624. dynamic_add_media_table = true,
  3625. -- allows get_sky to return a table instead of separate values (5.6.0)
  3626. get_sky_as_table = true,
  3627. }
  3628. * `minetest.has_feature(arg)`: returns `boolean, missing_features`
  3629. * `arg`: string or table in format `{foo=true, bar=true}`
  3630. * `missing_features`: `{foo=true, bar=true}`
  3631. * `minetest.get_player_information(player_name)`: Table containing information
  3632. about a player. Example return value:
  3633. {
  3634. address = "127.0.0.1", -- IP address of client
  3635. ip_version = 4, -- IPv4 / IPv6
  3636. connection_uptime = 200, -- seconds since client connected
  3637. protocol_version = 32, -- protocol version used by client
  3638. formspec_version = 2, -- supported formspec version
  3639. lang_code = "fr" -- Language code used for translation
  3640. -- the following keys can be missing if no stats have been collected yet
  3641. min_rtt = 0.01, -- minimum round trip time
  3642. max_rtt = 0.2, -- maximum round trip time
  3643. avg_rtt = 0.02, -- average round trip time
  3644. min_jitter = 0.01, -- minimum packet time jitter
  3645. max_jitter = 0.5, -- maximum packet time jitter
  3646. avg_jitter = 0.03, -- average packet time jitter
  3647. -- the following information is available in a debug build only!!!
  3648. -- DO NOT USE IN MODS
  3649. --ser_vers = 26, -- serialization version used by client
  3650. --major = 0, -- major version number
  3651. --minor = 4, -- minor version number
  3652. --patch = 10, -- patch version number
  3653. --vers_string = "0.4.9-git", -- full version string
  3654. --state = "Active" -- current client state
  3655. }
  3656. * `minetest.mkdir(path)`: returns success.
  3657. * Creates a directory specified by `path`, creating parent directories
  3658. if they don't exist.
  3659. * `minetest.rmdir(path, recursive)`: returns success.
  3660. * Removes a directory specified by `path`.
  3661. * If `recursive` is set to `true`, the directory is recursively removed.
  3662. Otherwise, the directory will only be removed if it is empty.
  3663. * Returns true on success, false on failure.
  3664. * `minetest.cpdir(source, destination)`: returns success.
  3665. * Copies a directory specified by `path` to `destination`
  3666. * Any files in `destination` will be overwritten if they already exist.
  3667. * Returns true on success, false on failure.
  3668. * `minetest.mvdir(source, destination)`: returns success.
  3669. * Moves a directory specified by `path` to `destination`.
  3670. * If the `destination` is a non-empty directory, then the move will fail.
  3671. * Returns true on success, false on failure.
  3672. * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
  3673. * is_dir is one of:
  3674. * nil: return all entries,
  3675. * true: return only subdirectory names, or
  3676. * false: return only file names.
  3677. * `minetest.safe_file_write(path, content)`: returns boolean indicating success
  3678. * Replaces contents of file at path with new contents in a safe (atomic)
  3679. way. Use this instead of below code when writing e.g. database files:
  3680. `local f = io.open(path, "wb"); f:write(content); f:close()`
  3681. * `minetest.get_version()`: returns a table containing components of the
  3682. engine version. Components:
  3683. * `project`: Name of the project, eg, "Minetest"
  3684. * `string`: Simple version, eg, "1.2.3-dev"
  3685. * `hash`: Full git version (only set if available),
  3686. eg, "1.2.3-dev-01234567-dirty".
  3687. Use this for informational purposes only. The information in the returned
  3688. table does not represent the capabilities of the engine, nor is it
  3689. reliable or verifiable. Compatible forks will have a different name and
  3690. version entirely. To check for the presence of engine features, test
  3691. whether the functions exported by the wanted features exist. For example:
  3692. `if minetest.check_for_falling then ... end`.
  3693. * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
  3694. * `data`: string of data to hash
  3695. * `raw`: return raw bytes instead of hex digits, default: false
  3696. * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
  3697. ColorString. If the ColorSpec is invalid, returns `nil`.
  3698. * `colorspec`: The ColorSpec to convert
  3699. * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
  3700. string of four bytes in an RGBA layout, returned as a string.
  3701. * `colorspec`: The ColorSpec to convert
  3702. * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
  3703. image and return it in string form.
  3704. * `width`: Width of the image
  3705. * `height`: Height of the image
  3706. * `data`: Image data, one of:
  3707. * array table of ColorSpec, length must be width*height
  3708. * string with raw RGBA pixels, length must be width*height*4
  3709. * `compression`: Optional zlib compression level, number in range 0 to 9.
  3710. The data is one-dimensional, starting in the upper left corner of the image
  3711. and laid out in scanlines going from left to right, then top to bottom.
  3712. Please note that it's not safe to use string.char to generate raw data,
  3713. use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
  3714. The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
  3715. You may use this to procedurally generate textures during server init.
  3716. Logging
  3717. -------
  3718. * `minetest.debug(...)`
  3719. * Equivalent to `minetest.log(table.concat({...}, "\t"))`
  3720. * `minetest.log([level,] text)`
  3721. * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
  3722. `"info"`, or `"verbose"`. Default is `"none"`.
  3723. Registration functions
  3724. ----------------------
  3725. Call these functions only at load time!
  3726. ### Environment
  3727. * `minetest.register_node(name, node definition)`
  3728. * `minetest.register_craftitem(name, item definition)`
  3729. * `minetest.register_tool(name, item definition)`
  3730. * `minetest.override_item(name, redefinition)`
  3731. * Overrides fields of an item registered with register_node/tool/craftitem.
  3732. * Note: Item must already be defined, (opt)depend on the mod defining it.
  3733. * Example: `minetest.override_item("default:mese",
  3734. {light_source=minetest.LIGHT_MAX})`
  3735. * `minetest.unregister_item(name)`
  3736. * Unregisters the item from the engine, and deletes the entry with key
  3737. `name` from `minetest.registered_items` and from the associated item table
  3738. according to its nature: `minetest.registered_nodes`, etc.
  3739. * `minetest.register_entity(name, entity definition)`
  3740. * `minetest.register_abm(abm definition)`
  3741. * `minetest.register_lbm(lbm definition)`
  3742. * `minetest.register_alias(alias, original_name)`
  3743. * Also use this to set the 'mapgen aliases' needed in a game for the core
  3744. mapgens. See [Mapgen aliases] section above.
  3745. * `minetest.register_alias_force(alias, original_name)`
  3746. * `minetest.register_ore(ore definition)`
  3747. * Returns an integer object handle uniquely identifying the registered
  3748. ore on success.
  3749. * The order of ore registrations determines the order of ore generation.
  3750. * `minetest.register_biome(biome definition)`
  3751. * Returns an integer object handle uniquely identifying the registered
  3752. biome on success. To get the biome ID, use `minetest.get_biome_id`.
  3753. * `minetest.unregister_biome(name)`
  3754. * Unregisters the biome from the engine, and deletes the entry with key
  3755. `name` from `minetest.registered_biomes`.
  3756. * Warning: This alters the biome to biome ID correspondences, so any
  3757. decorations or ores using the 'biomes' field must afterwards be cleared
  3758. and re-registered.
  3759. * `minetest.register_decoration(decoration definition)`
  3760. * Returns an integer object handle uniquely identifying the registered
  3761. decoration on success. To get the decoration ID, use
  3762. `minetest.get_decoration_id`.
  3763. * The order of decoration registrations determines the order of decoration
  3764. generation.
  3765. * `minetest.register_schematic(schematic definition)`
  3766. * Returns an integer object handle uniquely identifying the registered
  3767. schematic on success.
  3768. * If the schematic is loaded from a file, the `name` field is set to the
  3769. filename.
  3770. * If the function is called when loading the mod, and `name` is a relative
  3771. path, then the current mod path will be prepended to the schematic
  3772. filename.
  3773. * `minetest.clear_registered_biomes()`
  3774. * Clears all biomes currently registered.
  3775. * Warning: Clearing and re-registering biomes alters the biome to biome ID
  3776. correspondences, so any decorations or ores using the 'biomes' field must
  3777. afterwards be cleared and re-registered.
  3778. * `minetest.clear_registered_decorations()`
  3779. * Clears all decorations currently registered.
  3780. * `minetest.clear_registered_ores()`
  3781. * Clears all ores currently registered.
  3782. * `minetest.clear_registered_schematics()`
  3783. * Clears all schematics currently registered.
  3784. ### Gameplay
  3785. * `minetest.register_craft(recipe)`
  3786. * Check recipe table syntax for different types below.
  3787. * `minetest.clear_craft(recipe)`
  3788. * Will erase existing craft based either on output item or on input recipe.
  3789. * Specify either output or input only. If you specify both, input will be
  3790. ignored. For input use the same recipe table syntax as for
  3791. `minetest.register_craft(recipe)`. For output specify only the item,
  3792. without a quantity.
  3793. * Returns false if no erase candidate could be found, otherwise returns true.
  3794. * **Warning**! The type field ("shaped", "cooking" or any other) will be
  3795. ignored if the recipe contains output. Erasing is then done independently
  3796. from the crafting method.
  3797. * `minetest.register_chatcommand(cmd, chatcommand definition)`
  3798. * `minetest.override_chatcommand(name, redefinition)`
  3799. * Overrides fields of a chatcommand registered with `register_chatcommand`.
  3800. * `minetest.unregister_chatcommand(name)`
  3801. * Unregisters a chatcommands registered with `register_chatcommand`.
  3802. * `minetest.register_privilege(name, definition)`
  3803. * `definition` can be a description or a definition table (see [Privilege
  3804. definition]).
  3805. * If it is a description, the priv will be granted to singleplayer and admin
  3806. by default.
  3807. * To allow players with `basic_privs` to grant, see the `basic_privs`
  3808. minetest.conf setting.
  3809. * `minetest.register_authentication_handler(authentication handler definition)`
  3810. * Registers an auth handler that overrides the builtin one.
  3811. * This function can be called by a single mod once only.
  3812. Global callback registration functions
  3813. --------------------------------------
  3814. Call these functions only at load time!
  3815. * `minetest.register_globalstep(function(dtime))`
  3816. * Called every server step, usually interval of 0.1s
  3817. * `minetest.register_on_mods_loaded(function())`
  3818. * Called after mods have finished loading and before the media is cached or the
  3819. aliases handled.
  3820. * `minetest.register_on_shutdown(function())`
  3821. * Called before server shutdown
  3822. * **Warning**: If the server terminates abnormally (i.e. crashes), the
  3823. registered callbacks **will likely not be run**. Data should be saved at
  3824. semi-frequent intervals as well as on server shutdown.
  3825. * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
  3826. * Called when a node has been placed
  3827. * If return `true` no item is taken from `itemstack`
  3828. * `placer` may be any valid ObjectRef or nil.
  3829. * **Not recommended**; use `on_construct` or `after_place_node` in node
  3830. definition whenever possible.
  3831. * `minetest.register_on_dignode(function(pos, oldnode, digger))`
  3832. * Called when a node has been dug.
  3833. * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
  3834. definition whenever possible.
  3835. * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
  3836. * Called when a node is punched
  3837. * `minetest.register_on_generated(function(minp, maxp, blockseed))`
  3838. * Called after generating a piece of world. Modifying nodes inside the area
  3839. is a bit faster than usually.
  3840. * `minetest.register_on_newplayer(function(ObjectRef))`
  3841. * Called when a new player enters the world for the first time
  3842. * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
  3843. * Called when a player is punched
  3844. * Note: This callback is invoked even if the punched player is dead.
  3845. * `player`: ObjectRef - Player that was punched
  3846. * `hitter`: ObjectRef - Player that hit
  3847. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3848. (can be nil).
  3849. * `tool_capabilities`: Capability table of used item (can be nil)
  3850. * `dir`: Unit vector of direction of punch. Always defined. Points from
  3851. the puncher to the punched.
  3852. * `damage`: Number that represents the damage calculated by the engine
  3853. * should return `true` to prevent the default damage mechanism
  3854. * `minetest.register_on_rightclickplayer(function(player, clicker))`
  3855. * Called when the 'place/use' key was used while pointing a player
  3856. (not neccessarily an actual rightclick)
  3857. * `player`: ObjectRef - Player that is acted upon
  3858. * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
  3859. * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
  3860. * Called when the player gets damaged or healed
  3861. * `player`: ObjectRef of the player
  3862. * `hp_change`: the amount of change. Negative when it is damage.
  3863. * `reason`: a PlayerHPChangeReason table.
  3864. * The `type` field will have one of the following values:
  3865. * `set_hp`: A mod or the engine called `set_hp` without
  3866. giving a type - use this for custom damage types.
  3867. * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
  3868. * `fall`
  3869. * `node_damage`: `damage_per_second` from a neighbouring node.
  3870. `reason.node` will hold the node name or nil.
  3871. * `drown`
  3872. * `respawn`
  3873. * Any of the above types may have additional fields from mods.
  3874. * `reason.from` will be `mod` or `engine`.
  3875. * `modifier`: when true, the function should return the actual `hp_change`.
  3876. Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
  3877. Modifiers can return true as a second argument to stop the execution of further functions.
  3878. Non-modifiers receive the final HP change calculated by the modifiers.
  3879. * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
  3880. * Called when a player dies
  3881. * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
  3882. * `minetest.register_on_respawnplayer(function(ObjectRef))`
  3883. * Called when player is to be respawned
  3884. * Called _before_ repositioning of player occurs
  3885. * return true in func to disable regular player placement
  3886. * `minetest.register_on_prejoinplayer(function(name, ip))`
  3887. * Called when a client connects to the server, prior to authentication
  3888. * If it returns a string, the client is disconnected with that string as
  3889. reason.
  3890. * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
  3891. * Called when a player joins the game
  3892. * `last_login`: The timestamp of the previous login, or nil if player is new
  3893. * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
  3894. * Called when a player leaves the game
  3895. * `timed_out`: True for timeout, false for other reasons.
  3896. * `minetest.register_on_authplayer(function(name, ip, is_success))`
  3897. * Called when a client attempts to log into an account.
  3898. * `name`: The name of the account being authenticated.
  3899. * `ip`: The IP address of the client
  3900. * `is_success`: Whether the client was successfully authenticated
  3901. * For newly registered accounts, `is_success` will always be true
  3902. * `minetest.register_on_auth_fail(function(name, ip))`
  3903. * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
  3904. * `minetest.register_on_cheat(function(ObjectRef, cheat))`
  3905. * Called when a player cheats
  3906. * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
  3907. * `moved_too_fast`
  3908. * `interacted_too_far`
  3909. * `interacted_with_self`
  3910. * `interacted_while_dead`
  3911. * `finished_unknown_dig`
  3912. * `dug_unbreakable`
  3913. * `dug_too_fast`
  3914. * `minetest.register_on_chat_message(function(name, message))`
  3915. * Called always when a player says something
  3916. * Return `true` to mark the message as handled, which means that it will
  3917. not be sent to other players.
  3918. * `minetest.register_on_chatcommand(function(name, command, params))`
  3919. * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
  3920. is checked to see if the command exists, but after the input is parsed.
  3921. * Return `true` to mark the command as handled, which means that the default
  3922. handlers will be prevented.
  3923. * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
  3924. * Called when the server received input from `player` in a formspec with
  3925. the given `formname`. Specifically, this is called on any of the
  3926. following events:
  3927. * a button was pressed,
  3928. * Enter was pressed while the focus was on a text field
  3929. * a checkbox was toggled,
  3930. * something was selected in a dropdown list,
  3931. * a different tab was selected,
  3932. * selection was changed in a textlist or table,
  3933. * an entry was double-clicked in a textlist or table,
  3934. * a scrollbar was moved, or
  3935. * the form was actively closed by the player.
  3936. * Fields are sent for formspec elements which define a field. `fields`
  3937. is a table containing each formspecs element value (as string), with
  3938. the `name` parameter as index for each. The value depends on the
  3939. formspec element type:
  3940. * `animated_image`: Returns the index of the current frame.
  3941. * `button` and variants: If pressed, contains the user-facing button
  3942. text as value. If not pressed, is `nil`
  3943. * `field`, `textarea` and variants: Text in the field
  3944. * `dropdown`: Either the index or value, depending on the `index event`
  3945. dropdown argument.
  3946. * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
  3947. * `checkbox`: `"true"` if checked, `"false"` if unchecked
  3948. * `textlist`: See `minetest.explode_textlist_event`
  3949. * `table`: See `minetest.explode_table_event`
  3950. * `scrollbar`: See `minetest.explode_scrollbar_event`
  3951. * Special case: `["quit"]="true"` is sent when the user actively
  3952. closed the form by mouse click, keypress or through a button_exit[]
  3953. element.
  3954. * Special case: `["key_enter"]="true"` is sent when the user pressed
  3955. the Enter key and the focus was either nowhere (causing the formspec
  3956. to be closed) or on a button. If the focus was on a text field,
  3957. additionally, the index `key_enter_field` contains the name of the
  3958. text field. See also: `field_close_on_enter`.
  3959. * Newest functions are called first
  3960. * If function returns `true`, remaining functions are not called
  3961. * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
  3962. * Called when `player` crafts something
  3963. * `itemstack` is the output
  3964. * `old_craft_grid` contains the recipe (Note: the one in the inventory is
  3965. cleared).
  3966. * `craft_inv` is the inventory with the crafting grid
  3967. * Return either an `ItemStack`, to replace the output, or `nil`, to not
  3968. modify it.
  3969. * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
  3970. * The same as before, except that it is called before the player crafts, to
  3971. make craft prediction, and it should not change anything.
  3972. * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
  3973. * Determines how much of a stack may be taken, put or moved to a
  3974. player inventory.
  3975. * `player` (type `ObjectRef`) is the player who modified the inventory
  3976. `inventory` (type `InvRef`).
  3977. * List of possible `action` (string) values and their
  3978. `inventory_info` (table) contents:
  3979. * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  3980. * `put`: `{listname=string, index=number, stack=ItemStack}`
  3981. * `take`: Same as `put`
  3982. * Return a numeric value to limit the amount of items to be taken, put or
  3983. moved. A value of `-1` for `take` will make the source stack infinite.
  3984. * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
  3985. * Called after a take, put or move event from/to/in a player inventory
  3986. * Function arguments: see `minetest.register_allow_player_inventory_action`
  3987. * Does not accept or handle any return value.
  3988. * `minetest.register_on_protection_violation(function(pos, name))`
  3989. * Called by `builtin` and mods when a player violates protection at a
  3990. position (eg, digs a node or punches a protected entity).
  3991. * The registered functions can be called using
  3992. `minetest.record_protection_violation`.
  3993. * The provided function should check that the position is protected by the
  3994. mod calling this function before it prints a message, if it does, to
  3995. allow for multiple protection mods.
  3996. * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
  3997. * Called when an item is eaten, by `minetest.item_eat`
  3998. * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
  3999. * `minetest.register_on_priv_grant(function(name, granter, priv))`
  4000. * Called when `granter` grants the priv `priv` to `name`.
  4001. * Note that the callback will be called twice if it's done by a player,
  4002. once with granter being the player name, and again with granter being nil.
  4003. * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
  4004. * Called when `revoker` revokes the priv `priv` from `name`.
  4005. * Note that the callback will be called twice if it's done by a player,
  4006. once with revoker being the player name, and again with revoker being nil.
  4007. * `minetest.register_can_bypass_userlimit(function(name, ip))`
  4008. * Called when `name` user connects with `ip`.
  4009. * Return `true` to by pass the player limit
  4010. * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
  4011. * Called when an incoming mod channel message is received
  4012. * You should have joined some channels to receive events.
  4013. * If message comes from a server mod, `sender` field is an empty string.
  4014. * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
  4015. * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
  4016. engine's liquid transformation process.
  4017. * `pos_list` is an array of all modified positions.
  4018. * `node_list` is an array of the old node that was previously at the position
  4019. with the corresponding index in pos_list.
  4020. Setting-related
  4021. ---------------
  4022. * `minetest.settings`: Settings object containing all of the settings from the
  4023. main config file (`minetest.conf`).
  4024. * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
  4025. parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
  4026. Authentication
  4027. --------------
  4028. * `minetest.string_to_privs(str[, delim])`:
  4029. * Converts string representation of privs into table form
  4030. * `delim`: String separating the privs. Defaults to `","`.
  4031. * Returns `{ priv1 = true, ... }`
  4032. * `minetest.privs_to_string(privs[, delim])`:
  4033. * Returns the string representation of `privs`
  4034. * `delim`: String to delimit privs. Defaults to `","`.
  4035. * `minetest.get_player_privs(name) -> {priv1=true,...}`
  4036. * `minetest.check_player_privs(player_or_name, ...)`:
  4037. returns `bool, missing_privs`
  4038. * A quickhand for checking privileges.
  4039. * `player_or_name`: Either a Player object or the name of a player.
  4040. * `...` is either a list of strings, e.g. `"priva", "privb"` or
  4041. a table, e.g. `{ priva = true, privb = true }`.
  4042. * `minetest.check_password_entry(name, entry, password)`
  4043. * Returns true if the "password entry" for a player with name matches given
  4044. password, false otherwise.
  4045. * The "password entry" is the password representation generated by the
  4046. engine as returned as part of a `get_auth()` call on the auth handler.
  4047. * Only use this function for making it possible to log in via password from
  4048. external protocols such as IRC, other uses are frowned upon.
  4049. * `minetest.get_password_hash(name, raw_password)`
  4050. * Convert a name-password pair to a password hash that Minetest can use.
  4051. * The returned value alone is not a good basis for password checks based
  4052. on comparing the password hash in the database with the password hash
  4053. from the function, with an externally provided password, as the hash
  4054. in the db might use the new SRP verifier format.
  4055. * For this purpose, use `minetest.check_password_entry` instead.
  4056. * `minetest.get_player_ip(name)`: returns an IP address string for the player
  4057. `name`.
  4058. * The player needs to be online for this to be successful.
  4059. * `minetest.get_auth_handler()`: Return the currently active auth handler
  4060. * See the [Authentication handler definition]
  4061. * Use this to e.g. get the authentication data for a player:
  4062. `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  4063. * `minetest.notify_authentication_modified(name)`
  4064. * Must be called by the authentication handler for privilege changes.
  4065. * `name`: string; if omitted, all auth data should be considered modified
  4066. * `minetest.set_player_password(name, password_hash)`: Set password hash of
  4067. player `name`.
  4068. * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
  4069. `name`.
  4070. * `minetest.auth_reload()`
  4071. * See `reload()` in authentication handler definition
  4072. `minetest.set_player_password`, `minetest.set_player_privs`,
  4073. `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
  4074. handler.
  4075. Chat
  4076. ----
  4077. * `minetest.chat_send_all(text)`
  4078. * `minetest.chat_send_player(name, text)`
  4079. * `minetest.format_chat_message(name, message)`
  4080. * Used by the server to format a chat message, based on the setting `chat_message_format`.
  4081. Refer to the documentation of the setting for a list of valid placeholders.
  4082. * Takes player name and message, and returns the formatted string to be sent to players.
  4083. * Can be redefined by mods if required, for things like colored names or messages.
  4084. * **Only** the first occurrence of each placeholder will be replaced.
  4085. Environment access
  4086. ------------------
  4087. * `minetest.set_node(pos, node)`
  4088. * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
  4089. * Set node at position `pos`
  4090. * `node`: table `{name=string, param1=number, param2=number}`
  4091. * If param1 or param2 is omitted, it's set to `0`.
  4092. * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
  4093. * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
  4094. * Set node on all positions set in the first argument.
  4095. * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
  4096. * For node specification or position syntax see `minetest.set_node` call
  4097. * Faster than set_node due to single call, but still considerably slower
  4098. than Lua Voxel Manipulators (LVM) for large numbers of nodes.
  4099. Unlike LVMs, this will call node callbacks. It also allows setting nodes
  4100. in spread out positions which would cause LVMs to waste memory.
  4101. For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
  4102. times faster.
  4103. * `minetest.swap_node(pos, node)`
  4104. * Set node at position, but don't remove metadata
  4105. * `minetest.remove_node(pos)`
  4106. * By default it does the same as `minetest.set_node(pos, {name="air"})`
  4107. * `minetest.get_node(pos)`
  4108. * Returns the node at the given position as table in the format
  4109. `{name="node_name", param1=0, param2=0}`,
  4110. returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
  4111. * `minetest.get_node_or_nil(pos)`
  4112. * Same as `get_node` but returns `nil` for unloaded areas.
  4113. * `minetest.get_node_light(pos, timeofday)`
  4114. * Gets the light value at the given position. Note that the light value
  4115. "inside" the node at the given position is returned, so you usually want
  4116. to get the light value of a neighbor.
  4117. * `pos`: The position where to measure the light.
  4118. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4119. * Returns a number between `0` and `15` or `nil`
  4120. * `nil` is returned e.g. when the map isn't loaded at `pos`
  4121. * `minetest.get_natural_light(pos[, timeofday])`
  4122. * Figures out the sunlight (or moonlight) value at pos at the given time of
  4123. day.
  4124. * `pos`: The position of the node
  4125. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4126. * Returns a number between `0` and `15` or `nil`
  4127. * This function tests 203 nodes in the worst case, which happens very
  4128. unlikely
  4129. * `minetest.get_artificial_light(param1)`
  4130. * Calculates the artificial light (light from e.g. torches) value from the
  4131. `param1` value.
  4132. * `param1`: The param1 value of a `paramtype = "light"` node.
  4133. * Returns a number between `0` and `15`
  4134. * Currently it's the same as `math.floor(param1 / 16)`, except that it
  4135. ensures compatibility.
  4136. * `minetest.place_node(pos, node)`
  4137. * Place node with the same effects that a player would cause
  4138. * `minetest.dig_node(pos)`
  4139. * Dig node with the same effects that a player would cause
  4140. * Returns `true` if successful, `false` on failure (e.g. protected location)
  4141. * `minetest.punch_node(pos)`
  4142. * Punch node with the same effects that a player would cause
  4143. * `minetest.spawn_falling_node(pos)`
  4144. * Change node into falling node
  4145. * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
  4146. * `minetest.find_nodes_with_meta(pos1, pos2)`
  4147. * Get a table of positions of nodes that have metadata within a region
  4148. {pos1, pos2}.
  4149. * `minetest.get_meta(pos)`
  4150. * Get a `NodeMetaRef` at that position
  4151. * `minetest.get_node_timer(pos)`
  4152. * Get `NodeTimerRef`
  4153. * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
  4154. position.
  4155. * Returns `ObjectRef`, or `nil` if failed
  4156. * `minetest.add_item(pos, item)`: Spawn item
  4157. * Returns `ObjectRef`, or `nil` if failed
  4158. * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
  4159. * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  4160. ObjectRefs.
  4161. * `radius`: using an euclidean metric
  4162. * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
  4163. ObjectRefs.
  4164. * `pos1` and `pos2` are the min and max positions of the area to search.
  4165. * `minetest.set_timeofday(val)`
  4166. * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
  4167. * `minetest.get_timeofday()`
  4168. * `minetest.get_gametime()`: returns the time, in seconds, since the world was
  4169. created.
  4170. * `minetest.get_day_count()`: returns number days elapsed since world was
  4171. created.
  4172. * accounts for time changes.
  4173. * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
  4174. pos or `nil`.
  4175. * `radius`: using a maximum metric
  4176. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4177. * `search_center` is an optional boolean (default: `false`)
  4178. If true `pos` is also checked for the nodes
  4179. * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
  4180. * `pos1` and `pos2` are the min and max positions of the area to search.
  4181. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4182. * If `grouped` is true the return value is a table indexed by node name
  4183. which contains lists of positions.
  4184. * If `grouped` is false or absent the return values are as follows:
  4185. first value: Table with all node positions
  4186. second value: Table with the count of each node with the node name
  4187. as index
  4188. * Area volume is limited to 4,096,000 nodes
  4189. * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
  4190. list of positions.
  4191. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4192. * Return value: Table with all node positions with a node air above
  4193. * Area volume is limited to 4,096,000 nodes
  4194. * `minetest.get_perlin(noiseparams)`
  4195. * Return world-specific perlin noise.
  4196. * The actual seed used is the noiseparams seed plus the world seed.
  4197. * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
  4198. * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
  4199. * Return world-specific perlin noise.
  4200. * `minetest.get_voxel_manip([pos1, pos2])`
  4201. * Return voxel manipulator object.
  4202. * Loads the manipulator from the map if positions are passed.
  4203. * `minetest.set_gen_notify(flags, {deco_ids})`
  4204. * Set the types of on-generate notifications that should be collected.
  4205. * `flags` is a flag field with the available flags:
  4206. * dungeon
  4207. * temple
  4208. * cave_begin
  4209. * cave_end
  4210. * large_cave_begin
  4211. * large_cave_end
  4212. * decoration
  4213. * The second parameter is a list of IDs of decorations which notification
  4214. is requested for.
  4215. * `minetest.get_gen_notify()`
  4216. * Returns a flagstring and a table with the `deco_id`s.
  4217. * `minetest.get_decoration_id(decoration_name)`
  4218. * Returns the decoration ID number for the provided decoration name string,
  4219. or `nil` on failure.
  4220. * `minetest.get_mapgen_object(objectname)`
  4221. * Return requested mapgen object if available (see [Mapgen objects])
  4222. * `minetest.get_heat(pos)`
  4223. * Returns the heat at the position, or `nil` on failure.
  4224. * `minetest.get_humidity(pos)`
  4225. * Returns the humidity at the position, or `nil` on failure.
  4226. * `minetest.get_biome_data(pos)`
  4227. * Returns a table containing:
  4228. * `biome` the biome id of the biome at that position
  4229. * `heat` the heat at the position
  4230. * `humidity` the humidity at the position
  4231. * Or returns `nil` on failure.
  4232. * `minetest.get_biome_id(biome_name)`
  4233. * Returns the biome id, as used in the biomemap Mapgen object and returned
  4234. by `minetest.get_biome_data(pos)`, for a given biome_name string.
  4235. * `minetest.get_biome_name(biome_id)`
  4236. * Returns the biome name string for the provided biome id, or `nil` on
  4237. failure.
  4238. * If no biomes have been registered, such as in mgv6, returns `default`.
  4239. * `minetest.get_mapgen_params()`
  4240. * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
  4241. * Returns a table containing:
  4242. * `mgname`
  4243. * `seed`
  4244. * `chunksize`
  4245. * `water_level`
  4246. * `flags`
  4247. * `minetest.set_mapgen_params(MapgenParams)`
  4248. * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
  4249. instead.
  4250. * Set map generation parameters.
  4251. * Function cannot be called after the registration period; only
  4252. initialization and `on_mapgen_init`.
  4253. * Takes a table as an argument with the fields:
  4254. * `mgname`
  4255. * `seed`
  4256. * `chunksize`
  4257. * `water_level`
  4258. * `flags`
  4259. * Leave field unset to leave that parameter unchanged.
  4260. * `flags` contains a comma-delimited string of flags to set, or if the
  4261. prefix `"no"` is attached, clears instead.
  4262. * `flags` is in the same format and has the same options as `mg_flags` in
  4263. `minetest.conf`.
  4264. * `minetest.get_mapgen_setting(name)`
  4265. * Gets the *active* mapgen setting (or nil if none exists) in string
  4266. format with the following order of precedence:
  4267. 1) Settings loaded from map_meta.txt or overrides set during mod
  4268. execution.
  4269. 2) Settings set by mods without a metafile override
  4270. 3) Settings explicitly set in the user config file, minetest.conf
  4271. 4) Settings set as the user config default
  4272. * `minetest.get_mapgen_setting_noiseparams(name)`
  4273. * Same as above, but returns the value as a NoiseParams table if the
  4274. setting `name` exists and is a valid NoiseParams.
  4275. * `minetest.set_mapgen_setting(name, value, [override_meta])`
  4276. * Sets a mapgen param to `value`, and will take effect if the corresponding
  4277. mapgen setting is not already present in map_meta.txt.
  4278. * `override_meta` is an optional boolean (default: `false`). If this is set
  4279. to true, the setting will become the active setting regardless of the map
  4280. metafile contents.
  4281. * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
  4282. * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
  4283. * Same as above, except value is a NoiseParams table.
  4284. * `minetest.set_noiseparams(name, noiseparams, set_default)`
  4285. * Sets the noiseparams setting of `name` to the noiseparams table specified
  4286. in `noiseparams`.
  4287. * `set_default` is an optional boolean (default: `true`) that specifies
  4288. whether the setting should be applied to the default config or current
  4289. active config.
  4290. * `minetest.get_noiseparams(name)`
  4291. * Returns a table of the noiseparams for name.
  4292. * `minetest.generate_ores(vm, pos1, pos2)`
  4293. * Generate all registered ores within the VoxelManip `vm` and in the area
  4294. from `pos1` to `pos2`.
  4295. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4296. * `minetest.generate_decorations(vm, pos1, pos2)`
  4297. * Generate all registered decorations within the VoxelManip `vm` and in the
  4298. area from `pos1` to `pos2`.
  4299. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4300. * `minetest.clear_objects([options])`
  4301. * Clear all objects in the environment
  4302. * Takes an optional table as an argument with the field `mode`.
  4303. * mode = `"full"` : Load and go through every mapblock, clearing
  4304. objects (default).
  4305. * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
  4306. clear objects in unloaded mapblocks only when the
  4307. mapblocks are next activated.
  4308. * `minetest.load_area(pos1[, pos2])`
  4309. * Load the mapblocks containing the area from `pos1` to `pos2`.
  4310. `pos2` defaults to `pos1` if not specified.
  4311. * This function does not trigger map generation.
  4312. * `minetest.emerge_area(pos1, pos2, [callback], [param])`
  4313. * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
  4314. asynchronously fetched from memory, loaded from disk, or if inexistent,
  4315. generates them.
  4316. * If `callback` is a valid Lua function, this will be called for each block
  4317. emerged.
  4318. * The function signature of callback is:
  4319. `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
  4320. * `blockpos` is the *block* coordinates of the block that had been
  4321. emerged.
  4322. * `action` could be one of the following constant values:
  4323. * `minetest.EMERGE_CANCELLED`
  4324. * `minetest.EMERGE_ERRORED`
  4325. * `minetest.EMERGE_FROM_MEMORY`
  4326. * `minetest.EMERGE_FROM_DISK`
  4327. * `minetest.EMERGE_GENERATED`
  4328. * `calls_remaining` is the number of callbacks to be expected after
  4329. this one.
  4330. * `param` is the user-defined parameter passed to emerge_area (or
  4331. nil if the parameter was absent).
  4332. * `minetest.delete_area(pos1, pos2)`
  4333. * delete all mapblocks in the area from pos1 to pos2, inclusive
  4334. * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
  4335. * Checks if there is anything other than air between pos1 and pos2.
  4336. * Returns false if something is blocking the sight.
  4337. * Returns the position of the blocking node when `false`
  4338. * `pos1`: First position
  4339. * `pos2`: Second position
  4340. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
  4341. * Creates a `Raycast` object.
  4342. * `pos1`: start of the ray
  4343. * `pos2`: end of the ray
  4344. * `objects`: if false, only nodes will be returned. Default is `true`.
  4345. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  4346. returned. Default is `false`.
  4347. * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
  4348. * returns table containing path that can be walked on
  4349. * returns a table of 3D points representing a path from `pos1` to `pos2` or
  4350. `nil` on failure.
  4351. * Reasons for failure:
  4352. * No path exists at all
  4353. * No path exists within `searchdistance` (see below)
  4354. * Start or end pos is buried in land
  4355. * `pos1`: start position
  4356. * `pos2`: end position
  4357. * `searchdistance`: maximum distance from the search positions to search in.
  4358. In detail: Path must be completely inside a cuboid. The minimum
  4359. `searchdistance` of 1 will confine search between `pos1` and `pos2`.
  4360. Larger values will increase the size of this cuboid in all directions
  4361. * `max_jump`: maximum height difference to consider walkable
  4362. * `max_drop`: maximum height difference to consider droppable
  4363. * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
  4364. Difference between `"A*"` and `"A*_noprefetch"` is that
  4365. `"A*"` will pre-calculate the cost-data, the other will calculate it
  4366. on-the-fly
  4367. * `minetest.spawn_tree (pos, {treedef})`
  4368. * spawns L-system tree at given `pos` with definition in `treedef` table
  4369. * `minetest.transforming_liquid_add(pos)`
  4370. * add node to liquid flow update queue
  4371. * `minetest.get_node_max_level(pos)`
  4372. * get max available level for leveled node
  4373. * `minetest.get_node_level(pos)`
  4374. * get level of leveled node (water, snow)
  4375. * `minetest.set_node_level(pos, level)`
  4376. * set level of leveled node, default `level` equals `1`
  4377. * if `totallevel > maxlevel`, returns rest (`total-max`).
  4378. * `minetest.add_node_level(pos, level)`
  4379. * increase level of leveled node by level, default `level` equals `1`
  4380. * if `totallevel > maxlevel`, returns rest (`total-max`)
  4381. * `level` must be between -127 and 127
  4382. * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
  4383. * resets the light in a cuboid-shaped part of
  4384. the map and removes lighting bugs.
  4385. * Loads the area if it is not loaded.
  4386. * `pos1` is the corner of the cuboid with the least coordinates
  4387. (in node coordinates), inclusive.
  4388. * `pos2` is the opposite corner of the cuboid, inclusive.
  4389. * The actual updated cuboid might be larger than the specified one,
  4390. because only whole map blocks can be updated.
  4391. The actual updated area consists of those map blocks that intersect
  4392. with the given cuboid.
  4393. * However, the neighborhood of the updated area might change
  4394. as well, as light can spread out of the cuboid, also light
  4395. might be removed.
  4396. * returns `false` if the area is not fully generated,
  4397. `true` otherwise
  4398. * `minetest.check_single_for_falling(pos)`
  4399. * causes an unsupported `group:falling_node` node to fall and causes an
  4400. unattached `group:attached_node` node to fall.
  4401. * does not spread these updates to neighbours.
  4402. * `minetest.check_for_falling(pos)`
  4403. * causes an unsupported `group:falling_node` node to fall and causes an
  4404. unattached `group:attached_node` node to fall.
  4405. * spread these updates to neighbours and can cause a cascade
  4406. of nodes to fall.
  4407. * `minetest.get_spawn_level(x, z)`
  4408. * Returns a player spawn y co-ordinate for the provided (x, z)
  4409. co-ordinates, or `nil` for an unsuitable spawn point.
  4410. * For most mapgens a 'suitable spawn point' is one with y between
  4411. `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
  4412. so `nil` will be returned for many (x, z) co-ordinates.
  4413. * The spawn level returned is for a player spawn in unmodified terrain.
  4414. * The spawn level is intentionally above terrain level to cope with
  4415. full-node biome 'dust' nodes.
  4416. Mod channels
  4417. ------------
  4418. You can find mod channels communication scheme in `doc/mod_channels.png`.
  4419. * `minetest.mod_channel_join(channel_name)`
  4420. * Server joins channel `channel_name`, and creates it if necessary. You
  4421. should listen for incoming messages with
  4422. `minetest.register_on_modchannel_message`
  4423. Inventory
  4424. ---------
  4425. `minetest.get_inventory(location)`: returns an `InvRef`
  4426. * `location` = e.g.
  4427. * `{type="player", name="celeron55"}`
  4428. * `{type="node", pos={x=, y=, z=}}`
  4429. * `{type="detached", name="creative"}`
  4430. * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
  4431. an `InvRef`.
  4432. * `callbacks`: See [Detached inventory callbacks]
  4433. * `player_name`: Make detached inventory available to one player
  4434. exclusively, by default they will be sent to every player (even if not
  4435. used).
  4436. Note that this parameter is mostly just a workaround and will be removed
  4437. in future releases.
  4438. * Creates a detached inventory. If it already exists, it is cleared.
  4439. * `minetest.remove_detached_inventory(name)`
  4440. * Returns a `boolean` indicating whether the removal succeeded.
  4441. * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
  4442. returns leftover ItemStack or nil to indicate no inventory change
  4443. * See `minetest.item_eat` and `minetest.register_on_item_eat`
  4444. Formspec
  4445. --------
  4446. * `minetest.show_formspec(playername, formname, formspec)`
  4447. * `playername`: name of player to show formspec
  4448. * `formname`: name passed to `on_player_receive_fields` callbacks.
  4449. It should follow the `"modname:<whatever>"` naming convention
  4450. * `formspec`: formspec to display
  4451. * `minetest.close_formspec(playername, formname)`
  4452. * `playername`: name of player to close formspec
  4453. * `formname`: has to exactly match the one given in `show_formspec`, or the
  4454. formspec will not close.
  4455. * calling `show_formspec(playername, formname, "")` is equal to this
  4456. expression.
  4457. * to close a formspec regardless of the formname, call
  4458. `minetest.close_formspec(playername, "")`.
  4459. **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  4460. * `minetest.formspec_escape(string)`: returns a string
  4461. * escapes the characters "[", "]", "\", "," and ";", which can not be used
  4462. in formspecs.
  4463. * `minetest.explode_table_event(string)`: returns a table
  4464. * returns e.g. `{type="CHG", row=1, column=2}`
  4465. * `type` is one of:
  4466. * `"INV"`: no row selected
  4467. * `"CHG"`: selected
  4468. * `"DCL"`: double-click
  4469. * `minetest.explode_textlist_event(string)`: returns a table
  4470. * returns e.g. `{type="CHG", index=1}`
  4471. * `type` is one of:
  4472. * `"INV"`: no row selected
  4473. * `"CHG"`: selected
  4474. * `"DCL"`: double-click
  4475. * `minetest.explode_scrollbar_event(string)`: returns a table
  4476. * returns e.g. `{type="CHG", value=500}`
  4477. * `type` is one of:
  4478. * `"INV"`: something failed
  4479. * `"CHG"`: has been changed
  4480. * `"VAL"`: not changed
  4481. Item handling
  4482. -------------
  4483. * `minetest.inventorycube(img1, img2, img3)`
  4484. * Returns a string for making an image of a cube (useful as an item image)
  4485. * `minetest.get_pointed_thing_position(pointed_thing, above)`
  4486. * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
  4487. does not refer to a node or entity.
  4488. * If the optional `above` parameter is true and the `pointed_thing` refers
  4489. to a node, then it will return the `above` position of the `pointed_thing`.
  4490. * `minetest.dir_to_facedir(dir, is6d)`
  4491. * Convert a vector to a facedir value, used in `param2` for
  4492. `paramtype2="facedir"`.
  4493. * passing something non-`nil`/`false` for the optional second parameter
  4494. causes it to take the y component into account.
  4495. * `minetest.facedir_to_dir(facedir)`
  4496. * Convert a facedir back into a vector aimed directly out the "back" of a
  4497. node.
  4498. * `minetest.dir_to_wallmounted(dir)`
  4499. * Convert a vector to a wallmounted value, used for
  4500. `paramtype2="wallmounted"`.
  4501. * `minetest.wallmounted_to_dir(wallmounted)`
  4502. * Convert a wallmounted value back into a vector aimed directly out the
  4503. "back" of a node.
  4504. * `minetest.dir_to_yaw(dir)`
  4505. * Convert a vector into a yaw (angle)
  4506. * `minetest.yaw_to_dir(yaw)`
  4507. * Convert yaw (angle) to a vector
  4508. * `minetest.is_colored_paramtype(ptype)`
  4509. * Returns a boolean. Returns `true` if the given `paramtype2` contains
  4510. color information (`color`, `colorwallmounted` or `colorfacedir`).
  4511. * `minetest.strip_param2_color(param2, paramtype2)`
  4512. * Removes everything but the color information from the
  4513. given `param2` value.
  4514. * Returns `nil` if the given `paramtype2` does not contain color
  4515. information.
  4516. * `minetest.get_node_drops(node, toolname)`
  4517. * Returns list of itemstrings that are dropped by `node` when dug
  4518. with the item `toolname` (not limited to tools).
  4519. * `node`: node as table or node name
  4520. * `toolname`: name of the item used to dig (can be `nil`)
  4521. * `minetest.get_craft_result(input)`: returns `output, decremented_input`
  4522. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4523. * `input.width` = for example `3`
  4524. * `input.items` = for example
  4525. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4526. * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
  4527. * `output.time` = a number, if unsuccessful: `0`
  4528. * `output.replacements` = List of replacement `ItemStack`s that couldn't be
  4529. placed in `decremented_input.items`. Replacements can be placed in
  4530. `decremented_input` if the stack of the replaced item has a count of 1.
  4531. * `decremented_input` = like `input`
  4532. * `minetest.get_craft_recipe(output)`: returns input
  4533. * returns last registered recipe for output item (node)
  4534. * `output` is a node or item type such as `"default:torch"`
  4535. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4536. * `input.width` = for example `3`
  4537. * `input.items` = for example
  4538. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4539. * `input.items` = `nil` if no recipe found
  4540. * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
  4541. * returns indexed table with all registered recipes for query item (node)
  4542. or `nil` if no recipe was found.
  4543. * recipe entry table:
  4544. * `method`: 'normal' or 'cooking' or 'fuel'
  4545. * `width`: 0-3, 0 means shapeless recipe
  4546. * `items`: indexed [1-9] table with recipe items
  4547. * `output`: string with item name and quantity
  4548. * Example query for `"default:gold_ingot"` will return table:
  4549. {
  4550. [1]={method = "cooking", width = 3, output = "default:gold_ingot",
  4551. items = {1 = "default:gold_lump"}},
  4552. [2]={method = "normal", width = 1, output = "default:gold_ingot 9",
  4553. items = {1 = "default:goldblock"}}
  4554. }
  4555. * `minetest.handle_node_drops(pos, drops, digger)`
  4556. * `drops`: list of itemstrings
  4557. * Handles drops from nodes after digging: Default action is to put them
  4558. into digger's inventory.
  4559. * Can be overridden to get different functionality (e.g. dropping items on
  4560. ground)
  4561. * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
  4562. string.
  4563. * Creates an item string which contains palette index information
  4564. for hardware colorization. You can use the returned string
  4565. as an output in a craft recipe.
  4566. * `item`: the item stack which becomes colored. Can be in string,
  4567. table and native form.
  4568. * `palette_index`: this index is added to the item stack
  4569. * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
  4570. * Creates an item string which contains static color information
  4571. for hardware colorization. Use this method if you wish to colorize
  4572. an item that does not own a palette. You can use the returned string
  4573. as an output in a craft recipe.
  4574. * `item`: the item stack which becomes colored. Can be in string,
  4575. table and native form.
  4576. * `colorstring`: the new color of the item stack
  4577. Rollback
  4578. --------
  4579. * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
  4580. returns `{{actor, pos, time, oldnode, newnode}, ...}`
  4581. * Find who has done something to a node, or near a node
  4582. * `actor`: `"player:<name>"`, also `"liquid"`.
  4583. * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
  4584. `boolean, log_messages`.
  4585. * Revert latest actions of someone
  4586. * `actor`: `"player:<name>"`, also `"liquid"`.
  4587. Defaults for the `on_place` and `on_drop` item definition functions
  4588. -------------------------------------------------------------------
  4589. * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
  4590. * Place item as a node
  4591. * `param2` overrides `facedir` and wallmounted `param2`
  4592. * `prevent_after_place`: if set to `true`, `after_place_node` is not called
  4593. for the newly placed node to prevent a callback and placement loop
  4594. * returns `itemstack, position`
  4595. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4596. * `minetest.item_place_object(itemstack, placer, pointed_thing)`
  4597. * Place item as-is
  4598. * returns the leftover itemstack
  4599. * **Note**: This function is deprecated and will never be called.
  4600. * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
  4601. * Wrapper that calls `minetest.item_place_node` if appropriate
  4602. * Calls `on_rightclick` of `pointed_thing.under` if defined instead
  4603. * **Note**: is not called when wielded item overrides `on_place`
  4604. * `param2` overrides facedir and wallmounted `param2`
  4605. * returns `itemstack, position`
  4606. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4607. * `minetest.item_drop(itemstack, dropper, pos)`
  4608. * Drop the item
  4609. * returns the leftover itemstack
  4610. * `minetest.item_eat(hp_change[, replace_with_item])`
  4611. * Returns `function(itemstack, user, pointed_thing)` as a
  4612. function wrapper for `minetest.do_item_eat`.
  4613. * `replace_with_item` is the itemstring which is added to the inventory.
  4614. If the player is eating a stack, then replace_with_item goes to a
  4615. different spot.
  4616. Defaults for the `on_punch` and `on_dig` node definition callbacks
  4617. ------------------------------------------------------------------
  4618. * `minetest.node_punch(pos, node, puncher, pointed_thing)`
  4619. * Calls functions registered by `minetest.register_on_punchnode()`
  4620. * `minetest.node_dig(pos, node, digger)`
  4621. * Checks if node can be dug, puts item into inventory, removes node
  4622. * Calls functions registered by `minetest.registered_on_dignodes()`
  4623. Sounds
  4624. ------
  4625. * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
  4626. * `spec` is a `SimpleSoundSpec`
  4627. * `parameters` is a sound parameter table
  4628. * `ephemeral` is a boolean (default: false)
  4629. Ephemeral sounds will not return a handle and can't be stopped or faded.
  4630. It is recommend to use this for short sounds that happen in response to
  4631. player actions (e.g. door closing).
  4632. * `minetest.sound_stop(handle)`
  4633. * `handle` is a handle returned by `minetest.sound_play`
  4634. * `minetest.sound_fade(handle, step, gain)`
  4635. * `handle` is a handle returned by `minetest.sound_play`
  4636. * `step` determines how fast a sound will fade.
  4637. The gain will change by this much per second,
  4638. until it reaches the target gain.
  4639. Note: Older versions used a signed step. This is deprecated, but old
  4640. code will still work. (the client uses abs(step) to correct it)
  4641. * `gain` the target gain for the fade.
  4642. Fading to zero will delete the sound.
  4643. Timing
  4644. ------
  4645. * `minetest.after(time, func, ...)` : returns job table to use as below.
  4646. * Call the function `func` after `time` seconds, may be fractional
  4647. * Optional: Variable number of arguments that are passed to `func`
  4648. * `job:cancel()`
  4649. * Cancels the job function from being called
  4650. Async environment
  4651. -----------------
  4652. The engine allows you to submit jobs to be ran in an isolated environment
  4653. concurrently with normal server operation.
  4654. A job consists of a function to be ran in the async environment, any amount of
  4655. arguments (will be serialized) and a callback that will be called with the return
  4656. value of the job function once it is finished.
  4657. The async environment does *not* have access to the map, entities, players or any
  4658. globals defined in the 'usual' environment. Consequently, functions like
  4659. `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
  4660. Arguments and return values passed through this can contain certain userdata
  4661. objects that will be seamlessly copied (not shared) to the async environment.
  4662. This allows you easy interoperability for delegating work to jobs.
  4663. * `minetest.handle_async(func, callback, ...)`:
  4664. * Queue the function `func` to be ran in an async environment.
  4665. Note that there are multiple persistent workers and any of them may
  4666. end up running a given job. The engine will scale the amount of
  4667. worker threads automatically.
  4668. * When `func` returns the callback is called (in the normal environment)
  4669. with all of the return values as arguments.
  4670. * Optional: Variable number of arguments that are passed to `func`
  4671. * `minetest.register_async_dofile(path)`:
  4672. * Register a path to a Lua file to be imported when an async environment
  4673. is initialized. You can use this to preload code which you can then call
  4674. later using `minetest.handle_async()`.
  4675. ### List of APIs available in an async environment
  4676. Classes:
  4677. * `ItemStack`
  4678. * `PerlinNoise`
  4679. * `PerlinNoiseMap`
  4680. * `PseudoRandom`
  4681. * `PcgRandom`
  4682. * `SecureRandom`
  4683. * `VoxelArea`
  4684. * `VoxelManip`
  4685. * only if transferred into environment; can't read/write to map
  4686. * `Settings`
  4687. Class instances that can be transferred between environments:
  4688. * `ItemStack`
  4689. * `PerlinNoise`
  4690. * `PerlinNoiseMap`
  4691. * `VoxelManip`
  4692. Functions:
  4693. * Standalone helpers such as logging, filesystem, encoding,
  4694. hashing or compression APIs
  4695. * `minetest.request_insecure_environment` (same restrictions apply)
  4696. Variables:
  4697. * `minetest.settings`
  4698. * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
  4699. `registered_craftitems` and `registered_aliases`
  4700. * with all functions and userdata values replaced by `true`, calling any
  4701. callbacks here is obviously not possible
  4702. Server
  4703. ------
  4704. * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
  4705. server shutdown. Will display `message` to clients.
  4706. * `reconnect` == true displays a reconnect button
  4707. * `delay` adds an optional delay (in seconds) before shutdown.
  4708. Negative delay cancels the current active shutdown.
  4709. Zero delay triggers an immediate shutdown.
  4710. * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
  4711. * `minetest.get_server_status(name, joined)`
  4712. * Returns the server status string when a player joins or when the command
  4713. `/status` is called. Returns `nil` or an empty string when the message is
  4714. disabled.
  4715. * `joined`: Boolean value, indicates whether the function was called when
  4716. a player joined.
  4717. * This function may be overwritten by mods to customize the status message.
  4718. * `minetest.get_server_uptime()`: returns the server uptime in seconds
  4719. * `minetest.get_server_max_lag()`: returns the current maximum lag
  4720. of the server in seconds or nil if server is not fully loaded yet
  4721. * `minetest.remove_player(name)`: remove player from database (if they are not
  4722. connected).
  4723. * As auth data is not removed, minetest.player_exists will continue to
  4724. return true. Call the below method as well if you want to remove auth
  4725. data too.
  4726. * Returns a code (0: successful, 1: no such player, 2: player is connected)
  4727. * `minetest.remove_player_auth(name)`: remove player authentication data
  4728. * Returns boolean indicating success (false if player nonexistant)
  4729. * `minetest.dynamic_add_media(options, callback)`
  4730. * `options`: table containing the following parameters
  4731. * `filepath`: path to a media file on the filesystem
  4732. * `to_player`: name of the player the media should be sent to instead of
  4733. all players (optional)
  4734. * `ephemeral`: boolean that marks the media as ephemeral,
  4735. it will not be cached on the client (optional, default false)
  4736. * `callback`: function with arguments `name`, which is a player name
  4737. * Pushes the specified media file to client(s). (details below)
  4738. The file must be a supported image, sound or model format.
  4739. Dynamically added media is not persisted between server restarts.
  4740. * Returns false on error, true if the request was accepted
  4741. * The given callback will be called for every player as soon as the
  4742. media is available on the client.
  4743. * Details/Notes:
  4744. * If `ephemeral`=false and `to_player` is unset the file is added to the media
  4745. sent to clients on startup, this means the media will appear even on
  4746. old clients if they rejoin the server.
  4747. * If `ephemeral`=false the file must not be modified, deleted, moved or
  4748. renamed after calling this function.
  4749. * Regardless of any use of `ephemeral`, adding media files with the same
  4750. name twice is not possible/guaranteed to work. An exception to this is the
  4751. use of `to_player` to send the same, already existent file to multiple
  4752. chosen players.
  4753. * Clients will attempt to fetch files added this way via remote media,
  4754. this can make transfer of bigger files painless (if set up). Nevertheless
  4755. it is advised not to use dynamic media for big media files.
  4756. Bans
  4757. ----
  4758. * `minetest.get_ban_list()`: returns a list of all bans formatted as string
  4759. * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
  4760. IP address or name formatted as string
  4761. * `minetest.ban_player(name)`: ban the IP of a currently connected player
  4762. * Returns boolean indicating success
  4763. * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
  4764. IP address or name
  4765. * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
  4766. reason.
  4767. * Returns boolean indicating success (false if player nonexistant)
  4768. * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
  4769. optional reason, this will not prefix with 'Kicked: ' like kick_player.
  4770. If no reason is given, it will default to 'Disconnected.'
  4771. * Returns boolean indicating success (false if player nonexistant)
  4772. Particles
  4773. ---------
  4774. * `minetest.add_particle(particle definition)`
  4775. * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
  4776. expirationtime, size, collisiondetection, texture, playername)`
  4777. * `minetest.add_particlespawner(particlespawner definition)`
  4778. * Add a `ParticleSpawner`, an object that spawns an amount of particles
  4779. over `time` seconds.
  4780. * Returns an `id`, and -1 if adding didn't succeed
  4781. * Deprecated: `minetest.add_particlespawner(amount, time,
  4782. minpos, maxpos,
  4783. minvel, maxvel,
  4784. minacc, maxacc,
  4785. minexptime, maxexptime,
  4786. minsize, maxsize,
  4787. collisiondetection, texture, playername)`
  4788. * `minetest.delete_particlespawner(id, player)`
  4789. * Delete `ParticleSpawner` with `id` (return value from
  4790. `minetest.add_particlespawner`).
  4791. * If playername is specified, only deletes on the player's client,
  4792. otherwise on all clients.
  4793. Schematics
  4794. ----------
  4795. * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
  4796. * Create a schematic from the volume of map specified by the box formed by
  4797. p1 and p2.
  4798. * Apply the specified probability and per-node force-place to the specified
  4799. nodes according to the `probability_list`.
  4800. * `probability_list` is an array of tables containing two fields, `pos`
  4801. and `prob`.
  4802. * `pos` is the 3D vector specifying the absolute coordinates of the
  4803. node being modified,
  4804. * `prob` is an integer value from `0` to `255` that encodes
  4805. probability and per-node force-place. Probability has levels
  4806. 0-127, then 128 may be added to encode per-node force-place.
  4807. For probability stated as 0-255, divide by 2 and round down to
  4808. get values 0-127, then add 128 to apply per-node force-place.
  4809. * If there are two or more entries with the same pos value, the
  4810. last entry is used.
  4811. * If `pos` is not inside the box formed by `p1` and `p2`, it is
  4812. ignored.
  4813. * If `probability_list` equals `nil`, no probabilities are applied.
  4814. * Apply the specified probability to the specified horizontal slices
  4815. according to the `slice_prob_list`.
  4816. * `slice_prob_list` is an array of tables containing two fields, `ypos`
  4817. and `prob`.
  4818. * `ypos` indicates the y position of the slice with a probability
  4819. applied, the lowest slice being `ypos = 0`.
  4820. * If slice probability list equals `nil`, no slice probabilities
  4821. are applied.
  4822. * Saves schematic in the Minetest Schematic format to filename.
  4823. * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
  4824. * Place the schematic specified by schematic (see [Schematic specifier]) at
  4825. `pos`.
  4826. * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
  4827. * If the `rotation` parameter is omitted, the schematic is not rotated.
  4828. * `replacements` = `{["old_name"] = "convert_to", ...}`
  4829. * `force_placement` is a boolean indicating whether nodes other than `air`
  4830. and `ignore` are replaced by the schematic.
  4831. * Returns nil if the schematic could not be loaded.
  4832. * **Warning**: Once you have loaded a schematic from a file, it will be
  4833. cached. Future calls will always use the cached version and the
  4834. replacement list defined for it, regardless of whether the file or the
  4835. replacement list parameter have changed. The only way to load the file
  4836. anew is to restart the server.
  4837. * `flags` is a flag field with the available flags:
  4838. * place_center_x
  4839. * place_center_y
  4840. * place_center_z
  4841. * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
  4842. * This function is analogous to minetest.place_schematic, but places a
  4843. schematic onto the specified VoxelManip object `vmanip` instead of the
  4844. map.
  4845. * Returns false if any part of the schematic was cut-off due to the
  4846. VoxelManip not containing the full area required, and true if the whole
  4847. schematic was able to fit.
  4848. * Returns nil if the schematic could not be loaded.
  4849. * After execution, any external copies of the VoxelManip contents are
  4850. invalidated.
  4851. * `flags` is a flag field with the available flags:
  4852. * place_center_x
  4853. * place_center_y
  4854. * place_center_z
  4855. * `minetest.serialize_schematic(schematic, format, options)`
  4856. * Return the serialized schematic specified by schematic
  4857. (see [Schematic specifier])
  4858. * in the `format` of either "mts" or "lua".
  4859. * "mts" - a string containing the binary MTS data used in the MTS file
  4860. format.
  4861. * "lua" - a string containing Lua code representing the schematic in table
  4862. format.
  4863. * `options` is a table containing the following optional parameters:
  4864. * If `lua_use_comments` is true and `format` is "lua", the Lua code
  4865. generated will have (X, Z) position comments for every X row
  4866. generated in the schematic data for easier reading.
  4867. * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
  4868. the Lua code generated will use that number of spaces as indentation
  4869. instead of a tab character.
  4870. * `minetest.read_schematic(schematic, options)`
  4871. * Returns a Lua table representing the schematic (see: [Schematic specifier])
  4872. * `schematic` is the schematic to read (see: [Schematic specifier])
  4873. * `options` is a table containing the following optional parameters:
  4874. * `write_yslice_prob`: string value:
  4875. * `none`: no `write_yslice_prob` table is inserted,
  4876. * `low`: only probabilities that are not 254 or 255 are written in
  4877. the `write_ylisce_prob` table,
  4878. * `all`: write all probabilities to the `write_yslice_prob` table.
  4879. * The default for this option is `all`.
  4880. * Any invalid value will be interpreted as `all`.
  4881. HTTP Requests
  4882. -------------
  4883. * `minetest.request_http_api()`:
  4884. * returns `HTTPApiTable` containing http functions if the calling mod has
  4885. been granted access by being listed in the `secure.http_mods` or
  4886. `secure.trusted_mods` setting, otherwise returns `nil`.
  4887. * The returned table contains the functions `fetch`, `fetch_async` and
  4888. `fetch_async_get` described below.
  4889. * Only works at init time and must be called from the mod's main scope
  4890. (not from a function).
  4891. * Function only exists if minetest server was built with cURL support.
  4892. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
  4893. A LOCAL VARIABLE!**
  4894. * `HTTPApiTable.fetch(HTTPRequest req, callback)`
  4895. * Performs given request asynchronously and calls callback upon completion
  4896. * callback: `function(HTTPRequestResult res)`
  4897. * Use this HTTP function if you are unsure, the others are for advanced use
  4898. * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
  4899. * Performs given request asynchronously and returns handle for
  4900. `HTTPApiTable.fetch_async_get`
  4901. * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
  4902. * Return response data for given asynchronous HTTP request
  4903. Storage API
  4904. -----------
  4905. * `minetest.get_mod_storage()`:
  4906. * returns reference to mod private `StorageRef`
  4907. * must be called during mod load time
  4908. Misc.
  4909. -----
  4910. * `minetest.get_connected_players()`: returns list of `ObjectRefs`
  4911. * `minetest.is_player(obj)`: boolean, whether `obj` is a player
  4912. * `minetest.player_exists(name)`: boolean, whether player exists
  4913. (regardless of online status)
  4914. * `minetest.hud_replace_builtin(name, hud_definition)`
  4915. * Replaces definition of a builtin hud element
  4916. * `name`: `"breath"` or `"health"`
  4917. * `hud_definition`: definition to replace builtin definition
  4918. * `minetest.send_join_message(player_name)`
  4919. * This function can be overridden by mods to change the join message.
  4920. * `minetest.send_leave_message(player_name, timed_out)`
  4921. * This function can be overridden by mods to change the leave message.
  4922. * `minetest.hash_node_position(pos)`: returns an 48-bit integer
  4923. * `pos`: table {x=number, y=number, z=number},
  4924. * Gives a unique hash number for a node position (16+16+16=48bit)
  4925. * `minetest.get_position_from_hash(hash)`: returns a position
  4926. * Inverse transform of `minetest.hash_node_position`
  4927. * `minetest.get_item_group(name, group)`: returns a rating
  4928. * Get rating of a group of an item. (`0` means: not in group)
  4929. * `minetest.get_node_group(name, group)`: returns a rating
  4930. * Deprecated: An alias for the former.
  4931. * `minetest.raillike_group(name)`: returns a rating
  4932. * Returns rating of the connect_to_raillike group corresponding to name
  4933. * If name is not yet the name of a connect_to_raillike group, a new group
  4934. id is created, with that name.
  4935. * `minetest.get_content_id(name)`: returns an integer
  4936. * Gets the internal content ID of `name`
  4937. * `minetest.get_name_from_content_id(content_id)`: returns a string
  4938. * Gets the name of the content with that content ID
  4939. * `minetest.parse_json(string[, nullvalue])`: returns something
  4940. * Convert a string containing JSON data into the Lua equivalent
  4941. * `nullvalue`: returned in place of the JSON null; defaults to `nil`
  4942. * On success returns a table, a string, a number, a boolean or `nullvalue`
  4943. * On failure outputs an error message and returns `nil`
  4944. * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
  4945. * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
  4946. message.
  4947. * Convert a Lua table into a JSON string
  4948. * styled: Outputs in a human-readable format if this is set, defaults to
  4949. false.
  4950. * Unserializable things like functions and userdata will cause an error.
  4951. * **Warning**: JSON is more strict than the Lua table format.
  4952. 1. You can only use strings and positive integers of at least one as
  4953. keys.
  4954. 2. You can not mix string and integer keys.
  4955. This is due to the fact that JSON has two distinct array and object
  4956. values.
  4957. * Example: `write_json({10, {a = false}})`,
  4958. returns `'[10, {"a": false}]'`
  4959. * `minetest.serialize(table)`: returns a string
  4960. * Convert a table containing tables, strings, numbers, booleans and `nil`s
  4961. into string form readable by `minetest.deserialize`
  4962. * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
  4963. * `minetest.deserialize(string[, safe])`: returns a table
  4964. * Convert a string returned by `minetest.serialize` into a table
  4965. * `string` is loaded in an empty sandbox environment.
  4966. * Will load functions if safe is false or omitted. Although these functions
  4967. cannot directly access the global environment, they could bypass this
  4968. restriction with maliciously crafted Lua bytecode if mod security is
  4969. disabled.
  4970. * This function should not be used on untrusted data, regardless of the
  4971. value of `safe`. It is fine to serialize then deserialize user-provided
  4972. data, but directly providing user input to deserialize is always unsafe.
  4973. * Example: `deserialize('return { ["foo"] = "bar" }')`,
  4974. returns `{foo="bar"}`
  4975. * Example: `deserialize('print("foo")')`, returns `nil`
  4976. (function call fails), returns
  4977. `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
  4978. * `minetest.compress(data, method, ...)`: returns `compressed_data`
  4979. * Compress a string of data.
  4980. * `method` is a string identifying the compression method to be used.
  4981. * Supported compression methods:
  4982. * Deflate (zlib): `"deflate"`
  4983. * `...` indicates method-specific arguments. Currently defined arguments
  4984. are:
  4985. * Deflate: `level` - Compression level, `0`-`9` or `nil`.
  4986. * `minetest.decompress(compressed_data, method, ...)`: returns data
  4987. * Decompress a string of data (using ZLib).
  4988. * See documentation on `minetest.compress()` for supported compression
  4989. methods.
  4990. * `...` indicates method-specific arguments. Currently, no methods use this
  4991. * `minetest.rgba(red, green, blue[, alpha])`: returns a string
  4992. * Each argument is a 8 Bit unsigned integer
  4993. * Returns the ColorString from rgb or rgba values
  4994. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
  4995. * `minetest.encode_base64(string)`: returns string encoded in base64
  4996. * Encodes a string in base64.
  4997. * `minetest.decode_base64(string)`: returns string or nil on failure
  4998. * Padding characters are only supported starting at version 5.4.0, where
  4999. 5.5.0 and newer perform proper checks.
  5000. * Decodes a string encoded in base64.
  5001. * `minetest.is_protected(pos, name)`: returns boolean
  5002. * Returning `true` restricts the player `name` from modifying (i.e. digging,
  5003. placing) the node at position `pos`.
  5004. * `name` will be `""` for non-players or unknown players.
  5005. * This function should be overridden by protection mods. It is highly
  5006. recommended to grant access to players with the `protection_bypass` privilege.
  5007. * Cache and call the old version of this function if the position is
  5008. not protected by the mod. This will allow using multiple protection mods.
  5009. * Example:
  5010. local old_is_protected = minetest.is_protected
  5011. function minetest.is_protected(pos, name)
  5012. if mymod:position_protected_from(pos, name) then
  5013. return true
  5014. end
  5015. return old_is_protected(pos, name)
  5016. end
  5017. * `minetest.record_protection_violation(pos, name)`
  5018. * This function calls functions registered with
  5019. `minetest.register_on_protection_violation`.
  5020. * `minetest.is_creative_enabled(name)`: returns boolean
  5021. * Returning `true` means that Creative Mode is enabled for player `name`.
  5022. * `name` will be `""` for non-players or if the player is unknown.
  5023. * This function should be overridden by Creative Mode-related mods to
  5024. implement a per-player Creative Mode.
  5025. * By default, this function returns `true` if the setting
  5026. `creative_mode` is `true` and `false` otherwise.
  5027. * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
  5028. * Returns the position of the first node that `player_name` may not modify
  5029. in the specified cuboid between `pos1` and `pos2`.
  5030. * Returns `false` if no protections were found.
  5031. * Applies `is_protected()` to a 3D lattice of points in the defined volume.
  5032. The points are spaced evenly throughout the volume and have a spacing
  5033. similar to, but no larger than, `interval`.
  5034. * All corners and edges of the defined volume are checked.
  5035. * `interval` defaults to 4.
  5036. * `interval` should be carefully chosen and maximised to avoid an excessive
  5037. number of points being checked.
  5038. * Like `minetest.is_protected`, this function may be extended or
  5039. overwritten by mods to provide a faster implementation to check the
  5040. cuboid for intersections.
  5041. * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
  5042. orient_flags, prevent_after_place])`
  5043. * Attempt to predict the desired orientation of the facedir-capable node
  5044. defined by `itemstack`, and place it accordingly (on-wall, on the floor,
  5045. or hanging from the ceiling).
  5046. * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
  5047. stacks are handled normally.
  5048. * `orient_flags`: Optional table containing extra tweaks to the placement code:
  5049. * `invert_wall`: if `true`, place wall-orientation on the ground and
  5050. ground-orientation on the wall.
  5051. * `force_wall` : if `true`, always place the node in wall orientation.
  5052. * `force_ceiling`: if `true`, always place on the ceiling.
  5053. * `force_floor`: if `true`, always place the node on the floor.
  5054. * `force_facedir`: if `true`, forcefully reset the facedir to north
  5055. when placing on the floor or ceiling.
  5056. * The first four options are mutually-exclusive; the last in the list
  5057. takes precedence over the first.
  5058. * `prevent_after_place` is directly passed to `minetest.item_place_node`
  5059. * Returns the new itemstack after placement
  5060. * `minetest.rotate_node(itemstack, placer, pointed_thing)`
  5061. * calls `rotate_and_place()` with `infinitestacks` set according to the state
  5062. of the creative mode setting, checks for "sneak" to set the `invert_wall`
  5063. parameter and `prevent_after_place` set to `true`.
  5064. * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
  5065. tool_capabilities, dir, distance, damage)`
  5066. * Returns the amount of knockback applied on the punched player.
  5067. * Arguments are equivalent to `register_on_punchplayer`, except the following:
  5068. * `distance`: distance between puncher and punched player
  5069. * This function can be overriden by mods that wish to modify this behaviour.
  5070. * You may want to cache and call the old function to allow multiple mods to
  5071. change knockback behaviour.
  5072. * `minetest.forceload_block(pos[, transient])`
  5073. * forceloads the position `pos`.
  5074. * returns `true` if area could be forceloaded
  5075. * If `transient` is `false` or absent, the forceload will be persistent
  5076. (saved between server runs). If `true`, the forceload will be transient
  5077. (not saved between server runs).
  5078. * `minetest.forceload_free_block(pos[, transient])`
  5079. * stops forceloading the position `pos`
  5080. * If `transient` is `false` or absent, frees a persistent forceload.
  5081. If `true`, frees a transient forceload.
  5082. * `minetest.compare_block_status(pos, condition)`
  5083. * Checks whether the mapblock at positition `pos` is in the wanted condition.
  5084. * `condition` may be one of the following values:
  5085. * `"unknown"`: not in memory
  5086. * `"emerging"`: in the queue for loading from disk or generating
  5087. * `"loaded"`: in memory but inactive (no ABMs are executed)
  5088. * `"active"`: in memory and active
  5089. * Other values are reserved for future functionality extensions
  5090. * Return value, the comparison status:
  5091. * `false`: Mapblock does not fulfil the wanted condition
  5092. * `true`: Mapblock meets the requirement
  5093. * `nil`: Unsupported `condition` value
  5094. * `minetest.request_insecure_environment()`: returns an environment containing
  5095. insecure functions if the calling mod has been listed as trusted in the
  5096. `secure.trusted_mods` setting or security is disabled, otherwise returns
  5097. `nil`.
  5098. * Only works at init time and must be called from the mod's main scope
  5099. (ie: the init.lua of the mod, not from another Lua file or within a function).
  5100. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
  5101. IT IN A LOCAL VARIABLE!**
  5102. * `minetest.global_exists(name)`
  5103. * Checks if a global variable has been set, without triggering a warning.
  5104. Global objects
  5105. --------------
  5106. * `minetest.env`: `EnvRef` of the server environment and world.
  5107. * Any function in the minetest namespace can be called using the syntax
  5108. `minetest.env:somefunction(somearguments)`
  5109. instead of `minetest.somefunction(somearguments)`
  5110. * Deprecated, but support is not to be dropped soon
  5111. Global tables
  5112. -------------
  5113. ### Registered definition tables
  5114. * `minetest.registered_items`
  5115. * Map of registered items, indexed by name
  5116. * `minetest.registered_nodes`
  5117. * Map of registered node definitions, indexed by name
  5118. * `minetest.registered_craftitems`
  5119. * Map of registered craft item definitions, indexed by name
  5120. * `minetest.registered_tools`
  5121. * Map of registered tool definitions, indexed by name
  5122. * `minetest.registered_entities`
  5123. * Map of registered entity prototypes, indexed by name
  5124. * Values in this table may be modified directly.
  5125. Note: changes to initial properties will only affect entities spawned afterwards,
  5126. as they are only read when spawning.
  5127. * `minetest.object_refs`
  5128. * Map of object references, indexed by active object id
  5129. * `minetest.luaentities`
  5130. * Map of Lua entities, indexed by active object id
  5131. * `minetest.registered_abms`
  5132. * List of ABM definitions
  5133. * `minetest.registered_lbms`
  5134. * List of LBM definitions
  5135. * `minetest.registered_aliases`
  5136. * Map of registered aliases, indexed by name
  5137. * `minetest.registered_ores`
  5138. * Map of registered ore definitions, indexed by the `name` field.
  5139. * If `name` is nil, the key is the object handle returned by
  5140. `minetest.register_ore`.
  5141. * `minetest.registered_biomes`
  5142. * Map of registered biome definitions, indexed by the `name` field.
  5143. * If `name` is nil, the key is the object handle returned by
  5144. `minetest.register_biome`.
  5145. * `minetest.registered_decorations`
  5146. * Map of registered decoration definitions, indexed by the `name` field.
  5147. * If `name` is nil, the key is the object handle returned by
  5148. `minetest.register_decoration`.
  5149. * `minetest.registered_schematics`
  5150. * Map of registered schematic definitions, indexed by the `name` field.
  5151. * If `name` is nil, the key is the object handle returned by
  5152. `minetest.register_schematic`.
  5153. * `minetest.registered_chatcommands`
  5154. * Map of registered chat command definitions, indexed by name
  5155. * `minetest.registered_privileges`
  5156. * Map of registered privilege definitions, indexed by name
  5157. * Registered privileges can be modified directly in this table.
  5158. ### Registered callback tables
  5159. All callbacks registered with [Global callback registration functions] are added
  5160. to corresponding `minetest.registered_*` tables.
  5161. Class reference
  5162. ===============
  5163. Sorted alphabetically.
  5164. `AreaStore`
  5165. -----------
  5166. AreaStore is a data structure to calculate intersections of 3D cuboid volumes
  5167. and points. The `data` field (string) may be used to store and retrieve any
  5168. mod-relevant information to the specified area.
  5169. Despite its name, mods must take care of persisting AreaStore data. They may
  5170. use the provided load and write functions for this.
  5171. ### Methods
  5172. * `AreaStore(type_name)`
  5173. * Returns a new AreaStore instance
  5174. * `type_name`: optional, forces the internally used API.
  5175. * Possible values: `"LibSpatial"` (default).
  5176. * When other values are specified, or SpatialIndex is not available,
  5177. the custom Minetest functions are used.
  5178. * `get_area(id, include_corners, include_data)`
  5179. * Returns the area information about the specified ID.
  5180. * Returned values are either of these:
  5181. nil -- Area not found
  5182. true -- Without `include_corners` and `include_data`
  5183. {
  5184. min = pos, max = pos -- `include_corners == true`
  5185. data = string -- `include_data == true`
  5186. }
  5187. * `get_areas_for_pos(pos, include_corners, include_data)`
  5188. * Returns all areas as table, indexed by the area ID.
  5189. * Table values: see `get_area`.
  5190. * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
  5191. * Returns all areas that contain all nodes inside the area specified by`
  5192. `corner1 and `corner2` (inclusive).
  5193. * `accept_overlap`: if `true`, areas are returned that have nodes in
  5194. common (intersect) with the specified area.
  5195. * Returns the same values as `get_areas_for_pos`.
  5196. * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
  5197. * Returns the new area's ID, or nil if the insertion failed.
  5198. * The (inclusive) positions `corner1` and `corner2` describe the area.
  5199. * `data` is a string stored with the area.
  5200. * `id` (optional): will be used as the internal area ID if it is an unique
  5201. number between 0 and 2^32-2.
  5202. * `reserve(count)`
  5203. * Requires SpatialIndex, no-op function otherwise.
  5204. * Reserves resources for `count` many contained areas to improve
  5205. efficiency when working with many area entries. Additional areas can still
  5206. be inserted afterwards at the usual complexity.
  5207. * `remove_area(id)`: removes the area with the given id from the store, returns
  5208. success.
  5209. * `set_cache_params(params)`: sets params for the included prefiltering cache.
  5210. Calling invalidates the cache, so that its elements have to be newly
  5211. generated.
  5212. * `params` is a table with the following fields:
  5213. enabled = boolean, -- Whether to enable, default true
  5214. block_radius = int, -- The radius (in nodes) of the areas the cache
  5215. -- generates prefiltered lists for, minimum 16,
  5216. -- default 64
  5217. limit = int, -- The cache size, minimum 20, default 1000
  5218. * `to_string()`: Experimental. Returns area store serialized as a (binary)
  5219. string.
  5220. * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
  5221. a file.
  5222. * `from_string(str)`: Experimental. Deserializes string and loads it into the
  5223. AreaStore.
  5224. Returns success and, optionally, an error message.
  5225. * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
  5226. from a file.
  5227. `InvRef`
  5228. --------
  5229. An `InvRef` is a reference to an inventory.
  5230. ### Methods
  5231. * `is_empty(listname)`: return `true` if list is empty
  5232. * `get_size(listname)`: get size of a list
  5233. * `set_size(listname, size)`: set size of a list
  5234. * returns `false` on error (e.g. invalid `listname` or `size`)
  5235. * `get_width(listname)`: get width of a list
  5236. * `set_width(listname, width)`: set width of list; currently used for crafting
  5237. * `get_stack(listname, i)`: get a copy of stack index `i` in list
  5238. * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
  5239. * `get_list(listname)`: return full list (list of `ItemStack`s)
  5240. * `set_list(listname, list)`: set full list (size will not change)
  5241. * `get_lists()`: returns table that maps listnames to inventory lists
  5242. * `set_lists(lists)`: sets inventory lists (size will not change)
  5243. * `add_item(listname, stack)`: add item somewhere in list, returns leftover
  5244. `ItemStack`.
  5245. * `room_for_item(listname, stack):` returns `true` if the stack of items
  5246. can be fully added to the list
  5247. * `contains_item(listname, stack, [match_meta])`: returns `true` if
  5248. the stack of items can be fully taken from the list.
  5249. If `match_meta` is false, only the items' names are compared
  5250. (default: `false`).
  5251. * `remove_item(listname, stack)`: take as many items as specified from the
  5252. list, returns the items that were actually removed (as an `ItemStack`)
  5253. -- note that any item metadata is ignored, so attempting to remove a specific
  5254. unique item this way will likely remove the wrong one -- to do that use
  5255. `set_stack` with an empty `ItemStack`.
  5256. * `get_location()`: returns a location compatible to
  5257. `minetest.get_inventory(location)`.
  5258. * returns `{type="undefined"}` in case location is not known
  5259. ### Callbacks
  5260. Detached & nodemeta inventories provide the following callbacks for move actions:
  5261. #### Before
  5262. The `allow_*` callbacks return how many items can be moved.
  5263. * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
  5264. * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
  5265. * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
  5266. #### After
  5267. The `on_*` callbacks are called after the items have been placed in the inventories.
  5268. * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
  5269. * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
  5270. * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
  5271. #### Swapping
  5272. When a player tries to put an item to a place where another item is, the items are *swapped*.
  5273. This means that all callbacks will be called twice (once for each action).
  5274. `ItemStack`
  5275. -----------
  5276. An `ItemStack` is a stack of items.
  5277. It can be created via `ItemStack(x)`, where x is an `ItemStack`,
  5278. an itemstring, a table or `nil`.
  5279. ### Methods
  5280. * `is_empty()`: returns `true` if stack is empty.
  5281. * `get_name()`: returns item name (e.g. `"default:stone"`).
  5282. * `set_name(item_name)`: returns a boolean indicating whether the item was
  5283. cleared.
  5284. * `get_count()`: Returns number of items on the stack.
  5285. * `set_count(count)`: returns a boolean indicating whether the item was cleared
  5286. * `count`: number, unsigned 16 bit integer
  5287. * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
  5288. * `set_wear(wear)`: returns boolean indicating whether item was cleared
  5289. * `wear`: number, unsigned 16 bit integer
  5290. * `get_meta()`: returns ItemStackMetaRef. See section for more details
  5291. * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
  5292. stack).
  5293. * `set_metadata(metadata)`: (DEPRECATED) Returns true.
  5294. * `get_description()`: returns the description shown in inventory list tooltips.
  5295. * The engine uses this when showing item descriptions in tooltips.
  5296. * Fields for finding the description, in order:
  5297. * `description` in item metadata (See [Item Metadata].)
  5298. * `description` in item definition
  5299. * item name
  5300. * `get_short_description()`: returns the short description or nil.
  5301. * Unlike the description, this does not include new lines.
  5302. * Fields for finding the short description, in order:
  5303. * `short_description` in item metadata (See [Item Metadata].)
  5304. * `short_description` in item definition
  5305. * first line of the description (From item meta or def, see `get_description()`.)
  5306. * Returns nil if none of the above are set
  5307. * `clear()`: removes all items from the stack, making it empty.
  5308. * `replace(item)`: replace the contents of this stack.
  5309. * `item` can also be an itemstring or table.
  5310. * `to_string()`: returns the stack in itemstring form.
  5311. * `to_table()`: returns the stack in Lua table form.
  5312. * `get_stack_max()`: returns the maximum size of the stack (depends on the
  5313. item).
  5314. * `get_free_space()`: returns `get_stack_max() - get_count()`.
  5315. * `is_known()`: returns `true` if the item name refers to a defined item type.
  5316. * `get_definition()`: returns the item definition table.
  5317. * `get_tool_capabilities()`: returns the digging properties of the item,
  5318. or those of the hand if none are defined for this item type
  5319. * `add_wear(amount)`
  5320. * Increases wear by `amount` if the item is a tool, otherwise does nothing
  5321. * `amount`: number, integer
  5322. * `add_item(item)`: returns leftover `ItemStack`
  5323. * Put some item or stack onto this stack
  5324. * `item_fits(item)`: returns `true` if item or stack can be fully added to
  5325. this one.
  5326. * `take_item(n)`: returns taken `ItemStack`
  5327. * Take (and remove) up to `n` items from this stack
  5328. * `n`: number, default: `1`
  5329. * `peek_item(n)`: returns taken `ItemStack`
  5330. * Copy (don't remove) up to `n` items from this stack
  5331. * `n`: number, default: `1`
  5332. `ItemStackMetaRef`
  5333. ------------------
  5334. ItemStack metadata: reference extra data and functionality stored in a stack.
  5335. Can be obtained via `item:get_meta()`.
  5336. ### Methods
  5337. * All methods in MetaDataRef
  5338. * `set_tool_capabilities([tool_capabilities])`
  5339. * Overrides the item's tool capabilities
  5340. * A nil value will clear the override data and restore the original
  5341. behavior.
  5342. `MetaDataRef`
  5343. -------------
  5344. Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
  5345. and [`PlayerMetaRef`].
  5346. ### Methods
  5347. * `contains(key)`: Returns true if key present, otherwise false.
  5348. * Returns `nil` when the MetaData is inexistent.
  5349. * `get(key)`: Returns `nil` if key not present, else the stored string.
  5350. * `set_string(key, value)`: Value of `""` will delete the key.
  5351. * `get_string(key)`: Returns `""` if key not present.
  5352. * `set_int(key, value)`
  5353. * `get_int(key)`: Returns `0` if key not present.
  5354. * `set_float(key, value)`
  5355. * `get_float(key)`: Returns `0` if key not present.
  5356. * `to_table()`: returns `nil` or a table with keys:
  5357. * `fields`: key-value storage
  5358. * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
  5359. * `from_table(nil or {})`
  5360. * Any non-table value will clear the metadata
  5361. * See [Node Metadata] for an example
  5362. * returns `true` on success
  5363. * `equals(other)`
  5364. * returns `true` if this metadata has the same key-value pairs as `other`
  5365. `ModChannel`
  5366. ------------
  5367. An interface to use mod channels on client and server
  5368. ### Methods
  5369. * `leave()`: leave the mod channel.
  5370. * Server leaves channel `channel_name`.
  5371. * No more incoming or outgoing messages can be sent to this channel from
  5372. server mods.
  5373. * This invalidate all future object usage.
  5374. * Ensure you set mod_channel to nil after that to free Lua resources.
  5375. * `is_writeable()`: returns true if channel is writeable and mod can send over
  5376. it.
  5377. * `send_all(message)`: Send `message` though the mod channel.
  5378. * If mod channel is not writeable or invalid, message will be dropped.
  5379. * Message size is limited to 65535 characters by protocol.
  5380. `NodeMetaRef`
  5381. -------------
  5382. Node metadata: reference extra data and functionality stored in a node.
  5383. Can be obtained via `minetest.get_meta(pos)`.
  5384. ### Methods
  5385. * All methods in MetaDataRef
  5386. * `get_inventory()`: returns `InvRef`
  5387. * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
  5388. This will prevent them from being sent to the client. Note that the "private"
  5389. status will only be remembered if an associated key-value pair exists,
  5390. meaning it's best to call this when initializing all other meta (e.g.
  5391. `on_construct`).
  5392. `NodeTimerRef`
  5393. --------------
  5394. Node Timers: a high resolution persistent per-node timer.
  5395. Can be gotten via `minetest.get_node_timer(pos)`.
  5396. ### Methods
  5397. * `set(timeout,elapsed)`
  5398. * set a timer's state
  5399. * `timeout` is in seconds, and supports fractional values (0.1 etc)
  5400. * `elapsed` is in seconds, and supports fractional values (0.1 etc)
  5401. * will trigger the node's `on_timer` function after `(timeout - elapsed)`
  5402. seconds.
  5403. * `start(timeout)`
  5404. * start a timer
  5405. * equivalent to `set(timeout,0)`
  5406. * `stop()`
  5407. * stops the timer
  5408. * `get_timeout()`: returns current timeout in seconds
  5409. * if `timeout` equals `0`, timer is inactive
  5410. * `get_elapsed()`: returns current elapsed time in seconds
  5411. * the node's `on_timer` function will be called after `(timeout - elapsed)`
  5412. seconds.
  5413. * `is_started()`: returns boolean state of timer
  5414. * returns `true` if timer is started, otherwise `false`
  5415. `ObjectRef`
  5416. -----------
  5417. Moving things in the game are generally these.
  5418. This is basically a reference to a C++ `ServerActiveObject`.
  5419. ### Advice on handling `ObjectRefs`
  5420. When you receive an `ObjectRef` as a callback argument or from another API
  5421. function, it is possible to store the reference somewhere and keep it around.
  5422. It will keep functioning until the object is unloaded or removed.
  5423. However, doing this is **NOT** recommended as there is (intentionally) no method
  5424. to test if a previously acquired `ObjectRef` is still valid.
  5425. Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
  5426. Lua back to the engine.
  5427. Doing so is much less error-prone and you will never need to wonder if the
  5428. object you are working with still exists.
  5429. ### Methods
  5430. * `get_pos()`: returns `{x=num, y=num, z=num}`
  5431. * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
  5432. * `get_velocity()`: returns the velocity, a vector.
  5433. * `add_velocity(vel)`
  5434. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5435. * In comparison to using get_velocity, adding the velocity and then using
  5436. set_velocity, add_velocity is supposed to avoid synchronization problems.
  5437. Additionally, players also do not support set_velocity.
  5438. * If a player:
  5439. * Does not apply during free_move.
  5440. * Note that since the player speed is normalized at each move step,
  5441. increasing e.g. Y velocity beyond what would usually be achieved
  5442. (see: physics overrides) will cause existing X/Z velocity to be reduced.
  5443. * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
  5444. pressing the jump key (assuming default settings)
  5445. * `move_to(pos, continuous=false)`
  5446. * Does an interpolated move for Lua entities for visually smooth transitions.
  5447. * If `continuous` is true, the Lua entity will not be moved to the current
  5448. position before starting the interpolated move.
  5449. * For players this does the same as `set_pos`,`continuous` is ignored.
  5450. * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
  5451. * `puncher` = another `ObjectRef`,
  5452. * `time_from_last_punch` = time since last punch action of the puncher
  5453. * `direction`: can be `nil`
  5454. * `right_click(clicker)`; `clicker` is another `ObjectRef`
  5455. * `get_hp()`: returns number of health points
  5456. * `set_hp(hp, reason)`: set number of health points
  5457. * See reason in register_on_player_hpchange
  5458. * Is limited to the range of 0 ... 65535 (2^16 - 1)
  5459. * For players: HP are also limited by `hp_max` specified in the player's
  5460. object properties
  5461. * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
  5462. * `get_wield_list()`: returns the name of the inventory list the wielded item
  5463. is in.
  5464. * `get_wield_index()`: returns the index of the wielded item
  5465. * `get_wielded_item()`: returns an `ItemStack`
  5466. * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
  5467. successful.
  5468. * `set_armor_groups({group1=rating, group2=rating, ...})`
  5469. * `get_armor_groups()`: returns a table with the armor group ratings
  5470. * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
  5471. * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
  5472. * `frame_speed`: number, default: `15.0`
  5473. * `frame_blend`: number, default: `0.0`
  5474. * `frame_loop`: boolean, default: `true`
  5475. * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
  5476. `frame_loop`.
  5477. * `set_animation_frame_speed(frame_speed)`
  5478. * `frame_speed`: number, default: `15.0`
  5479. * `set_attach(parent[, bone, position, rotation, forced_visible])`
  5480. * `bone`: string. Default is `""`, the root bone
  5481. * `position`: `{x=num, y=num, z=num}`, relative, default `{x=0, y=0, z=0}`
  5482. * `rotation`: `{x=num, y=num, z=num}` = Rotation on each axis, in degrees.
  5483. Default `{x=0, y=0, z=0}`
  5484. * `forced_visible`: Boolean to control whether the attached entity
  5485. should appear in first person. Default `false`.
  5486. * This command may fail silently (do nothing) when it would result
  5487. in circular attachments.
  5488. * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
  5489. or nil if it isn't attached.
  5490. * `get_children()`: returns a list of ObjectRefs that are attached to the
  5491. object.
  5492. * `set_detach()`
  5493. * `set_bone_position([bone, position, rotation])`
  5494. * `bone`: string. Default is `""`, the root bone
  5495. * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
  5496. * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
  5497. * `get_bone_position(bone)`: returns position and rotation of the bone
  5498. * `set_properties(object property table)`
  5499. * `get_properties()`: returns object property table
  5500. * `is_player()`: returns true for players, false otherwise
  5501. * `get_nametag_attributes()`
  5502. * returns a table with the attributes of the nametag of an object
  5503. * {
  5504. text = "",
  5505. color = {a=0..255, r=0..255, g=0..255, b=0..255},
  5506. bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
  5507. }
  5508. * `set_nametag_attributes(attributes)`
  5509. * sets the attributes of the nametag of an object
  5510. * `attributes`:
  5511. {
  5512. text = "My Nametag",
  5513. color = ColorSpec,
  5514. -- ^ Text color
  5515. bgcolor = ColorSpec or false,
  5516. -- ^ Sets background color of nametag
  5517. -- `false` will cause the background to be set automatically based on user settings
  5518. -- Default: false
  5519. }
  5520. #### Lua entity only (no-op for other objects)
  5521. * `remove()`: remove object
  5522. * The object is removed after returning from Lua. However the `ObjectRef`
  5523. itself instantly becomes unusable with all further method calls having
  5524. no effect and returning `nil`.
  5525. * `set_velocity(vel)`
  5526. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5527. * `set_acceleration(acc)`
  5528. * `acc` is a vector
  5529. * `get_acceleration()`: returns the acceleration, a vector
  5530. * `set_rotation(rot)`
  5531. * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
  5532. and Z is roll (bank).
  5533. * `get_rotation()`: returns the rotation, a vector (radians)
  5534. * `set_yaw(yaw)`: sets the yaw in radians (heading).
  5535. * `get_yaw()`: returns number in radians
  5536. * `set_texture_mod(mod)`
  5537. * Set a texture modifier to the base texture, for sprites and meshes.
  5538. * When calling `set_texture_mod` again, the previous one is discarded.
  5539. * `mod` the texture modifier. See [Texture modifiers].
  5540. * `get_texture_mod()` returns current texture modifier
  5541. * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
  5542. * Specifies and starts a sprite animation
  5543. * Animations iterate along the frame `y` position.
  5544. * `start_frame`: {x=column number, y=row number}, the coordinate of the
  5545. first frame, default: `{x=0, y=0}`
  5546. * `num_frames`: Total frames in the texture, default: `1`
  5547. * `framelength`: Time per animated frame in seconds, default: `0.2`
  5548. * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
  5549. position according to the view direction. default: `false`.
  5550. * First column: subject facing the camera
  5551. * Second column: subject looking to the left
  5552. * Third column: subject backing the camera
  5553. * Fourth column: subject looking to the right
  5554. * Fifth column: subject viewed from above
  5555. * Sixth column: subject viewed from below
  5556. * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
  5557. * `get_luaentity()`
  5558. #### Player only (no-op for other objects)
  5559. * `get_player_name()`: returns `""` if is not a player
  5560. * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
  5561. table {x, y, z} representing the player's instantaneous velocity in nodes/s
  5562. * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
  5563. * `get_look_dir()`: get camera direction as a unit vector
  5564. * `get_look_vertical()`: pitch in radians
  5565. * Angle ranges between -pi/2 and pi/2, which are straight up and down
  5566. respectively.
  5567. * `get_look_horizontal()`: yaw in radians
  5568. * Angle is counter-clockwise from the +z direction.
  5569. * `set_look_vertical(radians)`: sets look pitch
  5570. * radians: Angle from looking forward, where positive is downwards.
  5571. * `set_look_horizontal(radians)`: sets look yaw
  5572. * radians: Angle from the +z direction, where positive is counter-clockwise.
  5573. * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
  5574. `get_look_vertical`.
  5575. * Angle ranges between -pi/2 and pi/2, which are straight down and up
  5576. respectively.
  5577. * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
  5578. `get_look_horizontal`.
  5579. * Angle is counter-clockwise from the +x direction.
  5580. * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
  5581. `set_look_vertical`.
  5582. * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
  5583. `set_look_horizontal`.
  5584. * `get_breath()`: returns player's breath
  5585. * `set_breath(value)`: sets player's breath
  5586. * values:
  5587. * `0`: player is drowning
  5588. * max: bubbles bar is not shown
  5589. * See [Object properties] for more information
  5590. * Is limited to range 0 ... 65535 (2^16 - 1)
  5591. * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
  5592. * `fov`: FOV value.
  5593. * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
  5594. Defaults to `false`.
  5595. * `transition_time`: If defined, enables smooth FOV transition.
  5596. Interpreted as the time (in seconds) to reach target FOV.
  5597. If set to 0, FOV change is instantaneous. Defaults to 0.
  5598. * Set `fov` to 0 to clear FOV override.
  5599. * `get_fov()`: Returns the following:
  5600. * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
  5601. * Boolean indicating whether the FOV value is a multiplier.
  5602. * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
  5603. * `set_attribute(attribute, value)`: DEPRECATED, use get_meta() instead
  5604. * Sets an extra attribute with value on player.
  5605. * `value` must be a string, or a number which will be converted to a
  5606. string.
  5607. * If `value` is `nil`, remove attribute from player.
  5608. * `get_attribute(attribute)`: DEPRECATED, use get_meta() instead
  5609. * Returns value (a string) for extra attribute.
  5610. * Returns `nil` if no attribute found.
  5611. * `get_meta()`: Returns a PlayerMetaRef.
  5612. * `set_inventory_formspec(formspec)`
  5613. * Redefine player's inventory form
  5614. * Should usually be called in `on_joinplayer`
  5615. * If `formspec` is `""`, the player's inventory is disabled.
  5616. * `get_inventory_formspec()`: returns a formspec string
  5617. * `set_formspec_prepend(formspec)`:
  5618. * the formspec string will be added to every formspec shown to the user,
  5619. except for those with a no_prepend[] tag.
  5620. * This should be used to set style elements such as background[] and
  5621. bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
  5622. * Only affects formspecs shown after this is called.
  5623. * `get_formspec_prepend(formspec)`: returns a formspec string.
  5624. * `get_player_control()`: returns table with player pressed keys
  5625. * The table consists of fields with the following boolean values
  5626. representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
  5627. `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
  5628. * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
  5629. and exist only to preserve backwards compatibility.
  5630. * Returns an empty table `{}` if the object is not a player.
  5631. * `get_player_control_bits()`: returns integer with bit packed player pressed
  5632. keys.
  5633. * Bits:
  5634. * 0 - up
  5635. * 1 - down
  5636. * 2 - left
  5637. * 3 - right
  5638. * 4 - jump
  5639. * 5 - aux1
  5640. * 6 - sneak
  5641. * 7 - dig
  5642. * 8 - place
  5643. * 9 - zoom
  5644. * Returns `0` (no bits set) if the object is not a player.
  5645. * `set_physics_override(override_table)`
  5646. * `override_table` is a table with the following fields:
  5647. * `speed`: multiplier to default walking speed value (default: `1`)
  5648. * `jump`: multiplier to default jump value (default: `1`)
  5649. * `gravity`: multiplier to default gravity value (default: `1`)
  5650. * `sneak`: whether player can sneak (default: `true`)
  5651. * `sneak_glitch`: whether player can use the new move code replications
  5652. of the old sneak side-effects: sneak ladders and 2 node sneak jump
  5653. (default: `false`)
  5654. * `new_move`: use new move/sneak code. When `false` the exact old code
  5655. is used for the specific old sneak behaviour (default: `true`)
  5656. * `get_physics_override()`: returns the table given to `set_physics_override`
  5657. * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
  5658. number on success
  5659. * `hud_remove(id)`: remove the HUD element of the specified id
  5660. * `hud_change(id, stat, value)`: change a value of a previously added HUD
  5661. element.
  5662. * element `stat` values:
  5663. `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
  5664. * `hud_get(id)`: gets the HUD element definition structure of the specified ID
  5665. * `hud_set_flags(flags)`: sets specified HUD flags of player.
  5666. * `flags`: A table with the following fields set to boolean values
  5667. * `hotbar`
  5668. * `healthbar`
  5669. * `crosshair`
  5670. * `wielditem`
  5671. * `breathbar`
  5672. * `minimap`: Modifies the client's permission to view the minimap.
  5673. The client may locally elect to not view the minimap.
  5674. * `minimap_radar`: is only usable when `minimap` is true
  5675. * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
  5676. This includes map seed, player position, look direction, the pointed node and block bounds.
  5677. Does not affect players with the `debug` privilege.
  5678. * If a flag equals `nil`, the flag is not modified
  5679. * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
  5680. * See `hud_set_flags` for a list of flags that can be toggled.
  5681. * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
  5682. * `count`: number of items, must be between `1` and `32`
  5683. * `hud_get_hotbar_itemcount`: returns number of visible items
  5684. * `hud_set_hotbar_image(texturename)`
  5685. * sets background image for hotbar
  5686. * `hud_get_hotbar_image`: returns texturename
  5687. * `hud_set_hotbar_selected_image(texturename)`
  5688. * sets image for selected item of hotbar
  5689. * `hud_get_hotbar_selected_image`: returns texturename
  5690. * `set_minimap_modes({mode, mode, ...}, selected_mode)`
  5691. * Overrides the available minimap modes (and toggle order), and changes the
  5692. selected mode.
  5693. * `mode` is a table consisting of up to four fields:
  5694. * `type`: Available type:
  5695. * `off`: Minimap off
  5696. * `surface`: Minimap in surface mode
  5697. * `radar`: Minimap in radar mode
  5698. * `texture`: Texture to be displayed instead of terrain map
  5699. (texture is centered around 0,0 and can be scaled).
  5700. Texture size is limited to 512 x 512 pixel.
  5701. * `label`: Optional label to display on minimap mode toggle
  5702. The translation must be handled within the mod.
  5703. * `size`: Sidelength or diameter, in number of nodes, of the terrain
  5704. displayed in minimap
  5705. * `texture`: Only for texture type, name of the texture to display
  5706. * `scale`: Only for texture type, scale of the texture map in nodes per
  5707. pixel (for example a `scale` of 2 means each pixel represents a 2x2
  5708. nodes square)
  5709. * `selected_mode` is the mode index to be selected after modes have been changed
  5710. (0 is the first mode).
  5711. * `set_sky(sky_parameters)`
  5712. * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
  5713. whether `set_sky` accepts this format. Check the legacy format otherwise.
  5714. * Passing no arguments resets the sky to its default values.
  5715. * `sky_parameters` is a table with the following optional fields:
  5716. * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
  5717. (default: `#ffffff`)
  5718. * `type`: Available types:
  5719. * `"regular"`: Uses 0 textures, `base_color` ignored
  5720. * `"skybox"`: Uses 6 textures, `base_color` used as fog.
  5721. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
  5722. (default: `"regular"`)
  5723. * `textures`: A table containing up to six textures in the following
  5724. order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
  5725. * `clouds`: Boolean for whether clouds appear. (default: `true`)
  5726. * `sky_color`: A table used in `"regular"` type only, containing the
  5727. following values (alpha is ignored):
  5728. * `day_sky`: ColorSpec, for the top half of the sky during the day.
  5729. (default: `#61b5f5`)
  5730. * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
  5731. (default: `#90d3f6`)
  5732. * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
  5733. (default: `#b4bafa`)
  5734. The resulting sky color will be a darkened version of the ColorSpec.
  5735. Warning: The darkening of the ColorSpec is subject to change.
  5736. * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
  5737. (default: `#bac1f0`)
  5738. The resulting sky color will be a darkened version of the ColorSpec.
  5739. Warning: The darkening of the ColorSpec is subject to change.
  5740. * `night_sky`: ColorSpec, for the top half of the sky during the night.
  5741. (default: `#006bff`)
  5742. The resulting sky color will be a dark version of the ColorSpec.
  5743. Warning: The darkening of the ColorSpec is subject to change.
  5744. * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
  5745. (default: `#4090ff`)
  5746. The resulting sky color will be a dark version of the ColorSpec.
  5747. Warning: The darkening of the ColorSpec is subject to change.
  5748. * `indoors`: ColorSpec, for when you're either indoors or underground.
  5749. (default: `#646464`)
  5750. * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
  5751. at sunrise and sunset. (default: `#f47d1d`)
  5752. * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
  5753. at sunrise and sunset. (default: `#7f99cc`)
  5754. * `fog_tint_type`: string, changes which mode the directional fog
  5755. abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
  5756. `"default"` uses the classic Minetest sun and moon tinting.
  5757. Will use tonemaps, if set to `"default"`. (default: `"default"`)
  5758. * `set_sky(base_color, type, {texture names}, clouds)`
  5759. * Deprecated. Use `set_sky(sky_parameters)`
  5760. * `base_color`: ColorSpec, defaults to white
  5761. * `type`: Available types:
  5762. * `"regular"`: Uses 0 textures, `bgcolor` ignored
  5763. * `"skybox"`: Uses 6 textures, `bgcolor` used
  5764. * `"plain"`: Uses 0 textures, `bgcolor` used
  5765. * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
  5766. `"plain"` custom skyboxes (default: `true`)
  5767. * `get_sky(as_table)`:
  5768. * `as_table`: boolean that determines whether the deprecated version of this
  5769. function is being used.
  5770. * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
  5771. * Deprecated: `false` or `nil` returns base_color, type, table of textures,
  5772. clouds.
  5773. * `get_sky_color()`:
  5774. * Deprecated: Use `get_sky(as_table)` instead.
  5775. * returns a table with the `sky_color` parameters as in `set_sky`.
  5776. * `set_sun(sun_parameters)`:
  5777. * Passing no arguments resets the sun to its default values.
  5778. * `sun_parameters` is a table with the following optional fields:
  5779. * `visible`: Boolean for whether the sun is visible.
  5780. (default: `true`)
  5781. * `texture`: A regular texture for the sun. Setting to `""`
  5782. will re-enable the mesh sun. (default: "sun.png", if it exists)
  5783. * `tonemap`: A 512x1 texture containing the tonemap for the sun
  5784. (default: `"sun_tonemap.png"`)
  5785. * `sunrise`: A regular texture for the sunrise texture.
  5786. (default: `"sunrisebg.png"`)
  5787. * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
  5788. (default: `true`)
  5789. * `scale`: Float controlling the overall size of the sun. (default: `1`)
  5790. * `get_sun()`: returns a table with the current sun parameters as in
  5791. `set_sun`.
  5792. * `set_moon(moon_parameters)`:
  5793. * Passing no arguments resets the moon to its default values.
  5794. * `moon_parameters` is a table with the following optional fields:
  5795. * `visible`: Boolean for whether the moon is visible.
  5796. (default: `true`)
  5797. * `texture`: A regular texture for the moon. Setting to `""`
  5798. will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
  5799. Note: Relative to the sun, the moon texture is rotated by 180°.
  5800. You can use the `^[transformR180` texture modifier to achieve the same orientation.
  5801. * `tonemap`: A 512x1 texture containing the tonemap for the moon
  5802. (default: `"moon_tonemap.png"`)
  5803. * `scale`: Float controlling the overall size of the moon (default: `1`)
  5804. * `get_moon()`: returns a table with the current moon parameters as in
  5805. `set_moon`.
  5806. * `set_stars(star_parameters)`:
  5807. * Passing no arguments resets stars to their default values.
  5808. * `star_parameters` is a table with the following optional fields:
  5809. * `visible`: Boolean for whether the stars are visible.
  5810. (default: `true`)
  5811. * `count`: Integer number to set the number of stars in
  5812. the skybox. Only applies to `"skybox"` and `"regular"` sky types.
  5813. (default: `1000`)
  5814. * `star_color`: ColorSpec, sets the colors of the stars,
  5815. alpha channel is used to set overall star brightness.
  5816. (default: `#ebebff69`)
  5817. * `scale`: Float controlling the overall size of the stars (default: `1`)
  5818. * `get_stars()`: returns a table with the current stars parameters as in
  5819. `set_stars`.
  5820. * `set_clouds(cloud_parameters)`: set cloud parameters
  5821. * Passing no arguments resets clouds to their default values.
  5822. * `cloud_parameters` is a table with the following optional fields:
  5823. * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
  5824. * `color`: basic cloud color with alpha channel, ColorSpec
  5825. (default `#fff0f0e5`).
  5826. * `ambient`: cloud color lower bound, use for a "glow at night" effect.
  5827. ColorSpec (alpha ignored, default `#000000`)
  5828. * `height`: cloud height, i.e. y of cloud base (default per conf,
  5829. usually `120`)
  5830. * `thickness`: cloud thickness in nodes (default `16`)
  5831. * `speed`: 2D cloud speed + direction in nodes per second
  5832. (default `{x=0, z=-2}`).
  5833. * `get_clouds()`: returns a table with the current cloud parameters as in
  5834. `set_clouds`.
  5835. * `override_day_night_ratio(ratio or nil)`
  5836. * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
  5837. amount.
  5838. * `nil`: Disables override, defaulting to sunlight based on day-night cycle
  5839. * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
  5840. * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
  5841. set animation for player model in third person view.
  5842. * Every animation equals to a `{x=starting frame, y=ending frame}` table.
  5843. * `frame_speed` sets the animations frame speed. Default is 30.
  5844. * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
  5845. `frame_speed`.
  5846. * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
  5847. camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
  5848. * in first person view
  5849. * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
  5850. * `get_eye_offset()`: returns first and third person offsets.
  5851. * `send_mapblock(blockpos)`:
  5852. * Sends a server-side loaded mapblock to the player.
  5853. * Returns `false` if failed.
  5854. * Resource intensive - use sparsely
  5855. * To get blockpos, integer divide pos by 16
  5856. * `set_lighting(light_definition)`: sets lighting for the player
  5857. * `light_definition` is a table with the following optional fields:
  5858. * `shadows` is a table that controls ambient shadows
  5859. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
  5860. * `get_lighting()`: returns the current state of lighting for the player.
  5861. * Result is a table with the same fields as `light_definition` in `set_lighting`.
  5862. `PcgRandom`
  5863. -----------
  5864. A 32-bit pseudorandom number generator.
  5865. Uses PCG32, an algorithm of the permuted congruential generator family,
  5866. offering very strong randomness.
  5867. It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
  5868. ### Methods
  5869. * `next()`: return next integer random number [`-2147483648`...`2147483647`]
  5870. * `next(min, max)`: return next integer random number [`min`...`max`]
  5871. * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
  5872. random number [`min`...`max`].
  5873. * This is only a rough approximation of a normal distribution with:
  5874. * `mean = (max - min) / 2`, and
  5875. * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
  5876. * Increasing `num_trials` improves accuracy of the approximation
  5877. `PerlinNoise`
  5878. -------------
  5879. A perlin noise generator.
  5880. It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
  5881. For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
  5882. plus the world seed, to create world-specific noise.
  5883. `PerlinNoise(noiseparams)`
  5884. `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
  5885. `minetest.get_perlin(noiseparams)`
  5886. `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
  5887. ### Methods
  5888. * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
  5889. * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
  5890. `PerlinNoiseMap`
  5891. ----------------
  5892. A fast, bulk perlin noise generator.
  5893. It can be created via `PerlinNoiseMap(noiseparams, size)` or
  5894. `minetest.get_perlin_map(noiseparams, size)`.
  5895. For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
  5896. plus the world seed, to create world-specific noise.
  5897. Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
  5898. for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
  5899. `nil` is returned).
  5900. For each of the functions with an optional `buffer` parameter: If `buffer` is
  5901. not nil, this table will be used to store the result instead of creating a new
  5902. table.
  5903. ### Methods
  5904. * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
  5905. with values starting at `pos={x=,y=}`
  5906. * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
  5907. 3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
  5908. * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
  5909. array of 2D noise with values starting at `pos={x=,y=}`
  5910. * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
  5911. * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
  5912. is stored internally.
  5913. * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
  5914. is stored internally.
  5915. * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
  5916. returns a slice of the most recently computed noise results. The result slice
  5917. begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
  5918. E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
  5919. offset y = 20:
  5920. `noisevals = noise:get_map_slice({y=20}, {y=2})`
  5921. It is important to note that `slice_offset` offset coordinates begin at 1,
  5922. and are relative to the starting position of the most recently calculated
  5923. noise.
  5924. To grab a single vertical column of noise starting at map coordinates
  5925. x = 1023, y=1000, z = 1000:
  5926. `noise:calc_3d_map({x=1000, y=1000, z=1000})`
  5927. `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
  5928. `PlayerMetaRef`
  5929. ---------------
  5930. Player metadata.
  5931. Uses the same method of storage as the deprecated player attribute API, so
  5932. data there will also be in player meta.
  5933. Can be obtained using `player:get_meta()`.
  5934. ### Methods
  5935. * All methods in MetaDataRef
  5936. `PseudoRandom`
  5937. --------------
  5938. A 16-bit pseudorandom number generator.
  5939. Uses a well-known LCG algorithm introduced by K&R.
  5940. It can be created via `PseudoRandom(seed)`.
  5941. ### Methods
  5942. * `next()`: return next integer random number [`0`...`32767`]
  5943. * `next(min, max)`: return next integer random number [`min`...`max`]
  5944. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
  5945. due to the simple implementation making bad distribution otherwise.
  5946. `Raycast`
  5947. ---------
  5948. A raycast on the map. It works with selection boxes.
  5949. Can be used as an iterator in a for loop as:
  5950. local ray = Raycast(...)
  5951. for pointed_thing in ray do
  5952. ...
  5953. end
  5954. The map is loaded as the ray advances. If the map is modified after the
  5955. `Raycast` is created, the changes may or may not have an effect on the object.
  5956. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  5957. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  5958. * `pos1`: start of the ray
  5959. * `pos2`: end of the ray
  5960. * `objects`: if false, only nodes will be returned. Default is true.
  5961. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  5962. returned. Default is false.
  5963. ### Methods
  5964. * `next()`: returns a `pointed_thing` with exact pointing location
  5965. * Returns the next thing pointed by the ray or nil.
  5966. `SecureRandom`
  5967. --------------
  5968. Interface for the operating system's crypto-secure PRNG.
  5969. It can be created via `SecureRandom()`. The constructor returns nil if a
  5970. secure random device cannot be found on the system.
  5971. ### Methods
  5972. * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
  5973. random bytes, as a string.
  5974. `Settings`
  5975. ----------
  5976. An interface to read config files in the format of `minetest.conf`.
  5977. It can be created via `Settings(filename)`.
  5978. ### Methods
  5979. * `get(key)`: returns a value
  5980. * `get_bool(key, [default])`: returns a boolean
  5981. * `default` is the value returned if `key` is not found.
  5982. * Returns `nil` if `key` is not found and `default` not specified.
  5983. * `get_np_group(key)`: returns a NoiseParams table
  5984. * `get_flags(key)`:
  5985. * Returns `{flag = true/false, ...}` according to the set flags.
  5986. * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
  5987. flags like `mgv5_spflags`.
  5988. * `set(key, value)`
  5989. * Setting names can't contain whitespace or any of `="{}#`.
  5990. * Setting values can't contain the sequence `\n"""`.
  5991. * Setting names starting with "secure." can't be set on the main settings
  5992. object (`minetest.settings`).
  5993. * `set_bool(key, value)`
  5994. * See documentation for set() above.
  5995. * `set_np_group(key, value)`
  5996. * `value` is a NoiseParams table.
  5997. * Also, see documentation for set() above.
  5998. * `remove(key)`: returns a boolean (`true` for success)
  5999. * `get_names()`: returns `{key1,...}`
  6000. * `write()`: returns a boolean (`true` for success)
  6001. * Writes changes to file.
  6002. * `to_table()`: returns `{[key1]=value1,...}`
  6003. ### Format
  6004. The settings have the format `key = value`. Example:
  6005. foo = example text
  6006. bar = """
  6007. Multiline
  6008. value
  6009. """
  6010. `StorageRef`
  6011. ------------
  6012. Mod metadata: per mod metadata, saved automatically.
  6013. Can be obtained via `minetest.get_mod_storage()` during load time.
  6014. WARNING: This storage backend is incaptable to save raw binary data due
  6015. to restrictions of JSON.
  6016. ### Methods
  6017. * All methods in MetaDataRef
  6018. Definition tables
  6019. =================
  6020. Object properties
  6021. -----------------
  6022. Used by `ObjectRef` methods. Part of an Entity definition.
  6023. These properties are not persistent, but are applied automatically to the
  6024. corresponding Lua entity using the given registration fields.
  6025. Player properties need to be saved manually.
  6026. {
  6027. hp_max = 1,
  6028. -- For players only. Defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
  6029. breath_max = 0,
  6030. -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
  6031. zoom_fov = 0.0,
  6032. -- For players only. Zoom FOV in degrees.
  6033. -- Note that zoom loads and/or generates world beyond the server's
  6034. -- maximum send and generate distances, so acts like a telescope.
  6035. -- Smaller zoom_fov values increase the distance loaded/generated.
  6036. -- Defaults to 15 in creative mode, 0 in survival mode.
  6037. -- zoom_fov = 0 disables zooming for the player.
  6038. eye_height = 1.625,
  6039. -- For players only. Camera height above feet position in nodes.
  6040. -- Defaults to 1.625.
  6041. physical = true,
  6042. -- Collide with `walkable` nodes.
  6043. collide_with_objects = true,
  6044. -- Collide with other objects if physical = true
  6045. collisionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5}, -- Default
  6046. selectionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
  6047. -- Selection box uses collision box dimensions when not set.
  6048. -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
  6049. -- object position.
  6050. pointable = true,
  6051. -- Overrides selection box when false
  6052. visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
  6053. -- "cube" is a node-sized cube.
  6054. -- "sprite" is a flat texture always facing the player.
  6055. -- "upright_sprite" is a vertical flat texture.
  6056. -- "mesh" uses the defined mesh model.
  6057. -- "wielditem" is used for dropped items.
  6058. -- (see builtin/game/item_entity.lua).
  6059. -- For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
  6060. -- If the item has a 'wield_image' the object will be an extrusion of
  6061. -- that, otherwise:
  6062. -- If 'itemname' is a cubic node or nodebox the object will appear
  6063. -- identical to 'itemname'.
  6064. -- If 'itemname' is a plantlike node the object will be an extrusion
  6065. -- of its texture.
  6066. -- Otherwise for non-node items, the object will be an extrusion of
  6067. -- 'inventory_image'.
  6068. -- If 'itemname' contains a ColorString or palette index (e.g. from
  6069. -- `minetest.itemstring_with_palette()`), the entity will inherit the color.
  6070. -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
  6071. visual_size = {x = 1, y = 1, z = 1},
  6072. -- Multipliers for the visual size. If `z` is not specified, `x` will be used
  6073. -- to scale the entity along both horizontal axes.
  6074. mesh = "model.obj",
  6075. -- File name of mesh when using "mesh" visual
  6076. textures = {},
  6077. -- Number of required textures depends on visual.
  6078. -- "cube" uses 6 textures just like a node, but all 6 must be defined.
  6079. -- "sprite" uses 1 texture.
  6080. -- "upright_sprite" uses 2 textures: {front, back}.
  6081. -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
  6082. -- "mesh" requires one texture for each mesh buffer/material (in order)
  6083. colors = {},
  6084. -- Number of required colors depends on visual
  6085. use_texture_alpha = false,
  6086. -- Use texture's alpha channel.
  6087. -- Excludes "upright_sprite" and "wielditem".
  6088. -- Note: currently causes visual issues when viewed through other
  6089. -- semi-transparent materials such as water.
  6090. spritediv = {x = 1, y = 1},
  6091. -- Used with spritesheet textures for animation and/or frame selection
  6092. -- according to position relative to player.
  6093. -- Defines the number of columns and rows in the spritesheet:
  6094. -- {columns, rows}.
  6095. initial_sprite_basepos = {x = 0, y = 0},
  6096. -- Used with spritesheet textures.
  6097. -- Defines the {column, row} position of the initially used frame in the
  6098. -- spritesheet.
  6099. is_visible = true,
  6100. -- If false, object is invisible and can't be pointed.
  6101. makes_footstep_sound = false,
  6102. -- If true, is able to make footstep sounds of nodes
  6103. -- (see node sound definition for details).
  6104. automatic_rotate = 0,
  6105. -- Set constant rotation in radians per second, positive or negative.
  6106. -- Object rotates along the local Y-axis, and works with set_rotation.
  6107. -- Set to 0 to disable constant rotation.
  6108. stepheight = 0,
  6109. -- If positive number, object will climb upwards when it moves
  6110. -- horizontally against a `walkable` node, if the height difference
  6111. -- is within `stepheight`.
  6112. automatic_face_movement_dir = 0.0,
  6113. -- Automatically set yaw to movement direction, offset in degrees.
  6114. -- 'false' to disable.
  6115. automatic_face_movement_max_rotation_per_sec = -1,
  6116. -- Limit automatic rotation to this value in degrees per second.
  6117. -- No limit if value <= 0.
  6118. backface_culling = true,
  6119. -- Set to false to disable backface_culling for model
  6120. glow = 0,
  6121. -- Add this much extra lighting when calculating texture color.
  6122. -- Value < 0 disables light's effect on texture color.
  6123. -- For faking self-lighting, UI style entities, or programmatic coloring
  6124. -- in mods.
  6125. nametag = "",
  6126. -- The name to display on the head of the object. By default empty.
  6127. -- If the object is a player, a nil or empty nametag is replaced by the player's name.
  6128. -- For all other objects, a nil or empty string removes the nametag.
  6129. -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
  6130. nametag_color = <ColorSpec>,
  6131. -- Sets text color of nametag
  6132. nametag_bgcolor = <ColorSpec>,
  6133. -- Sets background color of nametag
  6134. -- `false` will cause the background to be set automatically based on user settings.
  6135. -- Default: false
  6136. infotext = "",
  6137. -- Same as infotext for nodes. Empty by default
  6138. static_save = true,
  6139. -- If false, never save this object statically. It will simply be
  6140. -- deleted when the block gets unloaded.
  6141. -- The get_staticdata() callback is never called then.
  6142. -- Defaults to 'true'.
  6143. damage_texture_modifier = "^[brighten",
  6144. -- Texture modifier to be applied for a short duration when object is hit
  6145. shaded = true,
  6146. -- Setting this to 'false' disables diffuse lighting of entity
  6147. show_on_minimap = false,
  6148. -- Defaults to true for players, false for other entities.
  6149. -- If set to true the entity will show as a marker on the minimap.
  6150. }
  6151. Entity definition
  6152. -----------------
  6153. Used by `minetest.register_entity`.
  6154. {
  6155. initial_properties = {
  6156. visual = "mesh",
  6157. mesh = "boats_boat.obj",
  6158. ...,
  6159. },
  6160. -- A table of object properties, see the `Object properties` section.
  6161. -- Object properties being read directly from the entity definition
  6162. -- table is deprecated. Define object properties in this
  6163. -- `initial_properties` table instead.
  6164. on_activate = function(self, staticdata, dtime_s),
  6165. on_step = function(self, dtime, moveresult),
  6166. -- Called every server step
  6167. -- dtime: Elapsed time
  6168. -- moveresult: Table with collision info (only available if physical=true)
  6169. on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir),
  6170. on_rightclick = function(self, clicker),
  6171. get_staticdata = function(self),
  6172. -- Called sometimes; the string returned is passed to on_activate when
  6173. -- the entity is re-activated from static state
  6174. _custom_field = whatever,
  6175. -- You can define arbitrary member variables here (see Item definition
  6176. -- for more info) by using a '_' prefix
  6177. }
  6178. Collision info passed to `on_step` (`moveresult` argument):
  6179. {
  6180. touching_ground = boolean,
  6181. collides = boolean,
  6182. standing_on_object = boolean,
  6183. collisions = {
  6184. {
  6185. type = string, -- "node" or "object",
  6186. axis = string, -- "x", "y" or "z"
  6187. node_pos = vector, -- if type is "node"
  6188. object = ObjectRef, -- if type is "object"
  6189. old_velocity = vector,
  6190. new_velocity = vector,
  6191. },
  6192. ...
  6193. }
  6194. -- `collisions` does not contain data of unloaded mapblock collisions
  6195. -- or when the velocity changes are negligibly small
  6196. }
  6197. ABM (ActiveBlockModifier) definition
  6198. ------------------------------------
  6199. Used by `minetest.register_abm`.
  6200. {
  6201. label = "Lava cooling",
  6202. -- Descriptive label for profiling purposes (optional).
  6203. -- Definitions with identical labels will be listed as one.
  6204. nodenames = {"default:lava_source"},
  6205. -- Apply `action` function to these nodes.
  6206. -- `group:groupname` can also be used here.
  6207. neighbors = {"default:water_source", "default:water_flowing"},
  6208. -- Only apply `action` to nodes that have one of, or any
  6209. -- combination of, these neighbors.
  6210. -- If left out or empty, any neighbor will do.
  6211. -- `group:groupname` can also be used here.
  6212. interval = 1.0,
  6213. -- Operation interval in seconds
  6214. chance = 1,
  6215. -- Chance of triggering `action` per-node per-interval is 1.0 / this
  6216. -- value
  6217. min_y = -32768,
  6218. max_y = 32767,
  6219. -- min and max height levels where ABM will be processed
  6220. -- can be used to reduce CPU usage
  6221. catch_up = true,
  6222. -- If true, catch-up behaviour is enabled: The `chance` value is
  6223. -- temporarily reduced when returning to an area to simulate time lost
  6224. -- by the area being unattended. Note that the `chance` value can often
  6225. -- be reduced to 1.
  6226. action = function(pos, node, active_object_count, active_object_count_wider),
  6227. -- Function triggered for each qualifying node.
  6228. -- `active_object_count` is number of active objects in the node's
  6229. -- mapblock.
  6230. -- `active_object_count_wider` is number of active objects in the node's
  6231. -- mapblock plus all 26 neighboring mapblocks. If any neighboring
  6232. -- mapblocks are unloaded an estmate is calculated for them based on
  6233. -- loaded mapblocks.
  6234. }
  6235. LBM (LoadingBlockModifier) definition
  6236. -------------------------------------
  6237. Used by `minetest.register_lbm`.
  6238. A loading block modifier (LBM) is used to define a function that is called for
  6239. specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
  6240. gets loaded.
  6241. {
  6242. label = "Upgrade legacy doors",
  6243. -- Descriptive label for profiling purposes (optional).
  6244. -- Definitions with identical labels will be listed as one.
  6245. name = "modname:replace_legacy_door",
  6246. nodenames = {"default:lava_source"},
  6247. -- List of node names to trigger the LBM on.
  6248. -- Also non-registered nodes will work.
  6249. -- Groups (as of group:groupname) will work as well.
  6250. run_at_every_load = false,
  6251. -- Whether to run the LBM's action every time a block gets loaded,
  6252. -- and not only the first time the block gets loaded after the LBM
  6253. -- was introduced.
  6254. action = function(pos, node),
  6255. }
  6256. Tile definition
  6257. ---------------
  6258. * `"image.png"`
  6259. * `{name="image.png", animation={Tile Animation definition}}`
  6260. * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
  6261. * backface culling enabled by default for most nodes
  6262. * align style determines whether the texture will be rotated with the node
  6263. or kept aligned with its surroundings. "user" means that client
  6264. setting will be used, similar to `glasslike_framed_optional`.
  6265. Note: supported by solid nodes and nodeboxes only.
  6266. * scale is used to make texture span several (exactly `scale`) nodes,
  6267. instead of just one, in each direction. Works for world-aligned
  6268. textures only.
  6269. Note that as the effect is applied on per-mapblock basis, `16` should
  6270. be equally divisible by `scale` or you may get wrong results.
  6271. * `{name="image.png", color=ColorSpec}`
  6272. * the texture's color will be multiplied with this color.
  6273. * the tile's color overrides the owning node's color in all cases.
  6274. * deprecated, yet still supported field names:
  6275. * `image` (name)
  6276. Tile animation definition
  6277. -------------------------
  6278. {
  6279. type = "vertical_frames",
  6280. aspect_w = 16,
  6281. -- Width of a frame in pixels
  6282. aspect_h = 16,
  6283. -- Height of a frame in pixels
  6284. length = 3.0,
  6285. -- Full loop length
  6286. }
  6287. {
  6288. type = "sheet_2d",
  6289. frames_w = 5,
  6290. -- Width in number of frames
  6291. frames_h = 3,
  6292. -- Height in number of frames
  6293. frame_length = 0.5,
  6294. -- Length of a single frame
  6295. }
  6296. Item definition
  6297. ---------------
  6298. Used by `minetest.register_node`, `minetest.register_craftitem`, and
  6299. `minetest.register_tool`.
  6300. {
  6301. description = "Steel Axe",
  6302. -- Can contain new lines. "\n" has to be used as new line character.
  6303. -- See also: `get_description` in [`ItemStack`]
  6304. short_description = "Steel Axe",
  6305. -- Must not contain new lines.
  6306. -- Defaults to nil.
  6307. -- Use an [`ItemStack`] to get the short description, eg:
  6308. -- ItemStack(itemname):get_short_description()
  6309. groups = {},
  6310. -- key = name, value = rating; rating = 1..3.
  6311. -- If rating not applicable, use 1.
  6312. -- e.g. {wool = 1, fluffy = 3}
  6313. -- {soil = 2, outerspace = 1, crumbly = 1}
  6314. -- {bendy = 2, snappy = 1},
  6315. -- {hard = 1, metal = 1, spikes = 1}
  6316. inventory_image = "default_tool_steelaxe.png",
  6317. inventory_overlay = "overlay.png",
  6318. -- An overlay which does not get colorized
  6319. wield_image = "",
  6320. wield_overlay = "",
  6321. palette = "",
  6322. -- An image file containing the palette of a node.
  6323. -- You can set the currently used color as the "palette_index" field of
  6324. -- the item stack metadata.
  6325. -- The palette is always stretched to fit indices between 0 and 255, to
  6326. -- ensure compatibility with "colorfacedir" and "colorwallmounted" nodes.
  6327. color = "0xFFFFFFFF",
  6328. -- The color of the item. The palette overrides this.
  6329. wield_scale = {x = 1, y = 1, z = 1},
  6330. -- The default value of 99 may be configured by
  6331. -- users using the setting "default_stack_max"
  6332. stack_max = 99,
  6333. range = 4.0,
  6334. liquids_pointable = false,
  6335. -- If true, item points to all liquid nodes (`liquidtype ~= "none"`),
  6336. -- even those for which `pointable = false`
  6337. light_source = 0,
  6338. -- When used for nodes: Defines amount of light emitted by node.
  6339. -- Otherwise: Defines texture glow when viewed as a dropped item
  6340. -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
  6341. -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
  6342. -- behavior.
  6343. -- See "Tool Capabilities" section for an example including explanation
  6344. tool_capabilities = {
  6345. full_punch_interval = 1.0,
  6346. max_drop_level = 0,
  6347. groupcaps = {
  6348. -- For example:
  6349. choppy = {times = {[1] = 2.50, [2] = 1.40, [3] = 1.00},
  6350. uses = 20, maxlevel = 2},
  6351. },
  6352. damage_groups = {groupname = damage},
  6353. -- Damage values must be between -32768 and 32767 (2^15)
  6354. punch_attack_uses = nil,
  6355. -- Amount of uses this tool has for attacking players and entities
  6356. -- by punching them (0 = infinite uses).
  6357. -- For compatibility, this is automatically set from the first
  6358. -- suitable groupcap using the forumla "uses * 3^(maxlevel - 1)".
  6359. -- It is recommend to set this explicitly instead of relying on the
  6360. -- fallback behavior.
  6361. },
  6362. node_placement_prediction = nil,
  6363. -- If nil and item is node, prediction is made automatically.
  6364. -- If nil and item is not a node, no prediction is made.
  6365. -- If "" and item is anything, no prediction is made.
  6366. -- Otherwise should be name of node which the client immediately places
  6367. -- on ground when the player places the item. Server will always update
  6368. -- actual result to client in a short moment.
  6369. node_dig_prediction = "air",
  6370. -- if "", no prediction is made.
  6371. -- if "air", node is removed.
  6372. -- Otherwise should be name of node which the client immediately places
  6373. -- upon digging. Server will always update actual result shortly.
  6374. sound = {
  6375. -- Definition of items sounds to be played at various events.
  6376. -- All fields in this table are optional.
  6377. breaks = <SimpleSoundSpec>,
  6378. -- When tool breaks due to wear. Ignored for non-tools
  6379. eat = <SimpleSoundSpec>,
  6380. -- When item is eaten with `minetest.do_item_eat`
  6381. },
  6382. on_place = function(itemstack, placer, pointed_thing),
  6383. -- When the 'place' key was pressed with the item in hand
  6384. -- and a node was pointed at.
  6385. -- Shall place item and return the leftover itemstack
  6386. -- or nil to not modify the inventory.
  6387. -- The placer may be any ObjectRef or nil.
  6388. -- default: minetest.item_place
  6389. on_secondary_use = function(itemstack, user, pointed_thing),
  6390. -- Same as on_place but called when not pointing at a node.
  6391. -- Function must return either nil if inventory shall not be modified,
  6392. -- or an itemstack to replace the original itemstack.
  6393. -- The user may be any ObjectRef or nil.
  6394. -- default: nil
  6395. on_drop = function(itemstack, dropper, pos),
  6396. -- Shall drop item and return the leftover itemstack.
  6397. -- The dropper may be any ObjectRef or nil.
  6398. -- default: minetest.item_drop
  6399. on_use = function(itemstack, user, pointed_thing),
  6400. -- default: nil
  6401. -- When user pressed the 'punch/mine' key with the item in hand.
  6402. -- Function must return either nil if inventory shall not be modified,
  6403. -- or an itemstack to replace the original itemstack.
  6404. -- e.g. itemstack:take_item(); return itemstack
  6405. -- Otherwise, the function is free to do what it wants.
  6406. -- The user may be any ObjectRef or nil.
  6407. -- The default functions handle regular use cases.
  6408. after_use = function(itemstack, user, node, digparams),
  6409. -- default: nil
  6410. -- If defined, should return an itemstack and will be called instead of
  6411. -- wearing out the item (if tool). If returns nil, does nothing.
  6412. -- If after_use doesn't exist, it is the same as:
  6413. -- function(itemstack, user, node, digparams)
  6414. -- itemstack:add_wear(digparams.wear)
  6415. -- return itemstack
  6416. -- end
  6417. -- The user may be any ObjectRef or nil.
  6418. _custom_field = whatever,
  6419. -- Add your own custom fields. By convention, all custom field names
  6420. -- should start with `_` to avoid naming collisions with future engine
  6421. -- usage.
  6422. }
  6423. Node definition
  6424. ---------------
  6425. Used by `minetest.register_node`.
  6426. {
  6427. -- <all fields allowed in item definitions>,
  6428. drawtype = "normal", -- See "Node drawtypes"
  6429. visual_scale = 1.0,
  6430. -- Supported for drawtypes "plantlike", "signlike", "torchlike",
  6431. -- "firelike", "mesh", "nodebox", "allfaces".
  6432. -- For plantlike and firelike, the image will start at the bottom of the
  6433. -- node. For torchlike, the image will start at the surface to which the
  6434. -- node "attaches". For the other drawtypes the image will be centered
  6435. -- on the node.
  6436. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6437. -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
  6438. -- Old field name was 'tile_images'.
  6439. -- List can be shortened to needed length.
  6440. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6441. -- Same as `tiles`, but these textures are drawn on top of the base
  6442. -- tiles. You can use this to colorize only specific parts of your
  6443. -- texture. If the texture name is an empty string, that overlay is not
  6444. -- drawn. Since such tiles are drawn twice, it is not recommended to use
  6445. -- overlays on very common nodes.
  6446. special_tiles = {tile definition 1, Tile definition 2},
  6447. -- Special textures of node; used rarely.
  6448. -- Old field name was 'special_materials'.
  6449. -- List can be shortened to needed length.
  6450. color = ColorSpec,
  6451. -- The node's original color will be multiplied with this color.
  6452. -- If the node has a palette, then this setting only has an effect in
  6453. -- the inventory and on the wield item.
  6454. use_texture_alpha = ...,
  6455. -- Specifies how the texture's alpha channel will be used for rendering.
  6456. -- possible values:
  6457. -- * "opaque": Node is rendered opaque regardless of alpha channel
  6458. -- * "clip": A given pixel is either fully see-through or opaque
  6459. -- depending on the alpha channel being below/above 50% in value
  6460. -- * "blend": The alpha channel specifies how transparent a given pixel
  6461. -- of the rendered node is
  6462. -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
  6463. -- "clip" otherwise.
  6464. -- If set to a boolean value (deprecated): true either sets it to blend
  6465. -- or clip, false sets it to clip or opaque mode depending on the drawtype.
  6466. palette = "palette.png",
  6467. -- The node's `param2` is used to select a pixel from the image.
  6468. -- Pixels are arranged from left to right and from top to bottom.
  6469. -- The node's color will be multiplied with the selected pixel's color.
  6470. -- Tiles can override this behavior.
  6471. -- Only when `paramtype2` supports palettes.
  6472. post_effect_color = "green#0F",
  6473. -- Screen tint if player is inside node, see "ColorSpec"
  6474. paramtype = "none", -- See "Nodes"
  6475. paramtype2 = "none", -- See "Nodes"
  6476. place_param2 = nil, -- Force value for param2 when player places node
  6477. is_ground_content = true,
  6478. -- If false, the cave generator and dungeon generator will not carve
  6479. -- through this node.
  6480. -- Specifically, this stops mod-added nodes being removed by caves and
  6481. -- dungeons when those generate in a neighbor mapchunk and extend out
  6482. -- beyond the edge of that mapchunk.
  6483. sunlight_propagates = false,
  6484. -- If true, sunlight will go infinitely through this node
  6485. walkable = true, -- If true, objects collide with node
  6486. pointable = true, -- If true, can be pointed at
  6487. diggable = true, -- If false, can never be dug
  6488. climbable = false, -- If true, can be climbed on (ladder)
  6489. move_resistance = 0,
  6490. -- Slows down movement of players through this node (max. 7).
  6491. -- If this is nil, it will be equal to liquid_viscosity.
  6492. -- Note: If liquid movement physics apply to the node
  6493. -- (see `liquid_move_physics`), the movement speed will also be
  6494. -- affected by the `movement_liquid_*` settings.
  6495. buildable_to = false, -- If true, placed nodes can replace this node
  6496. floodable = false,
  6497. -- If true, liquids flow into and replace this node.
  6498. -- Warning: making a liquid node 'floodable' will cause problems.
  6499. liquidtype = "none", -- specifies liquid flowing physics
  6500. -- * "none": no liquid flowing physics
  6501. -- * "source": spawns flowing liquid nodes at all 4 sides and below;
  6502. -- recommended drawtype: "liquid".
  6503. -- * "flowing": spawned from source, spawns more flowing liquid nodes
  6504. -- around it until `liquid_range` is reached;
  6505. -- will drain out without a source;
  6506. -- recommended drawtype: "flowingliquid".
  6507. -- If it's "source" or "flowing" and `liquid_range > 0`, then
  6508. -- both `liquid_alternative_*` fields must be specified
  6509. liquid_alternative_flowing = "", -- Flowing version of source liquid
  6510. liquid_alternative_source = "", -- Source version of flowing liquid
  6511. liquid_viscosity = 0,
  6512. -- Controls speed at which the liquid spreads/flows (max. 7).
  6513. -- 0 is fastest, 7 is slowest.
  6514. -- By default, this also slows down movement of players inside the node
  6515. -- (can be overridden using `move_resistance`)
  6516. liquid_renewable = true,
  6517. -- If true, a new liquid source can be created by placing two or more
  6518. -- sources nearby
  6519. liquid_move_physics = nil, -- specifies movement physics if inside node
  6520. -- * false: No liquid movement physics apply.
  6521. -- * true: Enables liquid movement physics. Enables things like
  6522. -- ability to "swim" up/down, sinking slowly if not moving,
  6523. -- smoother speed change when falling into, etc. The `movement_liquid_*`
  6524. -- settings apply.
  6525. -- * nil: Will be treated as true if `liquidype ~= "none"`
  6526. -- and as false otherwise.
  6527. -- Default: nil
  6528. leveled = 0,
  6529. -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
  6530. -- Allows defining the nodebox height without using param2.
  6531. -- The nodebox height is 'leveled' / 64 nodes.
  6532. -- The maximum value of 'leveled' is `leveled_max`.
  6533. leveled_max = 127,
  6534. -- Maximum value for `leveled` (0-127), enforced in
  6535. -- `minetest.set_node_level` and `minetest.add_node_level`.
  6536. -- Values above 124 might causes collision detection issues.
  6537. liquid_range = 8,
  6538. -- Maximum distance that flowing liquid nodes can spread around
  6539. -- source on flat land;
  6540. -- maximum = 8; set to 0 to disable liquid flow
  6541. drowning = 0,
  6542. -- Player will take this amount of damage if no bubbles are left
  6543. damage_per_second = 0,
  6544. -- If player is inside node, this damage is caused
  6545. node_box = {type="regular"}, -- See "Node boxes"
  6546. connects_to = nodenames,
  6547. -- Used for nodebox nodes with the type == "connected".
  6548. -- Specifies to what neighboring nodes connections will be drawn.
  6549. -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
  6550. connect_sides = { "top", "bottom", "front", "left", "back", "right" },
  6551. -- Tells connected nodebox nodes to connect only to these sides of this
  6552. -- node
  6553. mesh = "model.obj",
  6554. -- File name of mesh when using "mesh" drawtype
  6555. selection_box = {
  6556. type = "fixed",
  6557. fixed = {
  6558. {-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
  6559. -- Node box format: see [Node boxes]
  6560. },
  6561. },
  6562. -- Custom selection box definition. Multiple boxes can be defined.
  6563. -- If "nodebox" drawtype is used and selection_box is nil, then node_box
  6564. -- definition is used for the selection box.
  6565. collision_box = {
  6566. type = "fixed",
  6567. fixed = {
  6568. {-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
  6569. -- Node box format: see [Node boxes]
  6570. },
  6571. },
  6572. -- Custom collision box definition. Multiple boxes can be defined.
  6573. -- If "nodebox" drawtype is used and collision_box is nil, then node_box
  6574. -- definition is used for the collision box.
  6575. -- Support maps made in and before January 2012
  6576. legacy_facedir_simple = false,
  6577. legacy_wallmounted = false,
  6578. waving = 0,
  6579. -- Valid for drawtypes:
  6580. -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
  6581. -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
  6582. -- 2 - wave node like leaves (whole node moves side-to-side)
  6583. -- 3 - wave node like liquids (whole node moves up and down)
  6584. -- Not all models will properly wave.
  6585. -- plantlike drawtype can only wave like plants.
  6586. -- allfaces_optional drawtype can only wave like leaves.
  6587. -- liquid, flowingliquid drawtypes can only wave like liquids.
  6588. sounds = {
  6589. -- Definition of node sounds to be played at various events.
  6590. -- All fields in this table are optional.
  6591. footstep = <SimpleSoundSpec>,
  6592. -- If walkable, played when object walks on it. If node is
  6593. -- climbable or a liquid, played when object moves through it
  6594. dig = <SimpleSoundSpec> or "__group",
  6595. -- While digging node.
  6596. -- If `"__group"`, then the sound will be
  6597. -- `default_dig_<groupname>`, where `<groupname>` is the
  6598. -- name of the item's digging group with the fastest digging time.
  6599. -- In case of a tie, one of the sounds will be played (but we
  6600. -- cannot predict which one)
  6601. -- Default value: `"__group"`
  6602. dug = <SimpleSoundSpec>,
  6603. -- Node was dug
  6604. place = <SimpleSoundSpec>,
  6605. -- Node was placed. Also played after falling
  6606. place_failed = <SimpleSoundSpec>,
  6607. -- When node placement failed.
  6608. -- Note: This happens if the _built-in_ node placement failed.
  6609. -- This sound will still be played if the node is placed in the
  6610. -- `on_place` callback manually.
  6611. fall = <SimpleSoundSpec>,
  6612. -- When node starts to fall or is detached
  6613. },
  6614. drop = "",
  6615. -- Name of dropped item when dug.
  6616. -- Default dropped item is the node itself.
  6617. -- Using a table allows multiple items, drop chances and item filtering.
  6618. -- Item filtering by string matching is deprecated.
  6619. drop = {
  6620. max_items = 1,
  6621. -- Maximum number of item lists to drop.
  6622. -- The entries in 'items' are processed in order. For each:
  6623. -- Item filtering is applied, chance of drop is applied, if both are
  6624. -- successful the entire item list is dropped.
  6625. -- Entry processing continues until the number of dropped item lists
  6626. -- equals 'max_items'.
  6627. -- Therefore, entries should progress from low to high drop chance.
  6628. items = {
  6629. -- Entry examples.
  6630. {
  6631. -- 1 in 1000 chance of dropping a diamond.
  6632. -- Default rarity is '1'.
  6633. rarity = 1000,
  6634. items = {"default:diamond"},
  6635. },
  6636. {
  6637. -- Only drop if using an item whose name is identical to one
  6638. -- of these.
  6639. tools = {"default:shovel_mese", "default:shovel_diamond"},
  6640. rarity = 5,
  6641. items = {"default:dirt"},
  6642. -- Whether all items in the dropped item list inherit the
  6643. -- hardware coloring palette color from the dug node.
  6644. -- Default is 'false'.
  6645. inherit_color = true,
  6646. },
  6647. {
  6648. -- Only drop if using an item whose name contains
  6649. -- "default:shovel_" (this item filtering by string matching
  6650. -- is deprecated, use tool_groups instead).
  6651. tools = {"~default:shovel_"},
  6652. rarity = 2,
  6653. -- The item list dropped.
  6654. items = {"default:sand", "default:desert_sand"},
  6655. },
  6656. {
  6657. -- Only drop if using an item in the "magicwand" group, or
  6658. -- an item that is in both the "pickaxe" and the "lucky"
  6659. -- groups.
  6660. tool_groups = {
  6661. "magicwand",
  6662. {"pickaxe", "lucky"}
  6663. },
  6664. items = {"default:coal_lump"},
  6665. },
  6666. },
  6667. },
  6668. on_construct = function(pos),
  6669. -- Node constructor; called after adding node.
  6670. -- Can set up metadata and stuff like that.
  6671. -- Not called for bulk node placement (i.e. schematics and VoxelManip).
  6672. -- default: nil
  6673. on_destruct = function(pos),
  6674. -- Node destructor; called before removing node.
  6675. -- Not called for bulk node placement.
  6676. -- default: nil
  6677. after_destruct = function(pos, oldnode),
  6678. -- Node destructor; called after removing node.
  6679. -- Not called for bulk node placement.
  6680. -- default: nil
  6681. on_flood = function(pos, oldnode, newnode),
  6682. -- Called when a liquid (newnode) is about to flood oldnode, if it has
  6683. -- `floodable = true` in the nodedef. Not called for bulk node placement
  6684. -- (i.e. schematics and VoxelManip) or air nodes. If return true the
  6685. -- node is not flooded, but on_flood callback will most likely be called
  6686. -- over and over again every liquid update interval.
  6687. -- Default: nil
  6688. -- Warning: making a liquid node 'floodable' will cause problems.
  6689. preserve_metadata = function(pos, oldnode, oldmeta, drops),
  6690. -- Called when oldnode is about be converted to an item, but before the
  6691. -- node is deleted from the world or the drops are added. This is
  6692. -- generally the result of either the node being dug or an attached node
  6693. -- becoming detached.
  6694. -- oldmeta is the NodeMetaRef of the oldnode before deletion.
  6695. -- drops is a table of ItemStacks, so any metadata to be preserved can
  6696. -- be added directly to one or more of the dropped items. See
  6697. -- "ItemStackMetaRef".
  6698. -- default: nil
  6699. after_place_node = function(pos, placer, itemstack, pointed_thing),
  6700. -- Called after constructing node when node was placed using
  6701. -- minetest.item_place_node / minetest.place_node.
  6702. -- If return true no item is taken from itemstack.
  6703. -- `placer` may be any valid ObjectRef or nil.
  6704. -- default: nil
  6705. after_dig_node = function(pos, oldnode, oldmetadata, digger),
  6706. -- oldmetadata is in table format.
  6707. -- Called after destructing node when node was dug using
  6708. -- minetest.node_dig / minetest.dig_node.
  6709. -- default: nil
  6710. can_dig = function(pos, [player]),
  6711. -- Returns true if node can be dug, or false if not.
  6712. -- default: nil
  6713. on_punch = function(pos, node, puncher, pointed_thing),
  6714. -- default: minetest.node_punch
  6715. -- Called when puncher (an ObjectRef) punches the node at pos.
  6716. -- By default calls minetest.register_on_punchnode callbacks.
  6717. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
  6718. -- default: nil
  6719. -- Called when clicker (an ObjectRef) used the 'place/build' key
  6720. -- (not neccessarily an actual rightclick)
  6721. -- while pointing at the node at pos with 'node' being the node table.
  6722. -- itemstack will hold clicker's wielded item.
  6723. -- Shall return the leftover itemstack.
  6724. -- Note: pointed_thing can be nil, if a mod calls this function.
  6725. -- This function does not get triggered by clients <=0.4.16 if the
  6726. -- "formspec" node metadata field is set.
  6727. on_dig = function(pos, node, digger),
  6728. -- default: minetest.node_dig
  6729. -- By default checks privileges, wears out item (if tool) and removes node.
  6730. -- return true if the node was dug successfully, false otherwise.
  6731. -- Deprecated: returning nil is the same as returning true.
  6732. on_timer = function(pos, elapsed),
  6733. -- default: nil
  6734. -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
  6735. -- elapsed is the total time passed since the timer was started.
  6736. -- return true to run the timer for another cycle with the same timeout
  6737. -- value.
  6738. on_receive_fields = function(pos, formname, fields, sender),
  6739. -- fields = {name1 = value1, name2 = value2, ...}
  6740. -- Called when an UI form (e.g. sign text input) returns data.
  6741. -- See minetest.register_on_player_receive_fields for more info.
  6742. -- default: nil
  6743. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  6744. -- Called when a player wants to move items inside the inventory.
  6745. -- Return value: number of items allowed to move.
  6746. allow_metadata_inventory_put = function(pos, listname, index, stack, player),
  6747. -- Called when a player wants to put something into the inventory.
  6748. -- Return value: number of items allowed to put.
  6749. -- Return value -1: Allow and don't modify item count in inventory.
  6750. allow_metadata_inventory_take = function(pos, listname, index, stack, player),
  6751. -- Called when a player wants to take something out of the inventory.
  6752. -- Return value: number of items allowed to take.
  6753. -- Return value -1: Allow and don't modify item count in inventory.
  6754. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  6755. on_metadata_inventory_put = function(pos, listname, index, stack, player),
  6756. on_metadata_inventory_take = function(pos, listname, index, stack, player),
  6757. -- Called after the actual action has happened, according to what was
  6758. -- allowed.
  6759. -- No return value.
  6760. on_blast = function(pos, intensity),
  6761. -- intensity: 1.0 = mid range of regular TNT.
  6762. -- If defined, called when an explosion touches the node, instead of
  6763. -- removing the node.
  6764. mod_origin = "modname",
  6765. -- stores which mod actually registered a node
  6766. -- if it can not find a source, returns "??"
  6767. -- useful for getting what mod truly registered something
  6768. -- example: if a node is registered as ":othermodname:nodename",
  6769. -- nodename will show "othermodname", but mod_orgin will say "modname"
  6770. }
  6771. Crafting recipes
  6772. ----------------
  6773. Used by `minetest.register_craft`.
  6774. ### Shaped
  6775. {
  6776. output = "default:pick_stone",
  6777. recipe = {
  6778. {"default:cobble", "default:cobble", "default:cobble"},
  6779. {"", "default:stick", ""},
  6780. {"", "default:stick", ""}, -- Also groups; e.g. "group:crumbly"
  6781. },
  6782. replacements = <list of item pairs>,
  6783. -- replacements: replace one input item with another item on crafting
  6784. -- (optional).
  6785. }
  6786. ### Shapeless
  6787. {
  6788. type = "shapeless",
  6789. output = "mushrooms:mushroom_stew",
  6790. recipe = {
  6791. "mushrooms:bowl",
  6792. "mushrooms:mushroom_brown",
  6793. "mushrooms:mushroom_red",
  6794. },
  6795. replacements = <list of item pairs>,
  6796. }
  6797. ### Tool repair
  6798. {
  6799. type = "toolrepair",
  6800. additional_wear = -0.02, -- multiplier of 65536
  6801. }
  6802. Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
  6803. group. Player can put 2 equal tools in the craft grid to get one "repaired" tool
  6804. back.
  6805. The wear of the output is determined by the wear of both tools, plus a
  6806. 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
  6807. you want `additional_wear` to be negative.
  6808. The formula used to calculate the resulting wear is:
  6809. 65536 - ( (65536 - tool_1_wear) + (65536 - tool_2_wear) + 65536 * additional_wear )
  6810. The result is rounded and can't be lower than 0. If the result is 65536 or higher,
  6811. no crafting is possible.
  6812. ### Cooking
  6813. {
  6814. type = "cooking",
  6815. output = "default:glass",
  6816. recipe = "default:sand",
  6817. cooktime = 3,
  6818. }
  6819. ### Furnace fuel
  6820. {
  6821. type = "fuel",
  6822. recipe = "bucket:bucket_lava",
  6823. burntime = 60,
  6824. replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
  6825. }
  6826. Ore definition
  6827. --------------
  6828. Used by `minetest.register_ore`.
  6829. See [Ores] section above for essential information.
  6830. {
  6831. ore_type = "scatter",
  6832. ore = "default:stone_with_coal",
  6833. ore_param2 = 3,
  6834. -- Facedir rotation. Default is 0 (unchanged rotation)
  6835. wherein = "default:stone",
  6836. -- A list of nodenames is supported too
  6837. clust_scarcity = 8 * 8 * 8,
  6838. -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
  6839. -- If the desired average distance between ores is 'd', set this to
  6840. -- d * d * d.
  6841. clust_num_ores = 8,
  6842. -- Number of ores in a cluster
  6843. clust_size = 3,
  6844. -- Size of the bounding box of the cluster.
  6845. -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
  6846. -- nodes are coal ore.
  6847. y_min = -31000,
  6848. y_max = 64,
  6849. -- Lower and upper limits for ore
  6850. flags = "",
  6851. -- Attributes for the ore generation, see 'Ore attributes' section above
  6852. noise_threshold = 0.5,
  6853. -- If noise is above this threshold, ore is placed. Not needed for a
  6854. -- uniform distribution.
  6855. noise_params = {
  6856. offset = 0,
  6857. scale = 1,
  6858. spread = {x = 100, y = 100, z = 100},
  6859. seed = 23,
  6860. octaves = 3,
  6861. persistence = 0.7
  6862. },
  6863. -- NoiseParams structure describing one of the perlin noises used for
  6864. -- ore distribution.
  6865. -- Needed by "sheet", "puff", "blob" and "vein" ores.
  6866. -- Omit from "scatter" ore for a uniform ore distribution.
  6867. -- Omit from "stratum" ore for a simple horizontal strata from y_min to
  6868. -- y_max.
  6869. biomes = {"desert", "rainforest"},
  6870. -- List of biomes in which this ore occurs.
  6871. -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
  6872. -- being used does not support biomes.
  6873. -- Can be a list of (or a single) biome names, IDs, or definitions.
  6874. -- Type-specific parameters
  6875. -- sheet
  6876. column_height_min = 1,
  6877. column_height_max = 16,
  6878. column_midpoint_factor = 0.5,
  6879. -- puff
  6880. np_puff_top = {
  6881. offset = 4,
  6882. scale = 2,
  6883. spread = {x = 100, y = 100, z = 100},
  6884. seed = 47,
  6885. octaves = 3,
  6886. persistence = 0.7
  6887. },
  6888. np_puff_bottom = {
  6889. offset = 4,
  6890. scale = 2,
  6891. spread = {x = 100, y = 100, z = 100},
  6892. seed = 11,
  6893. octaves = 3,
  6894. persistence = 0.7
  6895. },
  6896. -- vein
  6897. random_factor = 1.0,
  6898. -- stratum
  6899. np_stratum_thickness = {
  6900. offset = 8,
  6901. scale = 4,
  6902. spread = {x = 100, y = 100, z = 100},
  6903. seed = 17,
  6904. octaves = 3,
  6905. persistence = 0.7
  6906. },
  6907. stratum_thickness = 8,
  6908. }
  6909. Biome definition
  6910. ----------------
  6911. Used by `minetest.register_biome`.
  6912. The maximum number of biomes that can be used is 65535. However, using an
  6913. excessive number of biomes will slow down map generation. Depending on desired
  6914. performance and computing power the practical limit is much lower.
  6915. {
  6916. name = "tundra",
  6917. node_dust = "default:snow",
  6918. -- Node dropped onto upper surface after all else is generated
  6919. node_top = "default:dirt_with_snow",
  6920. depth_top = 1,
  6921. -- Node forming surface layer of biome and thickness of this layer
  6922. node_filler = "default:permafrost",
  6923. depth_filler = 3,
  6924. -- Node forming lower layer of biome and thickness of this layer
  6925. node_stone = "default:bluestone",
  6926. -- Node that replaces all stone nodes between roughly y_min and y_max.
  6927. node_water_top = "default:ice",
  6928. depth_water_top = 10,
  6929. -- Node forming a surface layer in seawater with the defined thickness
  6930. node_water = "",
  6931. -- Node that replaces all seawater nodes not in the surface layer
  6932. node_river_water = "default:ice",
  6933. -- Node that replaces river water in mapgens that use
  6934. -- default:river_water
  6935. node_riverbed = "default:gravel",
  6936. depth_riverbed = 2,
  6937. -- Node placed under river water and thickness of this layer
  6938. node_cave_liquid = "default:lava_source",
  6939. node_cave_liquid = {"default:water_source", "default:lava_source"},
  6940. -- Nodes placed inside 50% of the medium size caves.
  6941. -- Multiple nodes can be specified, each cave will use a randomly
  6942. -- chosen node from the list.
  6943. -- If this field is left out or 'nil', cave liquids fall back to
  6944. -- classic behaviour of lava and water distributed using 3D noise.
  6945. -- For no cave liquid, specify "air".
  6946. node_dungeon = "default:cobble",
  6947. -- Node used for primary dungeon structure.
  6948. -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
  6949. -- alias, if that is also absent, dungeon nodes fall back to the biome
  6950. -- 'node_stone'.
  6951. -- If present, the following two nodes are also used.
  6952. node_dungeon_alt = "default:mossycobble",
  6953. -- Node used for randomly-distributed alternative structure nodes.
  6954. -- If alternative structure nodes are not wanted leave this absent for
  6955. -- performance reasons.
  6956. node_dungeon_stair = "stairs:stair_cobble",
  6957. -- Node used for dungeon stairs.
  6958. -- If absent, stairs fall back to 'node_dungeon'.
  6959. y_max = 31000,
  6960. y_min = 1,
  6961. -- Upper and lower limits for biome.
  6962. -- Alternatively you can use xyz limits as shown below.
  6963. max_pos = {x = 31000, y = 128, z = 31000},
  6964. min_pos = {x = -31000, y = 9, z = -31000},
  6965. -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
  6966. -- Biome is limited to a cuboid defined by these positions.
  6967. -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
  6968. -- 31000 in 'max_pos'.
  6969. vertical_blend = 8,
  6970. -- Vertical distance in nodes above 'y_max' over which the biome will
  6971. -- blend with the biome above.
  6972. -- Set to 0 for no vertical blend. Defaults to 0.
  6973. heat_point = 0,
  6974. humidity_point = 50,
  6975. -- Characteristic temperature and humidity for the biome.
  6976. -- These values create 'biome points' on a voronoi diagram with heat and
  6977. -- humidity as axes. The resulting voronoi cells determine the
  6978. -- distribution of the biomes.
  6979. -- Heat and humidity have average values of 50, vary mostly between
  6980. -- 0 and 100 but can exceed these values.
  6981. }
  6982. Decoration definition
  6983. ---------------------
  6984. See [Decoration types]. Used by `minetest.register_decoration`.
  6985. {
  6986. deco_type = "simple",
  6987. place_on = "default:dirt_with_grass",
  6988. -- Node (or list of nodes) that the decoration can be placed on
  6989. sidelen = 8,
  6990. -- Size of the square divisions of the mapchunk being generated.
  6991. -- Determines the resolution of noise variation if used.
  6992. -- If the chunk size is not evenly divisible by sidelen, sidelen is made
  6993. -- equal to the chunk size.
  6994. fill_ratio = 0.02,
  6995. -- The value determines 'decorations per surface node'.
  6996. -- Used only if noise_params is not specified.
  6997. -- If >= 10.0 complete coverage is enabled and decoration placement uses
  6998. -- a different and much faster method.
  6999. noise_params = {
  7000. offset = 0,
  7001. scale = 0.45,
  7002. spread = {x = 100, y = 100, z = 100},
  7003. seed = 354,
  7004. octaves = 3,
  7005. persistence = 0.7,
  7006. lacunarity = 2.0,
  7007. flags = "absvalue"
  7008. },
  7009. -- NoiseParams structure describing the perlin noise used for decoration
  7010. -- distribution.
  7011. -- A noise value is calculated for each square division and determines
  7012. -- 'decorations per surface node' within each division.
  7013. -- If the noise value >= 10.0 complete coverage is enabled and
  7014. -- decoration placement uses a different and much faster method.
  7015. biomes = {"Oceanside", "Hills", "Plains"},
  7016. -- List of biomes in which this decoration occurs. Occurs in all biomes
  7017. -- if this is omitted, and ignored if the Mapgen being used does not
  7018. -- support biomes.
  7019. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7020. y_min = -31000,
  7021. y_max = 31000,
  7022. -- Lower and upper limits for decoration.
  7023. -- These parameters refer to the Y co-ordinate of the 'place_on' node.
  7024. spawn_by = "default:water",
  7025. -- Node (or list of nodes) that the decoration only spawns next to.
  7026. -- Checks two horizontal planes of 8 neighbouring nodes (including
  7027. -- diagonal neighbours), one plane level with the 'place_on' node and a
  7028. -- plane one node above that.
  7029. num_spawn_by = 1,
  7030. -- Number of spawn_by nodes that must be surrounding the decoration
  7031. -- position to occur.
  7032. -- If absent or -1, decorations occur next to any nodes.
  7033. flags = "liquid_surface, force_placement, all_floors, all_ceilings",
  7034. -- Flags for all decoration types.
  7035. -- "liquid_surface": Instead of placement on the highest solid surface
  7036. -- in a mapchunk column, placement is on the highest liquid surface.
  7037. -- Placement is disabled if solid nodes are found above the liquid
  7038. -- surface.
  7039. -- "force_placement": Nodes other than "air" and "ignore" are replaced
  7040. -- by the decoration.
  7041. -- "all_floors", "all_ceilings": Instead of placement on the highest
  7042. -- surface in a mapchunk the decoration is placed on all floor and/or
  7043. -- ceiling surfaces, for example in caves and dungeons.
  7044. -- Ceiling decorations act as an inversion of floor decorations so the
  7045. -- effect of 'place_offset_y' is inverted.
  7046. -- Y-slice probabilities do not function correctly for ceiling
  7047. -- schematic decorations as the behaviour is unchanged.
  7048. -- If a single decoration registration has both flags the floor and
  7049. -- ceiling decorations will be aligned vertically.
  7050. ----- Simple-type parameters
  7051. decoration = "default:grass",
  7052. -- The node name used as the decoration.
  7053. -- If instead a list of strings, a randomly selected node from the list
  7054. -- is placed as the decoration.
  7055. height = 1,
  7056. -- Decoration height in nodes.
  7057. -- If height_max is not 0, this is the lower limit of a randomly
  7058. -- selected height.
  7059. height_max = 0,
  7060. -- Upper limit of the randomly selected height.
  7061. -- If absent, the parameter 'height' is used as a constant.
  7062. param2 = 0,
  7063. -- Param2 value of decoration nodes.
  7064. -- If param2_max is not 0, this is the lower limit of a randomly
  7065. -- selected param2.
  7066. param2_max = 0,
  7067. -- Upper limit of the randomly selected param2.
  7068. -- If absent, the parameter 'param2' is used as a constant.
  7069. place_offset_y = 0,
  7070. -- Y offset of the decoration base node relative to the standard base
  7071. -- node position.
  7072. -- Can be positive or negative. Default is 0.
  7073. -- Effect is inverted for "all_ceilings" decorations.
  7074. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7075. -- to the 'place_on' node.
  7076. ----- Schematic-type parameters
  7077. schematic = "foobar.mts",
  7078. -- If schematic is a string, it is the filepath relative to the current
  7079. -- working directory of the specified Minetest schematic file.
  7080. -- Could also be the ID of a previously registered schematic.
  7081. schematic = {
  7082. size = {x = 4, y = 6, z = 4},
  7083. data = {
  7084. {name = "default:cobble", param1 = 255, param2 = 0},
  7085. {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
  7086. {name = "air", param1 = 255, param2 = 0},
  7087. ...
  7088. },
  7089. yslice_prob = {
  7090. {ypos = 2, prob = 128},
  7091. {ypos = 5, prob = 64},
  7092. ...
  7093. },
  7094. },
  7095. -- Alternative schematic specification by supplying a table. The fields
  7096. -- size and data are mandatory whereas yslice_prob is optional.
  7097. -- See 'Schematic specifier' for details.
  7098. replacements = {["oldname"] = "convert_to", ...},
  7099. flags = "place_center_x, place_center_y, place_center_z",
  7100. -- Flags for schematic decorations. See 'Schematic attributes'.
  7101. rotation = "90",
  7102. -- Rotation can be "0", "90", "180", "270", or "random"
  7103. place_offset_y = 0,
  7104. -- If the flag 'place_center_y' is set this parameter is ignored.
  7105. -- Y offset of the schematic base node layer relative to the 'place_on'
  7106. -- node.
  7107. -- Can be positive or negative. Default is 0.
  7108. -- Effect is inverted for "all_ceilings" decorations.
  7109. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7110. -- to the 'place_on' node.
  7111. }
  7112. Chat command definition
  7113. -----------------------
  7114. Used by `minetest.register_chatcommand`.
  7115. {
  7116. params = "<name> <privilege>", -- Short parameter description
  7117. description = "Remove privilege from player", -- Full description
  7118. privs = {privs=true}, -- Require the "privs" privilege to run
  7119. func = function(name, param),
  7120. -- Called when command is run. Returns boolean success and text output.
  7121. -- Special case: The help message is shown to the player if `func`
  7122. -- returns false without a text output.
  7123. }
  7124. Note that in params, use of symbols is as follows:
  7125. * `<>` signifies a placeholder to be replaced when the command is used. For
  7126. example, when a player name is needed: `<name>`
  7127. * `[]` signifies param is optional and not required when the command is used.
  7128. For example, if you require param1 but param2 is optional:
  7129. `<param1> [<param2>]`
  7130. * `|` signifies exclusive or. The command requires one param from the options
  7131. provided. For example: `<param1> | <param2>`
  7132. * `()` signifies grouping. For example, when param1 and param2 are both
  7133. required, or only param3 is required: `(<param1> <param2>) | <param3>`
  7134. Privilege definition
  7135. --------------------
  7136. Used by `minetest.register_privilege`.
  7137. {
  7138. description = "",
  7139. -- Privilege description
  7140. give_to_singleplayer = true,
  7141. -- Whether to grant the privilege to singleplayer.
  7142. give_to_admin = true,
  7143. -- Whether to grant the privilege to the server admin.
  7144. -- Uses value of 'give_to_singleplayer' by default.
  7145. on_grant = function(name, granter_name),
  7146. -- Called when given to player 'name' by 'granter_name'.
  7147. -- 'granter_name' will be nil if the priv was granted by a mod.
  7148. on_revoke = function(name, revoker_name),
  7149. -- Called when taken from player 'name' by 'revoker_name'.
  7150. -- 'revoker_name' will be nil if the priv was revoked by a mod.
  7151. -- Note that the above two callbacks will be called twice if a player is
  7152. -- responsible, once with the player name, and then with a nil player
  7153. -- name.
  7154. -- Return true in the above callbacks to stop register_on_priv_grant or
  7155. -- revoke being called.
  7156. }
  7157. Detached inventory callbacks
  7158. ----------------------------
  7159. Used by `minetest.create_detached_inventory`.
  7160. {
  7161. allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7162. -- Called when a player wants to move items inside the inventory.
  7163. -- Return value: number of items allowed to move.
  7164. allow_put = function(inv, listname, index, stack, player),
  7165. -- Called when a player wants to put something into the inventory.
  7166. -- Return value: number of items allowed to put.
  7167. -- Return value -1: Allow and don't modify item count in inventory.
  7168. allow_take = function(inv, listname, index, stack, player),
  7169. -- Called when a player wants to take something out of the inventory.
  7170. -- Return value: number of items allowed to take.
  7171. -- Return value -1: Allow and don't modify item count in inventory.
  7172. on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7173. on_put = function(inv, listname, index, stack, player),
  7174. on_take = function(inv, listname, index, stack, player),
  7175. -- Called after the actual action has happened, according to what was
  7176. -- allowed.
  7177. -- No return value.
  7178. }
  7179. HUD Definition
  7180. --------------
  7181. See [HUD] section.
  7182. Used by `Player:hud_add`. Returned by `Player:hud_get`.
  7183. {
  7184. hud_elem_type = "image", -- See HUD element types
  7185. -- Type of element, can be "image", "text", "statbar", "inventory",
  7186. -- "compass" or "minimap"
  7187. position = {x=0.5, y=0.5},
  7188. -- Left corner position of element
  7189. name = "<name>",
  7190. scale = {x = 2, y = 2},
  7191. text = "<text>",
  7192. text2 = "<text>",
  7193. number = 2,
  7194. item = 3,
  7195. -- Selected item in inventory. 0 for no item selected.
  7196. direction = 0,
  7197. -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  7198. alignment = {x=0, y=0},
  7199. offset = {x=0, y=0},
  7200. size = { x=100, y=100 },
  7201. -- Size of element in pixels
  7202. z_index = 0,
  7203. -- Z index : lower z-index HUDs are displayed behind higher z-index HUDs
  7204. style = 0,
  7205. -- For "text" elements sets font style: bitfield with 1 = bold, 2 = italic, 4 = monospace
  7206. }
  7207. Particle definition
  7208. -------------------
  7209. Used by `minetest.add_particle`.
  7210. {
  7211. pos = {x=0, y=0, z=0},
  7212. velocity = {x=0, y=0, z=0},
  7213. acceleration = {x=0, y=0, z=0},
  7214. -- Spawn particle at pos with velocity and acceleration
  7215. expirationtime = 1,
  7216. -- Disappears after expirationtime seconds
  7217. size = 1,
  7218. -- Scales the visual size of the particle texture.
  7219. -- If `node` is set, size can be set to 0 to spawn a randomly-sized
  7220. -- particle (just like actual node dig particles).
  7221. collisiondetection = false,
  7222. -- If true collides with `walkable` nodes and, depending on the
  7223. -- `object_collision` field, objects too.
  7224. collision_removal = false,
  7225. -- If true particle is removed when it collides.
  7226. -- Requires collisiondetection = true to have any effect.
  7227. object_collision = false,
  7228. -- If true particle collides with objects that are defined as
  7229. -- `physical = true,` and `collide_with_objects = true,`.
  7230. -- Requires collisiondetection = true to have any effect.
  7231. vertical = false,
  7232. -- If true faces player using y axis only
  7233. texture = "image.png",
  7234. -- The texture of the particle
  7235. playername = "singleplayer",
  7236. -- Optional, if specified spawns particle only on the player's client
  7237. animation = {Tile Animation definition},
  7238. -- Optional, specifies how to animate the particle texture
  7239. glow = 0
  7240. -- Optional, specify particle self-luminescence in darkness.
  7241. -- Values 0-14.
  7242. node = {name = "ignore", param2 = 0},
  7243. -- Optional, if specified the particle will have the same appearance as
  7244. -- node dig particles for the given node.
  7245. -- `texture` and `animation` will be ignored if this is set.
  7246. node_tile = 0,
  7247. -- Optional, only valid in combination with `node`
  7248. -- If set to a valid number 1-6, specifies the tile from which the
  7249. -- particle texture is picked.
  7250. -- Otherwise, the default behavior is used. (currently: any random tile)
  7251. }
  7252. `ParticleSpawner` definition
  7253. ----------------------------
  7254. Used by `minetest.add_particlespawner`.
  7255. {
  7256. amount = 1,
  7257. -- Number of particles spawned over the time period `time`.
  7258. time = 1,
  7259. -- Lifespan of spawner in seconds.
  7260. -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
  7261. -- a per-second basis.
  7262. minpos = {x=0, y=0, z=0},
  7263. maxpos = {x=0, y=0, z=0},
  7264. minvel = {x=0, y=0, z=0},
  7265. maxvel = {x=0, y=0, z=0},
  7266. minacc = {x=0, y=0, z=0},
  7267. maxacc = {x=0, y=0, z=0},
  7268. minexptime = 1,
  7269. maxexptime = 1,
  7270. minsize = 1,
  7271. maxsize = 1,
  7272. -- The particles' properties are random values between the min and max
  7273. -- values.
  7274. -- applies to: pos, velocity, acceleration, expirationtime, size
  7275. -- If `node` is set, min and maxsize can be set to 0 to spawn
  7276. -- randomly-sized particles (just like actual node dig particles).
  7277. collisiondetection = false,
  7278. -- If true collide with `walkable` nodes and, depending on the
  7279. -- `object_collision` field, objects too.
  7280. collision_removal = false,
  7281. -- If true particles are removed when they collide.
  7282. -- Requires collisiondetection = true to have any effect.
  7283. object_collision = false,
  7284. -- If true particles collide with objects that are defined as
  7285. -- `physical = true,` and `collide_with_objects = true,`.
  7286. -- Requires collisiondetection = true to have any effect.
  7287. attached = ObjectRef,
  7288. -- If defined, particle positions, velocities and accelerations are
  7289. -- relative to this object's position and yaw
  7290. vertical = false,
  7291. -- If true face player using y axis only
  7292. texture = "image.png",
  7293. -- The texture of the particle
  7294. playername = "singleplayer",
  7295. -- Optional, if specified spawns particles only on the player's client
  7296. animation = {Tile Animation definition},
  7297. -- Optional, specifies how to animate the particles' texture
  7298. glow = 0
  7299. -- Optional, specify particle self-luminescence in darkness.
  7300. -- Values 0-14.
  7301. node = {name = "ignore", param2 = 0},
  7302. -- Optional, if specified the particles will have the same appearance as
  7303. -- node dig particles for the given node.
  7304. -- `texture` and `animation` will be ignored if this is set.
  7305. node_tile = 0,
  7306. -- Optional, only valid in combination with `node`
  7307. -- If set to a valid number 1-6, specifies the tile from which the
  7308. -- particle texture is picked.
  7309. -- Otherwise, the default behavior is used. (currently: any random tile)
  7310. }
  7311. `HTTPRequest` definition
  7312. ------------------------
  7313. Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
  7314. {
  7315. url = "http://example.org",
  7316. timeout = 10,
  7317. -- Timeout for request to be completed in seconds. Default depends on engine settings.
  7318. method = "GET", "POST", "PUT" or "DELETE"
  7319. -- The http method to use. Defaults to "GET".
  7320. data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
  7321. -- Data for the POST, PUT or DELETE request.
  7322. -- Accepts both a string and a table. If a table is specified, encodes
  7323. -- table as x-www-form-urlencoded key-value pairs.
  7324. user_agent = "ExampleUserAgent",
  7325. -- Optional, if specified replaces the default minetest user agent with
  7326. -- given string
  7327. extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
  7328. -- Optional, if specified adds additional headers to the HTTP request.
  7329. -- You must make sure that the header strings follow HTTP specification
  7330. -- ("Key: Value").
  7331. multipart = boolean
  7332. -- Optional, if true performs a multipart HTTP request.
  7333. -- Default is false.
  7334. -- Post only, data must be array
  7335. post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
  7336. -- Deprecated, use `data` instead. Forces `method = "POST"`.
  7337. }
  7338. `HTTPRequestResult` definition
  7339. ------------------------------
  7340. Passed to `HTTPApiTable.fetch` callback. Returned by
  7341. `HTTPApiTable.fetch_async_get`.
  7342. {
  7343. completed = true,
  7344. -- If true, the request has finished (either succeeded, failed or timed
  7345. -- out)
  7346. succeeded = true,
  7347. -- If true, the request was successful
  7348. timeout = false,
  7349. -- If true, the request timed out
  7350. code = 200,
  7351. -- HTTP status code
  7352. data = "response"
  7353. }
  7354. Authentication handler definition
  7355. ---------------------------------
  7356. Used by `minetest.register_authentication_handler`.
  7357. {
  7358. get_auth = function(name),
  7359. -- Get authentication data for existing player `name` (`nil` if player
  7360. -- doesn't exist).
  7361. -- Returns following structure:
  7362. -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
  7363. create_auth = function(name, password),
  7364. -- Create new auth data for player `name`.
  7365. -- Note that `password` is not plain-text but an arbitrary
  7366. -- representation decided by the engine.
  7367. delete_auth = function(name),
  7368. -- Delete auth data of player `name`.
  7369. -- Returns boolean indicating success (false if player is nonexistent).
  7370. set_password = function(name, password),
  7371. -- Set password of player `name` to `password`.
  7372. -- Auth data should be created if not present.
  7373. set_privileges = function(name, privileges),
  7374. -- Set privileges of player `name`.
  7375. -- `privileges` is in table form, auth data should be created if not
  7376. -- present.
  7377. reload = function(),
  7378. -- Reload authentication data from the storage location.
  7379. -- Returns boolean indicating success.
  7380. record_login = function(name),
  7381. -- Called when player joins, used for keeping track of last_login
  7382. iterate = function(),
  7383. -- Returns an iterator (use with `for` loops) for all player names
  7384. -- currently in the auth database
  7385. }
  7386. Bit Library
  7387. -----------
  7388. Functions: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
  7389. See http://bitop.luajit.org/ for advanced information.