lua_api.txt 413 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982
  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. Minetest keeps and looks for files mostly in two paths. `path_share` or `path_user`.
  27. `path_share` contains possibly read-only content for the engine (incl. games and mods).
  28. `path_user` contains mods or games installed by the user but also the users
  29. worlds or settings.
  30. With a local build (`RUN_IN_PLACE=1`) `path_share` and `path_user` both point to
  31. the build directory. For system-wide builds on Linux the share path is usually at
  32. `/usr/share/minetest` while the user path resides in `.minetest` in the home directory.
  33. Paths on other operating systems will differ.
  34. Games
  35. =====
  36. Games are looked up from:
  37. * `$path_share/games/<gameid>/`
  38. * `$path_user/games/<gameid>/`
  39. Where `<gameid>` is unique to each game.
  40. The game directory can contain the following files:
  41. * `game.conf`, with the following keys:
  42. * `title`: Required, a human-readable title to address the game, e.g. `title = Minetest Game`.
  43. * `name`: (Deprecated) same as title.
  44. * `description`: Short description to be shown in the content tab
  45. * `allowed_mapgens = <comma-separated mapgens>`
  46. e.g. `allowed_mapgens = v5,v6,flat`
  47. Mapgens not in this list are removed from the list of mapgens for the
  48. game.
  49. If not specified, all mapgens are allowed.
  50. * `disallowed_mapgens = <comma-separated mapgens>`
  51. e.g. `disallowed_mapgens = v5,v6,flat`
  52. These mapgens are removed from the list of mapgens for the game.
  53. When both `allowed_mapgens` and `disallowed_mapgens` are
  54. specified, `allowed_mapgens` is applied before
  55. `disallowed_mapgens`.
  56. * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
  57. e.g. `disallowed_mapgen_settings = mgv5_spflags`
  58. These mapgen settings are hidden for this game in the world creation
  59. dialog and game start menu. Add `seed` to hide the seed input field.
  60. * `disabled_settings = <comma-separated settings>`
  61. e.g. `disabled_settings = enable_damage, creative_mode`
  62. These settings are hidden for this game in the "Start game" tab
  63. and will be initialized as `false` when the game is started.
  64. Prepend a setting name with an exclamation mark to initialize it to `true`
  65. (this does not work for `enable_server`).
  66. Only these settings are supported:
  67. `enable_damage`, `creative_mode`, `enable_server`.
  68. * `map_persistent`: Specifies whether newly created worlds should use
  69. a persistent map backend. Defaults to `true` (= "sqlite3")
  70. * `author`: The author of the game. It only appears when downloaded from
  71. ContentDB.
  72. * `release`: Ignore this: Should only ever be set by ContentDB, as it is
  73. an internal ID used to track versions.
  74. * `minetest.conf`:
  75. Used to set default settings when running this game.
  76. * `settingtypes.txt`:
  77. In the same format as the one in builtin.
  78. This settingtypes.txt will be parsed by the menu and the settings will be
  79. displayed in the "Games" category in the advanced settings tab.
  80. * If the game contains a folder called `textures` the server will load it as a
  81. texturepack, overriding mod textures.
  82. Any server texturepack will override mod textures and the game texturepack.
  83. Menu images
  84. -----------
  85. Games can provide custom main menu images. They are put inside a `menu`
  86. directory inside the game directory.
  87. The images are named `$identifier.png`, where `$identifier` is one of
  88. `overlay`, `background`, `footer`, `header`.
  89. If you want to specify multiple images for one identifier, add additional
  90. images named like `$identifier.$n.png`, with an ascending number $n starting
  91. with 1, and a random image will be chosen from the provided ones.
  92. Menu music
  93. -----------
  94. Games can provide custom main menu music. They are put inside a `menu`
  95. directory inside the game directory.
  96. The music files are named `theme.ogg`.
  97. If you want to specify multiple music files for one game, add additional
  98. images named like `theme.$n.ogg`, with an ascending number $n starting
  99. with 1 (max 10), and a random music file will be chosen from the provided ones.
  100. Mods
  101. ====
  102. Mod load path
  103. -------------
  104. Paths are relative to the directories listed in the [Paths] section above.
  105. * `games/<gameid>/mods/`
  106. * `mods/`
  107. * `worlds/<worldname>/worldmods/`
  108. World-specific games
  109. --------------------
  110. It is possible to include a game in a world; in this case, no mods or
  111. games are loaded or checked from anywhere else.
  112. This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
  113. directory exists.
  114. Mods should then be placed in `<worldname>/game/mods/`.
  115. Modpacks
  116. --------
  117. Mods can be put in a subdirectory, if the parent directory, which otherwise
  118. should be a mod, contains a file named `modpack.conf`.
  119. The file is a key-value store of modpack details.
  120. * `name`: The modpack name. Allows Minetest to determine the modpack name even
  121. if the folder is wrongly named.
  122. * `description`: Description of mod to be shown in the Mods tab of the main
  123. menu.
  124. * `author`: The author of the modpack. It only appears when downloaded from
  125. ContentDB.
  126. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  127. internal ID used to track versions.
  128. * `title`: A human-readable title to address the modpack.
  129. Note: to support 0.4.x, please also create an empty modpack.txt file.
  130. Mod directory structure
  131. -----------------------
  132. mods
  133. ├── modname
  134. │   ├── mod.conf
  135. │   ├── screenshot.png
  136. │   ├── settingtypes.txt
  137. │   ├── init.lua
  138. │   ├── models
  139. │   ├── textures
  140. │   │   ├── modname_stuff.png
  141. │   │   ├── modname_stuff_normal.png
  142. │   │   ├── modname_something_else.png
  143. │   │   ├── subfolder_foo
  144. │   │   │ ├── modname_more_stuff.png
  145. │   │   │ └── another_subfolder
  146. │   │   └── bar_subfolder
  147. │   ├── sounds
  148. │   ├── media
  149. │   ├── locale
  150. │   └── <custom data>
  151. └── another
  152. ### modname
  153. The location of this directory can be fetched by using
  154. `minetest.get_modpath(modname)`.
  155. ### mod.conf
  156. A `Settings` file that provides meta information about the mod.
  157. * `name`: The mod name. Allows Minetest to determine the mod name even if the
  158. folder is wrongly named.
  159. * `description`: Description of mod to be shown in the Mods tab of the main
  160. menu.
  161. * `depends`: A comma separated list of dependencies. These are mods that must be
  162. loaded before this mod.
  163. * `optional_depends`: A comma separated list of optional dependencies.
  164. Like a dependency, but no error if the mod doesn't exist.
  165. * `author`: The author of the mod. It only appears when downloaded from
  166. ContentDB.
  167. * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
  168. internal ID used to track versions.
  169. * `title`: A human-readable title to address the mod.
  170. ### `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. For this to work correctly, that mod must have
  225. `experimental` as a 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, 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, define dungeon nodes in biome definitions instead.
  262. ### Aliases for Mapgen V6
  263. #### Essential
  264. * `mapgen_stone`
  265. * `mapgen_water_source`
  266. * `mapgen_lava_source`
  267. * `mapgen_dirt`
  268. * `mapgen_dirt_with_grass`
  269. * `mapgen_sand`
  270. * `mapgen_tree`
  271. * `mapgen_leaves`
  272. * `mapgen_apple`
  273. * `mapgen_cobble`
  274. #### Optional
  275. * `mapgen_gravel` (falls back to stone)
  276. * `mapgen_desert_stone` (falls back to stone)
  277. * `mapgen_desert_sand` (falls back to sand)
  278. * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
  279. * `mapgen_snowblock` (falls back to dirt_with_grass)
  280. * `mapgen_snow` (not placed if missing)
  281. * `mapgen_ice` (falls back to water_source)
  282. * `mapgen_jungletree` (falls back to tree)
  283. * `mapgen_jungleleaves` (falls back to leaves)
  284. * `mapgen_junglegrass` (not placed if missing)
  285. * `mapgen_pine_tree` (falls back to tree)
  286. * `mapgen_pine_needles` (falls back to leaves)
  287. * `mapgen_stair_cobble` (falls back to cobble)
  288. * `mapgen_mossycobble` (falls back to cobble)
  289. * `mapgen_stair_desert_stone` (falls back to desert_stone)
  290. ### Setting the node used in Mapgen Singlenode
  291. By default the world is filled with air nodes. To set a different node use e.g.:
  292. minetest.register_alias("mapgen_singlenode", "default:stone")
  293. Textures
  294. ========
  295. Mods should generally prefix their textures with `modname_`, e.g. given
  296. the mod name `foomod`, a texture could be called:
  297. foomod_foothing.png
  298. Textures are referred to by their complete name, or alternatively by
  299. stripping out the file extension:
  300. * e.g. `foomod_foothing.png`
  301. * e.g. `foomod_foothing`
  302. Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
  303. and Targa (`.tga`).
  304. Since better alternatives exist, the latter two may be removed in the future.
  305. Texture modifiers
  306. -----------------
  307. There are various texture modifiers that can be used
  308. to let the client generate textures on-the-fly.
  309. The modifiers are applied directly in sRGB colorspace,
  310. i.e. without gamma-correction.
  311. ### Texture overlaying
  312. Textures can be overlaid by putting a `^` between them.
  313. Example:
  314. default_dirt.png^default_grass_side.png
  315. `default_grass_side.png` is overlaid over `default_dirt.png`.
  316. The texture with the lower resolution will be automatically upscaled to
  317. the higher resolution texture.
  318. ### Texture grouping
  319. Textures can be grouped together by enclosing them in `(` and `)`.
  320. Example: `cobble.png^(thing1.png^thing2.png)`
  321. A texture for `thing1.png^thing2.png` is created and the resulting
  322. texture is overlaid on top of `cobble.png`.
  323. ### Escaping
  324. Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
  325. passing complex texture names as arguments. Escaping is done with backslash and
  326. is required for `^` and `:`.
  327. Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
  328. The lower 50 percent of `color.png^[mask:trans.png` are overlaid
  329. on top of `cobble.png`.
  330. ### Advanced texture modifiers
  331. #### Crack
  332. * `[crack:<n>:<p>`
  333. * `[cracko:<n>:<p>`
  334. * `[crack:<t>:<n>:<p>`
  335. * `[cracko:<t>:<n>:<p>`
  336. Parameters:
  337. * `<t>`: tile count (in each direction)
  338. * `<n>`: animation frame count
  339. * `<p>`: current animation frame
  340. Draw a step of the crack animation on the texture.
  341. `crack` draws it normally, while `cracko` lays it over, keeping transparent
  342. pixels intact.
  343. Example:
  344. default_cobble.png^[crack:10:1
  345. #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
  346. * `<w>`: width
  347. * `<h>`: height
  348. * `<x>`: x position
  349. * `<y>`: y position
  350. * `<file>`: texture to combine
  351. Creates a texture of size `<w>` times `<h>` and blits the listed files to their
  352. specified coordinates.
  353. Example:
  354. [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
  355. #### `[resize:<w>x<h>`
  356. Resizes the texture to the given dimensions.
  357. Example:
  358. default_sandstone.png^[resize:16x16
  359. #### `[opacity:<r>`
  360. Makes the base image transparent according to the given ratio.
  361. `r` must be between 0 (transparent) and 255 (opaque).
  362. Example:
  363. default_sandstone.png^[opacity:127
  364. #### `[invert:<mode>`
  365. Inverts the given channels of the base image.
  366. Mode may contain the characters "r", "g", "b", "a".
  367. Only the channels that are mentioned in the mode string will be inverted.
  368. Example:
  369. default_apple.png^[invert:rgb
  370. #### `[brighten`
  371. Brightens the texture.
  372. Example:
  373. tnt_tnt_side.png^[brighten
  374. #### `[noalpha`
  375. Makes the texture completely opaque.
  376. Example:
  377. default_leaves.png^[noalpha
  378. #### `[makealpha:<r>,<g>,<b>`
  379. Convert one color to transparency.
  380. Example:
  381. default_cobble.png^[makealpha:128,128,128
  382. #### `[transform<t>`
  383. * `<t>`: transformation(s) to apply
  384. Rotates and/or flips the image.
  385. `<t>` can be a number (between 0 and 7) or a transform name.
  386. Rotations are counter-clockwise.
  387. 0 I identity
  388. 1 R90 rotate by 90 degrees
  389. 2 R180 rotate by 180 degrees
  390. 3 R270 rotate by 270 degrees
  391. 4 FX flip X
  392. 5 FXR90 flip X then rotate by 90 degrees
  393. 6 FY flip Y
  394. 7 FYR90 flip Y then rotate by 90 degrees
  395. Example:
  396. default_stone.png^[transformFXR90
  397. #### `[inventorycube{<top>{<left>{<right>`
  398. Escaping does not apply here and `^` is replaced by `&` in texture names
  399. instead.
  400. Create an inventory cube texture using the side textures.
  401. Example:
  402. [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
  403. Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
  404. `dirt.png^grass_side.png` textures
  405. #### `[lowpart:<percent>:<file>`
  406. Blit the lower `<percent>`% part of `<file>` on the texture.
  407. Example:
  408. base.png^[lowpart:25:overlay.png
  409. #### `[verticalframe:<t>:<n>`
  410. * `<t>`: animation frame count
  411. * `<n>`: current animation frame
  412. Crops the texture to a frame of a vertical animation.
  413. Example:
  414. default_torch_animated.png^[verticalframe:16:8
  415. #### `[mask:<file>`
  416. Apply a mask to the base image.
  417. The mask is applied using binary AND.
  418. #### `[sheet:<w>x<h>:<x>,<y>`
  419. Retrieves a tile at position x,y from the base image
  420. which it assumes to be a tilesheet with dimensions w,h.
  421. #### `[colorize:<color>:<ratio>`
  422. Colorize the textures with the given color.
  423. `<color>` is specified as a `ColorString`.
  424. `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
  425. it is an int, then it specifies how far to interpolate between the
  426. colors where 0 is only the texture color and 255 is only `<color>`. If
  427. omitted, the alpha of `<color>` will be used as the ratio. If it is
  428. the word "`alpha`", then each texture pixel will contain the RGB of
  429. `<color>` and the alpha of `<color>` multiplied by the alpha of the
  430. texture pixel.
  431. #### `[multiply:<color>`
  432. Multiplies texture colors with the given color.
  433. `<color>` is specified as a `ColorString`.
  434. Result is more like what you'd expect if you put a color on top of another
  435. color, meaning white surfaces get a lot of your new color while black parts
  436. don't change very much.
  437. #### `[png:<base64>`
  438. Embed a base64 encoded PNG image in the texture string.
  439. You can produce a valid string for this by calling
  440. `minetest.encode_base64(minetest.encode_png(tex))`,
  441. refer to the documentation of these functions for details.
  442. You can use this to send disposable images such as captchas
  443. to individual clients, or render things that would be too
  444. expensive to compose with `[combine:`.
  445. IMPORTANT: Avoid sending large images this way.
  446. This is not a replacement for asset files, do not use it to do anything
  447. that you could instead achieve by just using a file.
  448. In particular consider `minetest.dynamic_add_media` and test whether
  449. using other texture modifiers could result in a shorter string than
  450. embedding a whole image, this may vary by use case.
  451. Hardware coloring
  452. -----------------
  453. The goal of hardware coloring is to simplify the creation of
  454. colorful nodes. If your textures use the same pattern, and they only
  455. differ in their color (like colored wool blocks), you can use hardware
  456. coloring instead of creating and managing many texture files.
  457. All of these methods use color multiplication (so a white-black texture
  458. with red coloring will result in red-black color).
  459. ### Static coloring
  460. This method is useful if you wish to create nodes/items with
  461. the same texture, in different colors, each in a new node/item definition.
  462. #### Global color
  463. When you register an item or node, set its `color` field (which accepts a
  464. `ColorSpec`) to the desired color.
  465. An `ItemStack`'s static color can be overwritten by the `color` metadata
  466. field. If you set that field to a `ColorString`, that color will be used.
  467. #### Tile color
  468. Each tile may have an individual static color, which overwrites every
  469. other coloring method. To disable the coloring of a face,
  470. set its color to white (because multiplying with white does nothing).
  471. You can set the `color` property of the tiles in the node's definition
  472. if the tile is in table format.
  473. ### Palettes
  474. For nodes and items which can have many colors, a palette is more
  475. suitable. A palette is a texture, which can contain up to 256 pixels.
  476. Each pixel is one possible color for the node/item.
  477. You can register one node/item, which can have up to 256 colors.
  478. #### Palette indexing
  479. When using palettes, you always provide a pixel index for the given
  480. node or `ItemStack`. The palette is read from left to right and from
  481. top to bottom. If the palette has less than 256 pixels, then it is
  482. stretched to contain exactly 256 pixels (after arranging the pixels
  483. to one line). The indexing starts from 0.
  484. Examples:
  485. * 16x16 palette, index = 0: the top left corner
  486. * 16x16 palette, index = 4: the fifth pixel in the first row
  487. * 16x16 palette, index = 16: the pixel below the top left corner
  488. * 16x16 palette, index = 255: the bottom right corner
  489. * 2 (width) x 4 (height) palette, index = 31: the top left corner.
  490. The palette has 8 pixels, so each pixel is stretched to 32 pixels,
  491. to ensure the total 256 pixels.
  492. * 2x4 palette, index = 32: the top right corner
  493. * 2x4 palette, index = 63: the top right corner
  494. * 2x4 palette, index = 64: the pixel below the top left corner
  495. #### Using palettes with items
  496. When registering an item, set the item definition's `palette` field to
  497. a texture. You can also use texture modifiers.
  498. The `ItemStack`'s color depends on the `palette_index` field of the
  499. stack's metadata. `palette_index` is an integer, which specifies the
  500. index of the pixel to use.
  501. #### Linking palettes with nodes
  502. When registering a node, set the item definition's `palette` field to
  503. a texture. You can also use texture modifiers.
  504. The node's color depends on its `param2`, so you also must set an
  505. appropriate `paramtype2`:
  506. * `paramtype2 = "color"` for nodes which use their full `param2` for
  507. palette indexing. These nodes can have 256 different colors.
  508. The palette should contain 256 pixels.
  509. * `paramtype2 = "colorwallmounted"` for nodes which use the first
  510. five bits (most significant) of `param2` for palette indexing.
  511. The remaining three bits are describing rotation, as in `wallmounted`
  512. paramtype2. Division by 8 yields the palette index (without stretching the
  513. palette). These nodes can have 32 different colors, and the palette
  514. should contain 32 pixels.
  515. Examples:
  516. * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
  517. pixel will be picked from the palette.
  518. * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
  519. pixel will be picked from the palette.
  520. * `paramtype2 = "colorfacedir"` for nodes which use the first
  521. three bits of `param2` for palette indexing. The remaining
  522. five bits are describing rotation, as in `facedir` paramtype2.
  523. Division by 32 yields the palette index (without stretching the
  524. palette). These nodes can have 8 different colors, and the
  525. palette should contain 8 pixels.
  526. Examples:
  527. * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
  528. first (= 0 + 1) pixel will be picked from the palette.
  529. * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
  530. second (= 1 + 1) pixel will be picked from the palette.
  531. * `paramtype2 = "color4dir"` for nodes which use the first
  532. six bits of `param2` for palette indexing. The remaining
  533. two bits are describing rotation, as in `4dir` paramtype2.
  534. Division by 4 yields the palette index (without stretching the
  535. palette). These nodes can have 64 different colors, and the
  536. palette should contain 64 pixels.
  537. Examples:
  538. * `param2 = 17` is 4 * 4 + 1, so the rotation is 1 and the
  539. fifth (= 4 + 1) pixel will be picked from the palette.
  540. * `param2 = 35` is 8 * 4 + 3, so the rotation is 3 and the
  541. ninth (= 8 + 1) pixel will be picked from the palette.
  542. To colorize a node on the map, set its `param2` value (according
  543. to the node's paramtype2).
  544. ### Conversion between nodes in the inventory and on the map
  545. Static coloring is the same for both cases, there is no need
  546. for conversion.
  547. If the `ItemStack`'s metadata contains the `color` field, it will be
  548. lost on placement, because nodes on the map can only use palettes.
  549. If the `ItemStack`'s metadata contains the `palette_index` field, it is
  550. automatically transferred between node and item forms by the engine,
  551. when a player digs or places a colored node.
  552. You can disable this feature by setting the `drop` field of the node
  553. to itself (without metadata).
  554. To transfer the color to a special drop, you need a drop table.
  555. Example:
  556. minetest.register_node("mod:stone", {
  557. description = "Stone",
  558. tiles = {"default_stone.png"},
  559. paramtype2 = "color",
  560. palette = "palette.png",
  561. drop = {
  562. items = {
  563. -- assume that mod:cobblestone also has the same palette
  564. {items = {"mod:cobblestone"}, inherit_color = true },
  565. }
  566. }
  567. })
  568. ### Colored items in craft recipes
  569. Craft recipes only support item strings, but fortunately item strings
  570. can also contain metadata. Example craft recipe registration:
  571. minetest.register_craft({
  572. output = minetest.itemstring_with_palette("wool:block", 3),
  573. type = "shapeless",
  574. recipe = {
  575. "wool:block",
  576. "dye:red",
  577. },
  578. })
  579. To set the `color` field, you can use `minetest.itemstring_with_color`.
  580. Metadata field filtering in the `recipe` field are not supported yet,
  581. so the craft output is independent of the color of the ingredients.
  582. Soft texture overlay
  583. --------------------
  584. Sometimes hardware coloring is not enough, because it affects the
  585. whole tile. Soft texture overlays were added to Minetest to allow
  586. the dynamic coloring of only specific parts of the node's texture.
  587. For example a grass block may have colored grass, while keeping the
  588. dirt brown.
  589. These overlays are 'soft', because unlike texture modifiers, the layers
  590. are not merged in the memory, but they are simply drawn on top of each
  591. other. This allows different hardware coloring, but also means that
  592. tiles with overlays are drawn slower. Using too much overlays might
  593. cause FPS loss.
  594. For inventory and wield images you can specify overlays which
  595. hardware coloring does not modify. You have to set `inventory_overlay`
  596. and `wield_overlay` fields to an image name.
  597. To define a node overlay, simply set the `overlay_tiles` field of the node
  598. definition. These tiles are defined in the same way as plain tiles:
  599. they can have a texture name, color etc.
  600. To skip one face, set that overlay tile to an empty string.
  601. Example (colored grass block):
  602. minetest.register_node("default:dirt_with_grass", {
  603. description = "Dirt with Grass",
  604. -- Regular tiles, as usual
  605. -- The dirt tile disables palette coloring
  606. tiles = {{name = "default_grass.png"},
  607. {name = "default_dirt.png", color = "white"}},
  608. -- Overlay tiles: define them in the same style
  609. -- The top and bottom tile does not have overlay
  610. overlay_tiles = {"", "",
  611. {name = "default_grass_side.png"}},
  612. -- Global color, used in inventory
  613. color = "green",
  614. -- Palette in the world
  615. paramtype2 = "color",
  616. palette = "default_foilage.png",
  617. })
  618. Sounds
  619. ======
  620. Only Ogg Vorbis files are supported.
  621. For positional playing of sounds, only single-channel (mono) files are
  622. supported. Otherwise OpenAL will play them non-positionally.
  623. Mods should generally prefix their sounds with `modname_`, e.g. given
  624. the mod name "`foomod`", a sound could be called:
  625. foomod_foosound.ogg
  626. Sounds are referred to by their name with a dot, a single digit and the
  627. file extension stripped out. When a sound is played, the actual sound file
  628. is chosen randomly from the matching sounds.
  629. When playing the sound `foomod_foosound`, the sound is chosen randomly
  630. from the available ones of the following files:
  631. * `foomod_foosound.ogg`
  632. * `foomod_foosound.0.ogg`
  633. * `foomod_foosound.1.ogg`
  634. * (...)
  635. * `foomod_foosound.9.ogg`
  636. Examples of sound parameter tables:
  637. -- Play locationless on all clients
  638. {
  639. gain = 1.0, -- default
  640. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  641. pitch = 1.0, -- default
  642. }
  643. -- Play locationless to one player
  644. {
  645. to_player = name,
  646. gain = 1.0, -- default
  647. fade = 0.0, -- default, change to a value > 0 to fade the sound in
  648. pitch = 1.0, -- default
  649. }
  650. -- Play locationless to one player, looped
  651. {
  652. to_player = name,
  653. gain = 1.0, -- default
  654. loop = true,
  655. }
  656. -- Play at a location
  657. {
  658. pos = {x = 1, y = 2, z = 3},
  659. gain = 1.0, -- default
  660. max_hear_distance = 32, -- default, uses a Euclidean metric
  661. }
  662. -- Play connected to an object, looped
  663. {
  664. object = <an ObjectRef>,
  665. gain = 1.0, -- default
  666. max_hear_distance = 32, -- default, uses a Euclidean metric
  667. loop = true,
  668. }
  669. -- Play at a location, heard by anyone *but* the given player
  670. {
  671. pos = {x = 32, y = 0, z = 100},
  672. max_hear_distance = 40,
  673. exclude_player = name,
  674. }
  675. Looped sounds must either be connected to an object or played locationless to
  676. one player using `to_player = name`.
  677. A positional sound will only be heard by players that are within
  678. `max_hear_distance` of the sound position, at the start of the sound.
  679. `exclude_player = name` can be applied to locationless, positional and object-
  680. bound sounds to exclude a single player from hearing them.
  681. `SimpleSoundSpec`
  682. -----------------
  683. Specifies a sound name, gain (=volume) and pitch.
  684. This is either a string or a table.
  685. In string form, you just specify the sound name or
  686. the empty string for no sound.
  687. Table form has the following fields:
  688. * `name`: Sound name
  689. * `gain`: Volume (`1.0` = 100%)
  690. * `pitch`: Pitch (`1.0` = 100%)
  691. `gain` and `pitch` are optional and default to `1.0`.
  692. Examples:
  693. * `""`: No sound
  694. * `{}`: No sound
  695. * `"default_place_node"`: Play e.g. `default_place_node.ogg`
  696. * `{name = "default_place_node"}`: Same as above
  697. * `{name = "default_place_node", gain = 0.5}`: 50% volume
  698. * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
  699. Special sound files
  700. -------------------
  701. These sound files are played back by the engine if provided.
  702. * `player_damage`: Played when the local player takes damage (gain = 0.5)
  703. * `player_falling_damage`: Played when the local player takes
  704. damage by falling (gain = 0.5)
  705. * `player_jump`: Played when the local player jumps
  706. * `default_dig_<groupname>`: Default node digging sound (gain = 0.5)
  707. (see node sound definition for details)
  708. Registered definitions
  709. ======================
  710. Anything added using certain [Registration functions] gets added to one or more
  711. of the global [Registered definition tables].
  712. Note that in some cases you will stumble upon things that are not contained
  713. in these tables (e.g. when a mod has been removed). Always check for
  714. existence before trying to access the fields.
  715. Example:
  716. All nodes registered with `minetest.register_node` get added to the table
  717. `minetest.registered_nodes`.
  718. If you want to check the drawtype of a node, you could do it like this:
  719. local def = minetest.registered_nodes[nodename]
  720. local drawtype = def and def.drawtype
  721. Nodes
  722. =====
  723. Nodes are the bulk data of the world: cubes and other things that take the
  724. space of a cube. Huge amounts of them are handled efficiently, but they
  725. are quite static.
  726. The definition of a node is stored and can be accessed by using
  727. minetest.registered_nodes[node.name]
  728. See [Registered definitions].
  729. Nodes are passed by value between Lua and the engine.
  730. They are represented by a table:
  731. {name="name", param1=num, param2=num}
  732. `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
  733. them for certain automated functions. If you don't use these functions, you can
  734. use them to store arbitrary values.
  735. Node paramtypes
  736. ---------------
  737. The functions of `param1` and `param2` are determined by certain fields in the
  738. node definition.
  739. The function of `param1` is determined by `paramtype` in node definition.
  740. `param1` is reserved for the engine when `paramtype != "none"`.
  741. * `paramtype = "light"`
  742. * The value stores light with and without sun in its lower and upper 4 bits
  743. respectively.
  744. * Required by a light source node to enable spreading its light.
  745. * Required by the following drawtypes as they determine their visual
  746. brightness from their internal light value:
  747. * torchlike
  748. * signlike
  749. * firelike
  750. * fencelike
  751. * raillike
  752. * nodebox
  753. * mesh
  754. * plantlike
  755. * plantlike_rooted
  756. * `paramtype = "none"`
  757. * `param1` will not be used by the engine and can be used to store
  758. an arbitrary value
  759. The function of `param2` is determined by `paramtype2` in node definition.
  760. `param2` is reserved for the engine when `paramtype2 != "none"`.
  761. * `paramtype2 = "flowingliquid"`
  762. * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
  763. * The liquid level and a flag of the liquid are stored in `param2`
  764. * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
  765. see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
  766. to access/manipulate the content of this field
  767. * Bit 3: If set, liquid is flowing downwards (no graphical effect)
  768. * `paramtype2 = "wallmounted"`
  769. * Supported drawtypes: "torchlike", "signlike", "plantlike",
  770. "plantlike_rooted", "normal", "nodebox", "mesh"
  771. * The rotation of the node is stored in `param2`
  772. * Node is 'mounted'/facing towards one of 6 directions
  773. * You can make this value by using `minetest.dir_to_wallmounted()`
  774. * Values range 0 - 5
  775. * The value denotes at which direction the node is "mounted":
  776. 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z-
  777. * By default, on placement the param2 is automatically set to the
  778. appropriate rotation, depending on which side was pointed at
  779. * `paramtype2 = "facedir"`
  780. * Supported drawtypes: "normal", "nodebox", "mesh"
  781. * The rotation of the node is stored in `param2`.
  782. * Node is rotated around face and axis; 24 rotations in total.
  783. * Can be made by using `minetest.dir_to_facedir()`.
  784. * Chests and furnaces can be rotated that way, and also 'flipped'
  785. * Values range 0 - 23
  786. * facedir / 4 = axis direction:
  787. 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y-
  788. * The node is rotated 90 degrees around the X or Z axis so that its top face
  789. points in the desired direction. For the y- direction, it's rotated 180
  790. degrees around the Z axis.
  791. * facedir modulo 4 = left-handed rotation around the specified axis, in 90° steps.
  792. * By default, on placement the param2 is automatically set to the
  793. horizontal direction the player was looking at (values 0-3)
  794. * Special case: If the node is a connected nodebox, the nodebox
  795. will NOT rotate, only the textures will.
  796. * `paramtype2 = "4dir"`
  797. * Supported drawtypes: "normal", "nodebox", "mesh"
  798. * The rotation of the node is stored in `param2`.
  799. * Allows node to be rotated horizontally, 4 rotations in total
  800. * Can be made by using `minetest.dir_to_fourdir()`.
  801. * Chests and furnaces can be rotated that way, but not flipped
  802. * Values range 0 - 3
  803. * 4dir modulo 4 = rotation
  804. * Otherwise, behavior is identical to facedir
  805. * `paramtype2 = "leveled"`
  806. * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
  807. * Leveled nodebox:
  808. * The level of the top face of the nodebox is stored in `param2`.
  809. * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
  810. nodeboxes.
  811. * The nodebox height is (`param2` / 64) nodes.
  812. * The maximum accepted value of `param2` is 127.
  813. * Rooted plantlike:
  814. * The height of the 'plantlike' section is stored in `param2`.
  815. * The height is (`param2` / 16) nodes.
  816. * `paramtype2 = "degrotate"`
  817. * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
  818. stored in `param2`.
  819. * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
  820. get the actual rotation in degrees of the node.
  821. * `paramtype2 = "meshoptions"`
  822. * Only valid for "plantlike" drawtype. `param2` encodes the shape and
  823. optional modifiers of the "plant". `param2` is a bitfield.
  824. * Bits 0 to 2 select the shape.
  825. Use only one of the values below:
  826. * 0 = an "x" shaped plant (ordinary plant)
  827. * 1 = a "+" shaped plant (just rotated 45 degrees)
  828. * 2 = a "*" shaped plant with 3 faces instead of 2
  829. * 3 = a "#" shaped plant with 4 faces instead of 2
  830. * 4 = a "#" shaped plant with 4 faces that lean outwards
  831. * 5-7 are unused and reserved for future meshes.
  832. * Bits 3 to 7 are used to enable any number of optional modifiers.
  833. Just add the corresponding value(s) below to `param2`:
  834. * 8 - Makes the plant slightly vary placement horizontally
  835. * 16 - Makes the plant mesh 1.4x larger
  836. * 32 - Moves each face randomly a small bit down (1/8 max)
  837. * values 64 and 128 (bits 6-7) are reserved for future use.
  838. * Example: `param2 = 0` selects a normal "x" shaped plant
  839. * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
  840. * `paramtype2 = "color"`
  841. * `param2` tells which color is picked from the palette.
  842. The palette should have 256 pixels.
  843. * `paramtype2 = "colorfacedir"`
  844. * Same as `facedir`, but with colors.
  845. * The first three bits of `param2` tells which color is picked from the
  846. palette. The palette should have 8 pixels.
  847. * `paramtype2 = "color4dir"`
  848. * Same as `facedir`, but with colors.
  849. * The first six bits of `param2` tells which color is picked from the
  850. palette. The palette should have 64 pixels.
  851. * `paramtype2 = "colorwallmounted"`
  852. * Same as `wallmounted`, but with colors.
  853. * The first five bits of `param2` tells which color is picked from the
  854. palette. The palette should have 32 pixels.
  855. * `paramtype2 = "glasslikeliquidlevel"`
  856. * Only valid for "glasslike_framed" or "glasslike_framed_optional"
  857. drawtypes. "glasslike_framed_optional" nodes are only affected if the
  858. "Connected Glass" setting is enabled.
  859. * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
  860. full.
  861. * Bits 6 and 7 modify the appearance of the frame and node faces. One or
  862. both of these values may be added to `param2`:
  863. * 64 - Makes the node not connect with neighbors above or below it.
  864. * 128 - Makes the node not connect with neighbors to its sides.
  865. * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
  866. * `paramtype2 = "colordegrotate"`
  867. * Same as `degrotate`, but with colors.
  868. * The first (most-significant) three bits of `param2` tells which color
  869. is picked from the palette. The palette should have 8 pixels.
  870. * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
  871. * `paramtype2 = "none"`
  872. * `param2` will not be used by the engine and can be used to store
  873. an arbitrary value
  874. Nodes can also contain extra data. See [Node Metadata].
  875. Node drawtypes
  876. --------------
  877. There are a bunch of different looking node types.
  878. Look for examples in `games/devtest` or `games/minetest_game`.
  879. * `normal`
  880. * A node-sized cube.
  881. * `airlike`
  882. * Invisible, uses no texture.
  883. * `liquid`
  884. * The cubic source node for a liquid.
  885. * Faces bordering to the same node are never rendered.
  886. * Connects to node specified in `liquid_alternative_flowing`.
  887. * You *must* set `liquid_alternative_source` to the node's own name.
  888. * Use `backface_culling = false` for the tiles you want to make
  889. visible when inside the node.
  890. * `flowingliquid`
  891. * The flowing version of a liquid, appears with various heights and slopes.
  892. * Faces bordering to the same node are never rendered.
  893. * Connects to node specified in `liquid_alternative_source`.
  894. * You *must* set `liquid_alternative_flowing` to the node's own name.
  895. * Node textures are defined with `special_tiles` where the first tile
  896. is for the top and bottom faces and the second tile is for the side
  897. faces.
  898. * `tiles` is used for the item/inventory/wield image rendering.
  899. * Use `backface_culling = false` for the special tiles you want to make
  900. visible when inside the node
  901. * `glasslike`
  902. * Often used for partially-transparent nodes.
  903. * Only external sides of textures are visible.
  904. * `glasslike_framed`
  905. * All face-connected nodes are drawn as one volume within a surrounding
  906. frame.
  907. * The frame appearance is generated from the edges of the first texture
  908. specified in `tiles`. The width of the edges used are 1/16th of texture
  909. size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
  910. * The glass 'shine' (or other desired detail) on each node face is supplied
  911. by the second texture specified in `tiles`.
  912. * `glasslike_framed_optional`
  913. * This switches between the above 2 drawtypes according to the menu setting
  914. 'Connected Glass'.
  915. * `allfaces`
  916. * Often used for partially-transparent nodes.
  917. * External and internal sides of textures are visible.
  918. * `allfaces_optional`
  919. * Often used for leaves nodes.
  920. * This switches between `normal`, `glasslike` and `allfaces` according to
  921. the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
  922. * With 'Simple Leaves' selected, the texture specified in `special_tiles`
  923. is used instead, if present. This allows a visually thicker texture to be
  924. used to compensate for how `glasslike` reduces visual thickness.
  925. * `torchlike`
  926. * A single vertical texture.
  927. * If `paramtype2="[color]wallmounted"`:
  928. * If placed on top of a node, uses the first texture specified in `tiles`.
  929. * If placed against the underside of a node, uses the second texture
  930. specified in `tiles`.
  931. * If placed on the side of a node, uses the third texture specified in
  932. `tiles` and is perpendicular to that node.
  933. * If `paramtype2="none"`:
  934. * Will be rendered as if placed on top of a node (see
  935. above) and only the first texture is used.
  936. * `signlike`
  937. * A single texture parallel to, and mounted against, the top, underside or
  938. side of a node.
  939. * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
  940. * If `paramtype2="none"`, it will always be on the floor.
  941. * `plantlike`
  942. * Two vertical and diagonal textures at right-angles to each other.
  943. * See `paramtype2 = "meshoptions"` above for other options.
  944. * `firelike`
  945. * When above a flat surface, appears as 6 textures, the central 2 as
  946. `plantlike` plus 4 more surrounding those.
  947. * If not above a surface the central 2 do not appear, but the texture
  948. appears against the faces of surrounding nodes if they are present.
  949. * `fencelike`
  950. * A 3D model suitable for a wooden fence.
  951. * One placed node appears as a single vertical post.
  952. * Adjacently-placed nodes cause horizontal bars to appear between them.
  953. * `raillike`
  954. * Often used for tracks for mining carts.
  955. * Requires 4 textures to be specified in `tiles`, in order: Straight,
  956. curved, t-junction, crossing.
  957. * Each placed node automatically switches to a suitable rotated texture
  958. determined by the adjacent `raillike` nodes, in order to create a
  959. continuous track network.
  960. * Becomes a sloping node if placed against stepped nodes.
  961. * `nodebox`
  962. * Often used for stairs and slabs.
  963. * Allows defining nodes consisting of an arbitrary number of boxes.
  964. * See [Node boxes] below for more information.
  965. * `mesh`
  966. * Uses models for nodes.
  967. * Tiles should hold model materials textures.
  968. * Only static meshes are implemented.
  969. * For supported model formats see Irrlicht engine documentation.
  970. * `plantlike_rooted`
  971. * Enables underwater `plantlike` without air bubbles around the nodes.
  972. * Consists of a base cube at the co-ordinates of the node plus a
  973. `plantlike` extension above
  974. * If `paramtype2="leveled", the `plantlike` extension has a height
  975. of `param2 / 16` nodes, otherwise it's the height of 1 node
  976. * If `paramtype2="wallmounted"`, the `plantlike` extension
  977. will be at one of the corresponding 6 sides of the base cube.
  978. Also, the base cube rotates like a `normal` cube would
  979. * The `plantlike` extension visually passes through any nodes above the
  980. base cube without affecting them.
  981. * The base cube texture tiles are defined as normal, the `plantlike`
  982. extension uses the defined special tile, for example:
  983. `special_tiles = {{name = "default_papyrus.png"}},`
  984. `*_optional` drawtypes need less rendering time if deactivated
  985. (always client-side).
  986. Node boxes
  987. ----------
  988. Node selection boxes are defined using "node boxes".
  989. A nodebox is defined as any of:
  990. {
  991. -- A normal cube; the default in most things
  992. type = "regular"
  993. }
  994. {
  995. -- A fixed box (or boxes) (facedir param2 is used, if applicable)
  996. type = "fixed",
  997. fixed = box OR {box1, box2, ...}
  998. }
  999. {
  1000. -- A variable height box (or boxes) with the top face position defined
  1001. -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
  1002. -- by param2.
  1003. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
  1004. type = "leveled",
  1005. fixed = box OR {box1, box2, ...}
  1006. }
  1007. {
  1008. -- A box like the selection box for torches
  1009. -- (wallmounted param2 is used, if applicable)
  1010. type = "wallmounted",
  1011. wall_top = box,
  1012. wall_bottom = box,
  1013. wall_side = box
  1014. }
  1015. {
  1016. -- A node that has optional boxes depending on neighboring nodes'
  1017. -- presence and type. See also `connects_to`.
  1018. type = "connected",
  1019. fixed = box OR {box1, box2, ...}
  1020. connect_top = box OR {box1, box2, ...}
  1021. connect_bottom = box OR {box1, box2, ...}
  1022. connect_front = box OR {box1, box2, ...}
  1023. connect_left = box OR {box1, box2, ...}
  1024. connect_back = box OR {box1, box2, ...}
  1025. connect_right = box OR {box1, box2, ...}
  1026. -- The following `disconnected_*` boxes are the opposites of the
  1027. -- `connect_*` ones above, i.e. when a node has no suitable neighbor
  1028. -- on the respective side, the corresponding disconnected box is drawn.
  1029. disconnected_top = box OR {box1, box2, ...}
  1030. disconnected_bottom = box OR {box1, box2, ...}
  1031. disconnected_front = box OR {box1, box2, ...}
  1032. disconnected_left = box OR {box1, box2, ...}
  1033. disconnected_back = box OR {box1, box2, ...}
  1034. disconnected_right = box OR {box1, box2, ...}
  1035. disconnected = box OR {box1, box2, ...} -- when there is *no* neighbor
  1036. disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
  1037. -- neighbors to the sides
  1038. }
  1039. A `box` is defined as:
  1040. {x1, y1, z1, x2, y2, z2}
  1041. A box of a regular node would look like:
  1042. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  1043. To avoid collision issues, keep each value within the range of +/- 1.45.
  1044. This also applies to leveled nodeboxes, where the final height shall not
  1045. exceed this soft limit.
  1046. Map terminology and coordinates
  1047. ===============================
  1048. Nodes, mapblocks, mapchunks
  1049. ---------------------------
  1050. A 'node' is the fundamental cubic unit of a world and appears to a player as
  1051. roughly 1x1x1 meters in size.
  1052. A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
  1053. fundamental region of a world that is stored in the world database, sent to
  1054. clients and handled by many parts of the engine.
  1055. 'mapblock' is preferred terminology to 'block' to help avoid confusion with
  1056. 'node', however 'block' often appears in the API.
  1057. A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
  1058. (80x80x80 nodes) and is the volume of world generated in one operation by
  1059. the map generator.
  1060. The size in mapblocks has been chosen to optimize map generation.
  1061. Coordinates
  1062. -----------
  1063. ### Orientation of axes
  1064. For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
  1065. ### Node coordinates
  1066. Almost all positions used in the API use node coordinates.
  1067. ### Mapblock coordinates
  1068. Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
  1069. specify a particular mapblock.
  1070. For example blockpos (0,0,0) specifies the mapblock that extends from
  1071. node position (0,0,0) to node position (15,15,15).
  1072. #### Converting node position to the containing blockpos
  1073. To calculate the blockpos of the mapblock that contains the node at 'nodepos',
  1074. for each axis:
  1075. * blockpos = math.floor(nodepos / 16)
  1076. #### Converting blockpos to min/max node positions
  1077. To calculate the min/max node positions contained in the mapblock at 'blockpos',
  1078. for each axis:
  1079. * Minimum:
  1080. nodepos = blockpos * 16
  1081. * Maximum:
  1082. nodepos = blockpos * 16 + 15
  1083. HUD
  1084. ===
  1085. HUD element types
  1086. -----------------
  1087. The position field is used for all element types.
  1088. To account for differing resolutions, the position coordinates are the
  1089. percentage of the screen, ranging in value from `0` to `1`.
  1090. The `name` field is not yet used, but should contain a description of what the
  1091. HUD element represents.
  1092. The `direction` field is the direction in which something is drawn.
  1093. `0` draws from left to right, `1` draws from right to left, `2` draws from
  1094. top to bottom, and `3` draws from bottom to top.
  1095. The `alignment` field specifies how the item will be aligned. It is a table
  1096. where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
  1097. moved to the left/up, and `1` is to the right/down. Fractional values can be
  1098. used.
  1099. The `offset` field specifies a pixel offset from the position. Contrary to
  1100. position, the offset is not scaled to screen size. This allows for some
  1101. precisely positioned items in the HUD.
  1102. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
  1103. factor!
  1104. The `z_index` field specifies the order of HUD elements from back to front.
  1105. Lower z-index elements are displayed behind higher z-index elements. Elements
  1106. with same z-index are displayed in an arbitrary order. Default 0.
  1107. Supports negative values. By convention, the following values are recommended:
  1108. * -400: Graphical effects, such as vignette
  1109. * -300: Name tags, waypoints
  1110. * -200: Wieldhand
  1111. * -100: Things that block the player's view, e.g. masks
  1112. * 0: Default. For standard in-game HUD elements like crosshair, hotbar,
  1113. minimap, builtin statbars, etc.
  1114. * 100: Temporary text messages or notification icons
  1115. * 1000: Full-screen effects such as full-black screen or credits.
  1116. This includes effects that cover the entire screen
  1117. If your HUD element doesn't fit into any category, pick a number
  1118. between the suggested values
  1119. Below are the specific uses for fields in each type; fields not listed for that
  1120. type are ignored.
  1121. ### `image`
  1122. Displays an image on the HUD.
  1123. * `scale`: The scale of the image, with 1 being the original texture size.
  1124. Only the X coordinate scale is used (positive values).
  1125. Negative values represent that percentage of the screen it
  1126. should take; e.g. `x=-100` means 100% (width).
  1127. * `text`: The name of the texture that is displayed.
  1128. * `alignment`: The alignment of the image.
  1129. * `offset`: offset in pixels from position.
  1130. ### `text`
  1131. Displays text on the HUD.
  1132. * `scale`: Defines the bounding rectangle of the text.
  1133. A value such as `{x=100, y=100}` should work.
  1134. * `text`: The text to be displayed in the HUD element.
  1135. * `number`: An integer containing the RGB value of the color used to draw the
  1136. text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
  1137. * `alignment`: The alignment of the text.
  1138. * `offset`: offset in pixels from position.
  1139. * `size`: size of the text.
  1140. The player-set font size is multiplied by size.x (y value isn't used).
  1141. * `style`: determines font style
  1142. Bitfield with 1 = bold, 2 = italic, 4 = monospace
  1143. ### `statbar`
  1144. Displays a horizontal bar made up of half-images with an optional background.
  1145. * `text`: The name of the texture to use.
  1146. * `text2`: Optional texture name to enable a background / "off state"
  1147. texture (useful to visualize the maximal value). Both textures
  1148. must have the same size.
  1149. * `number`: The number of half-textures that are displayed.
  1150. If odd, will end with a vertically center-split texture.
  1151. * `item`: Same as `number` but for the "off state" texture
  1152. * `direction`: To which direction the images will extend to
  1153. * `offset`: offset in pixels from position.
  1154. * `size`: If used, will force full-image size to this value (override texture
  1155. pack image size)
  1156. ### `inventory`
  1157. * `text`: The name of the inventory list to be displayed.
  1158. * `number`: Number of items in the inventory to be displayed.
  1159. * `item`: Position of item that is selected.
  1160. * `direction`: Direction the list will be displayed in
  1161. * `offset`: offset in pixels from position.
  1162. ### `waypoint`
  1163. Displays distance to selected world position.
  1164. * `name`: The name of the waypoint.
  1165. * `text`: Distance suffix. Can be blank.
  1166. * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
  1167. If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
  1168. When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
  1169. `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
  1170. `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
  1171. `precision = n` will show multiples of `1/n`
  1172. * `number:` An integer containing the RGB value of the color used to draw the
  1173. text.
  1174. * `world_pos`: World position of the waypoint.
  1175. * `offset`: offset in pixels from position.
  1176. * `alignment`: The alignment of the waypoint.
  1177. ### `image_waypoint`
  1178. Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
  1179. * `scale`: The scale of the image, with 1 being the original texture size.
  1180. Only the X coordinate scale is used (positive values).
  1181. Negative values represent that percentage of the screen it
  1182. should take; e.g. `x=-100` means 100% (width).
  1183. * `text`: The name of the texture that is displayed.
  1184. * `alignment`: The alignment of the image.
  1185. * `world_pos`: World position of the waypoint.
  1186. * `offset`: offset in pixels from position.
  1187. ### `compass`
  1188. Displays an image oriented or translated according to current heading direction.
  1189. * `size`: The size of this element. Negative values represent percentage
  1190. of the screen; e.g. `x=-100` means 100% (width).
  1191. * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
  1192. * `text`: The name of the texture to use.
  1193. * `alignment`: The alignment of the image.
  1194. * `offset`: Offset in pixels from position.
  1195. * `direction`: How the image is rotated/translated:
  1196. * 0 - Rotate as heading direction
  1197. * 1 - Rotate in reverse direction
  1198. * 2 - Translate as landscape direction
  1199. * 3 - Translate in reverse direction
  1200. If translation is chosen, texture is repeated horizontally to fill the whole element.
  1201. ### `minimap`
  1202. Displays a minimap on the HUD.
  1203. * `size`: Size of the minimap to display. Minimap should be a square to avoid
  1204. distortion.
  1205. * `alignment`: The alignment of the minimap.
  1206. * `offset`: offset in pixels from position.
  1207. Representations of simple things
  1208. ================================
  1209. Vector (ie. a position)
  1210. -----------------------
  1211. vector.new(x, y, z)
  1212. See [Spatial Vectors] for details.
  1213. `pointed_thing`
  1214. ---------------
  1215. * `{type="nothing"}`
  1216. * `{type="node", under=pos, above=pos}`
  1217. * Indicates a pointed node selection box.
  1218. * `under` refers to the node position behind the pointed face.
  1219. * `above` refers to the node position in front of the pointed face.
  1220. * `{type="object", ref=ObjectRef}`
  1221. Exact pointing location (currently only `Raycast` supports these fields):
  1222. * `pointed_thing.intersection_point`: The absolute world coordinates of the
  1223. point on the selection box which is pointed at. May be in the selection box
  1224. if the pointer is in the box too.
  1225. * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
  1226. from 1).
  1227. * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
  1228. selected selection box. This specifies which face is pointed at.
  1229. Is a null vector `vector.zero()` when the pointer is inside the selection box.
  1230. For entities with rotated selection boxes, this will be rotated properly
  1231. by the entity's rotation - it will always be in absolute world space.
  1232. Flag Specifier Format
  1233. =====================
  1234. Flags using the standardized flag specifier format can be specified in either
  1235. of two ways, by string or table.
  1236. The string format is a comma-delimited set of flag names; whitespace and
  1237. unrecognized flag fields are ignored. Specifying a flag in the string sets the
  1238. flag, and specifying a flag prefixed by the string `"no"` explicitly
  1239. clears the flag from whatever the default may be.
  1240. In addition to the standard string flag format, the schematic flags field can
  1241. also be a table of flag names to boolean values representing whether or not the
  1242. flag is set. Additionally, if a field with the flag name prefixed with `"no"`
  1243. is present, mapped to a boolean of any value, the specified flag is unset.
  1244. E.g. A flag field of value
  1245. {place_center_x = true, place_center_y=false, place_center_z=true}
  1246. is equivalent to
  1247. {place_center_x = true, noplace_center_y=true, place_center_z=true}
  1248. which is equivalent to
  1249. "place_center_x, noplace_center_y, place_center_z"
  1250. or even
  1251. "place_center_x, place_center_z"
  1252. since, by default, no schematic attributes are set.
  1253. Items
  1254. =====
  1255. Items are things that can be held by players, dropped in the map and
  1256. stored in inventories.
  1257. Items come in the form of item stacks, which are collections of equal
  1258. items that occupy a single inventory slot.
  1259. Item types
  1260. ----------
  1261. There are three kinds of items: nodes, tools and craftitems.
  1262. * Node: Placeable item form of a node in the world's voxel grid
  1263. * Tool: Has a changeable wear property but cannot be stacked
  1264. * Craftitem: Has no special properties
  1265. Every registered node (the voxel in the world) has a corresponding
  1266. item form (the thing in your inventory) that comes along with it.
  1267. This item form can be placed which will create a node in the
  1268. world (by default).
  1269. Both the 'actual' node and its item form share the same identifier.
  1270. For all practical purposes, you can treat the node and its item form
  1271. interchangeably. We usually just say 'node' to the item form of
  1272. the node as well.
  1273. Note the definition of tools is purely technical. The only really
  1274. unique thing about tools is their wear, and that's basically it.
  1275. Beyond that, you can't make any gameplay-relevant assumptions
  1276. about tools or non-tools. It is perfectly valid to register something
  1277. that acts as tool in a gameplay sense as a craftitem, and vice-versa.
  1278. Craftitems can be used for items that neither need to be a node
  1279. nor a tool.
  1280. Amount and wear
  1281. ---------------
  1282. All item stacks have an amount between 0 and 65535. It is 1 by
  1283. default. Tool item stacks cannot have an amount greater than 1.
  1284. Tools use a wear (damage) value ranging from 0 to 65535. The
  1285. value 0 is the default and is used for unworn tools. The values
  1286. 1 to 65535 are used for worn tools, where a higher value stands for
  1287. a higher wear. Non-tools technically also have a wear property,
  1288. but it is always 0. There is also a special 'toolrepair' crafting
  1289. recipe that is only available to tools.
  1290. Item formats
  1291. ------------
  1292. Items and item stacks can exist in three formats: Serializes, table format
  1293. and `ItemStack`.
  1294. When an item must be passed to a function, it can usually be in any of
  1295. these formats.
  1296. ### Serialized
  1297. This is called "stackstring" or "itemstring". It is a simple string with
  1298. 1-4 components:
  1299. 1. Full item identifier ("item name")
  1300. 2. Optional amount
  1301. 3. Optional wear value
  1302. 4. Optional item metadata
  1303. Syntax:
  1304. <identifier> [<amount>[ <wear>[ <metadata>]]]
  1305. Examples:
  1306. * `"default:apple"`: 1 apple
  1307. * `"default:dirt 5"`: 5 dirt
  1308. * `"default:pick_stone"`: a new stone pickaxe
  1309. * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
  1310. * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
  1311. * a wooden pickaxe from the `default` mod,
  1312. * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
  1313. * with the `description` field set to `"My worn out pick"` in its metadata
  1314. * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
  1315. * analogous to the above example
  1316. * note how the wear is set to `0` as dirt is not a tool
  1317. You should ideally use the `ItemStack` format to build complex item strings
  1318. (especially if they use item metadata)
  1319. without relying on the serialization format. Example:
  1320. local stack = ItemStack("default:pick_wood")
  1321. stack:set_wear(21323)
  1322. stack:get_meta():set_string("description", "My worn out pick")
  1323. local itemstring = stack:to_string()
  1324. Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
  1325. and `minetest.itemstring_with_color(item, colorstring)` may be used to create
  1326. item strings encoding color information in their metadata.
  1327. ### Table format
  1328. Examples:
  1329. 5 dirt nodes:
  1330. {name="default:dirt", count=5, wear=0, metadata=""}
  1331. A wooden pick about 1/3 worn out:
  1332. {name="default:pick_wood", count=1, wear=21323, metadata=""}
  1333. An apple:
  1334. {name="default:apple", count=1, wear=0, metadata=""}
  1335. ### `ItemStack`
  1336. A native C++ format with many helper methods. Useful for converting
  1337. between formats. See the [Class reference] section for details.
  1338. Groups
  1339. ======
  1340. In a number of places, there is a group table. Groups define the
  1341. properties of a thing (item, node, armor of entity, tool capabilities)
  1342. in such a way that the engine and other mods can can interact with
  1343. the thing without actually knowing what the thing is.
  1344. Usage
  1345. -----
  1346. Groups are stored in a table, having the group names with keys and the
  1347. group ratings as values. Group ratings are integer values within the
  1348. range [-32767, 32767]. For example:
  1349. -- Default dirt
  1350. groups = {crumbly=3, soil=1}
  1351. -- A more special dirt-kind of thing
  1352. groups = {crumbly=2, soil=1, level=2, outerspace=1}
  1353. Groups always have a rating associated with them. If there is no
  1354. useful meaning for a rating for an enabled group, it shall be `1`.
  1355. When not defined, the rating of a group defaults to `0`. Thus when you
  1356. read groups, you must interpret `nil` and `0` as the same value, `0`.
  1357. You can read the rating of a group for an item or a node by using
  1358. minetest.get_item_group(itemname, groupname)
  1359. Groups of items
  1360. ---------------
  1361. Groups of items can define what kind of an item it is (e.g. wool).
  1362. Groups of nodes
  1363. ---------------
  1364. In addition to the general item things, groups are used to define whether
  1365. a node is destroyable and how long it takes to destroy by a tool.
  1366. Groups of entities
  1367. ------------------
  1368. For entities, groups are, as of now, used only for calculating damage.
  1369. The rating is the percentage of damage caused by items with this damage group.
  1370. See [Entity damage mechanism].
  1371. object:get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
  1372. object:set_armor_groups({fleshy=30, cracky=80})
  1373. Groups of tool capabilities
  1374. ---------------------------
  1375. Groups in tool capabilities define which groups of nodes and entities they
  1376. are effective towards.
  1377. Groups in crafting recipes
  1378. --------------------------
  1379. In crafting recipes, you can specify a group as an input item.
  1380. This means that any item in that group will be accepted as input.
  1381. The basic syntax is:
  1382. "group:<group_name>"
  1383. For example, `"group:meat"` will accept any item in the `meat` group.
  1384. It is also possible to require an input item to be in
  1385. multiple groups at once. The syntax for that is:
  1386. "group:<group_name_1>,<group_name_2>,(...),<group_name_n>"
  1387. For example, `"group:leaves,birch,trimmed"` accepts any item which is member
  1388. of *all* the groups `leaves` *and* `birch` *and* `trimmed`.
  1389. An example recipe: Craft a raw meat soup from any meat, any water and any bowl:
  1390. {
  1391. output = "food:meat_soup_raw",
  1392. recipe = {
  1393. {"group:meat"},
  1394. {"group:water"},
  1395. {"group:bowl"},
  1396. },
  1397. }
  1398. Another example: Craft red wool from white wool and red dye
  1399. (here, "red dye" is defined as any item which is member of
  1400. *both* the groups `dye` and `basecolor_red`).
  1401. {
  1402. type = "shapeless",
  1403. output = "wool:red",
  1404. recipe = {"wool:white", "group:dye,basecolor_red"},
  1405. }
  1406. Special groups
  1407. --------------
  1408. The asterisk `(*)` after a group name describes that there is no engine
  1409. functionality bound to it, and implementation is left up as a suggestion
  1410. to games.
  1411. ### Node and item groups
  1412. * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
  1413. that the item should be hidden in item lists.
  1414. ### Node-only groups
  1415. * `attached_node`: the node is 'attached' to a neighboring node. It checks
  1416. whether the node it is attached to is walkable. If it
  1417. isn't, the node will drop as an item.
  1418. * `1`: if the node is wallmounted, the node is attached in the wallmounted
  1419. direction. Otherwise, the node is attached to the node below.
  1420. * `2`: if the node is facedir or 4dir, the facedir or 4dir direction is checked.
  1421. No effect for other nodes.
  1422. Note: The "attaching face" of this node is tile no. 5 (back face).
  1423. * `3`: the node is always attached to the node below.
  1424. * `4`: the node is always attached to the node above.
  1425. * `bouncy`: value is bounce speed in percent.
  1426. If positive, jump/sneak on floor impact will increase/decrease bounce height.
  1427. Negative value is the same bounciness, but non-controllable.
  1428. * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
  1429. connect to each other
  1430. * `dig_immediate`: Player can always pick up node without reducing tool wear
  1431. * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
  1432. * `3`: the node always gets the digging time 0 seconds (torch)
  1433. * `disable_jump`: Player (and possibly other things) cannot jump from node
  1434. or if their feet are in the node. Note: not supported for `new_move = false`
  1435. * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
  1436. the top of this node. There's also an armor group with the same name.
  1437. The final player damage is determined by the following formula:
  1438. damage =
  1439. collision speed
  1440. * ((node_fall_damage_add_percent + 100) / 100) -- node group
  1441. * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
  1442. - (14) -- constant tolerance
  1443. Negative damage values are discarded as no damage.
  1444. * `falling_node`: if there is no walkable block under the node it will fall
  1445. * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
  1446. * `level`: Can be used to give an additional sense of progression in the game.
  1447. * A larger level will cause e.g. a weapon of a lower level make much less
  1448. damage, and get worn out much faster, or not be able to get drops
  1449. from destroyed nodes.
  1450. * `0` is something that is directly accessible at the start of gameplay
  1451. * There is no upper limit
  1452. * See also: `leveldiff` in [Tool Capabilities]
  1453. * `slippery`: Players and items will slide on the node.
  1454. Slipperiness rises steadily with `slippery` value, starting at 1.
  1455. ### Tool-only groups
  1456. * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
  1457. `"toolrepair"` crafting recipe
  1458. ### `ObjectRef` armor groups
  1459. * `immortal`: Skips all damage and breath handling for an object. This group
  1460. will also hide the integrated HUD status bars for players. It is
  1461. automatically set to all players when damage is disabled on the server and
  1462. cannot be reset (subject to change).
  1463. * `fall_damage_add_percent`: Modifies the fall damage suffered by players
  1464. when they hit the ground. It is analog to the node group with the same
  1465. name. See the node group above for the exact calculation.
  1466. * `punch_operable`: For entities; disables the regular damage mechanism for
  1467. players punching it by hand or a non-tool item, so that it can do something
  1468. else than take damage.
  1469. Known damage and digging time defining groups
  1470. ---------------------------------------------
  1471. * `crumbly`: dirt, sand
  1472. * `cracky`: tough but crackable stuff like stone.
  1473. * `snappy`: something that can be cut using things like scissors, shears,
  1474. bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
  1475. * `choppy`: something that can be cut using force; e.g. trees, wooden planks
  1476. * `fleshy`: Living things like animals and the player. This could imply
  1477. some blood effects when hitting.
  1478. * `explody`: Especially prone to explosions
  1479. * `oddly_breakable_by_hand`:
  1480. Can be added to nodes that shouldn't logically be breakable by the
  1481. hand but are. Somewhat similar to `dig_immediate`, but times are more
  1482. like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
  1483. digging speed of an item if it can dig at a faster speed than this
  1484. suggests for the hand.
  1485. Examples of custom groups
  1486. -------------------------
  1487. Item groups are often used for defining, well, _groups of items_.
  1488. * `meat`: any meat-kind of a thing (rating might define the size or healing
  1489. ability or be irrelevant -- it is not defined as of yet)
  1490. * `eatable`: anything that can be eaten. Rating might define HP gain in half
  1491. hearts.
  1492. * `flammable`: can be set on fire. Rating might define the intensity of the
  1493. fire, affecting e.g. the speed of the spreading of an open fire.
  1494. * `wool`: any wool (any origin, any color)
  1495. * `metal`: any metal
  1496. * `weapon`: any weapon
  1497. * `heavy`: anything considerably heavy
  1498. Digging time calculation specifics
  1499. ----------------------------------
  1500. Groups such as `crumbly`, `cracky` and `snappy` are used for this
  1501. purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
  1502. faster digging time.
  1503. The `level` group is used to limit the toughness of nodes an item capable
  1504. of digging can dig and to scale the digging times / damage to a greater extent.
  1505. **Please do understand this**, otherwise you cannot use the system to it's
  1506. full potential.
  1507. Items define their properties by a list of parameters for groups. They
  1508. cannot dig other groups; thus it is important to use a standard bunch of
  1509. groups to enable interaction with items.
  1510. Tool Capabilities
  1511. =================
  1512. 'Tool capabilities' is a property of items that defines two things:
  1513. 1) Which nodes it can dig and how fast
  1514. 2) Which objects it can hurt by punching and by how much
  1515. Tool capabilities are available for all items, not just tools.
  1516. But only tools can receive wear from digging and punching.
  1517. Missing or incomplete tool capabilities will default to the
  1518. player's hand.
  1519. Tool capabilities definition
  1520. ----------------------------
  1521. Tool capabilities define:
  1522. * Full punch interval
  1523. * Maximum drop level
  1524. * For an arbitrary list of node groups:
  1525. * Uses (until the tool breaks)
  1526. * Maximum level (usually `0`, `1`, `2` or `3`)
  1527. * Digging times
  1528. * Damage groups
  1529. * Punch attack uses (until the tool breaks)
  1530. ### Full punch interval `full_punch_interval`
  1531. When used as a weapon, the item will do full damage if this time is spent
  1532. between punches. If e.g. half the time is spent, the item will do half
  1533. damage.
  1534. ### Maximum drop level `max_drop_level`
  1535. Suggests the maximum level of node, when dug with the item, that will drop
  1536. its useful item. (e.g. iron ore to drop a lump of iron).
  1537. This value is not used in the engine; it is the responsibility of the game/mod
  1538. code to implement this.
  1539. ### Uses `uses` (tools only)
  1540. Determines how many uses the tool has when it is used for digging a node,
  1541. of this group, of the maximum level. The maximum supported number of
  1542. uses is 65535. The special number 0 is used for infinite uses.
  1543. For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
  1544. `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
  1545. node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
  1546. * `uses=10, leveldiff=0`: actual uses: 10
  1547. * `uses=10, leveldiff=1`: actual uses: 30
  1548. * `uses=10, leveldiff=2`: actual uses: 90
  1549. For non-tools, this has no effect.
  1550. ### Maximum level `maxlevel`
  1551. Tells what is the maximum level of a node of this group that the item will
  1552. be able to dig.
  1553. ### Digging times `times`
  1554. List of digging times for different ratings of the group, for nodes of the
  1555. maximum level.
  1556. For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
  1557. result in the item to be able to dig nodes that have a rating of `2` or `3`
  1558. for this group, and unable to dig the rating `1`, which is the toughest.
  1559. Unless there is a matching group that enables digging otherwise.
  1560. If the result digging time is 0, a delay of 0.15 seconds is added between
  1561. digging nodes; If the player releases LMB after digging, this delay is set to 0,
  1562. i.e. players can more quickly click the nodes away instead of holding LMB.
  1563. ### Damage groups
  1564. List of damage for groups of entities. See [Entity damage mechanism].
  1565. ### Punch attack uses (tools only)
  1566. Determines how many uses (before breaking) the tool has when dealing damage
  1567. to an object, when the full punch interval (see above) was always
  1568. waited out fully.
  1569. Wear received by the tool is proportional to the time spent, scaled by
  1570. the full punch interval.
  1571. For non-tools, this has no effect.
  1572. Example definition of the capabilities of an item
  1573. -------------------------------------------------
  1574. tool_capabilities = {
  1575. groupcaps={
  1576. crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
  1577. },
  1578. }
  1579. This makes the item capable of digging nodes that fulfill both of these:
  1580. * Have the `crumbly` group
  1581. * Have a `level` group less or equal to `2`
  1582. Table of resulting digging times:
  1583. crumbly 0 1 2 3 4 <- level
  1584. -> 0 - - - - -
  1585. 1 0.80 1.60 1.60 - -
  1586. 2 0.60 1.20 1.20 - -
  1587. 3 0.40 0.80 0.80 - -
  1588. level diff: 2 1 0 -1 -2
  1589. Table of resulting tool uses:
  1590. -> 0 - - - - -
  1591. 1 180 60 20 - -
  1592. 2 180 60 20 - -
  1593. 3 180 60 20 - -
  1594. **Notes**:
  1595. * At `crumbly==0`, the node is not diggable.
  1596. * At `crumbly==3`, the level difference digging time divider kicks in and makes
  1597. easy nodes to be quickly breakable.
  1598. * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
  1599. Entity damage mechanism
  1600. =======================
  1601. Damage calculation:
  1602. damage = 0
  1603. foreach group in cap.damage_groups:
  1604. damage += cap.damage_groups[group]
  1605. * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
  1606. * (object.armor_groups[group] / 100.0)
  1607. -- Where object.armor_groups[group] is 0 for inexistent values
  1608. return damage
  1609. Client predicts damage based on damage groups. Because of this, it is able to
  1610. give an immediate response when an entity is damaged or dies; the response is
  1611. pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
  1612. TODO).
  1613. Currently a smoke puff will appear when an entity dies.
  1614. The group `immortal` completely disables normal damage.
  1615. Entities can define a special armor group, which is `punch_operable`. This
  1616. group disables the regular damage mechanism for players punching it by hand or
  1617. a non-tool item, so that it can do something else than take damage.
  1618. On the Lua side, every punch calls:
  1619. entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
  1620. damage)
  1621. This should never be called directly, because damage is usually not handled by
  1622. the entity itself.
  1623. * `puncher` is the object performing the punch. Can be `nil`. Should never be
  1624. accessed unless absolutely required, to encourage interoperability.
  1625. * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
  1626. * `tool_capabilities` can be `nil`.
  1627. * `direction` is a unit vector, pointing from the source of the punch to
  1628. the punched object.
  1629. * `damage` damage that will be done to entity
  1630. Return value of this function will determine if damage is done by this function
  1631. (retval true) or shall be done by engine (retval false)
  1632. To punch an entity/object in Lua, call:
  1633. object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
  1634. * Return value is tool wear.
  1635. * Parameters are equal to the above callback.
  1636. * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
  1637. will be automatically filled in based on the location of `puncher`.
  1638. Metadata
  1639. ========
  1640. Node Metadata
  1641. -------------
  1642. The instance of a node in the world normally only contains the three values
  1643. mentioned in [Nodes]. However, it is possible to insert extra data into a node.
  1644. It is called "node metadata"; See `NodeMetaRef`.
  1645. Node metadata contains two things:
  1646. * A key-value store
  1647. * An inventory
  1648. Some of the values in the key-value store are handled specially:
  1649. * `formspec`: Defines an inventory menu that is opened with the
  1650. 'place/use' key. Only works if no `on_rightclick` was
  1651. defined for the node. See also [Formspec].
  1652. * `infotext`: Text shown on the screen when the node is pointed at.
  1653. Line-breaks will be applied automatically.
  1654. If the infotext is very long, it will be truncated.
  1655. Example:
  1656. local meta = minetest.get_meta(pos)
  1657. meta:set_string("formspec",
  1658. "size[8,9]"..
  1659. "list[context;main;0,0;8,4;]"..
  1660. "list[current_player;main;0,5;8,4;]")
  1661. meta:set_string("infotext", "Chest");
  1662. local inv = meta:get_inventory()
  1663. inv:set_size("main", 8*4)
  1664. print(dump(meta:to_table()))
  1665. meta:from_table({
  1666. inventory = {
  1667. main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
  1668. [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
  1669. [10] = "", [11] = "", [12] = "", [13] = "",
  1670. [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
  1671. [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
  1672. [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
  1673. [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
  1674. [32] = ""}
  1675. },
  1676. fields = {
  1677. formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
  1678. infotext = "Chest"
  1679. }
  1680. })
  1681. Item Metadata
  1682. -------------
  1683. Item stacks can store metadata too. See [`ItemStackMetaRef`].
  1684. Item metadata only contains a key-value store.
  1685. Some of the values in the key-value store are handled specially:
  1686. * `description`: Set the item stack's description.
  1687. See also: `get_description` in [`ItemStack`]
  1688. * `short_description`: Set the item stack's short description.
  1689. See also: `get_short_description` in [`ItemStack`]
  1690. * `color`: A `ColorString`, which sets the stack's color.
  1691. * `palette_index`: If the item has a palette, this is used to get the
  1692. current color from the palette.
  1693. * `count_meta`: Replace the displayed count with any string.
  1694. * `count_alignment`: Set the alignment of the displayed count value. This is an
  1695. int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
  1696. 4th bit specify the alignment in y-direction:
  1697. 0 = default, 1 = left / up, 2 = middle, 3 = right / down
  1698. The default currently is the same as right/down.
  1699. Example: 6 = 2 + 1*4 = middle,up
  1700. Example:
  1701. local meta = stack:get_meta()
  1702. meta:set_string("key", "value")
  1703. print(dump(meta:to_table()))
  1704. Example manipulations of "description" and expected output behaviors:
  1705. print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
  1706. print(ItemStack("foobar"):get_description()) --> Unknown Item
  1707. local stack = ItemStack("default:stone")
  1708. stack:get_meta():set_string("description", "Custom description\nAnother line")
  1709. print(stack:get_description()) --> Custom description\nAnother line
  1710. print(stack:get_short_description()) --> Custom description
  1711. stack:get_meta():set_string("short_description", "Short")
  1712. print(stack:get_description()) --> Custom description\nAnother line
  1713. print(stack:get_short_description()) --> Short
  1714. print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
  1715. Formspec
  1716. ========
  1717. Formspec defines a menu. This supports inventories and some of the
  1718. typical widgets like buttons, checkboxes, text input fields, etc.
  1719. It is a string, with a somewhat strange format.
  1720. A formspec is made out of formspec elements, which includes widgets
  1721. like buttons but also can be used to set stuff like background color.
  1722. Many formspec elements have a `name`, which is a unique identifier which
  1723. is used when the server receives user input. You must not use the name
  1724. "quit" for formspec elements.
  1725. Spaces and newlines can be inserted between the blocks, as is used in the
  1726. examples.
  1727. Position and size units are inventory slots unless the new coordinate system
  1728. is enabled. `X` and `Y` position the formspec element relative to the top left
  1729. of the menu or container. `W` and `H` are its width and height values.
  1730. If the new system is enabled, all elements have unified coordinates for all
  1731. elements with no padding or spacing in between. This is highly recommended
  1732. for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
  1733. Coordinates`.
  1734. Inventories with a `player:<name>` inventory location are only sent to the
  1735. player named `<name>`.
  1736. When displaying text which can contain formspec code, e.g. text set by a player,
  1737. use `minetest.formspec_escape`.
  1738. For colored text you can use `minetest.colorize`.
  1739. Since formspec version 3, elements drawn in the order they are defined. All
  1740. background elements are drawn before all other elements.
  1741. **WARNING**: do _not_ use an element name starting with `key_`; those names are
  1742. reserved to pass key press events to formspec!
  1743. **WARNING**: Minetest allows you to add elements to every single formspec instance
  1744. using `player:set_formspec_prepend()`, which may be the reason backgrounds are
  1745. appearing when you don't expect them to, or why things are styled differently
  1746. to normal. See [`no_prepend[]`] and [Styling Formspecs].
  1747. Examples
  1748. --------
  1749. ### Chest
  1750. size[8,9]
  1751. list[context;main;0,0;8,4;]
  1752. list[current_player;main;0,5;8,4;]
  1753. ### Furnace
  1754. size[8,9]
  1755. list[context;fuel;2,3;1,1;]
  1756. list[context;src;2,1;1,1;]
  1757. list[context;dst;5,1;2,2;]
  1758. list[current_player;main;0,5;8,4;]
  1759. ### Minecraft-like player inventory
  1760. size[8,7.5]
  1761. image[1,0.6;1,2;player.png]
  1762. list[current_player;main;0,3.5;8,4;]
  1763. list[current_player;craft;3,0;3,3;]
  1764. list[current_player;craftpreview;7,1;1,1;]
  1765. Version History
  1766. ---------------
  1767. * Formspec version 1 (pre-5.1.0):
  1768. * (too much)
  1769. * Formspec version 2 (5.1.0):
  1770. * Forced real coordinates
  1771. * background9[]: 9-slice scaling parameters
  1772. * Formspec version 3 (5.2.0):
  1773. * Formspec elements are drawn in the order of definition
  1774. * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
  1775. * box[] and image[] elements enable clipping by default
  1776. * new element: scroll_container[]
  1777. * Formspec version 4 (5.4.0):
  1778. * Allow dropdown indexing events
  1779. * Formspec version 5 (5.5.0):
  1780. * Added padding[] element
  1781. * Formspec version 6 (5.6.0):
  1782. * Add nine-slice images, animated_image, and fgimg_middle
  1783. Elements
  1784. --------
  1785. ### `formspec_version[<version>]`
  1786. * Set the formspec version to a certain number. If not specified,
  1787. version 1 is assumed.
  1788. * Must be specified before `size` element.
  1789. * Clients older than this version can neither show newer elements nor display
  1790. elements with new arguments correctly.
  1791. * Available since feature `formspec_version_element`.
  1792. * See also: [Version History]
  1793. ### `size[<W>,<H>,<fixed_size>]`
  1794. * Define the size of the menu in inventory slots
  1795. * `fixed_size`: `true`/`false` (optional)
  1796. * deprecated: `invsize[<W>,<H>;]`
  1797. ### `position[<X>,<Y>]`
  1798. * Must be used after `size` element.
  1799. * Defines the position on the game window of the formspec's `anchor` point.
  1800. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
  1801. for example:
  1802. * [0.0, 0.0] sets the position to the top left corner of the game window.
  1803. * [1.0, 1.0] sets the position to the bottom right of the game window.
  1804. * Defaults to the center of the game window [0.5, 0.5].
  1805. ### `anchor[<X>,<Y>]`
  1806. * Must be used after both `size` and `position` (if present) elements.
  1807. * Defines the location of the anchor point within the formspec.
  1808. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
  1809. for example:
  1810. * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
  1811. * [1.0, 0.0] sets the anchor to the top right of the formspec.
  1812. * Defaults to the center of the formspec [0.5, 0.5].
  1813. * `position` and `anchor` elements need suitable values to avoid a formspec
  1814. extending off the game window due to particular game window sizes.
  1815. ### `padding[<X>,<Y>]`
  1816. * Must be used after the `size`, `position`, and `anchor` elements (if present).
  1817. * Defines how much space is padded around the formspec if the formspec tries to
  1818. increase past the size of the screen and coordinates have to be shrunk.
  1819. * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
  1820. screen), and 0.5 represents half the screen (which forces the coordinate size
  1821. to 0). If negative, the formspec can extend off the edge of the screen.
  1822. * Defaults to [0.05, 0.05].
  1823. ### `no_prepend[]`
  1824. * Must be used after the `size`, `position`, `anchor`, and `padding` elements
  1825. (if present).
  1826. * Disables player:set_formspec_prepend() from applying to this formspec.
  1827. ### `real_coordinates[<bool>]`
  1828. * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
  1829. * When set to true, all following formspec elements will use the new coordinate system.
  1830. * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
  1831. (if present), the form size will use the new coordinate system.
  1832. * **Note**: Formspec prepends are not affected by the coordinates in the main form.
  1833. They must enable it explicitly.
  1834. * For information on converting forms to the new coordinate system, see `Migrating
  1835. to Real Coordinates`.
  1836. ### `container[<X>,<Y>]`
  1837. * Start of a container block, moves all physical elements in the container by
  1838. (X, Y).
  1839. * Must have matching `container_end`
  1840. * Containers can be nested, in which case the offsets are added
  1841. (child containers are relative to parent containers)
  1842. ### `container_end[]`
  1843. * End of a container, following elements are no longer relative to this
  1844. container.
  1845. ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
  1846. * Start of a scroll_container block. All contained elements will ...
  1847. * take the scroll_container coordinate as position origin,
  1848. * be additionally moved by the current value of the scrollbar with the name
  1849. `scrollbar name` times `scroll factor` along the orientation `orientation` and
  1850. * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
  1851. * `orientation`: possible values are `vertical` and `horizontal`.
  1852. * `scroll factor`: optional, defaults to `0.1`.
  1853. * Nesting is possible.
  1854. * Some elements might work a little different if they are in a scroll_container.
  1855. * Note: If you want the scroll_container to actually work, you also need to add a
  1856. scrollbar element with the specified name. Furthermore, it is highly recommended
  1857. to use a scrollbaroptions element on this scrollbar.
  1858. ### `scroll_container_end[]`
  1859. * End of a scroll_container, following elements are no longer bound to this
  1860. container.
  1861. ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
  1862. * Show an inventory list if it has been sent to the client.
  1863. * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
  1864. are moved) while the formspec is open, the formspec element may (but is not guaranteed
  1865. to) adapt to the new inventory list.
  1866. * Item slots are drawn in a grid from left to right, then up to down, ordered
  1867. according to the slot index.
  1868. * `W` and `H` are in inventory slots, not in coordinates.
  1869. * `starting item index` (Optional): The index of the first (upper-left) item to draw.
  1870. Indices start at `0`. Default is `0`.
  1871. * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
  1872. `starting item index`.
  1873. * **Note**: With the new coordinate system, the spacing between inventory
  1874. slots is one-fourth the size of an inventory slot by default. Also see
  1875. [Styling Formspecs] for changing the size of slots and spacing.
  1876. ### `listring[<inventory location>;<list name>]`
  1877. * Appends to an internal ring of inventory lists.
  1878. * Shift-clicking on items in one element of the ring
  1879. will send them to the next inventory list inside the ring
  1880. * The first occurrence of an element inside the ring will
  1881. determine the inventory where items will be sent to
  1882. ### `listring[]`
  1883. * Shorthand for doing `listring[<inventory location>;<list name>]`
  1884. for the last two inventory lists added by list[...]
  1885. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
  1886. * Sets background color of slots as `ColorString`
  1887. * Sets background color of slots on mouse hovering
  1888. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
  1889. * Sets background color of slots as `ColorString`
  1890. * Sets background color of slots on mouse hovering
  1891. * Sets color of slots border
  1892. ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
  1893. * Sets background color of slots as `ColorString`
  1894. * Sets background color of slots on mouse hovering
  1895. * Sets color of slots border
  1896. * Sets default background color of tooltips
  1897. * Sets default font color of tooltips
  1898. ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1899. * Adds tooltip for an element
  1900. * `bgcolor` tooltip background color as `ColorString` (optional)
  1901. * `fontcolor` tooltip font color as `ColorString` (optional)
  1902. ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
  1903. * Adds tooltip for an area. Other tooltips will take priority when present.
  1904. * `bgcolor` tooltip background color as `ColorString` (optional)
  1905. * `fontcolor` tooltip font color as `ColorString` (optional)
  1906. ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
  1907. * Show an image.
  1908. * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
  1909. * Requires formspec version >= 6.
  1910. * See `background9[]` documentation for more information.
  1911. ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
  1912. * Show an animated image. The image is drawn like a "vertical_frames" tile
  1913. animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
  1914. * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
  1915. * `texture name`: The image to use.
  1916. * `frame count`: The number of frames animating the image.
  1917. * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
  1918. * `frame start` (optional): The index of the frame to start on. Default `1`.
  1919. * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
  1920. * Requires formspec version >= 6.
  1921. * See `background9[]` documentation for more information.
  1922. ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
  1923. * Show a mesh model.
  1924. * `name`: Element name that can be used for styling
  1925. * `mesh`: The mesh model to use.
  1926. * `textures`: The mesh textures to use according to the mesh materials.
  1927. Texture names must be separated by commas.
  1928. * `rotation {X,Y}` (Optional): Initial rotation of the camera.
  1929. The axes are euler angles in degrees.
  1930. * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
  1931. * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
  1932. * `frame loop range` (Optional): Range of the animation frames.
  1933. * Defaults to the full range of all available frames.
  1934. * Syntax: `<begin>,<end>`
  1935. * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
  1936. ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
  1937. * Show an inventory image of registered item/node
  1938. ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
  1939. * Sets background color of formspec.
  1940. * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
  1941. of the non-fullscreen and the fullscreen background.
  1942. * `fullscreen` (optional) can be one of the following:
  1943. * `false`: Only the non-fullscreen background color is drawn. (default)
  1944. * `true`: Only the fullscreen background color is drawn.
  1945. * `both`: The non-fullscreen and the fullscreen background color are drawn.
  1946. * `neither`: No background color is drawn.
  1947. * Note: Leave a parameter empty to not modify the value.
  1948. * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
  1949. are not bools are only available since formspec version 3.
  1950. ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
  1951. * Example for formspec 8x4 in 16x resolution: image shall be sized
  1952. 8 times 16px times 4 times 16px.
  1953. ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
  1954. * Example for formspec 8x4 in 16x resolution:
  1955. image shall be sized 8 times 16px times 4 times 16px
  1956. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1957. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1958. ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
  1959. * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
  1960. * Middle is a rect which defines the middle of the 9-slice.
  1961. * `x` - The middle will be x pixels from all sides.
  1962. * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
  1963. * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
  1964. will be added to the width and height of the texture, allowing it to be used as the
  1965. distance from the far end.
  1966. * All numbers in middle are integers.
  1967. * If `auto_clip` is `true`, the background is clipped to the formspec size
  1968. (`x` and `y` are used as offset values, `w` and `h` are ignored)
  1969. * Available since formspec version 2
  1970. ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
  1971. * Textual password style field; will be sent to server when a button is clicked
  1972. * When enter is pressed in field, fields.key_enter_field will be sent with the
  1973. name of this field.
  1974. * With the old coordinate system, fields are a set height, but will be vertically
  1975. centered on `H`. With the new coordinate system, `H` will modify the height.
  1976. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1977. * `label`, if not blank, will be text printed on the top left above the field
  1978. * See `field_close_on_enter` to stop enter closing the formspec
  1979. ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  1980. * Textual field; will be sent to server when a button is clicked
  1981. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1982. the name of this field.
  1983. * With the old coordinate system, fields are a set height, but will be vertically
  1984. centered on `H`. With the new coordinate system, `H` will modify the height.
  1985. * `name` is the name of the field as returned in fields to `on_receive_fields`
  1986. * `label`, if not blank, will be text printed on the top left above the field
  1987. * `default` is the default value of the field
  1988. * `default` may contain variable references such as `${text}` which
  1989. will fill the value from the metadata value `text`
  1990. * **Note**: no extra text or more than a single variable is supported ATM.
  1991. * See `field_close_on_enter` to stop enter closing the formspec
  1992. ### `field[<name>;<label>;<default>]`
  1993. * As above, but without position/size units
  1994. * When enter is pressed in field, `fields.key_enter_field` will be sent with
  1995. the name of this field.
  1996. * Special field for creating simple forms, such as sign text input
  1997. * Must be used without a `size[]` element
  1998. * A "Proceed" button will be added automatically
  1999. * See `field_close_on_enter` to stop enter closing the formspec
  2000. ### `field_close_on_enter[<name>;<close_on_enter>]`
  2001. * <name> is the name of the field
  2002. * if <close_on_enter> is false, pressing enter in the field will submit the
  2003. form but not close it.
  2004. * defaults to true when not specified (ie: no tag for a field)
  2005. ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
  2006. * Same as fields above, but with multi-line input
  2007. * If the text overflows, a vertical scrollbar is added.
  2008. * If the name is empty, the textarea is read-only and
  2009. the background is not shown, which corresponds to a multi-line label.
  2010. ### `label[<X>,<Y>;<label>]`
  2011. * The label formspec element displays the text set in `label`
  2012. at the specified position.
  2013. * **Note**: If the new coordinate system is enabled, labels are
  2014. positioned from the center of the text, not the top.
  2015. * The text is displayed directly without automatic line breaking,
  2016. so label should not be used for big text chunks. Newlines can be
  2017. used to make labels multiline.
  2018. * **Note**: With the new coordinate system, newlines are spaced with
  2019. half a coordinate. With the old system, newlines are spaced 2/5 of
  2020. an inventory slot.
  2021. ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
  2022. * Displays a static formatted text with hyperlinks.
  2023. * **Note**: This element is currently unstable and subject to change.
  2024. * `x`, `y`, `w` and `h` work as per field
  2025. * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
  2026. * `text` is the formatted text using `Markup Language` described below.
  2027. ### `vertlabel[<X>,<Y>;<label>]`
  2028. * Textual label drawn vertically
  2029. * `label` is the text on the label
  2030. * **Note**: If the new coordinate system is enabled, vertlabels are
  2031. positioned from the center of the text, not the left.
  2032. ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
  2033. * Clickable button. When clicked, fields will be sent.
  2034. * With the old coordinate system, buttons are a set height, but will be vertically
  2035. centered on `H`. With the new coordinate system, `H` will modify the height.
  2036. * `label` is the text on the button
  2037. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  2038. * `texture name` is the filename of an image
  2039. * **Note**: Height is supported on both the old and new coordinate systems
  2040. for image_buttons.
  2041. ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
  2042. * `texture name` is the filename of an image
  2043. * `noclip=true` means the image button doesn't need to be within specified
  2044. formsize.
  2045. * `drawborder`: draw button border or not
  2046. * `pressed texture name` is the filename of an image on pressed state
  2047. ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
  2048. * `item name` is the registered name of an item/node
  2049. * The item description will be used as the tooltip. This can be overridden with
  2050. a tooltip element.
  2051. ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
  2052. * When clicked, fields will be sent and the form will quit.
  2053. * Same as `button` in all other respects.
  2054. ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
  2055. * When clicked, fields will be sent and the form will quit.
  2056. * Same as `image_button` in all other respects.
  2057. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
  2058. * Scrollable item list showing arbitrary text elements
  2059. * `name` fieldname sent to server on doubleclick value is current selected
  2060. element.
  2061. * `listelements` can be prepended by #color in hexadecimal format RRGGBB
  2062. (only).
  2063. * if you want a listelement to start with "#" write "##".
  2064. ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
  2065. * Scrollable itemlist showing arbitrary text elements
  2066. * `name` fieldname sent to server on doubleclick value is current selected
  2067. element.
  2068. * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
  2069. * if you want a listelement to start with "#" write "##"
  2070. * Index to be selected within textlist
  2071. * `true`/`false`: draw transparent background
  2072. * See also `minetest.explode_textlist_event`
  2073. (main menu: `core.explode_textlist_event`).
  2074. ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2075. * Show a tab**header** at specific position (ignores formsize)
  2076. * `X` and `Y`: position of the tabheader
  2077. * *Note*: Width and height are automatically chosen with this syntax
  2078. * `name` fieldname data is transferred to Lua
  2079. * `caption 1`...: name shown on top of tab
  2080. * `current_tab`: index of selected tab 1...
  2081. * `transparent` (optional): if true, tabs are semi-transparent
  2082. * `draw_border` (optional): if true, draw a thin line at tab base
  2083. ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2084. * Show a tab**header** at specific position (ignores formsize)
  2085. * **Important note**: This syntax for tabheaders can only be used with the
  2086. new coordinate system.
  2087. * `X` and `Y`: position of the tabheader
  2088. * `H`: height of the tabheader. Width is automatically determined with this syntax.
  2089. * `name` fieldname data is transferred to Lua
  2090. * `caption 1`...: name shown on top of tab
  2091. * `current_tab`: index of selected tab 1...
  2092. * `transparent` (optional): show transparent
  2093. * `draw_border` (optional): draw border
  2094. ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
  2095. * Show a tab**header** at specific position (ignores formsize)
  2096. * **Important note**: This syntax for tabheaders can only be used with the
  2097. new coordinate system.
  2098. * `X` and `Y`: position of the tabheader
  2099. * `W` and `H`: width and height of the tabheader
  2100. * `name` fieldname data is transferred to Lua
  2101. * `caption 1`...: name shown on top of tab
  2102. * `current_tab`: index of selected tab 1...
  2103. * `transparent` (optional): show transparent
  2104. * `draw_border` (optional): draw border
  2105. ### `box[<X>,<Y>;<W>,<H>;<color>]`
  2106. * Simple colored box
  2107. * `color` is color specified as a `ColorString`.
  2108. If the alpha component is left blank, the box will be semitransparent.
  2109. If the color is not specified, the box will use the options specified by
  2110. its style. If the color is specified, all styling options will be ignored.
  2111. ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2112. * Show a dropdown field
  2113. * **Important note**: There are two different operation modes:
  2114. 1. handle directly on change (only changed dropdown is submitted)
  2115. 2. read the value on pressing a button (all dropdown values are available)
  2116. * `X` and `Y`: position of the dropdown
  2117. * `W`: width of the dropdown. Height is automatically chosen with this syntax.
  2118. * Fieldname data is transferred to Lua
  2119. * Items to be shown in dropdown
  2120. * Index of currently selected dropdown item
  2121. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2122. event field value for selected items.
  2123. * `true`: Selected item index
  2124. * `false` (default): Selected item value
  2125. ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
  2126. * Show a dropdown field
  2127. * **Important note**: This syntax for dropdowns can only be used with the
  2128. new coordinate system.
  2129. * **Important note**: There are two different operation modes:
  2130. 1. handle directly on change (only changed dropdown is submitted)
  2131. 2. read the value on pressing a button (all dropdown values are available)
  2132. * `X` and `Y`: position of the dropdown
  2133. * `W` and `H`: width and height of the dropdown
  2134. * Fieldname data is transferred to Lua
  2135. * Items to be shown in dropdown
  2136. * Index of currently selected dropdown item
  2137. * `index event` (optional, allowed parameter since formspec version 4): Specifies the
  2138. event field value for selected items.
  2139. * `true`: Selected item index
  2140. * `false` (default): Selected item value
  2141. ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
  2142. * Show a checkbox
  2143. * `name` fieldname data is transferred to Lua
  2144. * `label` to be shown left of checkbox
  2145. * `selected` (optional): `true`/`false`
  2146. * **Note**: If the new coordinate system is enabled, checkboxes are
  2147. positioned from the center of the checkbox, not the top.
  2148. ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
  2149. * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
  2150. * There are two ways to use it:
  2151. 1. handle the changed event (only changed scrollbar is available)
  2152. 2. read the value on pressing a button (all scrollbars are available)
  2153. * `orientation`: `vertical`/`horizontal`. Default horizontal.
  2154. * Fieldname data is transferred to Lua
  2155. * Value of this trackbar is set to (`0`-`1000`) by default
  2156. * See also `minetest.explode_scrollbar_event`
  2157. (main menu: `core.explode_scrollbar_event`).
  2158. ### `scrollbaroptions[opt1;opt2;...]`
  2159. * Sets options for all following `scrollbar[]` elements
  2160. * `min=<int>`
  2161. * Sets scrollbar minimum value, defaults to `0`.
  2162. * `max=<int>`
  2163. * Sets scrollbar maximum value, defaults to `1000`.
  2164. If the max is equal to the min, the scrollbar will be disabled.
  2165. * `smallstep=<int>`
  2166. * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
  2167. scrolled.
  2168. * If this is set to a negative number, the value will be reset to `10`.
  2169. * `largestep=<int>`
  2170. * Sets scrollbar step value used by page up and page down.
  2171. * If this is set to a negative number, the value will be reset to `100`.
  2172. * `thumbsize=<int>`
  2173. * Sets size of the thumb on the scrollbar. Size is calculated in the number of
  2174. units the thumb spans out of the range of the scrollbar values.
  2175. * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
  2176. would span a tenth of the scrollbar space.
  2177. * If this is set to zero or less, the value will be reset to `1`.
  2178. * `arrows=<show/hide/default>`
  2179. * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
  2180. when the scrollbar gets too small, but shows them otherwise.
  2181. ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
  2182. * Show scrollable table using options defined by the previous `tableoptions[]`
  2183. * Displays cells as defined by the previous `tablecolumns[]`
  2184. * `name`: fieldname sent to server on row select or doubleclick
  2185. * `cell 1`...`cell n`: cell contents given in row-major order
  2186. * `selected idx`: index of row to be selected within table (first row = `1`)
  2187. * See also `minetest.explode_table_event`
  2188. (main menu: `core.explode_table_event`).
  2189. ### `tableoptions[<opt 1>;<opt 2>;...]`
  2190. * Sets options for `table[]`
  2191. * `color=#RRGGBB`
  2192. * default text color (`ColorString`), defaults to `#FFFFFF`
  2193. * `background=#RRGGBB`
  2194. * table background color (`ColorString`), defaults to `#000000`
  2195. * `border=<true/false>`
  2196. * should the table be drawn with a border? (default: `true`)
  2197. * `highlight=#RRGGBB`
  2198. * highlight background color (`ColorString`), defaults to `#466432`
  2199. * `highlight_text=#RRGGBB`
  2200. * highlight text color (`ColorString`), defaults to `#FFFFFF`
  2201. * `opendepth=<value>`
  2202. * all subtrees up to `depth < value` are open (default value = `0`)
  2203. * only useful when there is a column of type "tree"
  2204. ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
  2205. * Sets columns for `table[]`
  2206. * Types: `text`, `image`, `color`, `indent`, `tree`
  2207. * `text`: show cell contents as text
  2208. * `image`: cell contents are an image index, use column options to define
  2209. images.
  2210. * `color`: cell contents are a ColorString and define color of following
  2211. cell.
  2212. * `indent`: cell contents are a number and define indentation of following
  2213. cell.
  2214. * `tree`: same as indent, but user can open and close subtrees
  2215. (treeview-like).
  2216. * Column options:
  2217. * `align=<value>`
  2218. * for `text` and `image`: content alignment within cells.
  2219. Available values: `left` (default), `center`, `right`, `inline`
  2220. * `width=<value>`
  2221. * for `text` and `image`: minimum width in em (default: `0`)
  2222. * for `indent` and `tree`: indent width in em (default: `1.5`)
  2223. * `padding=<value>`: padding left of the column, in em (default `0.5`).
  2224. Exception: defaults to 0 for indent columns
  2225. * `tooltip=<value>`: tooltip text (default: empty)
  2226. * `image` column options:
  2227. * `0=<value>` sets image for image index 0
  2228. * `1=<value>` sets image for image index 1
  2229. * `2=<value>` sets image for image index 2
  2230. * and so on; defined indices need not be contiguous empty or
  2231. non-numeric cells are treated as `0`.
  2232. * `color` column options:
  2233. * `span=<value>`: number of following columns to affect
  2234. (default: infinite).
  2235. ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2236. * Set the style for the element(s) matching `selector` by name.
  2237. * `selector` can be one of:
  2238. * `<name>` - An element name. Includes `*`, which represents every element.
  2239. * `<name>:<state>` - An element name, a colon, and one or more states.
  2240. * `state` is a list of states separated by the `+` character.
  2241. * If a state is provided, the style will only take effect when the element is in that state.
  2242. * All provided states must be active for the style to apply.
  2243. * Note: this **must** be before the element is defined.
  2244. * See [Styling Formspecs].
  2245. ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
  2246. * Set the style for the element(s) matching `selector` by type.
  2247. * `selector` can be one of:
  2248. * `<type>` - An element type. Includes `*`, which represents every element.
  2249. * `<type>:<state>` - An element type, a colon, and one or more states.
  2250. * `state` is a list of states separated by the `+` character.
  2251. * If a state is provided, the style will only take effect when the element is in that state.
  2252. * All provided states must be active for the style to apply.
  2253. * See [Styling Formspecs].
  2254. ### `set_focus[<name>;<force>]`
  2255. * Sets the focus to the element with the same `name` parameter.
  2256. * **Note**: This element must be placed before the element it focuses.
  2257. * `force` (optional, default `false`): By default, focus is not applied for
  2258. re-sent formspecs with the same name so that player-set focus is kept.
  2259. `true` sets the focus to the specified element for every sent formspec.
  2260. * The following elements have the ability to be focused:
  2261. * checkbox
  2262. * button
  2263. * button_exit
  2264. * image_button
  2265. * image_button_exit
  2266. * item_image_button
  2267. * table
  2268. * textlist
  2269. * dropdown
  2270. * field
  2271. * pwdfield
  2272. * textarea
  2273. * scrollbar
  2274. Migrating to Real Coordinates
  2275. -----------------------------
  2276. In the old system, positions included padding and spacing. Padding is a gap between
  2277. the formspec window edges and content, and spacing is the gaps between items. For
  2278. example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
  2279. and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
  2280. in the new coordinate system from scratch.
  2281. To recreate an old layout with padding, you'll need to pass the positions and sizes
  2282. through the following formula to re-introduce padding:
  2283. ```
  2284. pos = (oldpos + 1)*spacing + padding
  2285. where
  2286. padding = 3/8
  2287. spacing = 5/4
  2288. ```
  2289. You'll need to change the `size[]` tag like this:
  2290. ```
  2291. size = (oldsize-1)*spacing + padding*2 + 1
  2292. ```
  2293. A few elements had random offsets in the old system. Here is a table which shows these
  2294. offsets when migrating:
  2295. | Element | Position | Size | Notes
  2296. |---------|------------|---------|-------
  2297. | box | +0.3, +0.1 | 0, -0.4 |
  2298. | button | | | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
  2299. | list | | | Spacing is now 0.25 for both directions, meaning lists will be taller in height
  2300. | label | 0, +0.3 | | The first line of text is now positioned centered exactly at the position specified
  2301. Styling Formspecs
  2302. -----------------
  2303. Formspec elements can be themed using the style elements:
  2304. style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
  2305. style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
  2306. style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
  2307. style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
  2308. Where a prop is:
  2309. property_name=property_value
  2310. For example:
  2311. style_type[button;bgcolor=#006699]
  2312. style[world_delete;bgcolor=red;textcolor=yellow]
  2313. button[4,3.95;2.6,1;world_delete;Delete]
  2314. A name/type can optionally be a comma separated list of names/types, like so:
  2315. world_delete,world_create,world_configure
  2316. button,image_button
  2317. A `*` type can be used to select every element in the formspec.
  2318. Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
  2319. world_delete:hovered+pressed
  2320. button:pressed
  2321. States allow you to apply styles in response to changes in the element, instead of applying at all times.
  2322. Setting a property to nothing will reset it to the default value. For example:
  2323. style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
  2324. style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
  2325. ### Supported Element Types
  2326. Some types may inherit styles from parent types.
  2327. * animated_image, inherits from image
  2328. * box
  2329. * button
  2330. * button_exit, inherits from button
  2331. * checkbox
  2332. * dropdown
  2333. * field
  2334. * image
  2335. * image_button
  2336. * item_image_button
  2337. * label
  2338. * list
  2339. * model
  2340. * pwdfield, inherits from field
  2341. * scrollbar
  2342. * tabheader
  2343. * table
  2344. * textarea
  2345. * textlist
  2346. * vertlabel, inherits from label
  2347. ### Valid Properties
  2348. * animated_image
  2349. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2350. * box
  2351. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2352. * Defaults to false in formspec_version version 3 or higher
  2353. * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
  2354. * Single value (e.g. `#FF0`): All corners/borders.
  2355. * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
  2356. top and bottom,left and right.
  2357. * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
  2358. * These work similarly to CSS borders.
  2359. * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
  2360. * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
  2361. * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
  2362. negative, the border will extend inside the box, whereas positive extends outside
  2363. the box. A width of zero results in no border; this is default.
  2364. * button, button_exit, image_button, item_image_button
  2365. * alpha - boolean, whether to draw alpha in bgimg. Default true.
  2366. * bgcolor - color, sets button tint.
  2367. * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
  2368. * This is deprecated, use states instead.
  2369. * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
  2370. * This is deprecated, use states instead.
  2371. * bgimg - standard background image. Defaults to none.
  2372. * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
  2373. * This is deprecated, use states instead.
  2374. * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
  2375. See background9[] documentation for more details. This property also pads the
  2376. button's content when set.
  2377. * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
  2378. * This is deprecated, use states instead.
  2379. * font - Sets font type. This is a comma separated list of options. Valid options:
  2380. * Main font type options. These cannot be combined with each other:
  2381. * `normal`: Default font
  2382. * `mono`: Monospaced font
  2383. * Font modification options. If used without a main font type, `normal` is used:
  2384. * `bold`: Makes font bold.
  2385. * `italic`: Makes font italic.
  2386. Default `normal`.
  2387. * font_size - Sets font size. Default is user-set. Can have multiple values:
  2388. * `<number>`: Sets absolute font size to `number`.
  2389. * `+<number>`/`-<number>`: Offsets default font size by `number` points.
  2390. * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
  2391. * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
  2392. * content_offset - 2d vector, shifts the position of the button's content without resizing it.
  2393. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2394. * padding - rect, adds space between the edges of the button and the content. This value is
  2395. relative to bgimg_middle.
  2396. * sound - a sound to be played when triggered.
  2397. * textcolor - color, default white.
  2398. * checkbox
  2399. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2400. * sound - a sound to be played when triggered.
  2401. * dropdown
  2402. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2403. * sound - a sound to be played when the entry is changed.
  2404. * field, pwdfield, textarea
  2405. * border - set to false to hide the textbox background and border. Default true.
  2406. * font - Sets font type. See button `font` property for more information.
  2407. * font_size - Sets font size. See button `font_size` property for more information.
  2408. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2409. * textcolor - color. Default white.
  2410. * model
  2411. * bgcolor - color, sets background color.
  2412. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2413. * Default to false in formspec_version version 3 or higher
  2414. * image
  2415. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2416. * Default to false in formspec_version version 3 or higher
  2417. * item_image
  2418. * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
  2419. * label, vertlabel
  2420. * font - Sets font type. See button `font` property for more information.
  2421. * font_size - Sets font size. See button `font_size` property for more information.
  2422. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2423. * list
  2424. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2425. * size - 2d vector, sets the size of inventory slots in coordinates.
  2426. * spacing - 2d vector, sets the space between inventory slots in coordinates.
  2427. * image_button (additional properties)
  2428. * fgimg - standard image. Defaults to none.
  2429. * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
  2430. * This is deprecated, use states instead.
  2431. * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
  2432. * This is deprecated, use states instead.
  2433. * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
  2434. See background9[] documentation for more details.
  2435. * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
  2436. * sound - a sound to be played when triggered.
  2437. * scrollbar
  2438. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2439. * tabheader
  2440. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2441. * sound - a sound to be played when a different tab is selected.
  2442. * textcolor - color. Default white.
  2443. * table, textlist
  2444. * font - Sets font type. See button `font` property for more information.
  2445. * font_size - Sets font size. See button `font_size` property for more information.
  2446. * noclip - boolean, set to true to allow the element to exceed formspec bounds.
  2447. ### Valid States
  2448. * *all elements*
  2449. * default - Equivalent to providing no states
  2450. * button, button_exit, image_button, item_image_button
  2451. * hovered - Active when the mouse is hovering over the element
  2452. * pressed - Active when the button is pressed
  2453. Markup Language
  2454. ---------------
  2455. Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
  2456. The markup language is currently unstable and subject to change. Use with caution.
  2457. Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
  2458. Tags can have attributes, in that case, attributes are in the opening tag in
  2459. form of a key/value separated with equal signs. Attribute values should not be quoted.
  2460. If you want to insert a literal greater-than sign or a backslash into the text,
  2461. you must escape it by preceding it with a backslash.
  2462. These are the technically basic tags but see below for usual tags. Base tags are:
  2463. `<style color=... font=... size=...>...</style>`
  2464. Changes the style of the text.
  2465. * `color`: Text color. Given color is a `colorspec`.
  2466. * `size`: Text size.
  2467. * `font`: Text font (`mono` or `normal`).
  2468. `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
  2469. Sets global style.
  2470. Global only styles:
  2471. * `background`: Text background, a `colorspec` or `none`.
  2472. * `margin`: Page margins in pixel.
  2473. * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
  2474. Inheriting styles (affects child elements):
  2475. * `color`: Default text color. Given color is a `colorspec`.
  2476. * `hovercolor`: Color of <action> tags when mouse is over.
  2477. * `size`: Default text size.
  2478. * `font`: Default text font (`mono` or `normal`).
  2479. * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
  2480. This tag needs to be placed only once as it changes the global settings of the
  2481. text. Anyway, if several tags are placed, each changed will be made in the order
  2482. tags appear.
  2483. `<tag name=... color=... hovercolor=... font=... size=...>`
  2484. Defines or redefines tag style. This can be used to define new tags.
  2485. * `name`: Name of the tag to define or change.
  2486. * `color`: Text color. Given color is a `colorspec`.
  2487. * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
  2488. * `size`: Text size.
  2489. * `font`: Text font (`mono` or `normal`).
  2490. Following tags are the usual tags for text layout. They are defined by default.
  2491. Other tags can be added using `<tag ...>` tag.
  2492. `<normal>...</normal>`: Normal size text
  2493. `<big>...</big>`: Big text
  2494. `<bigger>...</bigger>`: Bigger text
  2495. `<center>...</center>`: Centered text
  2496. `<left>...</left>`: Left-aligned text
  2497. `<right>...</right>`: Right-aligned text
  2498. `<justify>...</justify>`: Justified text
  2499. `<mono>...</mono>`: Monospaced font
  2500. `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
  2501. `<action name=...>...</action>`
  2502. Make that text a clickable text triggering an action.
  2503. * `name`: Name of the action (mandatory).
  2504. When clicked, the formspec is send to the server. The value of the text field
  2505. sent to `on_player_receive_fields` will be "action:" concatenated to the action
  2506. name.
  2507. `<img name=... float=... width=... height=...>`
  2508. Draws an image which is present in the client media cache.
  2509. * `name`: Name of the texture (mandatory).
  2510. * `float`: If present, makes the image floating (`left` or `right`).
  2511. * `width`: Force image width instead of taking texture width.
  2512. * `height`: Force image height instead of taking texture height.
  2513. If only width or height given, texture aspect is kept.
  2514. `<item name=... float=... width=... height=... rotate=...>`
  2515. Draws an item image.
  2516. * `name`: Item string of the item to draw (mandatory).
  2517. * `float`: If present, makes the image floating (`left` or `right`).
  2518. * `width`: Item image width.
  2519. * `height`: Item image height.
  2520. * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
  2521. rotation speeds in percent of standard speed (-1000 to 1000). Works only if
  2522. `inventory_items_animations` is set to true.
  2523. * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
  2524. X, Y and Z being angles around each three axes. Works only if
  2525. `inventory_items_animations` is set to true.
  2526. Inventory
  2527. =========
  2528. Inventory locations
  2529. -------------------
  2530. * `"context"`: Selected node metadata (deprecated: `"current_name"`)
  2531. * `"current_player"`: Player to whom the menu is shown
  2532. * `"player:<name>"`: Any player
  2533. * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
  2534. * `"detached:<name>"`: A detached inventory
  2535. Player Inventory lists
  2536. ----------------------
  2537. * `main`: list containing the default inventory
  2538. * `craft`: list containing the craft input
  2539. * `craftpreview`: list containing the craft prediction
  2540. * `craftresult`: list containing the crafted output
  2541. * `hand`: list containing an override for the empty hand
  2542. * Is not created automatically, use `InvRef:set_size`
  2543. * Is only used to enhance the empty hand's tool capabilities
  2544. Colors
  2545. ======
  2546. `ColorString`
  2547. -------------
  2548. `#RGB` defines a color in hexadecimal format.
  2549. `#RGBA` defines a color in hexadecimal format and alpha channel.
  2550. `#RRGGBB` defines a color in hexadecimal format.
  2551. `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
  2552. Named colors are also supported and are equivalent to
  2553. [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
  2554. To specify the value of the alpha channel, append `#A` or `#AA` to the end of
  2555. the color name (e.g. `colorname#08`).
  2556. `ColorSpec`
  2557. -----------
  2558. A ColorSpec specifies a 32-bit color. It can be written in any of the following
  2559. forms:
  2560. * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
  2561. * `colorspec = {a=255, r=0, g=255, b=0}`
  2562. * numerical form: The raw integer value of an ARGB8 quad:
  2563. * `colorspec = 0xFF00FF00`
  2564. * string form: A ColorString (defined above):
  2565. * `colorspec = "green"`
  2566. Escape sequences
  2567. ================
  2568. Most text can contain escape sequences, that can for example color the text.
  2569. There are a few exceptions: tab headers, dropdowns and vertical labels can't.
  2570. The following functions provide escape sequences:
  2571. * `minetest.get_color_escape_sequence(color)`:
  2572. * `color` is a ColorString
  2573. * The escape sequence sets the text color to `color`
  2574. * `minetest.colorize(color, message)`:
  2575. * Equivalent to:
  2576. `minetest.get_color_escape_sequence(color) ..
  2577. message ..
  2578. minetest.get_color_escape_sequence("#ffffff")`
  2579. * `minetest.get_background_escape_sequence(color)`
  2580. * `color` is a ColorString
  2581. * The escape sequence sets the background of the whole text element to
  2582. `color`. Only defined for item descriptions and tooltips.
  2583. * `minetest.strip_foreground_colors(str)`
  2584. * Removes foreground colors added by `get_color_escape_sequence`.
  2585. * `minetest.strip_background_colors(str)`
  2586. * Removes background colors added by `get_background_escape_sequence`.
  2587. * `minetest.strip_colors(str)`
  2588. * Removes all color escape sequences.
  2589. Spatial Vectors
  2590. ===============
  2591. Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
  2592. and has a class to represent them (`vector.*`), which this chapter is about.
  2593. For details on what a spatial vectors is, please refer to Wikipedia:
  2594. https://en.wikipedia.org/wiki/Euclidean_vector.
  2595. Spatial vectors are used for various things, including, but not limited to:
  2596. * any 3D spatial vector (x/y/z-directions)
  2597. * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
  2598. meaning here. Therefore, most vector operations make no sense in this use case.)
  2599. Note that they are *not* used for:
  2600. * n-dimensional vectors where n is not 3 (ie. n=2)
  2601. * arrays of the form `{num, num, num}`
  2602. The API documentation may refer to spatial vectors, as produced by `vector.new`,
  2603. by any of the following notations:
  2604. * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
  2605. * `vector.new(x, y, z)`
  2606. * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
  2607. Compatibility notes
  2608. -------------------
  2609. Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
  2610. Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
  2611. Note: Those old-style vectors can still be found in old mod code. Hence, mod and
  2612. engine APIs still need to be able to cope with them in many places.
  2613. Manually constructed tables are deprecated and highly discouraged. This interface
  2614. should be used to ensure seamless compatibility between mods and the Minetest API.
  2615. This is especially important to callback function parameters and functions overwritten
  2616. by mods.
  2617. Also, though not likely, the internal implementation of a vector might change in
  2618. the future.
  2619. In your own code, or if you define your own API, you can, of course, still use
  2620. other representations of vectors.
  2621. Vectors provided by API functions will provide an instance of this class if not
  2622. stated otherwise. Mods should adapt this for convenience reasons.
  2623. Special properties of the class
  2624. -------------------------------
  2625. Vectors can be indexed with numbers and allow method and operator syntax.
  2626. All these forms of addressing a vector `v` are valid:
  2627. `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
  2628. Note: Prefer letter over number indexing for performance and compatibility reasons.
  2629. Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
  2630. the same as `vector.foo(v, ...)`, apart from deprecated functionality.
  2631. `tostring` is defined for vectors, see `vector.to_string`.
  2632. The metatable that is used for vectors can be accessed via `vector.metatable`.
  2633. Do not modify it!
  2634. All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
  2635. Returned vectors always have a metatable set.
  2636. Common functions and methods
  2637. ----------------------------
  2638. For the following functions (and subchapters),
  2639. `v`, `v1`, `v2` are vectors,
  2640. `p1`, `p2` are position vectors,
  2641. `s` is a scalar (a number),
  2642. vectors are written like this: `(x, y, z)`:
  2643. * `vector.new([a[, b, c]])`:
  2644. * Returns a new vector `(a, b, c)`.
  2645. * Deprecated: `vector.new()` does the same as `vector.zero()` and
  2646. `vector.new(v)` does the same as `vector.copy(v)`
  2647. * `vector.zero()`:
  2648. * Returns a new vector `(0, 0, 0)`.
  2649. * `vector.copy(v)`:
  2650. * Returns a copy of the vector `v`.
  2651. * `vector.from_string(s[, init])`:
  2652. * Returns `v, np`, where `v` is a vector read from the given string `s` and
  2653. `np` is the next position in the string after the vector.
  2654. * Returns `nil` on failure.
  2655. * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
  2656. spaces, leaving away commas and adding an additional comma to the end
  2657. is allowed.
  2658. * `init`: If given starts looking for the vector at this string index.
  2659. * `vector.to_string(v)`:
  2660. * Returns a string of the form `"(x, y, z)"`.
  2661. * `tostring(v)` does the same.
  2662. * `vector.direction(p1, p2)`:
  2663. * Returns a vector of length 1 with direction `p1` to `p2`.
  2664. * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
  2665. * `vector.distance(p1, p2)`:
  2666. * Returns zero or a positive number, the distance between `p1` and `p2`.
  2667. * `vector.length(v)`:
  2668. * Returns zero or a positive number, the length of vector `v`.
  2669. * `vector.normalize(v)`:
  2670. * Returns a vector of length 1 with direction of vector `v`.
  2671. * If `v` has zero length, returns `(0, 0, 0)`.
  2672. * `vector.floor(v)`:
  2673. * Returns a vector, each dimension rounded down.
  2674. * `vector.round(v)`:
  2675. * Returns a vector, each dimension rounded to nearest integer.
  2676. * At a multiple of 0.5, rounds away from zero.
  2677. * `vector.apply(v, func)`:
  2678. * Returns a vector where the function `func` has been applied to each
  2679. component.
  2680. * `vector.combine(v, w, func)`:
  2681. * Returns a vector where the function `func` has combined both components of `v` and `w`
  2682. for each component
  2683. * `vector.equals(v1, v2)`:
  2684. * Returns a boolean, `true` if the vectors are identical.
  2685. * `vector.sort(v1, v2)`:
  2686. * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
  2687. * `vector.angle(v1, v2)`:
  2688. * Returns the angle between `v1` and `v2` in radians.
  2689. * `vector.dot(v1, v2)`:
  2690. * Returns the dot product of `v1` and `v2`.
  2691. * `vector.cross(v1, v2)`:
  2692. * Returns the cross product of `v1` and `v2`.
  2693. * `vector.offset(v, x, y, z)`:
  2694. * Returns the sum of the vectors `v` and `(x, y, z)`.
  2695. * `vector.check(v)`:
  2696. * Returns a boolean value indicating whether `v` is a real vector, eg. created
  2697. by a `vector.*` function.
  2698. * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
  2699. For the following functions `x` can be either a vector or a number:
  2700. * `vector.add(v, x)`:
  2701. * Returns a vector.
  2702. * If `x` is a vector: Returns the sum of `v` and `x`.
  2703. * If `x` is a number: Adds `x` to each component of `v`.
  2704. * `vector.subtract(v, x)`:
  2705. * Returns a vector.
  2706. * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
  2707. * If `x` is a number: Subtracts `x` from each component of `v`.
  2708. * `vector.multiply(v, s)`:
  2709. * Returns a scaled vector.
  2710. * Deprecated: If `s` is a vector: Returns the Schur product.
  2711. * `vector.divide(v, s)`:
  2712. * Returns a scaled vector.
  2713. * Deprecated: If `s` is a vector: Returns the Schur quotient.
  2714. Operators
  2715. ---------
  2716. Operators can be used if all of the involved vectors have metatables:
  2717. * `v1 == v2`:
  2718. * Returns whether `v1` and `v2` are identical.
  2719. * `-v`:
  2720. * Returns the additive inverse of v.
  2721. * `v1 + v2`:
  2722. * Returns the sum of both vectors.
  2723. * Note: `+` cannot be used together with scalars.
  2724. * `v1 - v2`:
  2725. * Returns the difference of `v1` subtracted by `v2`.
  2726. * Note: `-` cannot be used together with scalars.
  2727. * `v * s` or `s * v`:
  2728. * Returns `v` scaled by `s`.
  2729. * `v / s`:
  2730. * Returns `v` scaled by `1 / s`.
  2731. Rotation-related functions
  2732. --------------------------
  2733. For the following functions `a` is an angle in radians and `r` is a rotation
  2734. vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
  2735. angles in radians.
  2736. * `vector.rotate(v, r)`:
  2737. * Applies the rotation `r` to `v` and returns the result.
  2738. * `vector.rotate(vector.new(0, 0, 1), r)` and
  2739. `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
  2740. forward and up relative to an entity's rotation `r`.
  2741. * `vector.rotate_around_axis(v1, v2, a)`:
  2742. * Returns `v1` rotated around axis `v2` by `a` radians according to
  2743. the right hand rule.
  2744. * `vector.dir_to_rotation(direction[, up])`:
  2745. * Returns a rotation vector for `direction` pointing forward using `up`
  2746. as the up vector.
  2747. * If `up` is omitted, the roll of the returned vector defaults to zero.
  2748. * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
  2749. Further helpers
  2750. ---------------
  2751. There are more helper functions involving vectors, but they are listed elsewhere
  2752. because they only work on specific sorts of vectors or involve things that are not
  2753. vectors.
  2754. For example:
  2755. * `minetest.hash_node_position` (Only works on node positions.)
  2756. * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
  2757. Helper functions
  2758. ================
  2759. * `dump2(obj, name, dumped)`: returns a string which makes `obj`
  2760. human-readable, handles reference loops.
  2761. * `obj`: arbitrary variable
  2762. * `name`: string, default: `"_"`
  2763. * `dumped`: table, default: `{}`
  2764. * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
  2765. * `obj`: arbitrary variable
  2766. * `dumped`: table, default: `{}`
  2767. * `math.hypot(x, y)`
  2768. * Get the hypotenuse of a triangle with legs x and y.
  2769. Useful for distance calculation.
  2770. * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
  2771. * Get the sign of a number.
  2772. * tolerance: number, default: `0.0`
  2773. * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
  2774. `0` is returned.
  2775. * `math.factorial(x)`: returns the factorial of `x`
  2776. * `math.round(x)`: Returns `x` rounded to the nearest integer.
  2777. * At a multiple of 0.5, rounds away from zero.
  2778. * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
  2779. * `separator`: string, default: `","`
  2780. * `include_empty`: boolean, default: `false`
  2781. * `max_splits`: number, if it's negative, splits aren't limited,
  2782. default: `-1`
  2783. * `sep_is_pattern`: boolean, it specifies whether separator is a plain
  2784. string or a pattern (regex), default: `false`
  2785. * e.g. `"a,b":split","` returns `{"a","b"}`
  2786. * `string:trim()`: returns the string without whitespace pre- and suffixes
  2787. * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
  2788. * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
  2789. * Adds newlines to the string to keep it within the specified character
  2790. limit
  2791. * Note that the returned lines may be longer than the limit since it only
  2792. splits at word borders.
  2793. * `limit`: number, maximal amount of characters in one line
  2794. * `as_table`: boolean, if set to true, a table of lines instead of a string
  2795. is returned, default: `false`
  2796. * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
  2797. * `pos`: table {x=X, y=Y, z=Z}
  2798. * Converts the position `pos` to a human-readable, printable string
  2799. * `decimal_places`: number, if specified, the x, y and z values of
  2800. the position are rounded to the given decimal place.
  2801. * `minetest.string_to_pos(string)`: returns a position or `nil`
  2802. * Same but in reverse.
  2803. * If the string can't be parsed to a position, nothing is returned.
  2804. * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
  2805. * returns two positions
  2806. * Converts a string representing an area box into two positions
  2807. * X1, Y1, ... Z2 are coordinates
  2808. * `relative_to`: Optional. If set to a position, each coordinate
  2809. can use the tilde notation for relative positions
  2810. * Tilde notation: "~": Relative coordinate
  2811. "~<number>": Relative coordinate plus <number>
  2812. * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
  2813. returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
  2814. * `minetest.formspec_escape(string)`: returns a string
  2815. * escapes the characters "[", "]", "\", "," and ";", which cannot be used
  2816. in formspecs.
  2817. * `minetest.is_yes(arg)`
  2818. * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
  2819. * `minetest.is_nan(arg)`
  2820. * returns true when the passed number represents NaN.
  2821. * `minetest.get_us_time()`
  2822. * returns time with microsecond precision. May not return wall time.
  2823. * `table.copy(table)`: returns a table
  2824. * returns a deep copy of `table`
  2825. * `table.indexof(list, val)`: returns the smallest numerical index containing
  2826. the value `val` in the table `list`. Non-numerical indices are ignored.
  2827. If `val` could not be found, `-1` is returned. `list` must not have
  2828. negative indices.
  2829. * `table.insert_all(table, other_table)`:
  2830. * Appends all values in `other_table` to `table` - uses `#table + 1` to
  2831. find new indices.
  2832. * `table.key_value_swap(t)`: returns a table with keys and values swapped
  2833. * If multiple keys in `t` map to the same value, it is unspecified which
  2834. value maps to that key.
  2835. * `table.shuffle(table, [from], [to], [random_func])`:
  2836. * Shuffles elements `from` to `to` in `table` in place
  2837. * `from` defaults to `1`
  2838. * `to` defaults to `#table`
  2839. * `random_func` defaults to `math.random`. This function receives two
  2840. integers as arguments and should return a random integer inclusively
  2841. between them.
  2842. * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
  2843. position.
  2844. * returns the exact position on the surface of a pointed node
  2845. * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
  2846. * Simulates a tool being used once and returns the added wear,
  2847. such that, if only this function is used to calculate wear,
  2848. the tool will break exactly after `uses` times of uses
  2849. * `uses`: Number of times the tool can be used
  2850. * `initial_wear`: The initial wear the tool starts with (default: 0)
  2851. * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
  2852. Simulates an item that digs a node.
  2853. Returns a table with the following fields:
  2854. * `diggable`: `true` if node can be dug, `false` otherwise.
  2855. * `time`: Time it would take to dig the node.
  2856. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2857. `time` and `wear` are meaningless if node's not diggable
  2858. Parameters:
  2859. * `groups`: Table of the node groups of the node that would be dug
  2860. * `tool_capabilities`: Tool capabilities table of the item
  2861. * `wear`: Amount of wear the tool starts with (default: 0)
  2862. * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
  2863. Simulates an item that punches an object.
  2864. Returns a table with the following fields:
  2865. * `hp`: How much damage the punch would cause (between -65535 and 65535).
  2866. * `wear`: How much wear would be added to the tool (ignored for non-tools).
  2867. Parameters:
  2868. * `groups`: Damage groups of the object
  2869. * `tool_capabilities`: Tool capabilities table of the item
  2870. * `time_from_last_punch`: time in seconds since last punch action
  2871. * `wear`: Amount of wear the item starts with (default: 0)
  2872. Translations
  2873. ============
  2874. Texts can be translated client-side with the help of `minetest.translate` and
  2875. translation files.
  2876. Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
  2877. to generate and update translation files automatically from the Lua source.
  2878. Translating a string
  2879. --------------------
  2880. Two functions are provided to translate strings: `minetest.translate` and
  2881. `minetest.get_translator`.
  2882. * `minetest.get_translator(textdomain)` is a simple wrapper around
  2883. `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
  2884. equivalent to `minetest.translate(textdomain, str, ...)`.
  2885. It is intended to be used in the following way, so that it avoids verbose
  2886. repetitions of `minetest.translate`:
  2887. local S = minetest.get_translator(textdomain)
  2888. S(str, ...)
  2889. As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
  2890. * `minetest.translate(textdomain, str, ...)` translates the string `str` with
  2891. the given `textdomain` for disambiguation. The textdomain must match the
  2892. textdomain specified in the translation file in order to get the string
  2893. translated. This can be used so that a string is translated differently in
  2894. different contexts.
  2895. It is advised to use the name of the mod as textdomain whenever possible, to
  2896. avoid clashes with other mods.
  2897. This function must be given a number of arguments equal to the number of
  2898. arguments the translated string expects.
  2899. Arguments are literal strings -- they will not be translated, so if you want
  2900. them to be, they need to come as outputs of `minetest.translate` as well.
  2901. For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
  2902. by the translation of "Red". We can do the following:
  2903. local S = minetest.get_translator()
  2904. S("@1 Wool", S("Red"))
  2905. This will be displayed as "Red Wool" on old clients and on clients that do
  2906. not have localization enabled. However, if we have for instance a translation
  2907. file named `wool.fr.tr` containing the following:
  2908. @1 Wool=Laine @1
  2909. Red=Rouge
  2910. this will be displayed as "Laine Rouge" on clients with a French locale.
  2911. Operations on translated strings
  2912. --------------------------------
  2913. The output of `minetest.translate` is a string, with escape sequences adding
  2914. additional information to that string so that it can be translated on the
  2915. different clients. In particular, you can't expect operations like string.length
  2916. to work on them like you would expect them to, or string.gsub to work in the
  2917. expected manner. However, string concatenation will still work as expected
  2918. (note that you should only use this for things like formspecs; do not translate
  2919. sentences by breaking them into parts; arguments should be used instead), and
  2920. operations such as `minetest.colorize` which are also concatenation.
  2921. Translation file format
  2922. -----------------------
  2923. A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
  2924. it corresponds to. It must be put into the `locale` subdirectory of the mod.
  2925. The file should be a text file, with the following format:
  2926. * Lines beginning with `# textdomain:` (the space is significant) can be used
  2927. to specify the text domain of all following translations in the file.
  2928. * All other empty lines or lines beginning with `#` are ignored.
  2929. * Other lines should be in the format `original=translated`. Both `original`
  2930. and `translated` can contain escape sequences beginning with `@` to insert
  2931. arguments, literal `@`, `=` or newline (See [Escapes] below).
  2932. There must be no extraneous whitespace around the `=` or at the beginning or
  2933. the end of the line.
  2934. Escapes
  2935. -------
  2936. Strings that need to be translated can contain several escapes, preceded by `@`.
  2937. * `@@` acts as a literal `@`.
  2938. * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
  2939. string that will be inlined when translated. Due to how translations are
  2940. implemented, the original translation string **must** have its arguments in
  2941. increasing order, without gaps or repetitions, starting from 1.
  2942. * `@=` acts as a literal `=`. It is not required in strings given to
  2943. `minetest.translate`, but is in translation files to avoid being confused
  2944. with the `=` separating the original from the translation.
  2945. * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
  2946. As with `@=`, this escape is not required in strings given to
  2947. `minetest.translate`, but is in translation files.
  2948. * `@n` acts as a literal newline as well.
  2949. Server side translations
  2950. ------------------------
  2951. On some specific cases, server translation could be useful. For example, filter
  2952. a list on labels and send results to client. A method is supplied to achieve
  2953. that:
  2954. `minetest.get_translated_string(lang_code, string)`: Translates `string` using
  2955. translations for `lang_code` language. It gives the same result as if the string
  2956. was translated by the client.
  2957. The `lang_code` to use for a given player can be retrieved from
  2958. the table returned by `minetest.get_player_information(name)`.
  2959. IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
  2960. You do not need to use this to get translated strings to show up on the client.
  2961. Perlin noise
  2962. ============
  2963. Perlin noise creates a continuously-varying value depending on the input values.
  2964. Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
  2965. The result is used during map generation to create the terrain shape, vary heat
  2966. and humidity to distribute biomes, vary the density of decorations or vary the
  2967. structure of ores.
  2968. Structure of perlin noise
  2969. -------------------------
  2970. An 'octave' is a simple noise generator that outputs a value between -1 and 1.
  2971. The smooth wavy noise it generates has a single characteristic scale, almost
  2972. like a 'wavelength', so on its own does not create fine detail.
  2973. Due to this perlin noise combines several octaves to create variation on
  2974. multiple scales. Each additional octave has a smaller 'wavelength' than the
  2975. previous.
  2976. This combination results in noise varying very roughly between -2.0 and 2.0 and
  2977. with an average value of 0.0, so `scale` and `offset` are then used to multiply
  2978. and offset the noise variation.
  2979. The final perlin noise variation is created as follows:
  2980. noise = offset + scale * (octave1 +
  2981. octave2 * persistence +
  2982. octave3 * persistence ^ 2 +
  2983. octave4 * persistence ^ 3 +
  2984. ...)
  2985. Noise Parameters
  2986. ----------------
  2987. Noise Parameters are commonly called `NoiseParams`.
  2988. ### `offset`
  2989. After the multiplication by `scale` this is added to the result and is the final
  2990. step in creating the noise value.
  2991. Can be positive or negative.
  2992. ### `scale`
  2993. Once all octaves have been combined, the result is multiplied by this.
  2994. Can be positive or negative.
  2995. ### `spread`
  2996. For octave1, this is roughly the change of input value needed for a very large
  2997. variation in the noise value generated by octave1. It is almost like a
  2998. 'wavelength' for the wavy noise variation.
  2999. Each additional octave has a 'wavelength' that is smaller than the previous
  3000. octave, to create finer detail. `spread` will therefore roughly be the typical
  3001. size of the largest structures in the final noise variation.
  3002. `spread` is a vector with values for x, y, z to allow the noise variation to be
  3003. stretched or compressed in the desired axes.
  3004. Values are positive numbers.
  3005. ### `seed`
  3006. This is a whole number that determines the entire pattern of the noise
  3007. variation. Altering it enables different noise patterns to be created.
  3008. With other parameters equal, different seeds produce different noise patterns
  3009. and identical seeds produce identical noise patterns.
  3010. For this parameter you can randomly choose any whole number. Usually it is
  3011. preferable for this to be different from other seeds, but sometimes it is useful
  3012. to be able to create identical noise patterns.
  3013. In some noise APIs the world seed is added to the seed specified in noise
  3014. parameters. This is done to make the resulting noise pattern vary in different
  3015. worlds, and be 'world-specific'.
  3016. ### `octaves`
  3017. The number of simple noise generators that are combined.
  3018. A whole number, 1 or more.
  3019. Each additional octave adds finer detail to the noise but also increases the
  3020. noise calculation load.
  3021. 3 is a typical minimum for a high quality, complex and natural-looking noise
  3022. variation. 1 octave has a slight 'gridlike' appearance.
  3023. Choose the number of octaves according to the `spread` and `lacunarity`, and the
  3024. size of the finest detail you require. For example:
  3025. if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
  3026. nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
  3027. 512, 256, 128, 64, 32, 16 nodes.
  3028. Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
  3029. ### `persistence`
  3030. Each additional octave has an amplitude that is the amplitude of the previous
  3031. octave multiplied by `persistence`, to reduce the amplitude of finer details,
  3032. as is often helpful and natural to do so.
  3033. Since this controls the balance of fine detail to large-scale detail
  3034. `persistence` can be thought of as the 'roughness' of the noise.
  3035. A positive or negative non-zero number, often between 0.3 and 1.0.
  3036. A common medium value is 0.5, such that each octave has half the amplitude of
  3037. the previous octave.
  3038. This may need to be tuned when altering `lacunarity`; when doing so consider
  3039. that a common medium value is 1 / lacunarity.
  3040. ### `lacunarity`
  3041. Each additional octave has a 'wavelength' that is the 'wavelength' of the
  3042. previous octave multiplied by 1 / lacunarity, to create finer detail.
  3043. 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
  3044. A positive number no smaller than 1.0.
  3045. Values below 2.0 create higher quality noise at the expense of requiring more
  3046. octaves to cover a particular range of 'wavelengths'.
  3047. ### `flags`
  3048. Leave this field unset for no special handling.
  3049. Currently supported are `defaults`, `eased` and `absvalue`:
  3050. #### `defaults`
  3051. Specify this if you would like to keep auto-selection of eased/not-eased while
  3052. specifying some other flags.
  3053. #### `eased`
  3054. Maps noise gradient values onto a quintic S-curve before performing
  3055. interpolation. This results in smooth, rolling noise.
  3056. Disable this (`noeased`) for sharp-looking noise with a slightly gridded
  3057. appearance.
  3058. If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
  3059. not eased.
  3060. Easing a 3D noise significantly increases the noise calculation load, so use
  3061. with restraint.
  3062. #### `absvalue`
  3063. The absolute value of each octave's noise variation is used when combining the
  3064. octaves. The final perlin noise variation is created as follows:
  3065. noise = offset + scale * (abs(octave1) +
  3066. abs(octave2) * persistence +
  3067. abs(octave3) * persistence ^ 2 +
  3068. abs(octave4) * persistence ^ 3 +
  3069. ...)
  3070. ### Format example
  3071. For 2D or 3D perlin noise or perlin noise maps:
  3072. np_terrain = {
  3073. offset = 0,
  3074. scale = 1,
  3075. spread = {x = 500, y = 500, z = 500},
  3076. seed = 571347,
  3077. octaves = 5,
  3078. persistence = 0.63,
  3079. lacunarity = 2.0,
  3080. flags = "defaults, absvalue",
  3081. }
  3082. For 2D noise the Z component of `spread` is still defined but is ignored.
  3083. A single noise parameter table can be used for 2D or 3D noise.
  3084. Ores
  3085. ====
  3086. Ore types
  3087. ---------
  3088. These tell in what manner the ore is generated.
  3089. All default ores are of the uniformly-distributed scatter type.
  3090. ### `scatter`
  3091. Randomly chooses a location and generates a cluster of ore.
  3092. If `noise_params` is specified, the ore will be placed if the 3D perlin noise
  3093. at that point is greater than the `noise_threshold`, giving the ability to
  3094. create a non-equal distribution of ore.
  3095. ### `sheet`
  3096. Creates a sheet of ore in a blob shape according to the 2D perlin noise
  3097. described by `noise_params` and `noise_threshold`. This is essentially an
  3098. improved version of the so-called "stratus" ore seen in some unofficial mods.
  3099. This sheet consists of vertical columns of uniform randomly distributed height,
  3100. varying between the inclusive range `column_height_min` and `column_height_max`.
  3101. If `column_height_min` is not specified, this parameter defaults to 1.
  3102. If `column_height_max` is not specified, this parameter defaults to `clust_size`
  3103. for reverse compatibility. New code should prefer `column_height_max`.
  3104. The `column_midpoint_factor` parameter controls the position of the column at
  3105. which ore emanates from.
  3106. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
  3107. equally starting from each direction.
  3108. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
  3109. this parameter is not specified, the default is 0.5.
  3110. The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
  3111. ore type.
  3112. ### `puff`
  3113. Creates a sheet of ore in a cloud-like puff shape.
  3114. As with the `sheet` ore type, the size and shape of puffs are described by
  3115. `noise_params` and `noise_threshold` and are placed at random vertical
  3116. positions within the currently generated chunk.
  3117. The vertical top and bottom displacement of each puff are determined by the
  3118. noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
  3119. ### `blob`
  3120. Creates a deformed sphere of ore according to 3d perlin noise described by
  3121. `noise_params`. The maximum size of the blob is `clust_size`, and
  3122. `clust_scarcity` has the same meaning as with the `scatter` type.
  3123. ### `vein`
  3124. Creates veins of ore varying in density by according to the intersection of two
  3125. instances of 3d perlin noise with different seeds, both described by
  3126. `noise_params`.
  3127. `random_factor` varies the influence random chance has on placement of an ore
  3128. inside the vein, which is `1` by default. Note that modifying this parameter
  3129. may require adjusting `noise_threshold`.
  3130. The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
  3131. by this ore type.
  3132. This ore type is difficult to control since it is sensitive to small changes.
  3133. The following is a decent set of parameters to work from:
  3134. noise_params = {
  3135. offset = 0,
  3136. scale = 3,
  3137. spread = {x=200, y=200, z=200},
  3138. seed = 5390,
  3139. octaves = 4,
  3140. persistence = 0.5,
  3141. lacunarity = 2.0,
  3142. flags = "eased",
  3143. },
  3144. noise_threshold = 1.6
  3145. **WARNING**: Use this ore type *very* sparingly since it is ~200x more
  3146. computationally expensive than any other ore.
  3147. ### `stratum`
  3148. Creates a single undulating ore stratum that is continuous across mapchunk
  3149. borders and horizontally spans the world.
  3150. The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
  3151. the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
  3152. defines the stratum's vertical thickness (in units of nodes). Due to being
  3153. continuous across mapchunk borders the stratum's vertical thickness is
  3154. unlimited.
  3155. If the noise parameter `noise_params` is omitted the ore will occur from y_min
  3156. to y_max in a simple horizontal stratum.
  3157. A parameter `stratum_thickness` can be provided instead of the noise parameter
  3158. `np_stratum_thickness`, to create a constant thickness.
  3159. Leaving out one or both noise parameters makes the ore generation less
  3160. intensive, useful when adding multiple strata.
  3161. `y_min` and `y_max` define the limits of the ore generation and for performance
  3162. reasons should be set as close together as possible but without clipping the
  3163. stratum's Y variation.
  3164. Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
  3165. solid-ore stratum would require a `clust_scarcity` of 1.
  3166. The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
  3167. `random_factor` are ignored by this ore type.
  3168. Ore attributes
  3169. --------------
  3170. See section [Flag Specifier Format].
  3171. Currently supported flags:
  3172. `puff_cliffs`, `puff_additive_composition`.
  3173. ### `puff_cliffs`
  3174. If set, puff ore generation will not taper down large differences in
  3175. displacement when approaching the edge of a puff. This flag has no effect for
  3176. ore types other than `puff`.
  3177. ### `puff_additive_composition`
  3178. By default, when noise described by `np_puff_top` or `np_puff_bottom` results
  3179. in a negative displacement, the sub-column at that point is not generated. With
  3180. this attribute set, puff ore generation will instead generate the absolute
  3181. difference in noise displacement values. This flag has no effect for ore types
  3182. other than `puff`.
  3183. Decoration types
  3184. ================
  3185. The varying types of decorations that can be placed.
  3186. `simple`
  3187. --------
  3188. Creates a 1 times `H` times 1 column of a specified node (or a random node from
  3189. a list, if a decoration list is specified). Can specify a certain node it must
  3190. spawn next to, such as water or lava, for example. Can also generate a
  3191. decoration of random height between a specified lower and upper bound.
  3192. This type of decoration is intended for placement of grass, flowers, cacti,
  3193. papyri, waterlilies and so on.
  3194. `schematic`
  3195. -----------
  3196. Copies a box of `MapNodes` from a specified schematic file (or raw description).
  3197. Can specify a probability of a node randomly appearing when placed.
  3198. This decoration type is intended to be used for multi-node sized discrete
  3199. structures, such as trees, cave spikes, rocks, and so on.
  3200. Schematics
  3201. ==========
  3202. Schematic specifier
  3203. --------------------
  3204. A schematic specifier identifies a schematic by either a filename to a
  3205. Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  3206. in the form of a table. This table specifies the following fields:
  3207. * The `size` field is a 3D vector containing the dimensions of the provided
  3208. schematic. (required field)
  3209. * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
  3210. sets the probability of a particular horizontal slice of the schematic being
  3211. placed. (optional field)
  3212. `ypos` = 0 for the lowest horizontal slice of a schematic.
  3213. The default of `prob` is 255.
  3214. * The `data` field is a flat table of MapNode tables making up the schematic,
  3215. in the order of `[z [y [x]]]`. (required field)
  3216. Each MapNode table contains:
  3217. * `name`: the name of the map node to place (required)
  3218. * `prob` (alias `param1`): the probability of this node being placed
  3219. (default: 255)
  3220. * `param2`: the raw param2 value of the node being placed onto the map
  3221. (default: 0)
  3222. * `force_place`: boolean representing if the node should forcibly overwrite
  3223. any previous contents (default: false)
  3224. About probability values:
  3225. * A probability value of `0` or `1` means that node will never appear
  3226. (0% chance).
  3227. * A probability value of `254` or `255` means the node will always appear
  3228. (100% chance).
  3229. * If the probability value `p` is greater than `1`, then there is a
  3230. `(p / 256 * 100)` percent chance that node will appear when the schematic is
  3231. placed on the map.
  3232. Schematic attributes
  3233. --------------------
  3234. See section [Flag Specifier Format].
  3235. Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
  3236. `force_placement`.
  3237. * `place_center_x`: Placement of this decoration is centered along the X axis.
  3238. * `place_center_y`: Placement of this decoration is centered along the Y axis.
  3239. * `place_center_z`: Placement of this decoration is centered along the Z axis.
  3240. * `force_placement`: Schematic nodes other than "ignore" will replace existing
  3241. nodes.
  3242. Lua Voxel Manipulator
  3243. =====================
  3244. About VoxelManip
  3245. ----------------
  3246. VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
  3247. facility. The purpose of this object is for fast, low-level, bulk access to
  3248. reading and writing Map content. As such, setting map nodes through VoxelManip
  3249. will lack many of the higher level features and concepts you may be used to
  3250. with other methods of setting nodes. For example, nodes will not have their
  3251. construction and destruction callbacks run, and no rollback information is
  3252. logged.
  3253. It is important to note that VoxelManip is designed for speed, and *not* ease
  3254. of use or flexibility. If your mod requires a map manipulation facility that
  3255. will handle 100% of all edge cases, or the use of high level node placement
  3256. features, perhaps `minetest.set_node()` is better suited for the job.
  3257. In addition, VoxelManip might not be faster, or could even be slower, for your
  3258. specific use case. VoxelManip is most effective when setting large areas of map
  3259. at once - for example, if only setting a 3x3x3 node area, a
  3260. `minetest.set_node()` loop may be more optimal. Always profile code using both
  3261. methods of map manipulation to determine which is most appropriate for your
  3262. usage.
  3263. A recent simple test of setting cubic areas showed that `minetest.set_node()`
  3264. is faster than a VoxelManip for a 3x3x3 node cube or smaller.
  3265. Using VoxelManip
  3266. ----------------
  3267. A VoxelManip object can be created any time using either:
  3268. `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
  3269. If the optional position parameters are present for either of these routines,
  3270. the specified region will be pre-loaded into the VoxelManip object on creation.
  3271. Otherwise, the area of map you wish to manipulate must first be loaded into the
  3272. VoxelManip object using `VoxelManip:read_from_map()`.
  3273. Note that `VoxelManip:read_from_map()` returns two position vectors. The region
  3274. formed by these positions indicate the minimum and maximum (respectively)
  3275. positions of the area actually loaded in the VoxelManip, which may be larger
  3276. than the area requested. For convenience, the loaded area coordinates can also
  3277. be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
  3278. Now that the VoxelManip object is populated with map data, your mod can fetch a
  3279. copy of this data using either of two methods. `VoxelManip:get_node_at()`,
  3280. which retrieves an individual node in a MapNode formatted table at the position
  3281. requested is the simplest method to use, but also the slowest.
  3282. Nodes in a VoxelManip object may also be read in bulk to a flat array table
  3283. using:
  3284. * `VoxelManip:get_data()` for node content (in Content ID form, see section
  3285. [Content IDs]),
  3286. * `VoxelManip:get_light_data()` for node light levels, and
  3287. * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
  3288. See section [Flat array format] for more details.
  3289. It is very important to understand that the tables returned by any of the above
  3290. three functions represent a snapshot of the VoxelManip's internal state at the
  3291. time of the call. This copy of the data will not magically update itself if
  3292. another function modifies the internal VoxelManip state.
  3293. Any functions that modify a VoxelManip's contents work on the VoxelManip's
  3294. internal state unless otherwise explicitly stated.
  3295. Once the bulk data has been edited to your liking, the internal VoxelManip
  3296. state can be set using:
  3297. * `VoxelManip:set_data()` for node content (in Content ID form, see section
  3298. [Content IDs]),
  3299. * `VoxelManip:set_light_data()` for node light levels, and
  3300. * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
  3301. The parameter to each of the above three functions can use any table at all in
  3302. the same flat array format as produced by `get_data()` etc. and is not required
  3303. to be a table retrieved from `get_data()`.
  3304. Once the internal VoxelManip state has been modified to your liking, the
  3305. changes can be committed back to the map by calling `VoxelManip:write_to_map()`
  3306. ### Flat array format
  3307. Let
  3308. `Nx = p2.X - p1.X + 1`,
  3309. `Ny = p2.Y - p1.Y + 1`, and
  3310. `Nz = p2.Z - p1.Z + 1`.
  3311. Then, for a loaded region of p1..p2, this array ranges from `1` up to and
  3312. including the value of the expression `Nx * Ny * Nz`.
  3313. Positions offset from p1 are present in the array with the format of:
  3314. [
  3315. (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
  3316. (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
  3317. ...
  3318. (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
  3319. (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
  3320. ...
  3321. (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
  3322. ...
  3323. (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
  3324. ]
  3325. and the array index for a position p contained completely in p1..p2 is:
  3326. `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
  3327. Note that this is the same "flat 3D array" format as
  3328. `PerlinNoiseMap:get3dMap_flat()`.
  3329. VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
  3330. of the index for a single point in a flat VoxelManip array.
  3331. ### Content IDs
  3332. A Content ID is a unique integer identifier for a specific node type.
  3333. These IDs are used by VoxelManip in place of the node name string for
  3334. `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
  3335. `minetest.get_content_id()` to look up the Content ID for the specified node
  3336. name, and `minetest.get_name_from_content_id()` to look up the node name string
  3337. for a given Content ID.
  3338. After registration of a node, its Content ID will remain the same throughout
  3339. execution of the mod.
  3340. Note that the node being queried needs to have already been been registered.
  3341. The following builtin node types have their Content IDs defined as constants:
  3342. * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
  3343. * `minetest.CONTENT_AIR`: ID for "air" nodes
  3344. * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
  3345. ### Mapgen VoxelManip objects
  3346. Inside of `on_generated()` callbacks, it is possible to retrieve the same
  3347. VoxelManip object used by the core's Map Generator (commonly abbreviated
  3348. Mapgen). Most of the rules previously described still apply but with a few
  3349. differences:
  3350. * The Mapgen VoxelManip object is retrieved using:
  3351. `minetest.get_mapgen_object("voxelmanip")`
  3352. * This VoxelManip object already has the region of map just generated loaded
  3353. into it; it's not necessary to call `VoxelManip:read_from_map()`.
  3354. Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
  3355. parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
  3356. * The `on_generated()` callbacks of some mods may place individual nodes in the
  3357. generated area using non-VoxelManip map modification methods. Because the
  3358. same Mapgen VoxelManip object is passed through each `on_generated()`
  3359. callback, it becomes necessary for the Mapgen VoxelManip object to maintain
  3360. consistency with the current map state. For this reason, calling any of
  3361. `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
  3362. will also update the Mapgen VoxelManip object's internal state active on the
  3363. current thread.
  3364. * After modifying the Mapgen VoxelManip object's internal buffer, it may be
  3365. necessary to update lighting information using either:
  3366. `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
  3367. ### Other API functions operating on a VoxelManip
  3368. If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
  3369. `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
  3370. flowing. It is recommended to call this function only after having written all
  3371. buffered data back to the VoxelManip object, save for special situations where
  3372. the modder desires to only have certain liquid nodes begin flowing.
  3373. The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
  3374. will generate all registered decorations and ores throughout the full area
  3375. inside of the specified VoxelManip object.
  3376. `minetest.place_schematic_on_vmanip()` is otherwise identical to
  3377. `minetest.place_schematic()`, except instead of placing the specified schematic
  3378. directly on the map at the specified position, it will place the schematic
  3379. inside the VoxelManip.
  3380. ### Notes
  3381. * Attempting to read data from a VoxelManip object before map is read will
  3382. result in a zero-length array table for `VoxelManip:get_data()`, and an
  3383. "ignore" node at any position for `VoxelManip:get_node_at()`.
  3384. * If either a region of map has not yet been generated or is out-of-bounds of
  3385. the map, that region is filled with "ignore" nodes.
  3386. * Other mods, or the core itself, could possibly modify the area of map
  3387. currently loaded into a VoxelManip object. With the exception of Mapgen
  3388. VoxelManips (see above section), the internal buffers are not updated. For
  3389. this reason, it is strongly encouraged to complete the usage of a particular
  3390. VoxelManip object in the same callback it had been created.
  3391. * If a VoxelManip object will be used often, such as in an `on_generated()`
  3392. callback, consider passing a file-scoped table as the optional parameter to
  3393. `VoxelManip:get_data()`, which serves as a static buffer the function can use
  3394. to write map data to instead of returning a new table each call. This greatly
  3395. enhances performance by avoiding unnecessary memory allocations.
  3396. Methods
  3397. -------
  3398. * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
  3399. containing the region formed by `p1` and `p2`.
  3400. * returns actual emerged `pmin`, actual emerged `pmax`
  3401. * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
  3402. the map.
  3403. * **important**: data must be set using `VoxelManip:set_data()` before
  3404. calling this.
  3405. * if `light` is true, then lighting is automatically recalculated.
  3406. The default value is true.
  3407. If `light` is false, no light calculations happen, and you should correct
  3408. all modified blocks with `minetest.fix_light()` as soon as possible.
  3409. Keep in mind that modifying the map where light is incorrect can cause
  3410. more lighting bugs.
  3411. * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
  3412. the `VoxelManip` at that position
  3413. * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
  3414. that position.
  3415. * `get_data([buffer])`: Retrieves the node content data loaded into the
  3416. `VoxelManip` object.
  3417. * returns raw node data in the form of an array of node content IDs
  3418. * if the param `buffer` is present, this table will be used to store the
  3419. result instead.
  3420. * `set_data(data)`: Sets the data contents of the `VoxelManip` object
  3421. * `update_map()`: Does nothing, kept for compatibility.
  3422. * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
  3423. a uniform value.
  3424. * `light` is a table, `{day=<0...15>, night=<0...15>}`
  3425. * To be used only by a `VoxelManip` object from
  3426. `minetest.get_mapgen_object`.
  3427. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3428. area if left out.
  3429. * `get_light_data([buffer])`: Gets the light data read into the
  3430. `VoxelManip` object
  3431. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3432. `255`.
  3433. * Each value is the bitwise combination of day and night light values
  3434. (`0` to `15` each).
  3435. * `light = day + (night * 16)`
  3436. * If the param `buffer` is present, this table will be used to store the
  3437. result instead.
  3438. * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
  3439. in the `VoxelManip`.
  3440. * expects lighting data in the same format that `get_light_data()` returns
  3441. * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
  3442. `VoxelManip` object.
  3443. * Returns an array (indices 1 to volume) of integers ranging from `0` to
  3444. `255`.
  3445. * If the param `buffer` is present, this table will be used to store the
  3446. result instead.
  3447. * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
  3448. the `VoxelManip`.
  3449. * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the
  3450. `VoxelManip`.
  3451. * To be used only by a `VoxelManip` object from
  3452. `minetest.get_mapgen_object`.
  3453. * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
  3454. area if left out or nil. For almost all uses these should be left out
  3455. or nil to use the default.
  3456. * `propagate_shadow` is an optional boolean deciding whether shadows in a
  3457. generated mapchunk above are propagated down into the mapchunk, defaults
  3458. to `true` if left out.
  3459. * `update_liquids()`: Update liquid flow
  3460. * `was_modified()`: Returns `true` or `false` if the data in the voxel
  3461. manipulator had been modified since the last read from map, due to a call to
  3462. `minetest.set_data()` on the loaded area elsewhere.
  3463. * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
  3464. `VoxelArea`
  3465. -----------
  3466. A helper class for voxel areas.
  3467. It can be created via `VoxelArea(pmin, pmax)` or
  3468. `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
  3469. The coordinates are *inclusive*, like most other things in Minetest.
  3470. ### Methods
  3471. * `getExtent()`: returns a 3D vector containing the size of the area formed by
  3472. `MinEdge` and `MaxEdge`.
  3473. * `getVolume()`: returns the volume of the area formed by `MinEdge` and
  3474. `MaxEdge`.
  3475. * `index(x, y, z)`: returns the index of an absolute position in a flat array
  3476. starting at `1`.
  3477. * `x`, `y` and `z` must be integers to avoid an incorrect index result.
  3478. * The position (x, y, z) is not checked for being inside the area volume,
  3479. being outside can cause an incorrect index result.
  3480. * Useful for things like `VoxelManip`, raw Schematic specifiers,
  3481. `PerlinNoiseMap:get2d`/`3dMap`, and so on.
  3482. * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
  3483. * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
  3484. is not checked for being inside the area volume.
  3485. * `position(i)`: returns the absolute position vector corresponding to index
  3486. `i`.
  3487. * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
  3488. `MinEdge` and `MaxEdge`.
  3489. * `containsp(p)`: same as above, except takes a vector
  3490. * `containsi(i)`: same as above, except takes an index `i`
  3491. * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
  3492. indices.
  3493. * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
  3494. `[z [y [x]]]`.
  3495. * `iterp(minp, maxp)`: same as above, except takes a vector
  3496. ### Y stride and z stride of a flat array
  3497. For a particular position in a voxel area, whose flat array index is known,
  3498. it is often useful to know the index of a neighboring or nearby position.
  3499. The table below shows the changes of index required for 1 node movements along
  3500. the axes in a voxel area:
  3501. Movement Change of index
  3502. +x +1
  3503. -x -1
  3504. +y +ystride
  3505. -y -ystride
  3506. +z +zstride
  3507. -z -zstride
  3508. If, for example:
  3509. local area = VoxelArea(emin, emax)
  3510. The values of `ystride` and `zstride` can be obtained using `area.ystride` and
  3511. `area.zstride`.
  3512. Mapgen objects
  3513. ==============
  3514. A mapgen object is a construct used in map generation. Mapgen objects can be
  3515. used by an `on_generate` callback to speed up operations by avoiding
  3516. unnecessary recalculations, these can be retrieved using the
  3517. `minetest.get_mapgen_object()` function. If the requested Mapgen object is
  3518. unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
  3519. callback, `nil` is returned.
  3520. The following Mapgen objects are currently available:
  3521. ### `voxelmanip`
  3522. This returns three values; the `VoxelManip` object to be used, minimum and
  3523. maximum emerged position, in that order. All mapgens support this object.
  3524. ### `heightmap`
  3525. Returns an array containing the y coordinates of the ground levels of nodes in
  3526. the most recently generated chunk by the current mapgen.
  3527. ### `biomemap`
  3528. Returns an array containing the biome IDs of nodes in the most recently
  3529. generated chunk by the current mapgen.
  3530. ### `heatmap`
  3531. Returns an array containing the temperature values of nodes in the most
  3532. recently generated chunk by the current mapgen.
  3533. ### `humiditymap`
  3534. Returns an array containing the humidity values of nodes in the most recently
  3535. generated chunk by the current mapgen.
  3536. ### `gennotify`
  3537. Returns a table mapping requested generation notification types to arrays of
  3538. positions at which the corresponding generated structures are located within
  3539. the current chunk. To enable the capture of positions of interest to be recorded
  3540. call `minetest.set_gen_notify()` first.
  3541. Possible fields of the returned table are:
  3542. * `dungeon`: bottom center position of dungeon rooms
  3543. * `temple`: as above but for desert temples (mgv6 only)
  3544. * `cave_begin`
  3545. * `cave_end`
  3546. * `large_cave_begin`
  3547. * `large_cave_end`
  3548. * `decoration#id` (see below)
  3549. Decorations have a key in the format of `"decoration#id"`, where `id` is the
  3550. numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
  3551. For example, `decoration#123`.
  3552. The returned positions are the ground surface 'place_on' nodes,
  3553. not the decorations themselves. A 'simple' type decoration is often 1
  3554. node above the returned position and possibly displaced by 'place_offset_y'.
  3555. Registered entities
  3556. ===================
  3557. Functions receive a "luaentity" table as `self`:
  3558. * It has the member `name`, which is the registered name `("mod:thing")`
  3559. * It has the member `object`, which is an `ObjectRef` pointing to the object
  3560. * The original prototype is visible directly via a metatable
  3561. Callbacks:
  3562. * `on_activate(self, staticdata, dtime_s)`
  3563. * Called when the object is instantiated.
  3564. * `dtime_s` is the time passed since the object was unloaded, which can be
  3565. used for updating the entity state.
  3566. * `on_deactivate(self, removal)`
  3567. * Called when the object is about to get removed or unloaded.
  3568. * `removal`: boolean indicating whether the object is about to get removed.
  3569. Calling `object:remove()` on an active object will call this with `removal=true`.
  3570. The mapblock the entity resides in being unloaded will call this with `removal=false`.
  3571. * Note that this won't be called if the object hasn't been activated in the first place.
  3572. In particular, `minetest.clear_objects({mode = "full"})` won't call this,
  3573. whereas `minetest.clear_objects({mode = "quick"})` might call this.
  3574. * `on_step(self, dtime, moveresult)`
  3575. * Called on every server tick, after movement and collision processing.
  3576. * `dtime`: elapsed time since last call
  3577. * `moveresult`: table with collision info (only available if physical=true)
  3578. * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
  3579. * Called when somebody punches the object.
  3580. * Note that you probably want to handle most punches using the automatic
  3581. armor group system.
  3582. * `puncher`: an `ObjectRef` (can be `nil`)
  3583. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  3584. (can be `nil`).
  3585. * `tool_capabilities`: capability table of used item (can be `nil`)
  3586. * `dir`: unit vector of direction of punch. Always defined. Points from the
  3587. puncher to the punched.
  3588. * `damage`: damage that will be done to entity.
  3589. * Can return `true` to prevent the default damage mechanism.
  3590. * `on_death(self, killer)`
  3591. * Called when the object dies.
  3592. * `killer`: an `ObjectRef` (can be `nil`)
  3593. * `on_rightclick(self, clicker)`
  3594. * Called when `clicker` pressed the 'place/use' key while pointing
  3595. to the object (not necessarily an actual rightclick)
  3596. * `clicker`: an `ObjectRef` (may or may not be a player)
  3597. * `on_attach_child(self, child)`
  3598. * `child`: an `ObjectRef` of the child that attaches
  3599. * `on_detach_child(self, child)`
  3600. * `child`: an `ObjectRef` of the child that detaches
  3601. * `on_detach(self, parent)`
  3602. * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
  3603. * This happens before the parent object is removed from the world
  3604. * `get_staticdata(self)`
  3605. * Should return a string that will be passed to `on_activate` when the
  3606. object is instantiated the next time.
  3607. Collision info passed to `on_step` (`moveresult` argument):
  3608. {
  3609. touching_ground = boolean,
  3610. -- Note that touching_ground is only true if the entity was moving and
  3611. -- collided with ground.
  3612. collides = boolean,
  3613. standing_on_object = boolean,
  3614. collisions = {
  3615. {
  3616. type = string, -- "node" or "object",
  3617. axis = string, -- "x", "y" or "z"
  3618. node_pos = vector, -- if type is "node"
  3619. object = ObjectRef, -- if type is "object"
  3620. old_velocity = vector,
  3621. new_velocity = vector,
  3622. },
  3623. ...
  3624. }
  3625. -- `collisions` does not contain data of unloaded mapblock collisions
  3626. -- or when the velocity changes are negligibly small
  3627. }
  3628. L-system trees
  3629. ==============
  3630. Tree definition
  3631. ---------------
  3632. treedef={
  3633. axiom, --string initial tree axiom
  3634. rules_a, --string rules set A
  3635. rules_b, --string rules set B
  3636. rules_c, --string rules set C
  3637. rules_d, --string rules set D
  3638. trunk, --string trunk node name
  3639. leaves, --string leaves node name
  3640. leaves2, --string secondary leaves node name
  3641. leaves2_chance,--num chance (0-100) to replace leaves with leaves2
  3642. angle, --num angle in deg
  3643. iterations, --num max # of iterations, usually 2 -5
  3644. random_level, --num factor to lower number of iterations, usually 0 - 3
  3645. trunk_type, --string single/double/crossed) type of trunk: 1 node,
  3646. -- 2x2 nodes or 3x3 in cross shape
  3647. thin_branches, --boolean true -> use thin (1 node) branches
  3648. fruit, --string fruit node name
  3649. fruit_chance, --num chance (0-100) to replace leaves with fruit node
  3650. seed, --num random seed, if no seed is provided, the engine
  3651. will create one.
  3652. }
  3653. Key for special L-System symbols used in axioms
  3654. -----------------------------------------------
  3655. * `G`: move forward one unit with the pen up
  3656. * `F`: move forward one unit with the pen down drawing trunks and branches
  3657. * `f`: move forward one unit with the pen down drawing leaves (100% chance)
  3658. * `T`: move forward one unit with the pen down drawing trunks only
  3659. * `R`: move forward one unit with the pen down placing fruit
  3660. * `A`: replace with rules set A
  3661. * `B`: replace with rules set B
  3662. * `C`: replace with rules set C
  3663. * `D`: replace with rules set D
  3664. * `a`: replace with rules set A, chance 90%
  3665. * `b`: replace with rules set B, chance 80%
  3666. * `c`: replace with rules set C, chance 70%
  3667. * `d`: replace with rules set D, chance 60%
  3668. * `+`: yaw the turtle right by `angle` parameter
  3669. * `-`: yaw the turtle left by `angle` parameter
  3670. * `&`: pitch the turtle down by `angle` parameter
  3671. * `^`: pitch the turtle up by `angle` parameter
  3672. * `/`: roll the turtle to the right by `angle` parameter
  3673. * `*`: roll the turtle to the left by `angle` parameter
  3674. * `[`: save in stack current state info
  3675. * `]`: recover from stack state info
  3676. Example
  3677. -------
  3678. Spawn a small apple tree:
  3679. pos = {x=230,y=20,z=4}
  3680. apple_tree={
  3681. axiom="FFFFFAFFBF",
  3682. rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
  3683. rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
  3684. trunk="default:tree",
  3685. leaves="default:leaves",
  3686. angle=30,
  3687. iterations=2,
  3688. random_level=0,
  3689. trunk_type="single",
  3690. thin_branches=true,
  3691. fruit_chance=10,
  3692. fruit="default:apple"
  3693. }
  3694. minetest.spawn_tree(pos,apple_tree)
  3695. Privileges
  3696. ==========
  3697. Privileges provide a means for server administrators to give certain players
  3698. access to special abilities in the engine, games or mods.
  3699. For example, game moderators may need to travel instantly to any place in the world,
  3700. this ability is implemented in `/teleport` command which requires `teleport` privilege.
  3701. Registering privileges
  3702. ----------------------
  3703. A mod can register a custom privilege using `minetest.register_privilege` function
  3704. to give server administrators fine-grained access control over mod functionality.
  3705. For consistency and practical reasons, privileges should strictly increase the abilities of the user.
  3706. Do not register custom privileges that e.g. restrict the player from certain in-game actions.
  3707. Checking privileges
  3708. -------------------
  3709. A mod can call `minetest.check_player_privs` to test whether a player has privileges
  3710. to perform an operation.
  3711. Also, when registering a chat command with `minetest.register_chatcommand` a mod can
  3712. declare privileges that the command requires using the `privs` field of the command
  3713. definition.
  3714. Managing player privileges
  3715. --------------------------
  3716. A mod can update player privileges using `minetest.set_player_privs` function.
  3717. Players holding the `privs` privilege can see and manage privileges for all
  3718. players on the server.
  3719. A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
  3720. and `minetest.register_on_priv_revoke` functions.
  3721. Built-in privileges
  3722. -------------------
  3723. Minetest includes a set of built-in privileges that control capabilities
  3724. provided by the Minetest engine and can be used by mods:
  3725. * Basic privileges are normally granted to all players:
  3726. * `shout`: can communicate using the in-game chat.
  3727. * `interact`: can modify the world by digging, building and interacting
  3728. with the nodes, entities and other players. Players without the `interact`
  3729. privilege can only travel and observe the world.
  3730. * Advanced privileges allow bypassing certain aspects of the gameplay:
  3731. * `fast`: can use "fast mode" to move with maximum speed.
  3732. * `fly`: can use "fly mode" to move freely above the ground without falling.
  3733. * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
  3734. * `teleport`: can use `/teleport` command to move to any point in the world.
  3735. * `creative`: can access creative inventory.
  3736. * `bring`: can teleport other players to oneself.
  3737. * `give`: can use `/give` and `/giveme` commands to give any item
  3738. in the game to oneself or others.
  3739. * `settime`: can use `/time` command to change current in-game time.
  3740. * `debug`: can enable wireframe rendering mode.
  3741. * Security-related privileges:
  3742. * `privs`: can modify privileges of the players using `/grant[me]` and
  3743. `/revoke[me]` commands.
  3744. * `basic_privs`: can grant and revoke basic privileges as defined by
  3745. the `basic_privs` setting.
  3746. * `kick`: can kick other players from the server using `/kick` command.
  3747. * `ban`: can ban other players using `/ban` command.
  3748. * `password`: can use `/setpassword` and `/clearpassword` commands
  3749. to manage players' passwords.
  3750. * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
  3751. it is only an implementation suggestion for games.
  3752. * Administrative privileges:
  3753. * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
  3754. commands. Can clear inventory of other players using `/clearinv` command.
  3755. * `rollback`: can use `/rollback_check` and `/rollback` commands.
  3756. Related settings
  3757. ----------------
  3758. Minetest includes the following settings to control behavior of privileges:
  3759. * `default_privs`: defines privileges granted to new players.
  3760. * `basic_privs`: defines privileges that can be granted/revoked by players having
  3761. the `basic_privs` privilege. This can be used, for example, to give
  3762. limited moderation powers to selected users.
  3763. 'minetest' namespace reference
  3764. ==============================
  3765. Utilities
  3766. ---------
  3767. * `minetest.get_current_modname()`: returns the currently loading mod's name,
  3768. when loading a mod.
  3769. * `minetest.get_modpath(modname)`: returns the directory path for a mod,
  3770. e.g. `"/home/user/.minetest/usermods/modname"`.
  3771. * Returns nil if the mod is not enabled or does not exist (not installed).
  3772. * Works regardless of whether the mod has been loaded yet.
  3773. * Useful for loading additional `.lua` modules or static data from a mod,
  3774. or checking if a mod is enabled.
  3775. * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
  3776. * Does not include disabled mods, even if they are installed.
  3777. * `minetest.get_game_info()`: returns a table containing information about the
  3778. current game. Note that other meta information (e.g. version/release number)
  3779. can be manually read from `game.conf` in the game's root directory.
  3780. {
  3781. id = string,
  3782. title = string,
  3783. author = string,
  3784. -- The root directory of the game
  3785. path = string,
  3786. }
  3787. * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
  3788. * Useful for storing custom data
  3789. * `minetest.is_singleplayer()`
  3790. * `minetest.features`: Table containing API feature flags
  3791. {
  3792. glasslike_framed = true, -- 0.4.7
  3793. nodebox_as_selectionbox = true, -- 0.4.7
  3794. get_all_craft_recipes_works = true, -- 0.4.7
  3795. -- The transparency channel of textures can optionally be used on
  3796. -- nodes (0.4.7)
  3797. use_texture_alpha = true,
  3798. -- Tree and grass ABMs are no longer done from C++ (0.4.8)
  3799. no_legacy_abms = true,
  3800. -- Texture grouping is possible using parentheses (0.4.11)
  3801. texture_names_parens = true,
  3802. -- Unique Area ID for AreaStore:insert_area (0.4.14)
  3803. area_store_custom_ids = true,
  3804. -- add_entity supports passing initial staticdata to on_activate
  3805. -- (0.4.16)
  3806. add_entity_with_staticdata = true,
  3807. -- Chat messages are no longer predicted (0.4.16)
  3808. no_chat_message_prediction = true,
  3809. -- The transparency channel of textures can optionally be used on
  3810. -- objects (ie: players and lua entities) (5.0.0)
  3811. object_use_texture_alpha = true,
  3812. -- Object selectionbox is settable independently from collisionbox
  3813. -- (5.0.0)
  3814. object_independent_selectionbox = true,
  3815. -- Specifies whether binary data can be uploaded or downloaded using
  3816. -- the HTTP API (5.1.0)
  3817. httpfetch_binary_data = true,
  3818. -- Whether formspec_version[<version>] may be used (5.1.0)
  3819. formspec_version_element = true,
  3820. -- Whether AreaStore's IDs are kept on save/load (5.1.0)
  3821. area_store_persistent_ids = true,
  3822. -- Whether minetest.find_path is functional (5.2.0)
  3823. pathfinder_works = true,
  3824. -- Whether Collision info is available to an objects' on_step (5.3.0)
  3825. object_step_has_moveresult = true,
  3826. -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
  3827. direct_velocity_on_players = true,
  3828. -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
  3829. use_texture_alpha_string_modes = true,
  3830. -- degrotate param2 rotates in units of 1.5° instead of 2°
  3831. -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
  3832. degrotate_240_steps = true,
  3833. -- ABM supports min_y and max_y fields in definition (5.5.0)
  3834. abm_min_max_y = true,
  3835. -- dynamic_add_media supports passing a table with options (5.5.0)
  3836. dynamic_add_media_table = true,
  3837. -- particlespawners support texpools and animation of properties,
  3838. -- particle textures support smooth fade and scale animations, and
  3839. -- sprite-sheet particle animations can by synced to the lifetime
  3840. -- of individual particles (5.6.0)
  3841. particlespawner_tweenable = true,
  3842. -- allows get_sky to return a table instead of separate values (5.6.0)
  3843. get_sky_as_table = true,
  3844. -- VoxelManip:get_light_data accepts an optional buffer argument (5.7.0)
  3845. get_light_data_buffer = true,
  3846. -- When using a mod storage backend that is not "files" or "dummy",
  3847. -- the amount of data in mod storage is not constrained by
  3848. -- the amount of RAM available. (5.7.0)
  3849. mod_storage_on_disk = true,
  3850. -- "zstd" method for compress/decompress (5.7.0)
  3851. compress_zstd = true,
  3852. }
  3853. * `minetest.has_feature(arg)`: returns `boolean, missing_features`
  3854. * `arg`: string or table in format `{foo=true, bar=true}`
  3855. * `missing_features`: `{foo=true, bar=true}`
  3856. * `minetest.get_player_information(player_name)`: Table containing information
  3857. about a player. Example return value:
  3858. {
  3859. address = "127.0.0.1", -- IP address of client
  3860. ip_version = 4, -- IPv4 / IPv6
  3861. connection_uptime = 200, -- seconds since client connected
  3862. protocol_version = 32, -- protocol version used by client
  3863. formspec_version = 2, -- supported formspec version
  3864. lang_code = "fr" -- Language code used for translation
  3865. -- the following keys can be missing if no stats have been collected yet
  3866. min_rtt = 0.01, -- minimum round trip time
  3867. max_rtt = 0.2, -- maximum round trip time
  3868. avg_rtt = 0.02, -- average round trip time
  3869. min_jitter = 0.01, -- minimum packet time jitter
  3870. max_jitter = 0.5, -- maximum packet time jitter
  3871. avg_jitter = 0.03, -- average packet time jitter
  3872. -- the following information is available in a debug build only!!!
  3873. -- DO NOT USE IN MODS
  3874. --ser_vers = 26, -- serialization version used by client
  3875. --major = 0, -- major version number
  3876. --minor = 4, -- minor version number
  3877. --patch = 10, -- patch version number
  3878. --vers_string = "0.4.9-git", -- full version string
  3879. --state = "Active" -- current client state
  3880. }
  3881. * `minetest.mkdir(path)`: returns success.
  3882. * Creates a directory specified by `path`, creating parent directories
  3883. if they don't exist.
  3884. * `minetest.rmdir(path, recursive)`: returns success.
  3885. * Removes a directory specified by `path`.
  3886. * If `recursive` is set to `true`, the directory is recursively removed.
  3887. Otherwise, the directory will only be removed if it is empty.
  3888. * Returns true on success, false on failure.
  3889. * `minetest.cpdir(source, destination)`: returns success.
  3890. * Copies a directory specified by `path` to `destination`
  3891. * Any files in `destination` will be overwritten if they already exist.
  3892. * Returns true on success, false on failure.
  3893. * `minetest.mvdir(source, destination)`: returns success.
  3894. * Moves a directory specified by `path` to `destination`.
  3895. * If the `destination` is a non-empty directory, then the move will fail.
  3896. * Returns true on success, false on failure.
  3897. * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
  3898. * is_dir is one of:
  3899. * nil: return all entries,
  3900. * true: return only subdirectory names, or
  3901. * false: return only file names.
  3902. * `minetest.safe_file_write(path, content)`: returns boolean indicating success
  3903. * Replaces contents of file at path with new contents in a safe (atomic)
  3904. way. Use this instead of below code when writing e.g. database files:
  3905. `local f = io.open(path, "wb"); f:write(content); f:close()`
  3906. * `minetest.get_version()`: returns a table containing components of the
  3907. engine version. Components:
  3908. * `project`: Name of the project, eg, "Minetest"
  3909. * `string`: Simple version, eg, "1.2.3-dev"
  3910. * `hash`: Full git version (only set if available),
  3911. eg, "1.2.3-dev-01234567-dirty".
  3912. * `is_dev`: Boolean value indicating whether it's a development build
  3913. Use this for informational purposes only. The information in the returned
  3914. table does not represent the capabilities of the engine, nor is it
  3915. reliable or verifiable. Compatible forks will have a different name and
  3916. version entirely. To check for the presence of engine features, test
  3917. whether the functions exported by the wanted features exist. For example:
  3918. `if minetest.check_for_falling then ... end`.
  3919. * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
  3920. * `data`: string of data to hash
  3921. * `raw`: return raw bytes instead of hex digits, default: false
  3922. * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
  3923. ColorString. If the ColorSpec is invalid, returns `nil`.
  3924. * `colorspec`: The ColorSpec to convert
  3925. * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
  3926. string of four bytes in an RGBA layout, returned as a string.
  3927. * `colorspec`: The ColorSpec to convert
  3928. * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
  3929. image and return it in string form.
  3930. * `width`: Width of the image
  3931. * `height`: Height of the image
  3932. * `data`: Image data, one of:
  3933. * array table of ColorSpec, length must be width*height
  3934. * string with raw RGBA pixels, length must be width*height*4
  3935. * `compression`: Optional zlib compression level, number in range 0 to 9.
  3936. The data is one-dimensional, starting in the upper left corner of the image
  3937. and laid out in scanlines going from left to right, then top to bottom.
  3938. Please note that it's not safe to use string.char to generate raw data,
  3939. use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
  3940. The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
  3941. You may use this to procedurally generate textures during server init.
  3942. Logging
  3943. -------
  3944. * `minetest.debug(...)`
  3945. * Equivalent to `minetest.log(table.concat({...}, "\t"))`
  3946. * `minetest.log([level,] text)`
  3947. * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
  3948. `"info"`, or `"verbose"`. Default is `"none"`.
  3949. Registration functions
  3950. ----------------------
  3951. Call these functions only at load time!
  3952. ### Environment
  3953. * `minetest.register_node(name, node definition)`
  3954. * `minetest.register_craftitem(name, item definition)`
  3955. * `minetest.register_tool(name, item definition)`
  3956. * `minetest.override_item(name, redefinition)`
  3957. * Overrides fields of an item registered with register_node/tool/craftitem.
  3958. * Note: Item must already be defined, (opt)depend on the mod defining it.
  3959. * Example: `minetest.override_item("default:mese",
  3960. {light_source=minetest.LIGHT_MAX})`
  3961. * `minetest.unregister_item(name)`
  3962. * Unregisters the item from the engine, and deletes the entry with key
  3963. `name` from `minetest.registered_items` and from the associated item table
  3964. according to its nature: `minetest.registered_nodes`, etc.
  3965. * `minetest.register_entity(name, entity definition)`
  3966. * `minetest.register_abm(abm definition)`
  3967. * `minetest.register_lbm(lbm definition)`
  3968. * `minetest.register_alias(alias, original_name)`
  3969. * Also use this to set the 'mapgen aliases' needed in a game for the core
  3970. mapgens. See [Mapgen aliases] section above.
  3971. * `minetest.register_alias_force(alias, original_name)`
  3972. * `minetest.register_ore(ore definition)`
  3973. * Returns an integer object handle uniquely identifying the registered
  3974. ore on success.
  3975. * The order of ore registrations determines the order of ore generation.
  3976. * `minetest.register_biome(biome definition)`
  3977. * Returns an integer object handle uniquely identifying the registered
  3978. biome on success. To get the biome ID, use `minetest.get_biome_id`.
  3979. * `minetest.unregister_biome(name)`
  3980. * Unregisters the biome from the engine, and deletes the entry with key
  3981. `name` from `minetest.registered_biomes`.
  3982. * Warning: This alters the biome to biome ID correspondences, so any
  3983. decorations or ores using the 'biomes' field must afterwards be cleared
  3984. and re-registered.
  3985. * `minetest.register_decoration(decoration definition)`
  3986. * Returns an integer object handle uniquely identifying the registered
  3987. decoration on success. To get the decoration ID, use
  3988. `minetest.get_decoration_id`.
  3989. * The order of decoration registrations determines the order of decoration
  3990. generation.
  3991. * `minetest.register_schematic(schematic definition)`
  3992. * Returns an integer object handle uniquely identifying the registered
  3993. schematic on success.
  3994. * If the schematic is loaded from a file, the `name` field is set to the
  3995. filename.
  3996. * If the function is called when loading the mod, and `name` is a relative
  3997. path, then the current mod path will be prepended to the schematic
  3998. filename.
  3999. * `minetest.clear_registered_biomes()`
  4000. * Clears all biomes currently registered.
  4001. * Warning: Clearing and re-registering biomes alters the biome to biome ID
  4002. correspondences, so any decorations or ores using the 'biomes' field must
  4003. afterwards be cleared and re-registered.
  4004. * `minetest.clear_registered_decorations()`
  4005. * Clears all decorations currently registered.
  4006. * `minetest.clear_registered_ores()`
  4007. * Clears all ores currently registered.
  4008. * `minetest.clear_registered_schematics()`
  4009. * Clears all schematics currently registered.
  4010. ### Gameplay
  4011. * `minetest.register_craft(recipe)`
  4012. * Check recipe table syntax for different types below.
  4013. * `minetest.clear_craft(recipe)`
  4014. * Will erase existing craft based either on output item or on input recipe.
  4015. * Specify either output or input only. If you specify both, input will be
  4016. ignored. For input use the same recipe table syntax as for
  4017. `minetest.register_craft(recipe)`. For output specify only the item,
  4018. without a quantity.
  4019. * Returns false if no erase candidate could be found, otherwise returns true.
  4020. * **Warning**! The type field ("shaped", "cooking" or any other) will be
  4021. ignored if the recipe contains output. Erasing is then done independently
  4022. from the crafting method.
  4023. * `minetest.register_chatcommand(cmd, chatcommand definition)`
  4024. * `minetest.override_chatcommand(name, redefinition)`
  4025. * Overrides fields of a chatcommand registered with `register_chatcommand`.
  4026. * `minetest.unregister_chatcommand(name)`
  4027. * Unregisters a chatcommands registered with `register_chatcommand`.
  4028. * `minetest.register_privilege(name, definition)`
  4029. * `definition` can be a description or a definition table (see [Privilege
  4030. definition]).
  4031. * If it is a description, the priv will be granted to singleplayer and admin
  4032. by default.
  4033. * To allow players with `basic_privs` to grant, see the `basic_privs`
  4034. minetest.conf setting.
  4035. * `minetest.register_authentication_handler(authentication handler definition)`
  4036. * Registers an auth handler that overrides the builtin one.
  4037. * This function can be called by a single mod once only.
  4038. Global callback registration functions
  4039. --------------------------------------
  4040. Call these functions only at load time!
  4041. * `minetest.register_globalstep(function(dtime))`
  4042. * Called every server step, usually interval of 0.1s
  4043. * `minetest.register_on_mods_loaded(function())`
  4044. * Called after mods have finished loading and before the media is cached or the
  4045. aliases handled.
  4046. * `minetest.register_on_shutdown(function())`
  4047. * Called before server shutdown
  4048. * **Warning**: If the server terminates abnormally (i.e. crashes), the
  4049. registered callbacks **will likely not be run**. Data should be saved at
  4050. semi-frequent intervals as well as on server shutdown.
  4051. * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
  4052. * Called when a node has been placed
  4053. * If return `true` no item is taken from `itemstack`
  4054. * `placer` may be any valid ObjectRef or nil.
  4055. * **Not recommended**; use `on_construct` or `after_place_node` in node
  4056. definition whenever possible.
  4057. * `minetest.register_on_dignode(function(pos, oldnode, digger))`
  4058. * Called when a node has been dug.
  4059. * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
  4060. definition whenever possible.
  4061. * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
  4062. * Called when a node is punched
  4063. * `minetest.register_on_generated(function(minp, maxp, blockseed))`
  4064. * Called after generating a piece of world. Modifying nodes inside the area
  4065. is a bit faster than usual.
  4066. * `minetest.register_on_newplayer(function(ObjectRef))`
  4067. * Called when a new player enters the world for the first time
  4068. * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
  4069. * Called when a player is punched
  4070. * Note: This callback is invoked even if the punched player is dead.
  4071. * `player`: ObjectRef - Player that was punched
  4072. * `hitter`: ObjectRef - Player that hit
  4073. * `time_from_last_punch`: Meant for disallowing spamming of clicks
  4074. (can be nil).
  4075. * `tool_capabilities`: Capability table of used item (can be nil)
  4076. * `dir`: Unit vector of direction of punch. Always defined. Points from
  4077. the puncher to the punched.
  4078. * `damage`: Number that represents the damage calculated by the engine
  4079. * should return `true` to prevent the default damage mechanism
  4080. * `minetest.register_on_rightclickplayer(function(player, clicker))`
  4081. * Called when the 'place/use' key was used while pointing a player
  4082. (not necessarily an actual rightclick)
  4083. * `player`: ObjectRef - Player that is acted upon
  4084. * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
  4085. * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
  4086. * Called when the player gets damaged or healed
  4087. * `player`: ObjectRef of the player
  4088. * `hp_change`: the amount of change. Negative when it is damage.
  4089. * `reason`: a PlayerHPChangeReason table.
  4090. * The `type` field will have one of the following values:
  4091. * `set_hp`: A mod or the engine called `set_hp` without
  4092. giving a type - use this for custom damage types.
  4093. * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
  4094. * `fall`
  4095. * `node_damage`: `damage_per_second` from a neighboring node.
  4096. `reason.node` will hold the node name or nil.
  4097. * `drown`
  4098. * `respawn`
  4099. * Any of the above types may have additional fields from mods.
  4100. * `reason.from` will be `mod` or `engine`.
  4101. * `modifier`: when true, the function should return the actual `hp_change`.
  4102. Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
  4103. Modifiers can return true as a second argument to stop the execution of further functions.
  4104. Non-modifiers receive the final HP change calculated by the modifiers.
  4105. * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
  4106. * Called when a player dies
  4107. * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
  4108. * `minetest.register_on_respawnplayer(function(ObjectRef))`
  4109. * Called when player is to be respawned
  4110. * Called _before_ repositioning of player occurs
  4111. * return true in func to disable regular player placement
  4112. * `minetest.register_on_prejoinplayer(function(name, ip))`
  4113. * Called when a client connects to the server, prior to authentication
  4114. * If it returns a string, the client is disconnected with that string as
  4115. reason.
  4116. * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
  4117. * Called when a player joins the game
  4118. * `last_login`: The timestamp of the previous login, or nil if player is new
  4119. * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
  4120. * Called when a player leaves the game
  4121. * `timed_out`: True for timeout, false for other reasons.
  4122. * `minetest.register_on_authplayer(function(name, ip, is_success))`
  4123. * Called when a client attempts to log into an account.
  4124. * `name`: The name of the account being authenticated.
  4125. * `ip`: The IP address of the client
  4126. * `is_success`: Whether the client was successfully authenticated
  4127. * For newly registered accounts, `is_success` will always be true
  4128. * `minetest.register_on_auth_fail(function(name, ip))`
  4129. * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
  4130. * `minetest.register_on_cheat(function(ObjectRef, cheat))`
  4131. * Called when a player cheats
  4132. * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
  4133. * `moved_too_fast`
  4134. * `interacted_too_far`
  4135. * `interacted_with_self`
  4136. * `interacted_while_dead`
  4137. * `finished_unknown_dig`
  4138. * `dug_unbreakable`
  4139. * `dug_too_fast`
  4140. * `minetest.register_on_chat_message(function(name, message))`
  4141. * Called always when a player says something
  4142. * Return `true` to mark the message as handled, which means that it will
  4143. not be sent to other players.
  4144. * `minetest.register_on_chatcommand(function(name, command, params))`
  4145. * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
  4146. is checked to see if the command exists, but after the input is parsed.
  4147. * Return `true` to mark the command as handled, which means that the default
  4148. handlers will be prevented.
  4149. * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
  4150. * Called when the server received input from `player` in a formspec with
  4151. the given `formname`. Specifically, this is called on any of the
  4152. following events:
  4153. * a button was pressed,
  4154. * Enter was pressed while the focus was on a text field
  4155. * a checkbox was toggled,
  4156. * something was selected in a dropdown list,
  4157. * a different tab was selected,
  4158. * selection was changed in a textlist or table,
  4159. * an entry was double-clicked in a textlist or table,
  4160. * a scrollbar was moved, or
  4161. * the form was actively closed by the player.
  4162. * Fields are sent for formspec elements which define a field. `fields`
  4163. is a table containing each formspecs element value (as string), with
  4164. the `name` parameter as index for each. The value depends on the
  4165. formspec element type:
  4166. * `animated_image`: Returns the index of the current frame.
  4167. * `button` and variants: If pressed, contains the user-facing button
  4168. text as value. If not pressed, is `nil`
  4169. * `field`, `textarea` and variants: Text in the field
  4170. * `dropdown`: Either the index or value, depending on the `index event`
  4171. dropdown argument.
  4172. * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
  4173. * `checkbox`: `"true"` if checked, `"false"` if unchecked
  4174. * `textlist`: See `minetest.explode_textlist_event`
  4175. * `table`: See `minetest.explode_table_event`
  4176. * `scrollbar`: See `minetest.explode_scrollbar_event`
  4177. * Special case: `["quit"]="true"` is sent when the user actively
  4178. closed the form by mouse click, keypress or through a button_exit[]
  4179. element.
  4180. * Special case: `["key_enter"]="true"` is sent when the user pressed
  4181. the Enter key and the focus was either nowhere (causing the formspec
  4182. to be closed) or on a button. If the focus was on a text field,
  4183. additionally, the index `key_enter_field` contains the name of the
  4184. text field. See also: `field_close_on_enter`.
  4185. * Newest functions are called first
  4186. * If function returns `true`, remaining functions are not called
  4187. * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
  4188. * Called when `player` crafts something
  4189. * `itemstack` is the output
  4190. * `old_craft_grid` contains the recipe (Note: the one in the inventory is
  4191. cleared).
  4192. * `craft_inv` is the inventory with the crafting grid
  4193. * Return either an `ItemStack`, to replace the output, or `nil`, to not
  4194. modify it.
  4195. * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
  4196. * The same as before, except that it is called before the player crafts, to
  4197. make craft prediction, and it should not change anything.
  4198. * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
  4199. * Determines how much of a stack may be taken, put or moved to a
  4200. player inventory.
  4201. * `player` (type `ObjectRef`) is the player who modified the inventory
  4202. `inventory` (type `InvRef`).
  4203. * List of possible `action` (string) values and their
  4204. `inventory_info` (table) contents:
  4205. * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
  4206. * `put`: `{listname=string, index=number, stack=ItemStack}`
  4207. * `take`: Same as `put`
  4208. * Return a numeric value to limit the amount of items to be taken, put or
  4209. moved. A value of `-1` for `take` will make the source stack infinite.
  4210. * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
  4211. * Called after a take, put or move event from/to/in a player inventory
  4212. * Function arguments: see `minetest.register_allow_player_inventory_action`
  4213. * Does not accept or handle any return value.
  4214. * `minetest.register_on_protection_violation(function(pos, name))`
  4215. * Called by `builtin` and mods when a player violates protection at a
  4216. position (eg, digs a node or punches a protected entity).
  4217. * The registered functions can be called using
  4218. `minetest.record_protection_violation`.
  4219. * The provided function should check that the position is protected by the
  4220. mod calling this function before it prints a message, if it does, to
  4221. allow for multiple protection mods.
  4222. * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
  4223. * Called when an item is eaten, by `minetest.item_eat`
  4224. * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
  4225. * `minetest.register_on_item_pickup(function(itemstack, picker, pointed_thing, time_from_last_punch, ...))`
  4226. * Called by `minetest.item_pickup` before an item is picked up.
  4227. * Function is added to `minetest.registered_on_item_pickups`.
  4228. * Oldest functions are called first.
  4229. * Parameters are the same as in the `on_pickup` callback.
  4230. * Return an itemstack to cancel the default item pick-up response (i.e.: adding
  4231. the item into inventory).
  4232. * `minetest.register_on_priv_grant(function(name, granter, priv))`
  4233. * Called when `granter` grants the priv `priv` to `name`.
  4234. * Note that the callback will be called twice if it's done by a player,
  4235. once with granter being the player name, and again with granter being nil.
  4236. * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
  4237. * Called when `revoker` revokes the priv `priv` from `name`.
  4238. * Note that the callback will be called twice if it's done by a player,
  4239. once with revoker being the player name, and again with revoker being nil.
  4240. * `minetest.register_can_bypass_userlimit(function(name, ip))`
  4241. * Called when `name` user connects with `ip`.
  4242. * Return `true` to by pass the player limit
  4243. * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
  4244. * Called when an incoming mod channel message is received
  4245. * You should have joined some channels to receive events.
  4246. * If message comes from a server mod, `sender` field is an empty string.
  4247. * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
  4248. * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
  4249. engine's liquid transformation process.
  4250. * `pos_list` is an array of all modified positions.
  4251. * `node_list` is an array of the old node that was previously at the position
  4252. with the corresponding index in pos_list.
  4253. * `minetest.register_on_mapblocks_changed(function(modified_blocks, modified_block_count))`
  4254. * Called soon after any nodes or node metadata have been modified. No
  4255. modifications will be missed, but there may be false positives.
  4256. * Will never be called more than once per server step.
  4257. * `modified_blocks` is the set of modified mapblock position hashes. These
  4258. are in the same format as those produced by `minetest.hash_node_position`,
  4259. and can be converted to positions with `minetest.get_position_from_hash`.
  4260. The set is a table where the keys are hashes and the values are `true`.
  4261. * `modified_block_count` is the number of entries in the set.
  4262. * Note: callbacks must be registered at mod load time.
  4263. Setting-related
  4264. ---------------
  4265. * `minetest.settings`: Settings object containing all of the settings from the
  4266. main config file (`minetest.conf`).
  4267. * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
  4268. parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
  4269. Authentication
  4270. --------------
  4271. * `minetest.string_to_privs(str[, delim])`:
  4272. * Converts string representation of privs into table form
  4273. * `delim`: String separating the privs. Defaults to `","`.
  4274. * Returns `{ priv1 = true, ... }`
  4275. * `minetest.privs_to_string(privs[, delim])`:
  4276. * Returns the string representation of `privs`
  4277. * `delim`: String to delimit privs. Defaults to `","`.
  4278. * `minetest.get_player_privs(name) -> {priv1=true,...}`
  4279. * `minetest.check_player_privs(player_or_name, ...)`:
  4280. returns `bool, missing_privs`
  4281. * A quickhand for checking privileges.
  4282. * `player_or_name`: Either a Player object or the name of a player.
  4283. * `...` is either a list of strings, e.g. `"priva", "privb"` or
  4284. a table, e.g. `{ priva = true, privb = true }`.
  4285. * `minetest.check_password_entry(name, entry, password)`
  4286. * Returns true if the "password entry" for a player with name matches given
  4287. password, false otherwise.
  4288. * The "password entry" is the password representation generated by the
  4289. engine as returned as part of a `get_auth()` call on the auth handler.
  4290. * Only use this function for making it possible to log in via password from
  4291. external protocols such as IRC, other uses are frowned upon.
  4292. * `minetest.get_password_hash(name, raw_password)`
  4293. * Convert a name-password pair to a password hash that Minetest can use.
  4294. * The returned value alone is not a good basis for password checks based
  4295. on comparing the password hash in the database with the password hash
  4296. from the function, with an externally provided password, as the hash
  4297. in the db might use the new SRP verifier format.
  4298. * For this purpose, use `minetest.check_password_entry` instead.
  4299. * `minetest.get_player_ip(name)`: returns an IP address string for the player
  4300. `name`.
  4301. * The player needs to be online for this to be successful.
  4302. * `minetest.get_auth_handler()`: Return the currently active auth handler
  4303. * See the [Authentication handler definition]
  4304. * Use this to e.g. get the authentication data for a player:
  4305. `local auth_data = minetest.get_auth_handler().get_auth(playername)`
  4306. * `minetest.notify_authentication_modified(name)`
  4307. * Must be called by the authentication handler for privilege changes.
  4308. * `name`: string; if omitted, all auth data should be considered modified
  4309. * `minetest.set_player_password(name, password_hash)`: Set password hash of
  4310. player `name`.
  4311. * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
  4312. `name`.
  4313. * `minetest.auth_reload()`
  4314. * See `reload()` in authentication handler definition
  4315. `minetest.set_player_password`, `minetest.set_player_privs`,
  4316. `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
  4317. handler.
  4318. Chat
  4319. ----
  4320. * `minetest.chat_send_all(text)`
  4321. * `minetest.chat_send_player(name, text)`
  4322. * `minetest.format_chat_message(name, message)`
  4323. * Used by the server to format a chat message, based on the setting `chat_message_format`.
  4324. Refer to the documentation of the setting for a list of valid placeholders.
  4325. * Takes player name and message, and returns the formatted string to be sent to players.
  4326. * Can be redefined by mods if required, for things like colored names or messages.
  4327. * **Only** the first occurrence of each placeholder will be replaced.
  4328. Environment access
  4329. ------------------
  4330. * `minetest.set_node(pos, node)`
  4331. * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
  4332. * Set node at position `pos`
  4333. * `node`: table `{name=string, param1=number, param2=number}`
  4334. * If param1 or param2 is omitted, it's set to `0`.
  4335. * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
  4336. * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
  4337. * Set node on all positions set in the first argument.
  4338. * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
  4339. * For node specification or position syntax see `minetest.set_node` call
  4340. * Faster than set_node due to single call, but still considerably slower
  4341. than Lua Voxel Manipulators (LVM) for large numbers of nodes.
  4342. Unlike LVMs, this will call node callbacks. It also allows setting nodes
  4343. in spread out positions which would cause LVMs to waste memory.
  4344. For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
  4345. times faster.
  4346. * `minetest.swap_node(pos, node)`
  4347. * Set node at position, but don't remove metadata
  4348. * `minetest.remove_node(pos)`
  4349. * By default it does the same as `minetest.set_node(pos, {name="air"})`
  4350. * `minetest.get_node(pos)`
  4351. * Returns the node at the given position as table in the format
  4352. `{name="node_name", param1=0, param2=0}`,
  4353. returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
  4354. * `minetest.get_node_or_nil(pos)`
  4355. * Same as `get_node` but returns `nil` for unloaded areas.
  4356. * `minetest.get_node_light(pos, timeofday)`
  4357. * Gets the light value at the given position. Note that the light value
  4358. "inside" the node at the given position is returned, so you usually want
  4359. to get the light value of a neighbor.
  4360. * `pos`: The position where to measure the light.
  4361. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4362. * Returns a number between `0` and `15` or `nil`
  4363. * `nil` is returned e.g. when the map isn't loaded at `pos`
  4364. * `minetest.get_natural_light(pos[, timeofday])`
  4365. * Figures out the sunlight (or moonlight) value at pos at the given time of
  4366. day.
  4367. * `pos`: The position of the node
  4368. * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
  4369. * Returns a number between `0` and `15` or `nil`
  4370. * This function tests 203 nodes in the worst case, which happens very
  4371. unlikely
  4372. * `minetest.get_artificial_light(param1)`
  4373. * Calculates the artificial light (light from e.g. torches) value from the
  4374. `param1` value.
  4375. * `param1`: The param1 value of a `paramtype = "light"` node.
  4376. * Returns a number between `0` and `15`
  4377. * Currently it's the same as `math.floor(param1 / 16)`, except that it
  4378. ensures compatibility.
  4379. * `minetest.place_node(pos, node)`
  4380. * Place node with the same effects that a player would cause
  4381. * `minetest.dig_node(pos)`
  4382. * Dig node with the same effects that a player would cause
  4383. * Returns `true` if successful, `false` on failure (e.g. protected location)
  4384. * `minetest.punch_node(pos)`
  4385. * Punch node with the same effects that a player would cause
  4386. * `minetest.spawn_falling_node(pos)`
  4387. * Change node into falling node
  4388. * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
  4389. * `minetest.find_nodes_with_meta(pos1, pos2)`
  4390. * Get a table of positions of nodes that have metadata within a region
  4391. {pos1, pos2}.
  4392. * `minetest.get_meta(pos)`
  4393. * Get a `NodeMetaRef` at that position
  4394. * `minetest.get_node_timer(pos)`
  4395. * Get `NodeTimerRef`
  4396. * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
  4397. position.
  4398. * Returns `ObjectRef`, or `nil` if failed
  4399. * `minetest.add_item(pos, item)`: Spawn item
  4400. * Returns `ObjectRef`, or `nil` if failed
  4401. * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
  4402. * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  4403. ObjectRefs.
  4404. * `radius`: using a Euclidean metric
  4405. * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
  4406. ObjectRefs.
  4407. * `pos1` and `pos2` are the min and max positions of the area to search.
  4408. * `minetest.set_timeofday(val)`
  4409. * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
  4410. * `minetest.get_timeofday()`
  4411. * `minetest.get_gametime()`: returns the time, in seconds, since the world was
  4412. created.
  4413. * `minetest.get_day_count()`: returns number days elapsed since world was
  4414. created.
  4415. * accounts for time changes.
  4416. * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
  4417. pos or `nil`.
  4418. * `radius`: using a maximum metric
  4419. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4420. * `search_center` is an optional boolean (default: `false`)
  4421. If true `pos` is also checked for the nodes
  4422. * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
  4423. * `pos1` and `pos2` are the min and max positions of the area to search.
  4424. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4425. * If `grouped` is true the return value is a table indexed by node name
  4426. which contains lists of positions.
  4427. * If `grouped` is false or absent the return values are as follows:
  4428. first value: Table with all node positions
  4429. second value: Table with the count of each node with the node name
  4430. as index
  4431. * Area volume is limited to 4,096,000 nodes
  4432. * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
  4433. list of positions.
  4434. * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
  4435. * Return value: Table with all node positions with a node air above
  4436. * Area volume is limited to 4,096,000 nodes
  4437. * `minetest.get_perlin(noiseparams)`
  4438. * Return world-specific perlin noise.
  4439. * The actual seed used is the noiseparams seed plus the world seed.
  4440. * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
  4441. * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
  4442. * Return world-specific perlin noise.
  4443. * `minetest.get_voxel_manip([pos1, pos2])`
  4444. * Return voxel manipulator object.
  4445. * Loads the manipulator from the map if positions are passed.
  4446. * `minetest.set_gen_notify(flags, {deco_ids})`
  4447. * Set the types of on-generate notifications that should be collected.
  4448. * `flags` is a flag field with the available flags:
  4449. * dungeon
  4450. * temple
  4451. * cave_begin
  4452. * cave_end
  4453. * large_cave_begin
  4454. * large_cave_end
  4455. * decoration
  4456. * The second parameter is a list of IDs of decorations which notification
  4457. is requested for.
  4458. * `minetest.get_gen_notify()`
  4459. * Returns a flagstring and a table with the `deco_id`s.
  4460. * `minetest.get_decoration_id(decoration_name)`
  4461. * Returns the decoration ID number for the provided decoration name string,
  4462. or `nil` on failure.
  4463. * `minetest.get_mapgen_object(objectname)`
  4464. * Return requested mapgen object if available (see [Mapgen objects])
  4465. * `minetest.get_heat(pos)`
  4466. * Returns the heat at the position, or `nil` on failure.
  4467. * `minetest.get_humidity(pos)`
  4468. * Returns the humidity at the position, or `nil` on failure.
  4469. * `minetest.get_biome_data(pos)`
  4470. * Returns a table containing:
  4471. * `biome` the biome id of the biome at that position
  4472. * `heat` the heat at the position
  4473. * `humidity` the humidity at the position
  4474. * Or returns `nil` on failure.
  4475. * `minetest.get_biome_id(biome_name)`
  4476. * Returns the biome id, as used in the biomemap Mapgen object and returned
  4477. by `minetest.get_biome_data(pos)`, for a given biome_name string.
  4478. * `minetest.get_biome_name(biome_id)`
  4479. * Returns the biome name string for the provided biome id, or `nil` on
  4480. failure.
  4481. * If no biomes have been registered, such as in mgv6, returns `default`.
  4482. * `minetest.get_mapgen_params()`
  4483. * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
  4484. * Returns a table containing:
  4485. * `mgname`
  4486. * `seed`
  4487. * `chunksize`
  4488. * `water_level`
  4489. * `flags`
  4490. * `minetest.set_mapgen_params(MapgenParams)`
  4491. * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
  4492. instead.
  4493. * Set map generation parameters.
  4494. * Function cannot be called after the registration period.
  4495. * Takes a table as an argument with the fields:
  4496. * `mgname`
  4497. * `seed`
  4498. * `chunksize`
  4499. * `water_level`
  4500. * `flags`
  4501. * Leave field unset to leave that parameter unchanged.
  4502. * `flags` contains a comma-delimited string of flags to set, or if the
  4503. prefix `"no"` is attached, clears instead.
  4504. * `flags` is in the same format and has the same options as `mg_flags` in
  4505. `minetest.conf`.
  4506. * `minetest.get_mapgen_edges([mapgen_limit[, chunksize]])`
  4507. * Returns the minimum and maximum possible generated node positions
  4508. in that order.
  4509. * `mapgen_limit` is an optional number. If it is absent, its value is that
  4510. of the *active* mapgen setting `"mapgen_limit"`.
  4511. * `chunksize` is an optional number. If it is absent, its value is that
  4512. of the *active* mapgen setting `"chunksize"`.
  4513. * `minetest.get_mapgen_setting(name)`
  4514. * Gets the *active* mapgen setting (or nil if none exists) in string
  4515. format with the following order of precedence:
  4516. 1) Settings loaded from map_meta.txt or overrides set during mod
  4517. execution.
  4518. 2) Settings set by mods without a metafile override
  4519. 3) Settings explicitly set in the user config file, minetest.conf
  4520. 4) Settings set as the user config default
  4521. * `minetest.get_mapgen_setting_noiseparams(name)`
  4522. * Same as above, but returns the value as a NoiseParams table if the
  4523. setting `name` exists and is a valid NoiseParams.
  4524. * `minetest.set_mapgen_setting(name, value, [override_meta])`
  4525. * Sets a mapgen param to `value`, and will take effect if the corresponding
  4526. mapgen setting is not already present in map_meta.txt.
  4527. * `override_meta` is an optional boolean (default: `false`). If this is set
  4528. to true, the setting will become the active setting regardless of the map
  4529. metafile contents.
  4530. * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
  4531. * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
  4532. * Same as above, except value is a NoiseParams table.
  4533. * `minetest.set_noiseparams(name, noiseparams, set_default)`
  4534. * Sets the noiseparams setting of `name` to the noiseparams table specified
  4535. in `noiseparams`.
  4536. * `set_default` is an optional boolean (default: `true`) that specifies
  4537. whether the setting should be applied to the default config or current
  4538. active config.
  4539. * `minetest.get_noiseparams(name)`
  4540. * Returns a table of the noiseparams for name.
  4541. * `minetest.generate_ores(vm, pos1, pos2)`
  4542. * Generate all registered ores within the VoxelManip `vm` and in the area
  4543. from `pos1` to `pos2`.
  4544. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4545. * `minetest.generate_decorations(vm, pos1, pos2)`
  4546. * Generate all registered decorations within the VoxelManip `vm` and in the
  4547. area from `pos1` to `pos2`.
  4548. * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
  4549. * `minetest.clear_objects([options])`
  4550. * Clear all objects in the environment
  4551. * Takes an optional table as an argument with the field `mode`.
  4552. * mode = `"full"`: Load and go through every mapblock, clearing
  4553. objects (default).
  4554. * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
  4555. clear objects in unloaded mapblocks only when the
  4556. mapblocks are next activated.
  4557. * `minetest.load_area(pos1[, pos2])`
  4558. * Load the mapblocks containing the area from `pos1` to `pos2`.
  4559. `pos2` defaults to `pos1` if not specified.
  4560. * This function does not trigger map generation.
  4561. * `minetest.emerge_area(pos1, pos2, [callback], [param])`
  4562. * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
  4563. asynchronously fetched from memory, loaded from disk, or if inexistent,
  4564. generates them.
  4565. * If `callback` is a valid Lua function, this will be called for each block
  4566. emerged.
  4567. * The function signature of callback is:
  4568. `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
  4569. * `blockpos` is the *block* coordinates of the block that had been
  4570. emerged.
  4571. * `action` could be one of the following constant values:
  4572. * `minetest.EMERGE_CANCELLED`
  4573. * `minetest.EMERGE_ERRORED`
  4574. * `minetest.EMERGE_FROM_MEMORY`
  4575. * `minetest.EMERGE_FROM_DISK`
  4576. * `minetest.EMERGE_GENERATED`
  4577. * `calls_remaining` is the number of callbacks to be expected after
  4578. this one.
  4579. * `param` is the user-defined parameter passed to emerge_area (or
  4580. nil if the parameter was absent).
  4581. * `minetest.delete_area(pos1, pos2)`
  4582. * delete all mapblocks in the area from pos1 to pos2, inclusive
  4583. * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
  4584. * Checks if there is anything other than air between pos1 and pos2.
  4585. * Returns false if something is blocking the sight.
  4586. * Returns the position of the blocking node when `false`
  4587. * `pos1`: First position
  4588. * `pos2`: Second position
  4589. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
  4590. * Creates a `Raycast` object.
  4591. * `pos1`: start of the ray
  4592. * `pos2`: end of the ray
  4593. * `objects`: if false, only nodes will be returned. Default is `true`.
  4594. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  4595. returned. Default is `false`.
  4596. * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
  4597. * returns table containing path that can be walked on
  4598. * returns a table of 3D points representing a path from `pos1` to `pos2` or
  4599. `nil` on failure.
  4600. * Reasons for failure:
  4601. * No path exists at all
  4602. * No path exists within `searchdistance` (see below)
  4603. * Start or end pos is buried in land
  4604. * `pos1`: start position
  4605. * `pos2`: end position
  4606. * `searchdistance`: maximum distance from the search positions to search in.
  4607. In detail: Path must be completely inside a cuboid. The minimum
  4608. `searchdistance` of 1 will confine search between `pos1` and `pos2`.
  4609. Larger values will increase the size of this cuboid in all directions
  4610. * `max_jump`: maximum height difference to consider walkable
  4611. * `max_drop`: maximum height difference to consider droppable
  4612. * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
  4613. Difference between `"A*"` and `"A*_noprefetch"` is that
  4614. `"A*"` will pre-calculate the cost-data, the other will calculate it
  4615. on-the-fly
  4616. * `minetest.spawn_tree (pos, {treedef})`
  4617. * spawns L-system tree at given `pos` with definition in `treedef` table
  4618. * `minetest.transforming_liquid_add(pos)`
  4619. * add node to liquid flow update queue
  4620. * `minetest.get_node_max_level(pos)`
  4621. * get max available level for leveled node
  4622. * `minetest.get_node_level(pos)`
  4623. * get level of leveled node (water, snow)
  4624. * `minetest.set_node_level(pos, level)`
  4625. * set level of leveled node, default `level` equals `1`
  4626. * if `totallevel > maxlevel`, returns rest (`total-max`).
  4627. * `minetest.add_node_level(pos, level)`
  4628. * increase level of leveled node by level, default `level` equals `1`
  4629. * if `totallevel > maxlevel`, returns rest (`total-max`)
  4630. * `level` must be between -127 and 127
  4631. * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
  4632. * resets the light in a cuboid-shaped part of
  4633. the map and removes lighting bugs.
  4634. * Loads the area if it is not loaded.
  4635. * `pos1` is the corner of the cuboid with the least coordinates
  4636. (in node coordinates), inclusive.
  4637. * `pos2` is the opposite corner of the cuboid, inclusive.
  4638. * The actual updated cuboid might be larger than the specified one,
  4639. because only whole map blocks can be updated.
  4640. The actual updated area consists of those map blocks that intersect
  4641. with the given cuboid.
  4642. * However, the neighborhood of the updated area might change
  4643. as well, as light can spread out of the cuboid, also light
  4644. might be removed.
  4645. * returns `false` if the area is not fully generated,
  4646. `true` otherwise
  4647. * `minetest.check_single_for_falling(pos)`
  4648. * causes an unsupported `group:falling_node` node to fall and causes an
  4649. unattached `group:attached_node` node to fall.
  4650. * does not spread these updates to neighbors.
  4651. * `minetest.check_for_falling(pos)`
  4652. * causes an unsupported `group:falling_node` node to fall and causes an
  4653. unattached `group:attached_node` node to fall.
  4654. * spread these updates to neighbors and can cause a cascade
  4655. of nodes to fall.
  4656. * `minetest.get_spawn_level(x, z)`
  4657. * Returns a player spawn y co-ordinate for the provided (x, z)
  4658. co-ordinates, or `nil` for an unsuitable spawn point.
  4659. * For most mapgens a 'suitable spawn point' is one with y between
  4660. `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
  4661. so `nil` will be returned for many (x, z) co-ordinates.
  4662. * The spawn level returned is for a player spawn in unmodified terrain.
  4663. * The spawn level is intentionally above terrain level to cope with
  4664. full-node biome 'dust' nodes.
  4665. Mod channels
  4666. ------------
  4667. You can find mod channels communication scheme in `doc/mod_channels.png`.
  4668. * `minetest.mod_channel_join(channel_name)`
  4669. * Server joins channel `channel_name`, and creates it if necessary. You
  4670. should listen for incoming messages with
  4671. `minetest.register_on_modchannel_message`
  4672. Inventory
  4673. ---------
  4674. `minetest.get_inventory(location)`: returns an `InvRef`
  4675. * `location` = e.g.
  4676. * `{type="player", name="celeron55"}`
  4677. * `{type="node", pos={x=, y=, z=}}`
  4678. * `{type="detached", name="creative"}`
  4679. * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
  4680. an `InvRef`.
  4681. * `callbacks`: See [Detached inventory callbacks]
  4682. * `player_name`: Make detached inventory available to one player
  4683. exclusively, by default they will be sent to every player (even if not
  4684. used).
  4685. Note that this parameter is mostly just a workaround and will be removed
  4686. in future releases.
  4687. * Creates a detached inventory. If it already exists, it is cleared.
  4688. * `minetest.remove_detached_inventory(name)`
  4689. * Returns a `boolean` indicating whether the removal succeeded.
  4690. * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
  4691. returns leftover ItemStack or nil to indicate no inventory change
  4692. * See `minetest.item_eat` and `minetest.register_on_item_eat`
  4693. Formspec
  4694. --------
  4695. * `minetest.show_formspec(playername, formname, formspec)`
  4696. * `playername`: name of player to show formspec
  4697. * `formname`: name passed to `on_player_receive_fields` callbacks.
  4698. It should follow the `"modname:<whatever>"` naming convention
  4699. * `formspec`: formspec to display
  4700. * `minetest.close_formspec(playername, formname)`
  4701. * `playername`: name of player to close formspec
  4702. * `formname`: has to exactly match the one given in `show_formspec`, or the
  4703. formspec will not close.
  4704. * calling `show_formspec(playername, formname, "")` is equal to this
  4705. expression.
  4706. * to close a formspec regardless of the formname, call
  4707. `minetest.close_formspec(playername, "")`.
  4708. **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
  4709. * `minetest.formspec_escape(string)`: returns a string
  4710. * escapes the characters "[", "]", "\", "," and ";", which cannot be used
  4711. in formspecs.
  4712. * `minetest.explode_table_event(string)`: returns a table
  4713. * returns e.g. `{type="CHG", row=1, column=2}`
  4714. * `type` is one of:
  4715. * `"INV"`: no row selected
  4716. * `"CHG"`: selected
  4717. * `"DCL"`: double-click
  4718. * `minetest.explode_textlist_event(string)`: returns a table
  4719. * returns e.g. `{type="CHG", index=1}`
  4720. * `type` is one of:
  4721. * `"INV"`: no row selected
  4722. * `"CHG"`: selected
  4723. * `"DCL"`: double-click
  4724. * `minetest.explode_scrollbar_event(string)`: returns a table
  4725. * returns e.g. `{type="CHG", value=500}`
  4726. * `type` is one of:
  4727. * `"INV"`: something failed
  4728. * `"CHG"`: has been changed
  4729. * `"VAL"`: not changed
  4730. Item handling
  4731. -------------
  4732. * `minetest.inventorycube(img1, img2, img3)`
  4733. * Returns a string for making an image of a cube (useful as an item image)
  4734. * `minetest.get_pointed_thing_position(pointed_thing, above)`
  4735. * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
  4736. does not refer to a node or entity.
  4737. * If the optional `above` parameter is true and the `pointed_thing` refers
  4738. to a node, then it will return the `above` position of the `pointed_thing`.
  4739. * `minetest.dir_to_facedir(dir, is6d)`
  4740. * Convert a vector to a facedir value, used in `param2` for
  4741. `paramtype2="facedir"`.
  4742. * passing something non-`nil`/`false` for the optional second parameter
  4743. causes it to take the y component into account.
  4744. * `minetest.facedir_to_dir(facedir)`
  4745. * Convert a facedir back into a vector aimed directly out the "back" of a
  4746. node.
  4747. * `minetest.dir_to_fourdir(dir)`
  4748. * Convert a vector to a 4dir value, used in `param2` for
  4749. `paramtype2="4dir"`.
  4750. * `minetest.fourdir_to_dir(fourdir)`
  4751. * Convert a 4dir back into a vector aimed directly out the "back" of a
  4752. node.
  4753. * `minetest.dir_to_wallmounted(dir)`
  4754. * Convert a vector to a wallmounted value, used for
  4755. `paramtype2="wallmounted"`.
  4756. * `minetest.wallmounted_to_dir(wallmounted)`
  4757. * Convert a wallmounted value back into a vector aimed directly out the
  4758. "back" of a node.
  4759. * `minetest.dir_to_yaw(dir)`
  4760. * Convert a vector into a yaw (angle)
  4761. * `minetest.yaw_to_dir(yaw)`
  4762. * Convert yaw (angle) to a vector
  4763. * `minetest.is_colored_paramtype(ptype)`
  4764. * Returns a boolean. Returns `true` if the given `paramtype2` contains
  4765. color information (`color`, `colorwallmounted`, `colorfacedir`, etc.).
  4766. * `minetest.strip_param2_color(param2, paramtype2)`
  4767. * Removes everything but the color information from the
  4768. given `param2` value.
  4769. * Returns `nil` if the given `paramtype2` does not contain color
  4770. information.
  4771. * `minetest.get_node_drops(node, toolname)`
  4772. * Returns list of itemstrings that are dropped by `node` when dug
  4773. with the item `toolname` (not limited to tools).
  4774. * `node`: node as table or node name
  4775. * `toolname`: name of the item used to dig (can be `nil`)
  4776. * `minetest.get_craft_result(input)`: returns `output, decremented_input`
  4777. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4778. * `input.width` = for example `3`
  4779. * `input.items` = for example
  4780. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4781. * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
  4782. * `output.time` = a number, if unsuccessful: `0`
  4783. * `output.replacements` = List of replacement `ItemStack`s that couldn't be
  4784. placed in `decremented_input.items`. Replacements can be placed in
  4785. `decremented_input` if the stack of the replaced item has a count of 1.
  4786. * `decremented_input` = like `input`
  4787. * `minetest.get_craft_recipe(output)`: returns input
  4788. * returns last registered recipe for output item (node)
  4789. * `output` is a node or item type such as `"default:torch"`
  4790. * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
  4791. * `input.width` = for example `3`
  4792. * `input.items` = for example
  4793. `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
  4794. * `input.items` = `nil` if no recipe found
  4795. * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
  4796. * returns indexed table with all registered recipes for query item (node)
  4797. or `nil` if no recipe was found.
  4798. * recipe entry table:
  4799. * `method`: 'normal' or 'cooking' or 'fuel'
  4800. * `width`: 0-3, 0 means shapeless recipe
  4801. * `items`: indexed [1-9] table with recipe items
  4802. * `output`: string with item name and quantity
  4803. * Example result for `"default:gold_ingot"` with two recipes:
  4804. {
  4805. {
  4806. method = "cooking", width = 3,
  4807. output = "default:gold_ingot", items = {"default:gold_lump"}
  4808. },
  4809. {
  4810. method = "normal", width = 1,
  4811. output = "default:gold_ingot 9", items = {"default:goldblock"}
  4812. }
  4813. }
  4814. * `minetest.handle_node_drops(pos, drops, digger)`
  4815. * `drops`: list of itemstrings
  4816. * Handles drops from nodes after digging: Default action is to put them
  4817. into digger's inventory.
  4818. * Can be overridden to get different functionality (e.g. dropping items on
  4819. ground)
  4820. * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
  4821. string.
  4822. * Creates an item string which contains palette index information
  4823. for hardware colorization. You can use the returned string
  4824. as an output in a craft recipe.
  4825. * `item`: the item stack which becomes colored. Can be in string,
  4826. table and native form.
  4827. * `palette_index`: this index is added to the item stack
  4828. * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
  4829. * Creates an item string which contains static color information
  4830. for hardware colorization. Use this method if you wish to colorize
  4831. an item that does not own a palette. You can use the returned string
  4832. as an output in a craft recipe.
  4833. * `item`: the item stack which becomes colored. Can be in string,
  4834. table and native form.
  4835. * `colorstring`: the new color of the item stack
  4836. Rollback
  4837. --------
  4838. * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
  4839. returns `{{actor, pos, time, oldnode, newnode}, ...}`
  4840. * Find who has done something to a node, or near a node
  4841. * `actor`: `"player:<name>"`, also `"liquid"`.
  4842. * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
  4843. `boolean, log_messages`.
  4844. * Revert latest actions of someone
  4845. * `actor`: `"player:<name>"`, also `"liquid"`.
  4846. Defaults for the `on_place` and `on_drop` item definition functions
  4847. -------------------------------------------------------------------
  4848. * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
  4849. * Place item as a node
  4850. * `param2` overrides `facedir` and wallmounted `param2`
  4851. * `prevent_after_place`: if set to `true`, `after_place_node` is not called
  4852. for the newly placed node to prevent a callback and placement loop
  4853. * returns `itemstack, position`
  4854. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4855. * `minetest.item_place_object(itemstack, placer, pointed_thing)`
  4856. * Place item as-is
  4857. * returns the leftover itemstack
  4858. * **Note**: This function is deprecated and will never be called.
  4859. * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
  4860. * Wrapper that calls `minetest.item_place_node` if appropriate
  4861. * Calls `on_rightclick` of `pointed_thing.under` if defined instead
  4862. * **Note**: is not called when wielded item overrides `on_place`
  4863. * `param2` overrides facedir and wallmounted `param2`
  4864. * returns `itemstack, position`
  4865. * `position`: the location the node was placed to. `nil` if nothing was placed.
  4866. * `minetest.item_pickup(itemstack, picker, pointed_thing, time_from_last_punch, ...)`
  4867. * Runs callbacks registered by `minetest.register_on_item_pickup` and adds
  4868. the item to the picker's `"main"` inventory list.
  4869. * Parameters are the same as in `on_pickup`.
  4870. * Returns the leftover itemstack.
  4871. * `minetest.item_drop(itemstack, dropper, pos)`
  4872. * Drop the item
  4873. * returns the leftover itemstack
  4874. * `minetest.item_eat(hp_change[, replace_with_item])`
  4875. * Returns `function(itemstack, user, pointed_thing)` as a
  4876. function wrapper for `minetest.do_item_eat`.
  4877. * `replace_with_item` is the itemstring which is added to the inventory.
  4878. If the player is eating a stack, then replace_with_item goes to a
  4879. different spot.
  4880. Defaults for the `on_punch` and `on_dig` node definition callbacks
  4881. ------------------------------------------------------------------
  4882. * `minetest.node_punch(pos, node, puncher, pointed_thing)`
  4883. * Calls functions registered by `minetest.register_on_punchnode()`
  4884. * `minetest.node_dig(pos, node, digger)`
  4885. * Checks if node can be dug, puts item into inventory, removes node
  4886. * Calls functions registered by `minetest.registered_on_dignodes()`
  4887. Sounds
  4888. ------
  4889. * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
  4890. * `spec` is a `SimpleSoundSpec`
  4891. * `parameters` is a sound parameter table
  4892. * `ephemeral` is a boolean (default: false)
  4893. Ephemeral sounds will not return a handle and can't be stopped or faded.
  4894. It is recommend to use this for short sounds that happen in response to
  4895. player actions (e.g. door closing).
  4896. * `minetest.sound_stop(handle)`
  4897. * `handle` is a handle returned by `minetest.sound_play`
  4898. * `minetest.sound_fade(handle, step, gain)`
  4899. * `handle` is a handle returned by `minetest.sound_play`
  4900. * `step` determines how fast a sound will fade.
  4901. The gain will change by this much per second,
  4902. until it reaches the target gain.
  4903. Note: Older versions used a signed step. This is deprecated, but old
  4904. code will still work. (the client uses abs(step) to correct it)
  4905. * `gain` the target gain for the fade.
  4906. Fading to zero will delete the sound.
  4907. Timing
  4908. ------
  4909. * `minetest.after(time, func, ...)`: returns job table to use as below.
  4910. * Call the function `func` after `time` seconds, may be fractional
  4911. * Optional: Variable number of arguments that are passed to `func`
  4912. * `job:cancel()`
  4913. * Cancels the job function from being called
  4914. Async environment
  4915. -----------------
  4916. The engine allows you to submit jobs to be ran in an isolated environment
  4917. concurrently with normal server operation.
  4918. A job consists of a function to be ran in the async environment, any amount of
  4919. arguments (will be serialized) and a callback that will be called with the return
  4920. value of the job function once it is finished.
  4921. The async environment does *not* have access to the map, entities, players or any
  4922. globals defined in the 'usual' environment. Consequently, functions like
  4923. `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
  4924. Arguments and return values passed through this can contain certain userdata
  4925. objects that will be seamlessly copied (not shared) to the async environment.
  4926. This allows you easy interoperability for delegating work to jobs.
  4927. * `minetest.handle_async(func, callback, ...)`:
  4928. * Queue the function `func` to be ran in an async environment.
  4929. Note that there are multiple persistent workers and any of them may
  4930. end up running a given job. The engine will scale the amount of
  4931. worker threads automatically.
  4932. * When `func` returns the callback is called (in the normal environment)
  4933. with all of the return values as arguments.
  4934. * Optional: Variable number of arguments that are passed to `func`
  4935. * `minetest.register_async_dofile(path)`:
  4936. * Register a path to a Lua file to be imported when an async environment
  4937. is initialized. You can use this to preload code which you can then call
  4938. later using `minetest.handle_async()`.
  4939. ### List of APIs available in an async environment
  4940. Classes:
  4941. * `ItemStack`
  4942. * `PerlinNoise`
  4943. * `PerlinNoiseMap`
  4944. * `PseudoRandom`
  4945. * `PcgRandom`
  4946. * `SecureRandom`
  4947. * `VoxelArea`
  4948. * `VoxelManip`
  4949. * only if transferred into environment; can't read/write to map
  4950. * `Settings`
  4951. Class instances that can be transferred between environments:
  4952. * `ItemStack`
  4953. * `PerlinNoise`
  4954. * `PerlinNoiseMap`
  4955. * `VoxelManip`
  4956. Functions:
  4957. * Standalone helpers such as logging, filesystem, encoding,
  4958. hashing or compression APIs
  4959. * `minetest.request_insecure_environment` (same restrictions apply)
  4960. Variables:
  4961. * `minetest.settings`
  4962. * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
  4963. `registered_craftitems` and `registered_aliases`
  4964. * with all functions and userdata values replaced by `true`, calling any
  4965. callbacks here is obviously not possible
  4966. Server
  4967. ------
  4968. * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
  4969. server shutdown. Will display `message` to clients.
  4970. * `reconnect` == true displays a reconnect button
  4971. * `delay` adds an optional delay (in seconds) before shutdown.
  4972. Negative delay cancels the current active shutdown.
  4973. Zero delay triggers an immediate shutdown.
  4974. * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
  4975. * `minetest.get_server_status(name, joined)`
  4976. * Returns the server status string when a player joins or when the command
  4977. `/status` is called. Returns `nil` or an empty string when the message is
  4978. disabled.
  4979. * `joined`: Boolean value, indicates whether the function was called when
  4980. a player joined.
  4981. * This function may be overwritten by mods to customize the status message.
  4982. * `minetest.get_server_uptime()`: returns the server uptime in seconds
  4983. * `minetest.get_server_max_lag()`: returns the current maximum lag
  4984. of the server in seconds or nil if server is not fully loaded yet
  4985. * `minetest.remove_player(name)`: remove player from database (if they are not
  4986. connected).
  4987. * As auth data is not removed, minetest.player_exists will continue to
  4988. return true. Call the below method as well if you want to remove auth
  4989. data too.
  4990. * Returns a code (0: successful, 1: no such player, 2: player is connected)
  4991. * `minetest.remove_player_auth(name)`: remove player authentication data
  4992. * Returns boolean indicating success (false if player nonexistent)
  4993. * `minetest.dynamic_add_media(options, callback)`
  4994. * `options`: table containing the following parameters
  4995. * `filepath`: path to a media file on the filesystem
  4996. * `to_player`: name of the player the media should be sent to instead of
  4997. all players (optional)
  4998. * `ephemeral`: boolean that marks the media as ephemeral,
  4999. it will not be cached on the client (optional, default false)
  5000. * `callback`: function with arguments `name`, which is a player name
  5001. * Pushes the specified media file to client(s). (details below)
  5002. The file must be a supported image, sound or model format.
  5003. Dynamically added media is not persisted between server restarts.
  5004. * Returns false on error, true if the request was accepted
  5005. * The given callback will be called for every player as soon as the
  5006. media is available on the client.
  5007. * Details/Notes:
  5008. * If `ephemeral`=false and `to_player` is unset the file is added to the media
  5009. sent to clients on startup, this means the media will appear even on
  5010. old clients if they rejoin the server.
  5011. * If `ephemeral`=false the file must not be modified, deleted, moved or
  5012. renamed after calling this function.
  5013. * Regardless of any use of `ephemeral`, adding media files with the same
  5014. name twice is not possible/guaranteed to work. An exception to this is the
  5015. use of `to_player` to send the same, already existent file to multiple
  5016. chosen players.
  5017. * Clients will attempt to fetch files added this way via remote media,
  5018. this can make transfer of bigger files painless (if set up). Nevertheless
  5019. it is advised not to use dynamic media for big media files.
  5020. Bans
  5021. ----
  5022. * `minetest.get_ban_list()`: returns a list of all bans formatted as string
  5023. * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
  5024. IP address or name formatted as string
  5025. * `minetest.ban_player(name)`: ban the IP of a currently connected player
  5026. * Returns boolean indicating success
  5027. * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
  5028. IP address or name
  5029. * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
  5030. reason.
  5031. * Returns boolean indicating success (false if player nonexistent)
  5032. * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
  5033. optional reason, this will not prefix with 'Kicked: ' like kick_player.
  5034. If no reason is given, it will default to 'Disconnected.'
  5035. * Returns boolean indicating success (false if player nonexistent)
  5036. Particles
  5037. ---------
  5038. * `minetest.add_particle(particle definition)`
  5039. * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
  5040. expirationtime, size, collisiondetection, texture, playername)`
  5041. * `minetest.add_particlespawner(particlespawner definition)`
  5042. * Add a `ParticleSpawner`, an object that spawns an amount of particles
  5043. over `time` seconds.
  5044. * Returns an `id`, and -1 if adding didn't succeed
  5045. * Deprecated: `minetest.add_particlespawner(amount, time,
  5046. minpos, maxpos,
  5047. minvel, maxvel,
  5048. minacc, maxacc,
  5049. minexptime, maxexptime,
  5050. minsize, maxsize,
  5051. collisiondetection, texture, playername)`
  5052. * `minetest.delete_particlespawner(id, player)`
  5053. * Delete `ParticleSpawner` with `id` (return value from
  5054. `minetest.add_particlespawner`).
  5055. * If playername is specified, only deletes on the player's client,
  5056. otherwise on all clients.
  5057. Schematics
  5058. ----------
  5059. * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
  5060. * Create a schematic from the volume of map specified by the box formed by
  5061. p1 and p2.
  5062. * Apply the specified probability and per-node force-place to the specified
  5063. nodes according to the `probability_list`.
  5064. * `probability_list` is an array of tables containing two fields, `pos`
  5065. and `prob`.
  5066. * `pos` is the 3D vector specifying the absolute coordinates of the
  5067. node being modified,
  5068. * `prob` is an integer value from `0` to `255` that encodes
  5069. probability and per-node force-place. Probability has levels
  5070. 0-127, then 128 may be added to encode per-node force-place.
  5071. For probability stated as 0-255, divide by 2 and round down to
  5072. get values 0-127, then add 128 to apply per-node force-place.
  5073. * If there are two or more entries with the same pos value, the
  5074. last entry is used.
  5075. * If `pos` is not inside the box formed by `p1` and `p2`, it is
  5076. ignored.
  5077. * If `probability_list` equals `nil`, no probabilities are applied.
  5078. * Apply the specified probability to the specified horizontal slices
  5079. according to the `slice_prob_list`.
  5080. * `slice_prob_list` is an array of tables containing two fields, `ypos`
  5081. and `prob`.
  5082. * `ypos` indicates the y position of the slice with a probability
  5083. applied, the lowest slice being `ypos = 0`.
  5084. * If slice probability list equals `nil`, no slice probabilities
  5085. are applied.
  5086. * Saves schematic in the Minetest Schematic format to filename.
  5087. * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
  5088. * Place the schematic specified by schematic (see [Schematic specifier]) at
  5089. `pos`.
  5090. * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
  5091. * If the `rotation` parameter is omitted, the schematic is not rotated.
  5092. * `replacements` = `{["old_name"] = "convert_to", ...}`
  5093. * `force_placement` is a boolean indicating whether nodes other than `air`
  5094. and `ignore` are replaced by the schematic.
  5095. * Returns nil if the schematic could not be loaded.
  5096. * **Warning**: Once you have loaded a schematic from a file, it will be
  5097. cached. Future calls will always use the cached version and the
  5098. replacement list defined for it, regardless of whether the file or the
  5099. replacement list parameter have changed. The only way to load the file
  5100. anew is to restart the server.
  5101. * `flags` is a flag field with the available flags:
  5102. * place_center_x
  5103. * place_center_y
  5104. * place_center_z
  5105. * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
  5106. * This function is analogous to minetest.place_schematic, but places a
  5107. schematic onto the specified VoxelManip object `vmanip` instead of the
  5108. map.
  5109. * Returns false if any part of the schematic was cut-off due to the
  5110. VoxelManip not containing the full area required, and true if the whole
  5111. schematic was able to fit.
  5112. * Returns nil if the schematic could not be loaded.
  5113. * After execution, any external copies of the VoxelManip contents are
  5114. invalidated.
  5115. * `flags` is a flag field with the available flags:
  5116. * place_center_x
  5117. * place_center_y
  5118. * place_center_z
  5119. * `minetest.serialize_schematic(schematic, format, options)`
  5120. * Return the serialized schematic specified by schematic
  5121. (see [Schematic specifier])
  5122. * in the `format` of either "mts" or "lua".
  5123. * "mts" - a string containing the binary MTS data used in the MTS file
  5124. format.
  5125. * "lua" - a string containing Lua code representing the schematic in table
  5126. format.
  5127. * `options` is a table containing the following optional parameters:
  5128. * If `lua_use_comments` is true and `format` is "lua", the Lua code
  5129. generated will have (X, Z) position comments for every X row
  5130. generated in the schematic data for easier reading.
  5131. * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
  5132. the Lua code generated will use that number of spaces as indentation
  5133. instead of a tab character.
  5134. * `minetest.read_schematic(schematic, options)`
  5135. * Returns a Lua table representing the schematic (see: [Schematic specifier])
  5136. * `schematic` is the schematic to read (see: [Schematic specifier])
  5137. * `options` is a table containing the following optional parameters:
  5138. * `write_yslice_prob`: string value:
  5139. * `none`: no `write_yslice_prob` table is inserted,
  5140. * `low`: only probabilities that are not 254 or 255 are written in
  5141. the `write_ylisce_prob` table,
  5142. * `all`: write all probabilities to the `write_yslice_prob` table.
  5143. * The default for this option is `all`.
  5144. * Any invalid value will be interpreted as `all`.
  5145. HTTP Requests
  5146. -------------
  5147. * `minetest.request_http_api()`:
  5148. * returns `HTTPApiTable` containing http functions if the calling mod has
  5149. been granted access by being listed in the `secure.http_mods` or
  5150. `secure.trusted_mods` setting, otherwise returns `nil`.
  5151. * The returned table contains the functions `fetch`, `fetch_async` and
  5152. `fetch_async_get` described below.
  5153. * Only works at init time and must be called from the mod's main scope
  5154. (not from a function).
  5155. * Function only exists if minetest server was built with cURL support.
  5156. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
  5157. A LOCAL VARIABLE!**
  5158. * `HTTPApiTable.fetch(HTTPRequest req, callback)`
  5159. * Performs given request asynchronously and calls callback upon completion
  5160. * callback: `function(HTTPRequestResult res)`
  5161. * Use this HTTP function if you are unsure, the others are for advanced use
  5162. * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
  5163. * Performs given request asynchronously and returns handle for
  5164. `HTTPApiTable.fetch_async_get`
  5165. * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
  5166. * Return response data for given asynchronous HTTP request
  5167. Storage API
  5168. -----------
  5169. * `minetest.get_mod_storage()`:
  5170. * returns reference to mod private `StorageRef`
  5171. * must be called during mod load time
  5172. Misc.
  5173. -----
  5174. * `minetest.get_connected_players()`: returns list of `ObjectRefs`
  5175. * `minetest.is_player(obj)`: boolean, whether `obj` is a player
  5176. * `minetest.player_exists(name)`: boolean, whether player exists
  5177. (regardless of online status)
  5178. * `minetest.hud_replace_builtin(name, hud_definition)`
  5179. * Replaces definition of a builtin hud element
  5180. * `name`: `"breath"` or `"health"`
  5181. * `hud_definition`: definition to replace builtin definition
  5182. * `minetest.parse_relative_number(arg, relative_to)`: returns number or nil
  5183. * Helper function for chat commands.
  5184. * For parsing an optionally relative number of a chat command
  5185. parameter, using the chat command tilde notation.
  5186. * `arg`: String snippet containing the number; possible values:
  5187. * `"<number>"`: return as number
  5188. * `"~<number>"`: return `relative_to + <number>`
  5189. * `"~"`: return `relative_to`
  5190. * Anything else will return `nil`
  5191. * `relative_to`: Number to which the `arg` number might be relative to
  5192. * Examples:
  5193. * `minetest.parse_relative_number("5", 10)` returns 5
  5194. * `minetest.parse_relative_number("~5", 10)` returns 15
  5195. * `minetest.parse_relative_number("~", 10)` returns 10
  5196. * `minetest.send_join_message(player_name)`
  5197. * This function can be overridden by mods to change the join message.
  5198. * `minetest.send_leave_message(player_name, timed_out)`
  5199. * This function can be overridden by mods to change the leave message.
  5200. * `minetest.hash_node_position(pos)`: returns a 48-bit integer
  5201. * `pos`: table {x=number, y=number, z=number},
  5202. * Gives a unique hash number for a node position (16+16+16=48bit)
  5203. * `minetest.get_position_from_hash(hash)`: returns a position
  5204. * Inverse transform of `minetest.hash_node_position`
  5205. * `minetest.get_item_group(name, group)`: returns a rating
  5206. * Get rating of a group of an item. (`0` means: not in group)
  5207. * `minetest.get_node_group(name, group)`: returns a rating
  5208. * Deprecated: An alias for the former.
  5209. * `minetest.raillike_group(name)`: returns a rating
  5210. * Returns rating of the connect_to_raillike group corresponding to name
  5211. * If name is not yet the name of a connect_to_raillike group, a new group
  5212. id is created, with that name.
  5213. * `minetest.get_content_id(name)`: returns an integer
  5214. * Gets the internal content ID of `name`
  5215. * `minetest.get_name_from_content_id(content_id)`: returns a string
  5216. * Gets the name of the content with that content ID
  5217. * `minetest.parse_json(string[, nullvalue])`: returns something
  5218. * Convert a string containing JSON data into the Lua equivalent
  5219. * `nullvalue`: returned in place of the JSON null; defaults to `nil`
  5220. * On success returns a table, a string, a number, a boolean or `nullvalue`
  5221. * On failure outputs an error message and returns `nil`
  5222. * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
  5223. * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
  5224. message.
  5225. * Convert a Lua table into a JSON string
  5226. * styled: Outputs in a human-readable format if this is set, defaults to
  5227. false.
  5228. * Unserializable things like functions and userdata will cause an error.
  5229. * **Warning**: JSON is more strict than the Lua table format.
  5230. 1. You can only use strings and positive integers of at least one as
  5231. keys.
  5232. 2. You cannot mix string and integer keys.
  5233. This is due to the fact that JSON has two distinct array and object
  5234. values.
  5235. * Example: `write_json({10, {a = false}})`,
  5236. returns `'[10, {"a": false}]'`
  5237. * `minetest.serialize(table)`: returns a string
  5238. * Convert a table containing tables, strings, numbers, booleans and `nil`s
  5239. into string form readable by `minetest.deserialize`
  5240. * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
  5241. * `minetest.deserialize(string[, safe])`: returns a table
  5242. * Convert a string returned by `minetest.serialize` into a table
  5243. * `string` is loaded in an empty sandbox environment.
  5244. * Will load functions if safe is false or omitted. Although these functions
  5245. cannot directly access the global environment, they could bypass this
  5246. restriction with maliciously crafted Lua bytecode if mod security is
  5247. disabled.
  5248. * This function should not be used on untrusted data, regardless of the
  5249. value of `safe`. It is fine to serialize then deserialize user-provided
  5250. data, but directly providing user input to deserialize is always unsafe.
  5251. * Example: `deserialize('return { ["foo"] = "bar" }')`,
  5252. returns `{foo="bar"}`
  5253. * Example: `deserialize('print("foo")')`, returns `nil`
  5254. (function call fails), returns
  5255. `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
  5256. * `minetest.compress(data, method, ...)`: returns `compressed_data`
  5257. * Compress a string of data.
  5258. * `method` is a string identifying the compression method to be used.
  5259. * Supported compression methods:
  5260. * Deflate (zlib): `"deflate"`
  5261. * Zstandard: `"zstd"`
  5262. * `...` indicates method-specific arguments. Currently defined arguments
  5263. are:
  5264. * Deflate: `level` - Compression level, `0`-`9` or `nil`.
  5265. * Zstandard: `level` - Compression level. Integer or `nil`. Default `3`.
  5266. Note any supported Zstandard compression level could be used here,
  5267. but these are subject to change between Zstandard versions.
  5268. * `minetest.decompress(compressed_data, method, ...)`: returns data
  5269. * Decompress a string of data using the algorithm specified by `method`.
  5270. * See documentation on `minetest.compress()` for supported compression
  5271. methods.
  5272. * `...` indicates method-specific arguments. Currently, no methods use this
  5273. * `minetest.rgba(red, green, blue[, alpha])`: returns a string
  5274. * Each argument is an 8 Bit unsigned integer
  5275. * Returns the ColorString from rgb or rgba values
  5276. * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
  5277. * `minetest.encode_base64(string)`: returns string encoded in base64
  5278. * Encodes a string in base64.
  5279. * `minetest.decode_base64(string)`: returns string or nil on failure
  5280. * Padding characters are only supported starting at version 5.4.0, where
  5281. 5.5.0 and newer perform proper checks.
  5282. * Decodes a string encoded in base64.
  5283. * `minetest.is_protected(pos, name)`: returns boolean
  5284. * Returning `true` restricts the player `name` from modifying (i.e. digging,
  5285. placing) the node at position `pos`.
  5286. * `name` will be `""` for non-players or unknown players.
  5287. * This function should be overridden by protection mods. It is highly
  5288. recommended to grant access to players with the `protection_bypass` privilege.
  5289. * Cache and call the old version of this function if the position is
  5290. not protected by the mod. This will allow using multiple protection mods.
  5291. * Example:
  5292. local old_is_protected = minetest.is_protected
  5293. function minetest.is_protected(pos, name)
  5294. if mymod:position_protected_from(pos, name) then
  5295. return true
  5296. end
  5297. return old_is_protected(pos, name)
  5298. end
  5299. * `minetest.record_protection_violation(pos, name)`
  5300. * This function calls functions registered with
  5301. `minetest.register_on_protection_violation`.
  5302. * `minetest.is_creative_enabled(name)`: returns boolean
  5303. * Returning `true` means that Creative Mode is enabled for player `name`.
  5304. * `name` will be `""` for non-players or if the player is unknown.
  5305. * This function should be overridden by Creative Mode-related mods to
  5306. implement a per-player Creative Mode.
  5307. * By default, this function returns `true` if the setting
  5308. `creative_mode` is `true` and `false` otherwise.
  5309. * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
  5310. * Returns the position of the first node that `player_name` may not modify
  5311. in the specified cuboid between `pos1` and `pos2`.
  5312. * Returns `false` if no protections were found.
  5313. * Applies `is_protected()` to a 3D lattice of points in the defined volume.
  5314. The points are spaced evenly throughout the volume and have a spacing
  5315. similar to, but no larger than, `interval`.
  5316. * All corners and edges of the defined volume are checked.
  5317. * `interval` defaults to 4.
  5318. * `interval` should be carefully chosen and maximized to avoid an excessive
  5319. number of points being checked.
  5320. * Like `minetest.is_protected`, this function may be extended or
  5321. overwritten by mods to provide a faster implementation to check the
  5322. cuboid for intersections.
  5323. * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
  5324. orient_flags, prevent_after_place])`
  5325. * Attempt to predict the desired orientation of the facedir-capable node
  5326. defined by `itemstack`, and place it accordingly (on-wall, on the floor,
  5327. or hanging from the ceiling).
  5328. * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
  5329. stacks are handled normally.
  5330. * `orient_flags`: Optional table containing extra tweaks to the placement code:
  5331. * `invert_wall`: if `true`, place wall-orientation on the ground and
  5332. ground-orientation on the wall.
  5333. * `force_wall`: if `true`, always place the node in wall orientation.
  5334. * `force_ceiling`: if `true`, always place on the ceiling.
  5335. * `force_floor`: if `true`, always place the node on the floor.
  5336. * `force_facedir`: if `true`, forcefully reset the facedir to north
  5337. when placing on the floor or ceiling.
  5338. * The first four options are mutually-exclusive; the last in the list
  5339. takes precedence over the first.
  5340. * `prevent_after_place` is directly passed to `minetest.item_place_node`
  5341. * Returns the new itemstack after placement
  5342. * `minetest.rotate_node(itemstack, placer, pointed_thing)`
  5343. * calls `rotate_and_place()` with `infinitestacks` set according to the state
  5344. of the creative mode setting, checks for "sneak" to set the `invert_wall`
  5345. parameter and `prevent_after_place` set to `true`.
  5346. * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
  5347. tool_capabilities, dir, distance, damage)`
  5348. * Returns the amount of knockback applied on the punched player.
  5349. * Arguments are equivalent to `register_on_punchplayer`, except the following:
  5350. * `distance`: distance between puncher and punched player
  5351. * This function can be overridden by mods that wish to modify this behavior.
  5352. * You may want to cache and call the old function to allow multiple mods to
  5353. change knockback behavior.
  5354. * `minetest.forceload_block(pos[, transient[, limit]])`
  5355. * forceloads the position `pos`.
  5356. * returns `true` if area could be forceloaded
  5357. * If `transient` is `false` or absent, the forceload will be persistent
  5358. (saved between server runs). If `true`, the forceload will be transient
  5359. (not saved between server runs).
  5360. * `limit` is an optional limit on the number of blocks that can be
  5361. forceloaded at once. If `limit` is negative, there is no limit. If it is
  5362. absent, the limit is the value of the setting `"max_forceloaded_blocks"`.
  5363. If the call would put the number of blocks over the limit, the call fails.
  5364. * `minetest.forceload_free_block(pos[, transient])`
  5365. * stops forceloading the position `pos`
  5366. * If `transient` is `false` or absent, frees a persistent forceload.
  5367. If `true`, frees a transient forceload.
  5368. * `minetest.compare_block_status(pos, condition)`
  5369. * Checks whether the mapblock at position `pos` is in the wanted condition.
  5370. * `condition` may be one of the following values:
  5371. * `"unknown"`: not in memory
  5372. * `"emerging"`: in the queue for loading from disk or generating
  5373. * `"loaded"`: in memory but inactive (no ABMs are executed)
  5374. * `"active"`: in memory and active
  5375. * Other values are reserved for future functionality extensions
  5376. * Return value, the comparison status:
  5377. * `false`: Mapblock does not fulfill the wanted condition
  5378. * `true`: Mapblock meets the requirement
  5379. * `nil`: Unsupported `condition` value
  5380. * `minetest.request_insecure_environment()`: returns an environment containing
  5381. insecure functions if the calling mod has been listed as trusted in the
  5382. `secure.trusted_mods` setting or security is disabled, otherwise returns
  5383. `nil`.
  5384. * Only works at init time and must be called from the mod's main scope
  5385. (ie: the init.lua of the mod, not from another Lua file or within a function).
  5386. * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
  5387. IT IN A LOCAL VARIABLE!**
  5388. * `minetest.global_exists(name)`
  5389. * Checks if a global variable has been set, without triggering a warning.
  5390. Global objects
  5391. --------------
  5392. * `minetest.env`: `EnvRef` of the server environment and world.
  5393. * Any function in the minetest namespace can be called using the syntax
  5394. `minetest.env:somefunction(somearguments)`
  5395. instead of `minetest.somefunction(somearguments)`
  5396. * Deprecated, but support is not to be dropped soon
  5397. Global tables
  5398. -------------
  5399. ### Registered definition tables
  5400. * `minetest.registered_items`
  5401. * Map of registered items, indexed by name
  5402. * `minetest.registered_nodes`
  5403. * Map of registered node definitions, indexed by name
  5404. * `minetest.registered_craftitems`
  5405. * Map of registered craft item definitions, indexed by name
  5406. * `minetest.registered_tools`
  5407. * Map of registered tool definitions, indexed by name
  5408. * `minetest.registered_entities`
  5409. * Map of registered entity prototypes, indexed by name
  5410. * Values in this table may be modified directly.
  5411. Note: changes to initial properties will only affect entities spawned afterwards,
  5412. as they are only read when spawning.
  5413. * `minetest.object_refs`
  5414. * Map of object references, indexed by active object id
  5415. * `minetest.luaentities`
  5416. * Map of Lua entities, indexed by active object id
  5417. * `minetest.registered_abms`
  5418. * List of ABM definitions
  5419. * `minetest.registered_lbms`
  5420. * List of LBM definitions
  5421. * `minetest.registered_aliases`
  5422. * Map of registered aliases, indexed by name
  5423. * `minetest.registered_ores`
  5424. * Map of registered ore definitions, indexed by the `name` field.
  5425. * If `name` is nil, the key is the object handle returned by
  5426. `minetest.register_ore`.
  5427. * `minetest.registered_biomes`
  5428. * Map of registered biome definitions, indexed by the `name` field.
  5429. * If `name` is nil, the key is the object handle returned by
  5430. `minetest.register_biome`.
  5431. * `minetest.registered_decorations`
  5432. * Map of registered decoration definitions, indexed by the `name` field.
  5433. * If `name` is nil, the key is the object handle returned by
  5434. `minetest.register_decoration`.
  5435. * `minetest.registered_schematics`
  5436. * Map of registered schematic definitions, indexed by the `name` field.
  5437. * If `name` is nil, the key is the object handle returned by
  5438. `minetest.register_schematic`.
  5439. * `minetest.registered_chatcommands`
  5440. * Map of registered chat command definitions, indexed by name
  5441. * `minetest.registered_privileges`
  5442. * Map of registered privilege definitions, indexed by name
  5443. * Registered privileges can be modified directly in this table.
  5444. ### Registered callback tables
  5445. All callbacks registered with [Global callback registration functions] are added
  5446. to corresponding `minetest.registered_*` tables.
  5447. Class reference
  5448. ===============
  5449. Sorted alphabetically.
  5450. `AreaStore`
  5451. -----------
  5452. AreaStore is a data structure to calculate intersections of 3D cuboid volumes
  5453. and points. The `data` field (string) may be used to store and retrieve any
  5454. mod-relevant information to the specified area.
  5455. Despite its name, mods must take care of persisting AreaStore data. They may
  5456. use the provided load and write functions for this.
  5457. ### Methods
  5458. * `AreaStore(type_name)`
  5459. * Returns a new AreaStore instance
  5460. * `type_name`: optional, forces the internally used API.
  5461. * Possible values: `"LibSpatial"` (default).
  5462. * When other values are specified, or SpatialIndex is not available,
  5463. the custom Minetest functions are used.
  5464. * `get_area(id, include_corners, include_data)`
  5465. * Returns the area information about the specified ID.
  5466. * Returned values are either of these:
  5467. nil -- Area not found
  5468. true -- Without `include_corners` and `include_data`
  5469. {
  5470. min = pos, max = pos -- `include_corners == true`
  5471. data = string -- `include_data == true`
  5472. }
  5473. * `get_areas_for_pos(pos, include_corners, include_data)`
  5474. * Returns all areas as table, indexed by the area ID.
  5475. * Table values: see `get_area`.
  5476. * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
  5477. * Returns all areas that contain all nodes inside the area specified by`
  5478. `corner1 and `corner2` (inclusive).
  5479. * `accept_overlap`: if `true`, areas are returned that have nodes in
  5480. common (intersect) with the specified area.
  5481. * Returns the same values as `get_areas_for_pos`.
  5482. * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
  5483. * Returns the new area's ID, or nil if the insertion failed.
  5484. * The (inclusive) positions `corner1` and `corner2` describe the area.
  5485. * `data` is a string stored with the area.
  5486. * `id` (optional): will be used as the internal area ID if it is a unique
  5487. number between 0 and 2^32-2.
  5488. * `reserve(count)`
  5489. * Requires SpatialIndex, no-op function otherwise.
  5490. * Reserves resources for `count` many contained areas to improve
  5491. efficiency when working with many area entries. Additional areas can still
  5492. be inserted afterwards at the usual complexity.
  5493. * `remove_area(id)`: removes the area with the given id from the store, returns
  5494. success.
  5495. * `set_cache_params(params)`: sets params for the included prefiltering cache.
  5496. Calling invalidates the cache, so that its elements have to be newly
  5497. generated.
  5498. * `params` is a table with the following fields:
  5499. enabled = boolean, -- Whether to enable, default true
  5500. block_radius = int, -- The radius (in nodes) of the areas the cache
  5501. -- generates prefiltered lists for, minimum 16,
  5502. -- default 64
  5503. limit = int, -- The cache size, minimum 20, default 1000
  5504. * `to_string()`: Experimental. Returns area store serialized as a (binary)
  5505. string.
  5506. * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
  5507. a file.
  5508. * `from_string(str)`: Experimental. Deserializes string and loads it into the
  5509. AreaStore.
  5510. Returns success and, optionally, an error message.
  5511. * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
  5512. from a file.
  5513. `InvRef`
  5514. --------
  5515. An `InvRef` is a reference to an inventory.
  5516. ### Methods
  5517. * `is_empty(listname)`: return `true` if list is empty
  5518. * `get_size(listname)`: get size of a list
  5519. * `set_size(listname, size)`: set size of a list
  5520. * returns `false` on error (e.g. invalid `listname` or `size`)
  5521. * `get_width(listname)`: get width of a list
  5522. * `set_width(listname, width)`: set width of list; currently used for crafting
  5523. * `get_stack(listname, i)`: get a copy of stack index `i` in list
  5524. * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
  5525. * `get_list(listname)`: return full list (list of `ItemStack`s)
  5526. * `set_list(listname, list)`: set full list (size will not change)
  5527. * `get_lists()`: returns table that maps listnames to inventory lists
  5528. * `set_lists(lists)`: sets inventory lists (size will not change)
  5529. * `add_item(listname, stack)`: add item somewhere in list, returns leftover
  5530. `ItemStack`.
  5531. * `room_for_item(listname, stack):` returns `true` if the stack of items
  5532. can be fully added to the list
  5533. * `contains_item(listname, stack, [match_meta])`: returns `true` if
  5534. the stack of items can be fully taken from the list.
  5535. If `match_meta` is false, only the items' names are compared
  5536. (default: `false`).
  5537. * `remove_item(listname, stack)`: take as many items as specified from the
  5538. list, returns the items that were actually removed (as an `ItemStack`)
  5539. -- note that any item metadata is ignored, so attempting to remove a specific
  5540. unique item this way will likely remove the wrong one -- to do that use
  5541. `set_stack` with an empty `ItemStack`.
  5542. * `get_location()`: returns a location compatible to
  5543. `minetest.get_inventory(location)`.
  5544. * returns `{type="undefined"}` in case location is not known
  5545. ### Callbacks
  5546. Detached & nodemeta inventories provide the following callbacks for move actions:
  5547. #### Before
  5548. The `allow_*` callbacks return how many items can be moved.
  5549. * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
  5550. * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
  5551. * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
  5552. #### After
  5553. The `on_*` callbacks are called after the items have been placed in the inventories.
  5554. * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
  5555. * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
  5556. * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
  5557. #### Swapping
  5558. When a player tries to put an item to a place where another item is, the items are *swapped*.
  5559. This means that all callbacks will be called twice (once for each action).
  5560. `ItemStack`
  5561. -----------
  5562. An `ItemStack` is a stack of items.
  5563. It can be created via `ItemStack(x)`, where x is an `ItemStack`,
  5564. an itemstring, a table or `nil`.
  5565. ### Methods
  5566. * `is_empty()`: returns `true` if stack is empty.
  5567. * `get_name()`: returns item name (e.g. `"default:stone"`).
  5568. * `set_name(item_name)`: returns a boolean indicating whether the item was
  5569. cleared.
  5570. * `get_count()`: Returns number of items on the stack.
  5571. * `set_count(count)`: returns a boolean indicating whether the item was cleared
  5572. * `count`: number, unsigned 16 bit integer
  5573. * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
  5574. * `set_wear(wear)`: returns boolean indicating whether item was cleared
  5575. * `wear`: number, unsigned 16 bit integer
  5576. * `get_meta()`: returns ItemStackMetaRef. See section for more details
  5577. * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
  5578. stack).
  5579. * `set_metadata(metadata)`: (DEPRECATED) Returns true.
  5580. * `get_description()`: returns the description shown in inventory list tooltips.
  5581. * The engine uses this when showing item descriptions in tooltips.
  5582. * Fields for finding the description, in order:
  5583. * `description` in item metadata (See [Item Metadata].)
  5584. * `description` in item definition
  5585. * item name
  5586. * `get_short_description()`: returns the short description or nil.
  5587. * Unlike the description, this does not include new lines.
  5588. * Fields for finding the short description, in order:
  5589. * `short_description` in item metadata (See [Item Metadata].)
  5590. * `short_description` in item definition
  5591. * first line of the description (From item meta or def, see `get_description()`.)
  5592. * Returns nil if none of the above are set
  5593. * `clear()`: removes all items from the stack, making it empty.
  5594. * `replace(item)`: replace the contents of this stack.
  5595. * `item` can also be an itemstring or table.
  5596. * `to_string()`: returns the stack in itemstring form.
  5597. * `to_table()`: returns the stack in Lua table form.
  5598. * `get_stack_max()`: returns the maximum size of the stack (depends on the
  5599. item).
  5600. * `get_free_space()`: returns `get_stack_max() - get_count()`.
  5601. * `is_known()`: returns `true` if the item name refers to a defined item type.
  5602. * `get_definition()`: returns the item definition table.
  5603. * `get_tool_capabilities()`: returns the digging properties of the item,
  5604. or those of the hand if none are defined for this item type
  5605. * `add_wear(amount)`
  5606. * Increases wear by `amount` if the item is a tool, otherwise does nothing
  5607. * Valid `amount` range is [0,65536]
  5608. * `amount`: number, integer
  5609. * `add_wear_by_uses(max_uses)`
  5610. * Increases wear in such a way that, if only this function is called,
  5611. the item breaks after `max_uses` times
  5612. * Valid `max_uses` range is [0,65536]
  5613. * Does nothing if item is not a tool or if `max_uses` is 0
  5614. * `add_item(item)`: returns leftover `ItemStack`
  5615. * Put some item or stack onto this stack
  5616. * `item_fits(item)`: returns `true` if item or stack can be fully added to
  5617. this one.
  5618. * `take_item(n)`: returns taken `ItemStack`
  5619. * Take (and remove) up to `n` items from this stack
  5620. * `n`: number, default: `1`
  5621. * `peek_item(n)`: returns taken `ItemStack`
  5622. * Copy (don't remove) up to `n` items from this stack
  5623. * `n`: number, default: `1`
  5624. * `equals(other)`:
  5625. * returns `true` if this stack is identical to `other`.
  5626. * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
  5627. as stack metadata can be serialized in arbitrary order.
  5628. * Note: if `other` is an itemstring or table representation of an
  5629. ItemStack, this will always return false, even if it is
  5630. "equivalent".
  5631. ### Operators
  5632. * `stack1 == stack2`:
  5633. * Returns whether `stack1` and `stack2` are identical.
  5634. * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
  5635. as stack metadata can be serialized in arbitrary order.
  5636. * Note: if `stack2` is an itemstring or table representation of an
  5637. ItemStack, this will always return false, even if it is
  5638. "equivalent".
  5639. `ItemStackMetaRef`
  5640. ------------------
  5641. ItemStack metadata: reference extra data and functionality stored in a stack.
  5642. Can be obtained via `item:get_meta()`.
  5643. ### Methods
  5644. * All methods in MetaDataRef
  5645. * `set_tool_capabilities([tool_capabilities])`
  5646. * Overrides the item's tool capabilities
  5647. * A nil value will clear the override data and restore the original
  5648. behavior.
  5649. `MetaDataRef`
  5650. -------------
  5651. Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
  5652. and [`PlayerMetaRef`].
  5653. Note: If a metadata value is in the format `${k}`, an attempt to get the value
  5654. will return the value associated with key `k`. There is a low recursion limit.
  5655. This behavior is **deprecated** and will be removed in a future version. Usage
  5656. of the `${k}` syntax in formspecs is not deprecated.
  5657. ### Methods
  5658. * `contains(key)`: Returns true if key present, otherwise false.
  5659. * Returns `nil` when the MetaData is inexistent.
  5660. * `get(key)`: Returns `nil` if key not present, else the stored string.
  5661. * `set_string(key, value)`: Value of `""` will delete the key.
  5662. * `get_string(key)`: Returns `""` if key not present.
  5663. * `set_int(key, value)`
  5664. * `get_int(key)`: Returns `0` if key not present.
  5665. * `set_float(key, value)`
  5666. * `get_float(key)`: Returns `0` if key not present.
  5667. * `get_keys()`: returns a list of all keys in the metadata.
  5668. * `to_table()`: returns `nil` or a table with keys:
  5669. * `fields`: key-value storage
  5670. * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
  5671. * `from_table(nil or {})`
  5672. * Any non-table value will clear the metadata
  5673. * See [Node Metadata] for an example
  5674. * returns `true` on success
  5675. * `equals(other)`
  5676. * returns `true` if this metadata has the same key-value pairs as `other`
  5677. `ModChannel`
  5678. ------------
  5679. An interface to use mod channels on client and server
  5680. ### Methods
  5681. * `leave()`: leave the mod channel.
  5682. * Server leaves channel `channel_name`.
  5683. * No more incoming or outgoing messages can be sent to this channel from
  5684. server mods.
  5685. * This invalidate all future object usage.
  5686. * Ensure you set mod_channel to nil after that to free Lua resources.
  5687. * `is_writeable()`: returns true if channel is writeable and mod can send over
  5688. it.
  5689. * `send_all(message)`: Send `message` though the mod channel.
  5690. * If mod channel is not writeable or invalid, message will be dropped.
  5691. * Message size is limited to 65535 characters by protocol.
  5692. `NodeMetaRef`
  5693. -------------
  5694. Node metadata: reference extra data and functionality stored in a node.
  5695. Can be obtained via `minetest.get_meta(pos)`.
  5696. ### Methods
  5697. * All methods in MetaDataRef
  5698. * `get_inventory()`: returns `InvRef`
  5699. * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
  5700. This will prevent them from being sent to the client. Note that the "private"
  5701. status will only be remembered if an associated key-value pair exists,
  5702. meaning it's best to call this when initializing all other meta (e.g.
  5703. `on_construct`).
  5704. `NodeTimerRef`
  5705. --------------
  5706. Node Timers: a high resolution persistent per-node timer.
  5707. Can be gotten via `minetest.get_node_timer(pos)`.
  5708. ### Methods
  5709. * `set(timeout,elapsed)`
  5710. * set a timer's state
  5711. * `timeout` is in seconds, and supports fractional values (0.1 etc)
  5712. * `elapsed` is in seconds, and supports fractional values (0.1 etc)
  5713. * will trigger the node's `on_timer` function after `(timeout - elapsed)`
  5714. seconds.
  5715. * `start(timeout)`
  5716. * start a timer
  5717. * equivalent to `set(timeout,0)`
  5718. * `stop()`
  5719. * stops the timer
  5720. * `get_timeout()`: returns current timeout in seconds
  5721. * if `timeout` equals `0`, timer is inactive
  5722. * `get_elapsed()`: returns current elapsed time in seconds
  5723. * the node's `on_timer` function will be called after `(timeout - elapsed)`
  5724. seconds.
  5725. * `is_started()`: returns boolean state of timer
  5726. * returns `true` if timer is started, otherwise `false`
  5727. `ObjectRef`
  5728. -----------
  5729. Moving things in the game are generally these.
  5730. This is basically a reference to a C++ `ServerActiveObject`.
  5731. ### Advice on handling `ObjectRefs`
  5732. When you receive an `ObjectRef` as a callback argument or from another API
  5733. function, it is possible to store the reference somewhere and keep it around.
  5734. It will keep functioning until the object is unloaded or removed.
  5735. However, doing this is **NOT** recommended as there is (intentionally) no method
  5736. to test if a previously acquired `ObjectRef` is still valid.
  5737. Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
  5738. Lua back to the engine.
  5739. Doing so is much less error-prone and you will never need to wonder if the
  5740. object you are working with still exists.
  5741. ### Attachments
  5742. It is possible to attach objects to other objects (`set_attach` method).
  5743. When an object is attached, it is positioned relative to the parent's position
  5744. and rotation. `get_pos` and `get_rotation` will always return the parent's
  5745. values and changes via their setter counterparts are ignored.
  5746. To change position or rotation call `set_attach` again with the new values.
  5747. **Note**: Just like model dimensions, the relative position in `set_attach`
  5748. must be multiplied by 10 compared to world positions.
  5749. It is also possible to attach to a bone of the parent object. In that case the
  5750. child will follow movement and rotation of that bone.
  5751. ### Methods
  5752. * `get_pos()`: returns `{x=num, y=num, z=num}`
  5753. * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
  5754. * `get_velocity()`: returns the velocity, a vector.
  5755. * `add_velocity(vel)`
  5756. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5757. * In comparison to using get_velocity, adding the velocity and then using
  5758. set_velocity, add_velocity is supposed to avoid synchronization problems.
  5759. Additionally, players also do not support set_velocity.
  5760. * If a player:
  5761. * Does not apply during free_move.
  5762. * Note that since the player speed is normalized at each move step,
  5763. increasing e.g. Y velocity beyond what would usually be achieved
  5764. (see: physics overrides) will cause existing X/Z velocity to be reduced.
  5765. * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
  5766. pressing the jump key (assuming default settings)
  5767. * `move_to(pos, continuous=false)`
  5768. * Does an interpolated move for Lua entities for visually smooth transitions.
  5769. * If `continuous` is true, the Lua entity will not be moved to the current
  5770. position before starting the interpolated move.
  5771. * For players this does the same as `set_pos`,`continuous` is ignored.
  5772. * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
  5773. * `puncher` = another `ObjectRef`,
  5774. * `time_from_last_punch` = time since last punch action of the puncher
  5775. * `direction`: can be `nil`
  5776. * `right_click(clicker)`; `clicker` is another `ObjectRef`
  5777. * `get_hp()`: returns number of health points
  5778. * `set_hp(hp, reason)`: set number of health points
  5779. * See reason in register_on_player_hpchange
  5780. * Is limited to the range of 0 ... 65535 (2^16 - 1)
  5781. * For players: HP are also limited by `hp_max` specified in object properties
  5782. * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
  5783. * `get_wield_list()`: returns the name of the inventory list the wielded item
  5784. is in.
  5785. * `get_wield_index()`: returns the index of the wielded item
  5786. * `get_wielded_item()`: returns an `ItemStack`
  5787. * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
  5788. successful.
  5789. * `set_armor_groups({group1=rating, group2=rating, ...})`
  5790. * `get_armor_groups()`: returns a table with the armor group ratings
  5791. * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
  5792. * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
  5793. * `frame_speed`: number, default: `15.0`
  5794. * `frame_blend`: number, default: `0.0`
  5795. * `frame_loop`: boolean, default: `true`
  5796. * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
  5797. `frame_loop`.
  5798. * `set_animation_frame_speed(frame_speed)`
  5799. * `frame_speed`: number, default: `15.0`
  5800. * `set_attach(parent[, bone, position, rotation, forced_visible])`
  5801. * `parent`: `ObjectRef` to attach to
  5802. * `bone`: default `""` (the root bone)
  5803. * `position`: relative position, default `{x=0, y=0, z=0}`
  5804. * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
  5805. * `forced_visible`: Boolean to control whether the attached entity
  5806. should appear in first person, default `false`.
  5807. * Please also read the [Attachments] section above.
  5808. * This command may fail silently (do nothing) when it would result
  5809. in circular attachments.
  5810. * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
  5811. or nil if it isn't attached.
  5812. * `get_children()`: returns a list of ObjectRefs that are attached to the
  5813. object.
  5814. * `set_detach()`
  5815. * `set_bone_position([bone, position, rotation])`
  5816. * `bone`: string. Default is `""`, the root bone
  5817. * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
  5818. * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
  5819. * `get_bone_position(bone)`: returns position and rotation of the bone
  5820. * `set_properties(object property table)`
  5821. * `get_properties()`: returns object property table
  5822. * `is_player()`: returns true for players, false otherwise
  5823. * `get_nametag_attributes()`
  5824. * returns a table with the attributes of the nametag of an object
  5825. * {
  5826. text = "",
  5827. color = {a=0..255, r=0..255, g=0..255, b=0..255},
  5828. bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
  5829. }
  5830. * `set_nametag_attributes(attributes)`
  5831. * sets the attributes of the nametag of an object
  5832. * `attributes`:
  5833. {
  5834. text = "My Nametag",
  5835. color = ColorSpec,
  5836. -- ^ Text color
  5837. bgcolor = ColorSpec or false,
  5838. -- ^ Sets background color of nametag
  5839. -- `false` will cause the background to be set automatically based on user settings
  5840. -- Default: false
  5841. }
  5842. #### Lua entity only (no-op for other objects)
  5843. * `remove()`: remove object
  5844. * The object is removed after returning from Lua. However the `ObjectRef`
  5845. itself instantly becomes unusable with all further method calls having
  5846. no effect and returning `nil`.
  5847. * `set_velocity(vel)`
  5848. * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
  5849. * `set_acceleration(acc)`
  5850. * `acc` is a vector
  5851. * `get_acceleration()`: returns the acceleration, a vector
  5852. * `set_rotation(rot)`
  5853. * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
  5854. and Z is roll (bank).
  5855. * Does not reset rotation incurred through `automatic_rotate`.
  5856. Remove & readd your objects to force a certain rotation.
  5857. * `get_rotation()`: returns the rotation, a vector (radians)
  5858. * `set_yaw(yaw)`: sets the yaw in radians (heading).
  5859. * `get_yaw()`: returns number in radians
  5860. * `set_texture_mod(mod)`
  5861. * Set a texture modifier to the base texture, for sprites and meshes.
  5862. * When calling `set_texture_mod` again, the previous one is discarded.
  5863. * `mod` the texture modifier. See [Texture modifiers].
  5864. * `get_texture_mod()` returns current texture modifier
  5865. * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
  5866. * Specifies and starts a sprite animation
  5867. * Animations iterate along the frame `y` position.
  5868. * `start_frame`: {x=column number, y=row number}, the coordinate of the
  5869. first frame, default: `{x=0, y=0}`
  5870. * `num_frames`: Total frames in the texture, default: `1`
  5871. * `framelength`: Time per animated frame in seconds, default: `0.2`
  5872. * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
  5873. position according to the view direction. default: `false`.
  5874. * First column: subject facing the camera
  5875. * Second column: subject looking to the left
  5876. * Third column: subject backing the camera
  5877. * Fourth column: subject looking to the right
  5878. * Fifth column: subject viewed from above
  5879. * Sixth column: subject viewed from below
  5880. * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
  5881. * `get_luaentity()`
  5882. #### Player only (no-op for other objects)
  5883. * `get_player_name()`: returns `""` if is not a player
  5884. * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
  5885. table {x, y, z} representing the player's instantaneous velocity in nodes/s
  5886. * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
  5887. * `get_look_dir()`: get camera direction as a unit vector
  5888. * `get_look_vertical()`: pitch in radians
  5889. * Angle ranges between -pi/2 and pi/2, which are straight up and down
  5890. respectively.
  5891. * `get_look_horizontal()`: yaw in radians
  5892. * Angle is counter-clockwise from the +z direction.
  5893. * `set_look_vertical(radians)`: sets look pitch
  5894. * radians: Angle from looking forward, where positive is downwards.
  5895. * `set_look_horizontal(radians)`: sets look yaw
  5896. * radians: Angle from the +z direction, where positive is counter-clockwise.
  5897. * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
  5898. `get_look_vertical`.
  5899. * Angle ranges between -pi/2 and pi/2, which are straight down and up
  5900. respectively.
  5901. * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
  5902. `get_look_horizontal`.
  5903. * Angle is counter-clockwise from the +x direction.
  5904. * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
  5905. `set_look_vertical`.
  5906. * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
  5907. `set_look_horizontal`.
  5908. * `get_breath()`: returns player's breath
  5909. * `set_breath(value)`: sets player's breath
  5910. * values:
  5911. * `0`: player is drowning
  5912. * max: bubbles bar is not shown
  5913. * See [Object properties] for more information
  5914. * Is limited to range 0 ... 65535 (2^16 - 1)
  5915. * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
  5916. * `fov`: FOV value.
  5917. * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
  5918. Defaults to `false`.
  5919. * `transition_time`: If defined, enables smooth FOV transition.
  5920. Interpreted as the time (in seconds) to reach target FOV.
  5921. If set to 0, FOV change is instantaneous. Defaults to 0.
  5922. * Set `fov` to 0 to clear FOV override.
  5923. * `get_fov()`: Returns the following:
  5924. * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
  5925. * Boolean indicating whether the FOV value is a multiplier.
  5926. * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
  5927. * `set_attribute(attribute, value)`: DEPRECATED, use get_meta() instead
  5928. * Sets an extra attribute with value on player.
  5929. * `value` must be a string, or a number which will be converted to a
  5930. string.
  5931. * If `value` is `nil`, remove attribute from player.
  5932. * `get_attribute(attribute)`: DEPRECATED, use get_meta() instead
  5933. * Returns value (a string) for extra attribute.
  5934. * Returns `nil` if no attribute found.
  5935. * `get_meta()`: Returns a PlayerMetaRef.
  5936. * `set_inventory_formspec(formspec)`
  5937. * Redefine player's inventory form
  5938. * Should usually be called in `on_joinplayer`
  5939. * If `formspec` is `""`, the player's inventory is disabled.
  5940. * `get_inventory_formspec()`: returns a formspec string
  5941. * `set_formspec_prepend(formspec)`:
  5942. * the formspec string will be added to every formspec shown to the user,
  5943. except for those with a no_prepend[] tag.
  5944. * This should be used to set style elements such as background[] and
  5945. bgcolor[], any non-style elements (eg: label) may result in weird behavior.
  5946. * Only affects formspecs shown after this is called.
  5947. * `get_formspec_prepend(formspec)`: returns a formspec string.
  5948. * `get_player_control()`: returns table with player pressed keys
  5949. * The table consists of fields with the following boolean values
  5950. representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
  5951. `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
  5952. * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
  5953. and exist only to preserve backwards compatibility.
  5954. * Returns an empty table `{}` if the object is not a player.
  5955. * `get_player_control_bits()`: returns integer with bit packed player pressed
  5956. keys.
  5957. * Bits:
  5958. * 0 - up
  5959. * 1 - down
  5960. * 2 - left
  5961. * 3 - right
  5962. * 4 - jump
  5963. * 5 - aux1
  5964. * 6 - sneak
  5965. * 7 - dig
  5966. * 8 - place
  5967. * 9 - zoom
  5968. * Returns `0` (no bits set) if the object is not a player.
  5969. * `set_physics_override(override_table)`
  5970. * `override_table` is a table with the following fields:
  5971. * `speed`: multiplier to default walking speed value (default: `1`)
  5972. * `jump`: multiplier to default jump value (default: `1`)
  5973. * `gravity`: multiplier to default gravity value (default: `1`)
  5974. * `sneak`: whether player can sneak (default: `true`)
  5975. * `sneak_glitch`: whether player can use the new move code replications
  5976. of the old sneak side-effects: sneak ladders and 2 node sneak jump
  5977. (default: `false`)
  5978. * `new_move`: use new move/sneak code. When `false` the exact old code
  5979. is used for the specific old sneak behavior (default: `true`)
  5980. * `get_physics_override()`: returns the table given to `set_physics_override`
  5981. * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
  5982. number on success
  5983. * `hud_remove(id)`: remove the HUD element of the specified id
  5984. * `hud_change(id, stat, value)`: change a value of a previously added HUD
  5985. element.
  5986. * `stat` supports the same keys as in the hud definition table except for
  5987. `"hud_elem_type"`.
  5988. * `hud_get(id)`: gets the HUD element definition structure of the specified ID
  5989. * `hud_set_flags(flags)`: sets specified HUD flags of player.
  5990. * `flags`: A table with the following fields set to boolean values
  5991. * `hotbar`
  5992. * `healthbar`
  5993. * `crosshair`
  5994. * `wielditem`
  5995. * `breathbar`
  5996. * `minimap`: Modifies the client's permission to view the minimap.
  5997. The client may locally elect to not view the minimap.
  5998. * `minimap_radar`: is only usable when `minimap` is true
  5999. * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
  6000. This includes map seed, player position, look direction, the pointed node and block bounds.
  6001. Does not affect players with the `debug` privilege.
  6002. * If a flag equals `nil`, the flag is not modified
  6003. * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
  6004. * See `hud_set_flags` for a list of flags that can be toggled.
  6005. * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
  6006. * `count`: number of items, must be between `1` and `32`
  6007. * `hud_get_hotbar_itemcount`: returns number of visible items
  6008. * `hud_set_hotbar_image(texturename)`
  6009. * sets background image for hotbar
  6010. * `hud_get_hotbar_image`: returns texturename
  6011. * `hud_set_hotbar_selected_image(texturename)`
  6012. * sets image for selected item of hotbar
  6013. * `hud_get_hotbar_selected_image`: returns texturename
  6014. * `set_minimap_modes({mode, mode, ...}, selected_mode)`
  6015. * Overrides the available minimap modes (and toggle order), and changes the
  6016. selected mode.
  6017. * `mode` is a table consisting of up to four fields:
  6018. * `type`: Available type:
  6019. * `off`: Minimap off
  6020. * `surface`: Minimap in surface mode
  6021. * `radar`: Minimap in radar mode
  6022. * `texture`: Texture to be displayed instead of terrain map
  6023. (texture is centered around 0,0 and can be scaled).
  6024. Texture size is limited to 512 x 512 pixel.
  6025. * `label`: Optional label to display on minimap mode toggle
  6026. The translation must be handled within the mod.
  6027. * `size`: Sidelength or diameter, in number of nodes, of the terrain
  6028. displayed in minimap
  6029. * `texture`: Only for texture type, name of the texture to display
  6030. * `scale`: Only for texture type, scale of the texture map in nodes per
  6031. pixel (for example a `scale` of 2 means each pixel represents a 2x2
  6032. nodes square)
  6033. * `selected_mode` is the mode index to be selected after modes have been changed
  6034. (0 is the first mode).
  6035. * `set_sky(sky_parameters)`
  6036. * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
  6037. whether `set_sky` accepts this format. Check the legacy format otherwise.
  6038. * Passing no arguments resets the sky to its default values.
  6039. * `sky_parameters` is a table with the following optional fields:
  6040. * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
  6041. (default: `#ffffff`)
  6042. * `type`: Available types:
  6043. * `"regular"`: Uses 0 textures, `base_color` ignored
  6044. * `"skybox"`: Uses 6 textures, `base_color` used as fog.
  6045. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
  6046. (default: `"regular"`)
  6047. * `textures`: A table containing up to six textures in the following
  6048. order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
  6049. * `clouds`: Boolean for whether clouds appear. (default: `true`)
  6050. * `sky_color`: A table used in `"regular"` type only, containing the
  6051. following values (alpha is ignored):
  6052. * `day_sky`: ColorSpec, for the top half of the sky during the day.
  6053. (default: `#61b5f5`)
  6054. * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
  6055. (default: `#90d3f6`)
  6056. * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
  6057. (default: `#b4bafa`)
  6058. The resulting sky color will be a darkened version of the ColorSpec.
  6059. Warning: The darkening of the ColorSpec is subject to change.
  6060. * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
  6061. (default: `#bac1f0`)
  6062. The resulting sky color will be a darkened version of the ColorSpec.
  6063. Warning: The darkening of the ColorSpec is subject to change.
  6064. * `night_sky`: ColorSpec, for the top half of the sky during the night.
  6065. (default: `#006bff`)
  6066. The resulting sky color will be a dark version of the ColorSpec.
  6067. Warning: The darkening of the ColorSpec is subject to change.
  6068. * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
  6069. (default: `#4090ff`)
  6070. The resulting sky color will be a dark version of the ColorSpec.
  6071. Warning: The darkening of the ColorSpec is subject to change.
  6072. * `indoors`: ColorSpec, for when you're either indoors or underground.
  6073. (default: `#646464`)
  6074. * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
  6075. at sunrise and sunset. (default: `#f47d1d`)
  6076. * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
  6077. at sunrise and sunset. (default: `#7f99cc`)
  6078. * `fog_tint_type`: string, changes which mode the directional fog
  6079. abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
  6080. `"default"` uses the classic Minetest sun and moon tinting.
  6081. Will use tonemaps, if set to `"default"`. (default: `"default"`)
  6082. * `set_sky(base_color, type, {texture names}, clouds)`
  6083. * Deprecated. Use `set_sky(sky_parameters)`
  6084. * `base_color`: ColorSpec, defaults to white
  6085. * `type`: Available types:
  6086. * `"regular"`: Uses 0 textures, `bgcolor` ignored
  6087. * `"skybox"`: Uses 6 textures, `bgcolor` used
  6088. * `"plain"`: Uses 0 textures, `bgcolor` used
  6089. * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
  6090. `"plain"` custom skyboxes (default: `true`)
  6091. * `get_sky(as_table)`:
  6092. * `as_table`: boolean that determines whether the deprecated version of this
  6093. function is being used.
  6094. * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
  6095. * Deprecated: `false` or `nil` returns base_color, type, table of textures,
  6096. clouds.
  6097. * `get_sky_color()`:
  6098. * Deprecated: Use `get_sky(as_table)` instead.
  6099. * returns a table with the `sky_color` parameters as in `set_sky`.
  6100. * `set_sun(sun_parameters)`:
  6101. * Passing no arguments resets the sun to its default values.
  6102. * `sun_parameters` is a table with the following optional fields:
  6103. * `visible`: Boolean for whether the sun is visible.
  6104. (default: `true`)
  6105. * `texture`: A regular texture for the sun. Setting to `""`
  6106. will re-enable the mesh sun. (default: "sun.png", if it exists)
  6107. The texture appears non-rotated at sunrise and rotated 180 degrees
  6108. (upside down) at sunset.
  6109. * `tonemap`: A 512x1 texture containing the tonemap for the sun
  6110. (default: `"sun_tonemap.png"`)
  6111. * `sunrise`: A regular texture for the sunrise texture.
  6112. (default: `"sunrisebg.png"`)
  6113. * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
  6114. (default: `true`)
  6115. * `scale`: Float controlling the overall size of the sun. (default: `1`)
  6116. Note: For legacy reasons, the sun is bigger than the moon by a factor
  6117. of about `1.57` for equal `scale` values.
  6118. * `get_sun()`: returns a table with the current sun parameters as in
  6119. `set_sun`.
  6120. * `set_moon(moon_parameters)`:
  6121. * Passing no arguments resets the moon to its default values.
  6122. * `moon_parameters` is a table with the following optional fields:
  6123. * `visible`: Boolean for whether the moon is visible.
  6124. (default: `true`)
  6125. * `texture`: A regular texture for the moon. Setting to `""`
  6126. will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
  6127. The texture appears non-rotated at sunrise / moonset and rotated 180
  6128. degrees (upside down) at sunset / moonrise.
  6129. Note: Relative to the sun, the moon texture is hence rotated by 180°.
  6130. You can use the `^[transformR180` texture modifier to achieve the same orientation.
  6131. * `tonemap`: A 512x1 texture containing the tonemap for the moon
  6132. (default: `"moon_tonemap.png"`)
  6133. * `scale`: Float controlling the overall size of the moon (default: `1`)
  6134. Note: For legacy reasons, the sun is bigger than the moon by a factor
  6135. of about `1.57` for equal `scale` values.
  6136. * `get_moon()`: returns a table with the current moon parameters as in
  6137. `set_moon`.
  6138. * `set_stars(star_parameters)`:
  6139. * Passing no arguments resets stars to their default values.
  6140. * `star_parameters` is a table with the following optional fields:
  6141. * `visible`: Boolean for whether the stars are visible.
  6142. (default: `true`)
  6143. * `day_opacity`: Float for maximum opacity of stars at day.
  6144. No effect if `visible` is false.
  6145. (default: 0.0; maximum: 1.0; minimum: 0.0)
  6146. * `count`: Integer number to set the number of stars in
  6147. the skybox. Only applies to `"skybox"` and `"regular"` sky types.
  6148. (default: `1000`)
  6149. * `star_color`: ColorSpec, sets the colors of the stars,
  6150. alpha channel is used to set overall star brightness.
  6151. (default: `#ebebff69`)
  6152. * `scale`: Float controlling the overall size of the stars (default: `1`)
  6153. * `get_stars()`: returns a table with the current stars parameters as in
  6154. `set_stars`.
  6155. * `set_clouds(cloud_parameters)`: set cloud parameters
  6156. * Passing no arguments resets clouds to their default values.
  6157. * `cloud_parameters` is a table with the following optional fields:
  6158. * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
  6159. * `color`: basic cloud color with alpha channel, ColorSpec
  6160. (default `#fff0f0e5`).
  6161. * `ambient`: cloud color lower bound, use for a "glow at night" effect.
  6162. ColorSpec (alpha ignored, default `#000000`)
  6163. * `height`: cloud height, i.e. y of cloud base (default per conf,
  6164. usually `120`)
  6165. * `thickness`: cloud thickness in nodes (default `16`)
  6166. * `speed`: 2D cloud speed + direction in nodes per second
  6167. (default `{x=0, z=-2}`).
  6168. * `get_clouds()`: returns a table with the current cloud parameters as in
  6169. `set_clouds`.
  6170. * `override_day_night_ratio(ratio or nil)`
  6171. * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
  6172. amount.
  6173. * `nil`: Disables override, defaulting to sunlight based on day-night cycle
  6174. * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
  6175. * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
  6176. set animation for player model in third person view.
  6177. * Every animation equals to a `{x=starting frame, y=ending frame}` table.
  6178. * `frame_speed` sets the animations frame speed. Default is 30.
  6179. * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
  6180. `frame_speed`.
  6181. * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
  6182. camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
  6183. * in first person view
  6184. * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
  6185. * `get_eye_offset()`: returns first and third person offsets.
  6186. * `send_mapblock(blockpos)`:
  6187. * Sends an already loaded mapblock to the player.
  6188. * Returns `false` if nothing was sent (note that this can also mean that
  6189. the client already has the block)
  6190. * Resource intensive - use sparsely
  6191. * `set_lighting(light_definition)`: sets lighting for the player
  6192. * `light_definition` is a table with the following optional fields:
  6193. * `shadows` is a table that controls ambient shadows
  6194. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
  6195. * `get_lighting()`: returns the current state of lighting for the player.
  6196. * Result is a table with the same fields as `light_definition` in `set_lighting`.
  6197. * `respawn()`: Respawns the player using the same mechanism as the death screen,
  6198. including calling on_respawnplayer callbacks.
  6199. `PcgRandom`
  6200. -----------
  6201. A 32-bit pseudorandom number generator.
  6202. Uses PCG32, an algorithm of the permuted congruential generator family,
  6203. offering very strong randomness.
  6204. It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
  6205. ### Methods
  6206. * `next()`: return next integer random number [`-2147483648`...`2147483647`]
  6207. * `next(min, max)`: return next integer random number [`min`...`max`]
  6208. * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
  6209. random number [`min`...`max`].
  6210. * This is only a rough approximation of a normal distribution with:
  6211. * `mean = (max - min) / 2`, and
  6212. * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
  6213. * Increasing `num_trials` improves accuracy of the approximation
  6214. `PerlinNoise`
  6215. -------------
  6216. A perlin noise generator.
  6217. It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
  6218. For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
  6219. plus the world seed, to create world-specific noise.
  6220. `PerlinNoise(noiseparams)`
  6221. `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
  6222. `minetest.get_perlin(noiseparams)`
  6223. `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
  6224. ### Methods
  6225. * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
  6226. * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
  6227. `PerlinNoiseMap`
  6228. ----------------
  6229. A fast, bulk perlin noise generator.
  6230. It can be created via `PerlinNoiseMap(noiseparams, size)` or
  6231. `minetest.get_perlin_map(noiseparams, size)`.
  6232. For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
  6233. plus the world seed, to create world-specific noise.
  6234. Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
  6235. for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
  6236. `nil` is returned).
  6237. For each of the functions with an optional `buffer` parameter: If `buffer` is
  6238. not nil, this table will be used to store the result instead of creating a new
  6239. table.
  6240. ### Methods
  6241. * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
  6242. with values starting at `pos={x=,y=}`
  6243. * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
  6244. 3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
  6245. * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
  6246. array of 2D noise with values starting at `pos={x=,y=}`
  6247. * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
  6248. * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
  6249. is stored internally.
  6250. * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
  6251. is stored internally.
  6252. * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
  6253. returns a slice of the most recently computed noise results. The result slice
  6254. begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
  6255. E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
  6256. offset y = 20:
  6257. `noisevals = noise:get_map_slice({y=20}, {y=2})`
  6258. It is important to note that `slice_offset` offset coordinates begin at 1,
  6259. and are relative to the starting position of the most recently calculated
  6260. noise.
  6261. To grab a single vertical column of noise starting at map coordinates
  6262. x = 1023, y=1000, z = 1000:
  6263. `noise:calc_3d_map({x=1000, y=1000, z=1000})`
  6264. `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
  6265. `PlayerMetaRef`
  6266. ---------------
  6267. Player metadata.
  6268. Uses the same method of storage as the deprecated player attribute API, so
  6269. data there will also be in player meta.
  6270. Can be obtained using `player:get_meta()`.
  6271. ### Methods
  6272. * All methods in MetaDataRef
  6273. `PseudoRandom`
  6274. --------------
  6275. A 16-bit pseudorandom number generator.
  6276. Uses a well-known LCG algorithm introduced by K&R.
  6277. It can be created via `PseudoRandom(seed)`.
  6278. ### Methods
  6279. * `next()`: return next integer random number [`0`...`32767`]
  6280. * `next(min, max)`: return next integer random number [`min`...`max`]
  6281. * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
  6282. due to the simple implementation making bad distribution otherwise.
  6283. `Raycast`
  6284. ---------
  6285. A raycast on the map. It works with selection boxes.
  6286. Can be used as an iterator in a for loop as:
  6287. local ray = Raycast(...)
  6288. for pointed_thing in ray do
  6289. ...
  6290. end
  6291. The map is loaded as the ray advances. If the map is modified after the
  6292. `Raycast` is created, the changes may or may not have an effect on the object.
  6293. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  6294. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  6295. * `pos1`: start of the ray
  6296. * `pos2`: end of the ray
  6297. * `objects`: if false, only nodes will be returned. Default is true.
  6298. * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
  6299. returned. Default is false.
  6300. ### Limitations
  6301. Raycasts don't always work properly for attached objects as the server has no knowledge of models & bones.
  6302. **Rotated selectionboxes paired with `automatic_rotate` are not reliable** either since the server
  6303. can't reliably know the total rotation of the objects on different clients (which may differ on a per-client basis).
  6304. The server calculates the total rotation incurred through `automatic_rotate` as a "best guess"
  6305. assuming the object was active & rotating on the client all the time since its creation.
  6306. This may be significantly out of sync with what clients see.
  6307. Additionally, network latency and delayed property sending may create a mismatch of client- & server rotations.
  6308. In singleplayer mode, raycasts on objects with rotated selectionboxes & automatic rotate will usually only be slightly off;
  6309. toggling automatic rotation may however cause errors to add up.
  6310. In multiplayer mode, the error may be arbitrarily large.
  6311. ### Methods
  6312. * `next()`: returns a `pointed_thing` with exact pointing location
  6313. * Returns the next thing pointed by the ray or nil.
  6314. `SecureRandom`
  6315. --------------
  6316. Interface for the operating system's crypto-secure PRNG.
  6317. It can be created via `SecureRandom()`. The constructor returns nil if a
  6318. secure random device cannot be found on the system.
  6319. ### Methods
  6320. * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
  6321. random bytes, as a string.
  6322. `Settings`
  6323. ----------
  6324. An interface to read config files in the format of `minetest.conf`.
  6325. It can be created via `Settings(filename)`.
  6326. ### Methods
  6327. * `get(key)`: returns a value
  6328. * `get_bool(key, [default])`: returns a boolean
  6329. * `default` is the value returned if `key` is not found.
  6330. * Returns `nil` if `key` is not found and `default` not specified.
  6331. * `get_np_group(key)`: returns a NoiseParams table
  6332. * `get_flags(key)`:
  6333. * Returns `{flag = true/false, ...}` according to the set flags.
  6334. * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
  6335. flags like `mgv5_spflags`.
  6336. * `set(key, value)`
  6337. * Setting names can't contain whitespace or any of `="{}#`.
  6338. * Setting values can't contain the sequence `\n"""`.
  6339. * Setting names starting with "secure." can't be set on the main settings
  6340. object (`minetest.settings`).
  6341. * `set_bool(key, value)`
  6342. * See documentation for set() above.
  6343. * `set_np_group(key, value)`
  6344. * `value` is a NoiseParams table.
  6345. * Also, see documentation for set() above.
  6346. * `remove(key)`: returns a boolean (`true` for success)
  6347. * `get_names()`: returns `{key1,...}`
  6348. * `write()`: returns a boolean (`true` for success)
  6349. * Writes changes to file.
  6350. * `to_table()`: returns `{[key1]=value1,...}`
  6351. ### Format
  6352. The settings have the format `key = value`. Example:
  6353. foo = example text
  6354. bar = """
  6355. Multiline
  6356. value
  6357. """
  6358. `StorageRef`
  6359. ------------
  6360. Mod metadata: per mod metadata, saved automatically.
  6361. Can be obtained via `minetest.get_mod_storage()` during load time.
  6362. WARNING: This storage backend is incapable of saving raw binary data due
  6363. to restrictions of JSON.
  6364. ### Methods
  6365. * All methods in MetaDataRef
  6366. Definition tables
  6367. =================
  6368. Object properties
  6369. -----------------
  6370. Used by `ObjectRef` methods. Part of an Entity definition.
  6371. These properties are not persistent, but are applied automatically to the
  6372. corresponding Lua entity using the given registration fields.
  6373. Player properties need to be saved manually.
  6374. {
  6375. hp_max = 10,
  6376. -- Defines the maximum and default HP of the entity
  6377. -- For Lua entities the maximum is not enforced.
  6378. -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
  6379. breath_max = 0,
  6380. -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
  6381. zoom_fov = 0.0,
  6382. -- For players only. Zoom FOV in degrees.
  6383. -- Note that zoom loads and/or generates world beyond the server's
  6384. -- maximum send and generate distances, so acts like a telescope.
  6385. -- Smaller zoom_fov values increase the distance loaded/generated.
  6386. -- Defaults to 15 in creative mode, 0 in survival mode.
  6387. -- zoom_fov = 0 disables zooming for the player.
  6388. eye_height = 1.625,
  6389. -- For players only. Camera height above feet position in nodes.
  6390. physical = false,
  6391. -- Collide with `walkable` nodes.
  6392. collide_with_objects = true,
  6393. -- Collide with other objects if physical = true
  6394. collisionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, -- default
  6395. selectionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, rotate = false },
  6396. -- { xmin, ymin, zmin, xmax, ymax, zmax } in nodes from object position.
  6397. -- Collision boxes cannot rotate, setting `rotate = true` on it has no effect.
  6398. -- If not set, the selection box copies the collision box, and will also not rotate.
  6399. -- If `rotate = false`, the selection box will not rotate with the object itself, remaining fixed to the axes.
  6400. -- If `rotate = true`, it will match the object's rotation and any attachment rotations.
  6401. -- Raycasts use the selection box and object's rotation, but do *not* obey attachment rotations.
  6402. pointable = true,
  6403. -- Whether the object can be pointed at
  6404. visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
  6405. -- "cube" is a node-sized cube.
  6406. -- "sprite" is a flat texture always facing the player.
  6407. -- "upright_sprite" is a vertical flat texture.
  6408. -- "mesh" uses the defined mesh model.
  6409. -- "wielditem" is used for dropped items.
  6410. -- (see builtin/game/item_entity.lua).
  6411. -- For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
  6412. -- If the item has a 'wield_image' the object will be an extrusion of
  6413. -- that, otherwise:
  6414. -- If 'itemname' is a cubic node or nodebox the object will appear
  6415. -- identical to 'itemname'.
  6416. -- If 'itemname' is a plantlike node the object will be an extrusion
  6417. -- of its texture.
  6418. -- Otherwise for non-node items, the object will be an extrusion of
  6419. -- 'inventory_image'.
  6420. -- If 'itemname' contains a ColorString or palette index (e.g. from
  6421. -- `minetest.itemstring_with_palette()`), the entity will inherit the color.
  6422. -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
  6423. visual_size = {x = 1, y = 1, z = 1},
  6424. -- Multipliers for the visual size. If `z` is not specified, `x` will be used
  6425. -- to scale the entity along both horizontal axes.
  6426. mesh = "model.obj",
  6427. -- File name of mesh when using "mesh" visual
  6428. textures = {},
  6429. -- Number of required textures depends on visual.
  6430. -- "cube" uses 6 textures just like a node, but all 6 must be defined.
  6431. -- "sprite" uses 1 texture.
  6432. -- "upright_sprite" uses 2 textures: {front, back}.
  6433. -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
  6434. -- "mesh" requires one texture for each mesh buffer/material (in order)
  6435. colors = {},
  6436. -- Number of required colors depends on visual
  6437. use_texture_alpha = false,
  6438. -- Use texture's alpha channel.
  6439. -- Excludes "upright_sprite" and "wielditem".
  6440. -- Note: currently causes visual issues when viewed through other
  6441. -- semi-transparent materials such as water.
  6442. spritediv = {x = 1, y = 1},
  6443. -- Used with spritesheet textures for animation and/or frame selection
  6444. -- according to position relative to player.
  6445. -- Defines the number of columns and rows in the spritesheet:
  6446. -- {columns, rows}.
  6447. initial_sprite_basepos = {x = 0, y = 0},
  6448. -- Used with spritesheet textures.
  6449. -- Defines the {column, row} position of the initially used frame in the
  6450. -- spritesheet.
  6451. is_visible = true,
  6452. -- If false, object is invisible and can't be pointed.
  6453. makes_footstep_sound = false,
  6454. -- If true, is able to make footstep sounds of nodes
  6455. -- (see node sound definition for details).
  6456. automatic_rotate = 0,
  6457. -- Set constant rotation in radians per second, positive or negative.
  6458. -- Object rotates along the local Y-axis, and works with set_rotation.
  6459. -- Set to 0 to disable constant rotation.
  6460. stepheight = 0,
  6461. -- If positive number, object will climb upwards when it moves
  6462. -- horizontally against a `walkable` node, if the height difference
  6463. -- is within `stepheight`.
  6464. automatic_face_movement_dir = 0.0,
  6465. -- Automatically set yaw to movement direction, offset in degrees.
  6466. -- 'false' to disable.
  6467. automatic_face_movement_max_rotation_per_sec = -1,
  6468. -- Limit automatic rotation to this value in degrees per second.
  6469. -- No limit if value <= 0.
  6470. backface_culling = true,
  6471. -- Set to false to disable backface_culling for model
  6472. glow = 0,
  6473. -- Add this much extra lighting when calculating texture color.
  6474. -- Value < 0 disables light's effect on texture color.
  6475. -- For faking self-lighting, UI style entities, or programmatic coloring
  6476. -- in mods.
  6477. nametag = "",
  6478. -- The name to display on the head of the object. By default empty.
  6479. -- If the object is a player, a nil or empty nametag is replaced by the player's name.
  6480. -- For all other objects, a nil or empty string removes the nametag.
  6481. -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
  6482. nametag_color = <ColorSpec>,
  6483. -- Sets text color of nametag
  6484. nametag_bgcolor = <ColorSpec>,
  6485. -- Sets background color of nametag
  6486. -- `false` will cause the background to be set automatically based on user settings.
  6487. -- Default: false
  6488. infotext = "",
  6489. -- Same as infotext for nodes. Empty by default
  6490. static_save = true,
  6491. -- If false, never save this object statically. It will simply be
  6492. -- deleted when the block gets unloaded.
  6493. -- The get_staticdata() callback is never called then.
  6494. -- Defaults to 'true'.
  6495. damage_texture_modifier = "^[brighten",
  6496. -- Texture modifier to be applied for a short duration when object is hit
  6497. shaded = true,
  6498. -- Setting this to 'false' disables diffuse lighting of entity
  6499. show_on_minimap = false,
  6500. -- Defaults to true for players, false for other entities.
  6501. -- If set to true the entity will show as a marker on the minimap.
  6502. }
  6503. Entity definition
  6504. -----------------
  6505. Used by `minetest.register_entity`.
  6506. {
  6507. initial_properties = {
  6508. visual = "mesh",
  6509. mesh = "boats_boat.obj",
  6510. ...,
  6511. },
  6512. -- A table of object properties, see the `Object properties` section.
  6513. -- The properties in this table are applied to the object
  6514. -- once when it is spawned.
  6515. -- Refer to the "Registered entities" section for explanations
  6516. on_activate = function(self, staticdata, dtime_s),
  6517. on_deactivate = function(self, removal),
  6518. on_step = function(self, dtime, moveresult),
  6519. on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
  6520. on_death = function(self, killer),
  6521. on_rightclick = function(self, clicker),
  6522. on_attach_child = function(self, child),
  6523. on_detach_child = function(self, child),
  6524. on_detach = function(self, parent),
  6525. get_staticdata = function(self),
  6526. _custom_field = whatever,
  6527. -- You can define arbitrary member variables here (see Item definition
  6528. -- for more info) by using a '_' prefix
  6529. }
  6530. ABM (ActiveBlockModifier) definition
  6531. ------------------------------------
  6532. Used by `minetest.register_abm`.
  6533. {
  6534. label = "Lava cooling",
  6535. -- Descriptive label for profiling purposes (optional).
  6536. -- Definitions with identical labels will be listed as one.
  6537. nodenames = {"default:lava_source"},
  6538. -- Apply `action` function to these nodes.
  6539. -- `group:groupname` can also be used here.
  6540. neighbors = {"default:water_source", "default:water_flowing"},
  6541. -- Only apply `action` to nodes that have one of, or any
  6542. -- combination of, these neighbors.
  6543. -- If left out or empty, any neighbor will do.
  6544. -- `group:groupname` can also be used here.
  6545. interval = 1.0,
  6546. -- Operation interval in seconds
  6547. chance = 1,
  6548. -- Chance of triggering `action` per-node per-interval is 1.0 / this
  6549. -- value
  6550. min_y = -32768,
  6551. max_y = 32767,
  6552. -- min and max height levels where ABM will be processed (inclusive)
  6553. -- can be used to reduce CPU usage
  6554. catch_up = true,
  6555. -- If true, catch-up behavior is enabled: The `chance` value is
  6556. -- temporarily reduced when returning to an area to simulate time lost
  6557. -- by the area being unattended. Note that the `chance` value can often
  6558. -- be reduced to 1.
  6559. action = function(pos, node, active_object_count, active_object_count_wider),
  6560. -- Function triggered for each qualifying node.
  6561. -- `active_object_count` is number of active objects in the node's
  6562. -- mapblock.
  6563. -- `active_object_count_wider` is number of active objects in the node's
  6564. -- mapblock plus all 26 neighboring mapblocks. If any neighboring
  6565. -- mapblocks are unloaded an estimate is calculated for them based on
  6566. -- loaded mapblocks.
  6567. }
  6568. LBM (LoadingBlockModifier) definition
  6569. -------------------------------------
  6570. Used by `minetest.register_lbm`.
  6571. A loading block modifier (LBM) is used to define a function that is called for
  6572. specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
  6573. gets activated (not loaded!)
  6574. {
  6575. label = "Upgrade legacy doors",
  6576. -- Descriptive label for profiling purposes (optional).
  6577. -- Definitions with identical labels will be listed as one.
  6578. name = "modname:replace_legacy_door",
  6579. -- Identifier of the LBM, should follow the modname:<whatever> convention
  6580. nodenames = {"default:lava_source"},
  6581. -- List of node names to trigger the LBM on.
  6582. -- Names of non-registered nodes and groups (as group:groupname)
  6583. -- will work as well.
  6584. run_at_every_load = false,
  6585. -- Whether to run the LBM's action every time a block gets activated,
  6586. -- and not only the first time the block gets activated after the LBM
  6587. -- was introduced.
  6588. action = function(pos, node, dtime_s),
  6589. -- Function triggered for each qualifying node.
  6590. -- `dtime_s` is the in-game time (in seconds) elapsed since the block
  6591. -- was last active
  6592. }
  6593. Tile definition
  6594. ---------------
  6595. * `"image.png"`
  6596. * `{name="image.png", animation={Tile Animation definition}}`
  6597. * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
  6598. * backface culling enabled by default for most nodes
  6599. * align style determines whether the texture will be rotated with the node
  6600. or kept aligned with its surroundings. "user" means that client
  6601. setting will be used, similar to `glasslike_framed_optional`.
  6602. Note: supported by solid nodes and nodeboxes only.
  6603. * scale is used to make texture span several (exactly `scale`) nodes,
  6604. instead of just one, in each direction. Works for world-aligned
  6605. textures only.
  6606. Note that as the effect is applied on per-mapblock basis, `16` should
  6607. be equally divisible by `scale` or you may get wrong results.
  6608. * `{name="image.png", color=ColorSpec}`
  6609. * the texture's color will be multiplied with this color.
  6610. * the tile's color overrides the owning node's color in all cases.
  6611. * deprecated, yet still supported field names:
  6612. * `image` (name)
  6613. Tile animation definition
  6614. -------------------------
  6615. {
  6616. type = "vertical_frames",
  6617. aspect_w = 16,
  6618. -- Width of a frame in pixels
  6619. aspect_h = 16,
  6620. -- Height of a frame in pixels
  6621. length = 3.0,
  6622. -- Full loop length
  6623. }
  6624. {
  6625. type = "sheet_2d",
  6626. frames_w = 5,
  6627. -- Width in number of frames
  6628. frames_h = 3,
  6629. -- Height in number of frames
  6630. frame_length = 0.5,
  6631. -- Length of a single frame
  6632. }
  6633. Item definition
  6634. ---------------
  6635. Used by `minetest.register_node`, `minetest.register_craftitem`, and
  6636. `minetest.register_tool`.
  6637. {
  6638. description = "",
  6639. -- Can contain new lines. "\n" has to be used as new line character.
  6640. -- See also: `get_description` in [`ItemStack`]
  6641. short_description = "",
  6642. -- Must not contain new lines.
  6643. -- Defaults to nil.
  6644. -- Use an [`ItemStack`] to get the short description, e.g.:
  6645. -- ItemStack(itemname):get_short_description()
  6646. groups = {},
  6647. -- key = name, value = rating; rating = <number>.
  6648. -- If rating not applicable, use 1.
  6649. -- e.g. {wool = 1, fluffy = 3}
  6650. -- {soil = 2, outerspace = 1, crumbly = 1}
  6651. -- {bendy = 2, snappy = 1},
  6652. -- {hard = 1, metal = 1, spikes = 1}
  6653. inventory_image = "",
  6654. -- Texture shown in the inventory GUI
  6655. -- Defaults to a 3D rendering of the node if left empty.
  6656. inventory_overlay = "",
  6657. -- An overlay texture which is not affected by colorization
  6658. wield_image = "",
  6659. -- Texture shown when item is held in hand
  6660. -- Defaults to a 3D rendering of the node if left empty.
  6661. wield_overlay = "",
  6662. -- Like inventory_overlay but only used in the same situation as wield_image
  6663. wield_scale = {x = 1, y = 1, z = 1},
  6664. -- Scale for the item when held in hand
  6665. palette = "",
  6666. -- An image file containing the palette of a node.
  6667. -- You can set the currently used color as the "palette_index" field of
  6668. -- the item stack metadata.
  6669. -- The palette is always stretched to fit indices between 0 and 255, to
  6670. -- ensure compatibility with "colorfacedir" (and similar) nodes.
  6671. color = "#ffffffff",
  6672. -- Color the item is colorized with. The palette overrides this.
  6673. stack_max = 99,
  6674. -- Maximum amount of items that can be in a single stack.
  6675. -- The default can be changed by the setting `default_stack_max`
  6676. range = 4.0,
  6677. -- Range of node and object pointing that is possible with this item held
  6678. liquids_pointable = false,
  6679. -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
  6680. -- even those for which `pointable = false`
  6681. light_source = 0,
  6682. -- When used for nodes: Defines amount of light emitted by node.
  6683. -- Otherwise: Defines texture glow when viewed as a dropped item
  6684. -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
  6685. -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
  6686. -- behavior.
  6687. -- See "Tool Capabilities" section for an example including explanation
  6688. tool_capabilities = {
  6689. full_punch_interval = 1.0,
  6690. max_drop_level = 0,
  6691. groupcaps = {
  6692. -- For example:
  6693. choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
  6694. },
  6695. damage_groups = {groupname = damage},
  6696. -- Damage values must be between -32768 and 32767 (2^15)
  6697. punch_attack_uses = nil,
  6698. -- Amount of uses this tool has for attacking players and entities
  6699. -- by punching them (0 = infinite uses).
  6700. -- For compatibility, this is automatically set from the first
  6701. -- suitable groupcap using the formula "uses * 3^(maxlevel - 1)".
  6702. -- It is recommend to set this explicitly instead of relying on the
  6703. -- fallback behavior.
  6704. },
  6705. node_placement_prediction = nil,
  6706. -- If nil and item is node, prediction is made automatically.
  6707. -- If nil and item is not a node, no prediction is made.
  6708. -- If "" and item is anything, no prediction is made.
  6709. -- Otherwise should be name of node which the client immediately places
  6710. -- on ground when the player places the item. Server will always update
  6711. -- with actual result shortly.
  6712. node_dig_prediction = "air",
  6713. -- if "", no prediction is made.
  6714. -- if "air", node is removed.
  6715. -- Otherwise should be name of node which the client immediately places
  6716. -- upon digging. Server will always update with actual result shortly.
  6717. sound = {
  6718. -- Definition of item sounds to be played at various events.
  6719. -- All fields in this table are optional.
  6720. breaks = <SimpleSoundSpec>,
  6721. -- When tool breaks due to wear. Ignored for non-tools
  6722. eat = <SimpleSoundSpec>,
  6723. -- When item is eaten with `minetest.do_item_eat`
  6724. punch_use = <SimpleSoundSpec>,
  6725. -- When item is used with the 'punch/mine' key pointing at a node or entity
  6726. punch_use_air = <SimpleSoundSpec>,
  6727. -- When item is used with the 'punch/mine' key pointing at nothing (air)
  6728. },
  6729. on_place = function(itemstack, placer, pointed_thing),
  6730. -- When the 'place' key was pressed with the item in hand
  6731. -- and a node was pointed at.
  6732. -- Shall place item and return the leftover itemstack
  6733. -- or nil to not modify the inventory.
  6734. -- The placer may be any ObjectRef or nil.
  6735. -- default: minetest.item_place
  6736. on_secondary_use = function(itemstack, user, pointed_thing),
  6737. -- Same as on_place but called when not pointing at a node.
  6738. -- Function must return either nil if inventory shall not be modified,
  6739. -- or an itemstack to replace the original itemstack.
  6740. -- The user may be any ObjectRef or nil.
  6741. -- default: nil
  6742. on_drop = function(itemstack, dropper, pos),
  6743. -- Shall drop item and return the leftover itemstack.
  6744. -- The dropper may be any ObjectRef or nil.
  6745. -- default: minetest.item_drop
  6746. on_pickup = function(itemstack, picker, pointed_thing, time_from_last_punch, ...),
  6747. -- Called when a dropped item is punched by a player.
  6748. -- Shall pick-up the item and return the leftover itemstack or nil to not
  6749. -- modify the dropped item.
  6750. -- Parameters:
  6751. -- * `itemstack`: The `ItemStack` to be picked up.
  6752. -- * `picker`: Any `ObjectRef` or `nil`.
  6753. -- * `pointed_thing` (optional): The dropped item (a `"__builtin:item"`
  6754. -- luaentity) as `type="object"` `pointed_thing`.
  6755. -- * `time_from_last_punch, ...` (optional): Other parameters from
  6756. -- `luaentity:on_punch`.
  6757. -- default: `minetest.item_pickup`
  6758. on_use = function(itemstack, user, pointed_thing),
  6759. -- default: nil
  6760. -- When user pressed the 'punch/mine' key with the item in hand.
  6761. -- Function must return either nil if inventory shall not be modified,
  6762. -- or an itemstack to replace the original itemstack.
  6763. -- e.g. itemstack:take_item(); return itemstack
  6764. -- Otherwise, the function is free to do what it wants.
  6765. -- The user may be any ObjectRef or nil.
  6766. -- The default functions handle regular use cases.
  6767. after_use = function(itemstack, user, node, digparams),
  6768. -- default: nil
  6769. -- If defined, should return an itemstack and will be called instead of
  6770. -- wearing out the item (if tool). If returns nil, does nothing.
  6771. -- If after_use doesn't exist, it is the same as:
  6772. -- function(itemstack, user, node, digparams)
  6773. -- itemstack:add_wear(digparams.wear)
  6774. -- return itemstack
  6775. -- end
  6776. -- The user may be any ObjectRef or nil.
  6777. _custom_field = whatever,
  6778. -- Add your own custom fields. By convention, all custom field names
  6779. -- should start with `_` to avoid naming collisions with future engine
  6780. -- usage.
  6781. }
  6782. Node definition
  6783. ---------------
  6784. Used by `minetest.register_node`.
  6785. {
  6786. -- <all fields allowed in item definitions>
  6787. drawtype = "normal", -- See "Node drawtypes"
  6788. visual_scale = 1.0,
  6789. -- Supported for drawtypes "plantlike", "signlike", "torchlike",
  6790. -- "firelike", "mesh", "nodebox", "allfaces".
  6791. -- For plantlike and firelike, the image will start at the bottom of the
  6792. -- node. For torchlike, the image will start at the surface to which the
  6793. -- node "attaches". For the other drawtypes the image will be centered
  6794. -- on the node.
  6795. tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6796. -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
  6797. -- List can be shortened to needed length.
  6798. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
  6799. -- Same as `tiles`, but these textures are drawn on top of the base
  6800. -- tiles. You can use this to colorize only specific parts of your
  6801. -- texture. If the texture name is an empty string, that overlay is not
  6802. -- drawn. Since such tiles are drawn twice, it is not recommended to use
  6803. -- overlays on very common nodes.
  6804. special_tiles = {tile definition 1, Tile definition 2},
  6805. -- Special textures of node; used rarely.
  6806. -- List can be shortened to needed length.
  6807. color = ColorSpec,
  6808. -- The node's original color will be multiplied with this color.
  6809. -- If the node has a palette, then this setting only has an effect in
  6810. -- the inventory and on the wield item.
  6811. use_texture_alpha = ...,
  6812. -- Specifies how the texture's alpha channel will be used for rendering.
  6813. -- possible values:
  6814. -- * "opaque": Node is rendered opaque regardless of alpha channel
  6815. -- * "clip": A given pixel is either fully see-through or opaque
  6816. -- depending on the alpha channel being below/above 50% in value
  6817. -- * "blend": The alpha channel specifies how transparent a given pixel
  6818. -- of the rendered node is
  6819. -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
  6820. -- "clip" otherwise.
  6821. -- If set to a boolean value (deprecated): true either sets it to blend
  6822. -- or clip, false sets it to clip or opaque mode depending on the drawtype.
  6823. palette = "",
  6824. -- The node's `param2` is used to select a pixel from the image.
  6825. -- Pixels are arranged from left to right and from top to bottom.
  6826. -- The node's color will be multiplied with the selected pixel's color.
  6827. -- Tiles can override this behavior.
  6828. -- Only when `paramtype2` supports palettes.
  6829. post_effect_color = "#00000000",
  6830. -- Screen tint if player is inside node, see "ColorSpec"
  6831. paramtype = "none", -- See "Nodes"
  6832. paramtype2 = "none", -- See "Nodes"
  6833. place_param2 = 0,
  6834. -- Value for param2 that is set when player places node
  6835. is_ground_content = true,
  6836. -- If false, the cave generator and dungeon generator will not carve
  6837. -- through this node.
  6838. -- Specifically, this stops mod-added nodes being removed by caves and
  6839. -- dungeons when those generate in a neighbor mapchunk and extend out
  6840. -- beyond the edge of that mapchunk.
  6841. sunlight_propagates = false,
  6842. -- If true, sunlight will go infinitely through this node
  6843. walkable = true, -- If true, objects collide with node
  6844. pointable = true, -- If true, can be pointed at
  6845. diggable = true, -- If false, can never be dug
  6846. climbable = false, -- If true, can be climbed on like a ladder
  6847. move_resistance = 0,
  6848. -- Slows down movement of players through this node (max. 7).
  6849. -- If this is nil, it will be equal to liquid_viscosity.
  6850. -- Note: If liquid movement physics apply to the node
  6851. -- (see `liquid_move_physics`), the movement speed will also be
  6852. -- affected by the `movement_liquid_*` settings.
  6853. buildable_to = false, -- If true, placed nodes can replace this node
  6854. floodable = false,
  6855. -- If true, liquids flow into and replace this node.
  6856. -- Warning: making a liquid node 'floodable' will cause problems.
  6857. liquidtype = "none", -- specifies liquid flowing physics
  6858. -- * "none": no liquid flowing physics
  6859. -- * "source": spawns flowing liquid nodes at all 4 sides and below;
  6860. -- recommended drawtype: "liquid".
  6861. -- * "flowing": spawned from source, spawns more flowing liquid nodes
  6862. -- around it until `liquid_range` is reached;
  6863. -- will drain out without a source;
  6864. -- recommended drawtype: "flowingliquid".
  6865. -- If it's "source" or "flowing", then the
  6866. -- `liquid_alternative_*` fields _must_ be specified
  6867. liquid_alternative_flowing = "",
  6868. liquid_alternative_source = "",
  6869. -- These fields may contain node names that represent the
  6870. -- flowing version (`liquid_alternative_flowing`) and
  6871. -- source version (`liquid_alternative_source`) of a liquid.
  6872. --
  6873. -- Specifically, these fields are required if any of these is true:
  6874. -- * `liquidtype ~= "none" or
  6875. -- * `drawtype == "liquid" or
  6876. -- * `drawtype == "flowingliquid"
  6877. --
  6878. -- Liquids consist of up to two nodes: source and flowing.
  6879. --
  6880. -- There are two ways to define a liquid:
  6881. -- 1) Source node and flowing node. This requires both fields to be
  6882. -- specified for both nodes.
  6883. -- 2) Standalone source node (cannot flow). `liquid_alternative_source`
  6884. -- must be specified and `liquid_range` must be set to 0.
  6885. --
  6886. -- Example:
  6887. -- liquid_alternative_flowing = "example:water_flowing",
  6888. -- liquid_alternative_source = "example:water_source",
  6889. liquid_viscosity = 0,
  6890. -- Controls speed at which the liquid spreads/flows (max. 7).
  6891. -- 0 is fastest, 7 is slowest.
  6892. -- By default, this also slows down movement of players inside the node
  6893. -- (can be overridden using `move_resistance`)
  6894. liquid_renewable = true,
  6895. -- If true, a new liquid source can be created by placing two or more
  6896. -- sources nearby
  6897. liquid_move_physics = nil, -- specifies movement physics if inside node
  6898. -- * false: No liquid movement physics apply.
  6899. -- * true: Enables liquid movement physics. Enables things like
  6900. -- ability to "swim" up/down, sinking slowly if not moving,
  6901. -- smoother speed change when falling into, etc. The `movement_liquid_*`
  6902. -- settings apply.
  6903. -- * nil: Will be treated as true if `liquidtype ~= "none"`
  6904. -- and as false otherwise.
  6905. leveled = 0,
  6906. -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
  6907. -- Allows defining the nodebox height without using param2.
  6908. -- The nodebox height is 'leveled' / 64 nodes.
  6909. -- The maximum value of 'leveled' is `leveled_max`.
  6910. leveled_max = 127,
  6911. -- Maximum value for `leveled` (0-127), enforced in
  6912. -- `minetest.set_node_level` and `minetest.add_node_level`.
  6913. -- Values above 124 might causes collision detection issues.
  6914. liquid_range = 8,
  6915. -- Maximum distance that flowing liquid nodes can spread around
  6916. -- source on flat land;
  6917. -- maximum = 8; set to 0 to disable liquid flow
  6918. drowning = 0,
  6919. -- Player will take this amount of damage if no bubbles are left
  6920. damage_per_second = 0,
  6921. -- If player is inside node, this damage is caused
  6922. node_box = {type = "regular"}, -- See "Node boxes"
  6923. connects_to = {},
  6924. -- Used for nodebox nodes with the type == "connected".
  6925. -- Specifies to what neighboring nodes connections will be drawn.
  6926. -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
  6927. connect_sides = {},
  6928. -- Tells connected nodebox nodes to connect only to these sides of this
  6929. -- node. possible: "top", "bottom", "front", "left", "back", "right"
  6930. mesh = "",
  6931. -- File name of mesh when using "mesh" drawtype
  6932. selection_box = {
  6933. -- see [Node boxes] for possibilities
  6934. },
  6935. -- Custom selection box definition. Multiple boxes can be defined.
  6936. -- If "nodebox" drawtype is used and selection_box is nil, then node_box
  6937. -- definition is used for the selection box.
  6938. collision_box = {
  6939. -- see [Node boxes] for possibilities
  6940. },
  6941. -- Custom collision box definition. Multiple boxes can be defined.
  6942. -- If "nodebox" drawtype is used and collision_box is nil, then node_box
  6943. -- definition is used for the collision box.
  6944. -- Support maps made in and before January 2012
  6945. legacy_facedir_simple = false,
  6946. legacy_wallmounted = false,
  6947. waving = 0,
  6948. -- Valid for drawtypes:
  6949. -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
  6950. -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
  6951. -- 2 - wave node like leaves (whole node moves side-to-side)
  6952. -- 3 - wave node like liquids (whole node moves up and down)
  6953. -- Not all models will properly wave.
  6954. -- plantlike drawtype can only wave like plants.
  6955. -- allfaces_optional drawtype can only wave like leaves.
  6956. -- liquid, flowingliquid drawtypes can only wave like liquids.
  6957. sounds = {
  6958. -- Definition of node sounds to be played at various events.
  6959. -- All fields in this table are optional.
  6960. footstep = <SimpleSoundSpec>,
  6961. -- If walkable, played when object walks on it. If node is
  6962. -- climbable or a liquid, played when object moves through it
  6963. dig = <SimpleSoundSpec> or "__group",
  6964. -- While digging node.
  6965. -- If `"__group"`, then the sound will be
  6966. -- `{name = "default_dig_<groupname>", gain = 0.5}` , where `<groupname>` is the
  6967. -- name of the item's digging group with the fastest digging time.
  6968. -- In case of a tie, one of the sounds will be played (but we
  6969. -- cannot predict which one)
  6970. -- Default value: `"__group"`
  6971. dug = <SimpleSoundSpec>,
  6972. -- Node was dug
  6973. place = <SimpleSoundSpec>,
  6974. -- Node was placed. Also played after falling
  6975. place_failed = <SimpleSoundSpec>,
  6976. -- When node placement failed.
  6977. -- Note: This happens if the _built-in_ node placement failed.
  6978. -- This sound will still be played if the node is placed in the
  6979. -- `on_place` callback manually.
  6980. fall = <SimpleSoundSpec>,
  6981. -- When node starts to fall or is detached
  6982. },
  6983. drop = "",
  6984. -- Name of dropped item when dug.
  6985. -- Default dropped item is the node itself.
  6986. -- Using a table allows multiple items, drop chances and item filtering:
  6987. drop = {
  6988. max_items = 1,
  6989. -- Maximum number of item lists to drop.
  6990. -- The entries in 'items' are processed in order. For each:
  6991. -- Item filtering is applied, chance of drop is applied, if both are
  6992. -- successful the entire item list is dropped.
  6993. -- Entry processing continues until the number of dropped item lists
  6994. -- equals 'max_items'.
  6995. -- Therefore, entries should progress from low to high drop chance.
  6996. items = {
  6997. -- Examples:
  6998. {
  6999. -- 1 in 1000 chance of dropping a diamond.
  7000. -- Default rarity is '1'.
  7001. rarity = 1000,
  7002. items = {"default:diamond"},
  7003. },
  7004. {
  7005. -- Only drop if using an item whose name is identical to one
  7006. -- of these.
  7007. tools = {"default:shovel_mese", "default:shovel_diamond"},
  7008. rarity = 5,
  7009. items = {"default:dirt"},
  7010. -- Whether all items in the dropped item list inherit the
  7011. -- hardware coloring palette color from the dug node.
  7012. -- Default is 'false'.
  7013. inherit_color = true,
  7014. },
  7015. {
  7016. -- Only drop if using an item whose name contains
  7017. -- "default:shovel_" (this item filtering by string matching
  7018. -- is deprecated, use tool_groups instead).
  7019. tools = {"~default:shovel_"},
  7020. rarity = 2,
  7021. -- The item list dropped.
  7022. items = {"default:sand", "default:desert_sand"},
  7023. },
  7024. {
  7025. -- Only drop if using an item in the "magicwand" group, or
  7026. -- an item that is in both the "pickaxe" and the "lucky"
  7027. -- groups.
  7028. tool_groups = {
  7029. "magicwand",
  7030. {"pickaxe", "lucky"}
  7031. },
  7032. items = {"default:coal_lump"},
  7033. },
  7034. },
  7035. },
  7036. on_construct = function(pos),
  7037. -- Node constructor; called after adding node.
  7038. -- Can set up metadata and stuff like that.
  7039. -- Not called for bulk node placement (i.e. schematics and VoxelManip).
  7040. -- Note: Within an on_construct callback, minetest.set_node can cause an
  7041. -- infinite loop if it invokes the same callback.
  7042. -- Consider using minetest.swap_node instead.
  7043. -- default: nil
  7044. on_destruct = function(pos),
  7045. -- Node destructor; called before removing node.
  7046. -- Not called for bulk node placement.
  7047. -- default: nil
  7048. after_destruct = function(pos, oldnode),
  7049. -- Node destructor; called after removing node.
  7050. -- Not called for bulk node placement.
  7051. -- default: nil
  7052. on_flood = function(pos, oldnode, newnode),
  7053. -- Called when a liquid (newnode) is about to flood oldnode, if it has
  7054. -- `floodable = true` in the nodedef. Not called for bulk node placement
  7055. -- (i.e. schematics and VoxelManip) or air nodes. If return true the
  7056. -- node is not flooded, but on_flood callback will most likely be called
  7057. -- over and over again every liquid update interval.
  7058. -- Default: nil
  7059. -- Warning: making a liquid node 'floodable' will cause problems.
  7060. preserve_metadata = function(pos, oldnode, oldmeta, drops),
  7061. -- Called when oldnode is about be converted to an item, but before the
  7062. -- node is deleted from the world or the drops are added. This is
  7063. -- generally the result of either the node being dug or an attached node
  7064. -- becoming detached.
  7065. -- oldmeta are the metadata fields (table) of the node before deletion.
  7066. -- drops is a table of ItemStacks, so any metadata to be preserved can
  7067. -- be added directly to one or more of the dropped items. See
  7068. -- "ItemStackMetaRef".
  7069. -- default: nil
  7070. after_place_node = function(pos, placer, itemstack, pointed_thing),
  7071. -- Called after constructing node when node was placed using
  7072. -- minetest.item_place_node / minetest.place_node.
  7073. -- If return true no item is taken from itemstack.
  7074. -- `placer` may be any valid ObjectRef or nil.
  7075. -- default: nil
  7076. after_dig_node = function(pos, oldnode, oldmetadata, digger),
  7077. -- oldmetadata is in table format.
  7078. -- Called after destructing node when node was dug using
  7079. -- minetest.node_dig / minetest.dig_node.
  7080. -- default: nil
  7081. can_dig = function(pos, [player]),
  7082. -- Returns true if node can be dug, or false if not.
  7083. -- default: nil
  7084. on_punch = function(pos, node, puncher, pointed_thing),
  7085. -- default: minetest.node_punch
  7086. -- Called when puncher (an ObjectRef) punches the node at pos.
  7087. -- By default calls minetest.register_on_punchnode callbacks.
  7088. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
  7089. -- default: nil
  7090. -- Called when clicker (an ObjectRef) used the 'place/build' key
  7091. -- (not necessarily an actual rightclick)
  7092. -- while pointing at the node at pos with 'node' being the node table.
  7093. -- itemstack will hold clicker's wielded item.
  7094. -- Shall return the leftover itemstack.
  7095. -- Note: pointed_thing can be nil, if a mod calls this function.
  7096. -- This function does not get triggered by clients <=0.4.16 if the
  7097. -- "formspec" node metadata field is set.
  7098. on_dig = function(pos, node, digger),
  7099. -- default: minetest.node_dig
  7100. -- By default checks privileges, wears out item (if tool) and removes node.
  7101. -- return true if the node was dug successfully, false otherwise.
  7102. -- Deprecated: returning nil is the same as returning true.
  7103. on_timer = function(pos, elapsed),
  7104. -- default: nil
  7105. -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
  7106. -- elapsed is the total time passed since the timer was started.
  7107. -- return true to run the timer for another cycle with the same timeout
  7108. -- value.
  7109. on_receive_fields = function(pos, formname, fields, sender),
  7110. -- fields = {name1 = value1, name2 = value2, ...}
  7111. -- Called when an UI form (e.g. sign text input) returns data.
  7112. -- See minetest.register_on_player_receive_fields for more info.
  7113. -- default: nil
  7114. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  7115. -- Called when a player wants to move items inside the inventory.
  7116. -- Return value: number of items allowed to move.
  7117. allow_metadata_inventory_put = function(pos, listname, index, stack, player),
  7118. -- Called when a player wants to put something into the inventory.
  7119. -- Return value: number of items allowed to put.
  7120. -- Return value -1: Allow and don't modify item count in inventory.
  7121. allow_metadata_inventory_take = function(pos, listname, index, stack, player),
  7122. -- Called when a player wants to take something out of the inventory.
  7123. -- Return value: number of items allowed to take.
  7124. -- Return value -1: Allow and don't modify item count in inventory.
  7125. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
  7126. on_metadata_inventory_put = function(pos, listname, index, stack, player),
  7127. on_metadata_inventory_take = function(pos, listname, index, stack, player),
  7128. -- Called after the actual action has happened, according to what was
  7129. -- allowed.
  7130. -- No return value.
  7131. on_blast = function(pos, intensity),
  7132. -- intensity: 1.0 = mid range of regular TNT.
  7133. -- If defined, called when an explosion touches the node, instead of
  7134. -- removing the node.
  7135. mod_origin = "modname",
  7136. -- stores which mod actually registered a node
  7137. -- If the source could not be determined it contains "??"
  7138. -- Useful for getting which mod truly registered something
  7139. -- example: if a node is registered as ":othermodname:nodename",
  7140. -- nodename will show "othermodname", but mod_origin will say "modname"
  7141. }
  7142. Crafting recipes
  7143. ----------------
  7144. Crafting converts one or more inputs to one output itemstack of arbitrary
  7145. count (except for fuels, which don't have an output). The conversion reduces
  7146. each input ItemStack by 1.
  7147. Craft recipes are registered by `minetest.register_craft` and use a
  7148. table format. The accepted parameters are listed below.
  7149. Recipe input items can either be specified by item name (item count = 1)
  7150. or by group (see "Groups in crafting recipes" for details).
  7151. The following sections describe the types and syntaxes of recipes.
  7152. ### Shaped
  7153. This is the default recipe type (when no `type` is specified).
  7154. A shaped recipe takes one or multiple items as input and has
  7155. a single item stack as output. The input items must be specified
  7156. in a 2-dimensional matrix (see parameters below) to specify the
  7157. exact arrangement (the "shape") in which the player must place them
  7158. in the crafting grid.
  7159. For example, for a 3x3 recipe, the `recipes` table must have
  7160. 3 rows and 3 columns.
  7161. In order to craft the recipe, the players' crafting grid must
  7162. have equal or larger dimensions (both width and height).
  7163. Parameters:
  7164. * `type = "shaped"`: (optional) specifies recipe type as shaped
  7165. * `output`: Itemstring of output itemstack (item counts >= 1 are allowed)
  7166. * `recipe`: A 2-dimensional matrix of items, with a width *w* and height *h*.
  7167. * *w* and *h* are chosen by you, they don't have to be equal but must be at least 1
  7168. * The matrix is specified as a table containing tables containing itemnames
  7169. * The inner tables are the rows. There must be *h* tables, specified from the top to the bottom row
  7170. * Values inside of the inner table are the columns.
  7171. Each inner table must contain a list of *w* items, specified from left to right
  7172. * Empty slots *must* be filled with the empty string
  7173. * `replacements`: (optional) Allows you to replace input items with some other items
  7174. when something is crafted
  7175. * Provided as a list of item pairs of the form `{ old_item, new_item }` where
  7176. `old_item` is the input item to replace (same syntax as for a regular input
  7177. slot; groups are allowed) and `new_item` is an itemstring for the item stack
  7178. it will become
  7179. * When the output is crafted, Minetest iterates through the list
  7180. of input items if the crafting grid. For each input item stack, it checks if
  7181. it matches with an `old_item` in the item pair list.
  7182. * If it matches, the item will be replaced. Also, this item pair
  7183. will *not* be applied again for the remaining items
  7184. * If it does not match, the item is consumed (reduced by 1) normally
  7185. * The `new_item` will appear in one of 3 places:
  7186. * Crafting grid, if the input stack size was exactly 1
  7187. * Player inventory, if input stack size was larger
  7188. * Drops as item entity, if it fits neither in craft grid or inventory
  7189. #### Examples
  7190. A typical shaped recipe:
  7191. -- Stone pickaxe
  7192. {
  7193. output = "example:stone_pickaxe",
  7194. -- A 3x3 recipe which needs 3 stone in the 1st row,
  7195. -- and 1 stick in the horizontal middle in each of the 2nd and 3nd row.
  7196. -- The 4 remaining slots have to be empty.
  7197. recipe = {
  7198. {"example:stone", "example:stone", "example:stone"}, -- row 1
  7199. {"", "example:stick", "" }, -- row 2
  7200. {"", "example:stick", "" }, -- row 3
  7201. -- ^ column 1 ^ column 2 ^ column 3
  7202. },
  7203. -- There is no replacements table, so every input item
  7204. -- will be consumed.
  7205. }
  7206. Simple replacement example:
  7207. -- Wet sponge
  7208. {
  7209. output = "example:wet_sponge",
  7210. -- 1x2 recipe with a water bucket above a dry sponge
  7211. recipe = {
  7212. {"example:water_bucket"},
  7213. {"example:dry_sponge"},
  7214. },
  7215. -- When the wet sponge is crafted, the water bucket
  7216. -- in the input slot is replaced with an empty
  7217. -- bucket
  7218. replacements = {
  7219. {"example:water_bucket", "example:empty_bucket"},
  7220. },
  7221. }
  7222. Complex replacement example 1:
  7223. -- Very wet sponge
  7224. {
  7225. output = "example:very_wet_sponge",
  7226. -- 3x3 recipe with a wet sponge in the center
  7227. -- and 4 water buckets around it
  7228. recipe = {
  7229. {"","example:water_bucket",""},
  7230. {"example:water_bucket","example:wet_sponge","example:water_bucket"},
  7231. {"","example:water_bucket",""},
  7232. },
  7233. -- When the wet sponge is crafted, all water buckets
  7234. -- in the input slot become empty
  7235. replacements = {
  7236. -- Without these repetitions, only the first
  7237. -- water bucket would be replaced.
  7238. {"example:water_bucket", "example:empty_bucket"},
  7239. {"example:water_bucket", "example:empty_bucket"},
  7240. {"example:water_bucket", "example:empty_bucket"},
  7241. {"example:water_bucket", "example:empty_bucket"},
  7242. },
  7243. }
  7244. Complex replacement example 2:
  7245. -- Magic book:
  7246. -- 3 magic orbs + 1 book crafts a magic book,
  7247. -- and the orbs will be replaced with 3 different runes.
  7248. {
  7249. output = "example:magic_book",
  7250. -- 3x2 recipe
  7251. recipe = {
  7252. -- 3 items in the group `magic_orb` on top of a book in the middle
  7253. {"group:magic_orb", "group:magic_orb", "group:magic_orb"},
  7254. {"", "example:book", ""},
  7255. },
  7256. -- When the book is crafted, the 3 magic orbs will be turned into
  7257. -- 3 runes: ice rune, earth rune and fire rune (from left to right)
  7258. replacements = {
  7259. {"group:magic_orb", "example:ice_rune"},
  7260. {"group:magic_orb", "example:earth_rune"},
  7261. {"group:magic_orb", "example:fire_rune"},
  7262. },
  7263. }
  7264. ### Shapeless
  7265. Takes a list of input items (at least 1). The order or arrangement
  7266. of input items does not matter.
  7267. In order to craft the recipe, the players' crafting grid must have matching or
  7268. larger *count* of slots. The grid dimensions do not matter.
  7269. Parameters:
  7270. * `type = "shapeless"`: Mandatory
  7271. * `output`: Same as for shaped recipe
  7272. * `recipe`: List of item names
  7273. * `replacements`: Same as for shaped recipe
  7274. #### Example
  7275. {
  7276. -- Craft a mushroom stew from a bowl, a brown mushroom and a red mushroom
  7277. -- (no matter where in the input grid the items are placed)
  7278. type = "shapeless",
  7279. output = "example:mushroom_stew",
  7280. recipe = {
  7281. "example:bowl",
  7282. "example:mushroom_brown",
  7283. "example:mushroom_red",
  7284. },
  7285. }
  7286. ### Tool repair
  7287. Syntax:
  7288. {
  7289. type = "toolrepair",
  7290. additional_wear = -0.02, -- multiplier of 65536
  7291. }
  7292. Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
  7293. group. If this recipe is used, repairing is possible with any crafting grid
  7294. with at least 2 slots.
  7295. The player can put 2 equal tools in the craft grid to get one "repaired" tool
  7296. back.
  7297. The wear of the output is determined by the wear of both tools, plus a
  7298. 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
  7299. you want `additional_wear` to be negative.
  7300. The formula used to calculate the resulting wear is:
  7301. 65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear))
  7302. The result is rounded and can't be lower than 0. If the result is 65536 or higher,
  7303. no crafting is possible.
  7304. ### Cooking
  7305. A cooking recipe has a single input item, a single output item stack
  7306. and a cooking time. It represents cooking/baking/smelting/etc. items in
  7307. an oven, furnace, or something similar; the exact meaning is up for games
  7308. to decide, if they choose to use cooking at all.
  7309. The engine does not implement anything specific to cooking recipes, but
  7310. the recipes can be retrieved later using `minetest.get_craft_result` to
  7311. have a consistent interface across different games/mods.
  7312. Parameters:
  7313. * `type = "cooking"`: Mandatory
  7314. * `output`: Same as for shaped recipe
  7315. * `recipe`: An itemname of the single input item
  7316. * `cooktime`: (optional) Time it takes to cook this item, in seconds.
  7317. A floating-point number. (default: 3.0)
  7318. * `replacements`: Same meaning as for shaped recipes, but the mods
  7319. that utilize cooking recipes (e.g. for adding a furnace
  7320. node) need to implement replacements on their own
  7321. Note: Games and mods are free to re-interpret the cooktime in special
  7322. cases, e.g. for a super furnace that cooks items twice as fast.
  7323. #### Example
  7324. Cooking sand to glass in 3 seconds:
  7325. {
  7326. type = "cooking",
  7327. output = "example:glass",
  7328. recipe = "example:sand",
  7329. cooktime = 3.0,
  7330. }
  7331. ### Fuel
  7332. A fuel recipe is an item associated with a "burning time" and an optional
  7333. item replacement. There is no output. This is usually used as fuel for
  7334. furnaces, ovens, stoves, etc.
  7335. Like with cooking recipes, the engine does not do anything specific with
  7336. fuel recipes and it's up to games and mods to use them by retrieving
  7337. them via `minetest.get_craft_result`.
  7338. Parameters:
  7339. * `type = "fuel"`: Mandatory
  7340. * `recipe`: Itemname of the item to be used as fuel
  7341. * `burntime`: (optional) Burning time this item provides, in seconds.
  7342. A floating-point number. (default: 1.0)
  7343. * `replacements`: Same meaning as for shaped recipes, but the mods
  7344. that utilize fuels need to implement replacements
  7345. on their own
  7346. Note: Games and mods are free to re-interpret the burntime in special
  7347. cases, e.g. for an efficient furnace in which fuels burn twice as
  7348. long.
  7349. #### Examples
  7350. Coal lump with a burntime of 20 seconds. Will be consumed when used.
  7351. {
  7352. type = "fuel",
  7353. recipe = "example:coal_lump",
  7354. burntime = 20.0,
  7355. }
  7356. Lava bucket with a burn time of 60 seconds. Will become an empty bucket
  7357. if used:
  7358. {
  7359. type = "fuel",
  7360. recipe = "example:lava_bucket",
  7361. burntime = 60.0,
  7362. replacements = {{"example:lava_bucket", "example:empty_bucket"}},
  7363. }
  7364. Ore definition
  7365. --------------
  7366. Used by `minetest.register_ore`.
  7367. See [Ores] section above for essential information.
  7368. {
  7369. ore_type = "",
  7370. -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
  7371. ore = "",
  7372. -- Ore node to place
  7373. ore_param2 = 0,
  7374. -- Param2 to set for ore (e.g. facedir rotation)
  7375. wherein = "",
  7376. -- Node to place ore in. Multiple are possible by passing a list.
  7377. clust_scarcity = 8 * 8 * 8,
  7378. -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
  7379. -- If the desired average distance between ores is 'd', set this to
  7380. -- d * d * d.
  7381. clust_num_ores = 8,
  7382. -- Number of ores in a cluster
  7383. clust_size = 3,
  7384. -- Size of the bounding box of the cluster.
  7385. -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
  7386. -- nodes are coal ore.
  7387. y_min = -31000,
  7388. y_max = 31000,
  7389. -- Lower and upper limits for ore (inclusive)
  7390. flags = "",
  7391. -- Attributes for the ore generation, see 'Ore attributes' section above
  7392. noise_threshold = 0,
  7393. -- If noise is above this threshold, ore is placed. Not needed for a
  7394. -- uniform distribution.
  7395. noise_params = {
  7396. offset = 0,
  7397. scale = 1,
  7398. spread = {x = 100, y = 100, z = 100},
  7399. seed = 23,
  7400. octaves = 3,
  7401. persistence = 0.7
  7402. },
  7403. -- NoiseParams structure describing one of the perlin noises used for
  7404. -- ore distribution.
  7405. -- Needed by "sheet", "puff", "blob" and "vein" ores.
  7406. -- Omit from "scatter" ore for a uniform ore distribution.
  7407. -- Omit from "stratum" ore for a simple horizontal strata from y_min to
  7408. -- y_max.
  7409. biomes = {"desert", "rainforest"},
  7410. -- List of biomes in which this ore occurs.
  7411. -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
  7412. -- being used does not support biomes.
  7413. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7414. -- Type-specific parameters
  7415. -- "sheet"
  7416. column_height_min = 1,
  7417. column_height_max = 16,
  7418. column_midpoint_factor = 0.5,
  7419. -- "puff"
  7420. np_puff_top = {
  7421. offset = 4,
  7422. scale = 2,
  7423. spread = {x = 100, y = 100, z = 100},
  7424. seed = 47,
  7425. octaves = 3,
  7426. persistence = 0.7
  7427. },
  7428. np_puff_bottom = {
  7429. offset = 4,
  7430. scale = 2,
  7431. spread = {x = 100, y = 100, z = 100},
  7432. seed = 11,
  7433. octaves = 3,
  7434. persistence = 0.7
  7435. },
  7436. -- "vein"
  7437. random_factor = 1.0,
  7438. -- "stratum"
  7439. np_stratum_thickness = {
  7440. offset = 8,
  7441. scale = 4,
  7442. spread = {x = 100, y = 100, z = 100},
  7443. seed = 17,
  7444. octaves = 3,
  7445. persistence = 0.7
  7446. },
  7447. stratum_thickness = 8, -- only used if no noise defined
  7448. }
  7449. Biome definition
  7450. ----------------
  7451. Used by `minetest.register_biome`.
  7452. The maximum number of biomes that can be used is 65535. However, using an
  7453. excessive number of biomes will slow down map generation. Depending on desired
  7454. performance and computing power the practical limit is much lower.
  7455. {
  7456. name = "tundra",
  7457. node_dust = "default:snow",
  7458. -- Node dropped onto upper surface after all else is generated
  7459. node_top = "default:dirt_with_snow",
  7460. depth_top = 1,
  7461. -- Node forming surface layer of biome and thickness of this layer
  7462. node_filler = "default:permafrost",
  7463. depth_filler = 3,
  7464. -- Node forming lower layer of biome and thickness of this layer
  7465. node_stone = "default:bluestone",
  7466. -- Node that replaces all stone nodes between roughly y_min and y_max.
  7467. node_water_top = "default:ice",
  7468. depth_water_top = 10,
  7469. -- Node forming a surface layer in seawater with the defined thickness
  7470. node_water = "",
  7471. -- Node that replaces all seawater nodes not in the surface layer
  7472. node_river_water = "default:ice",
  7473. -- Node that replaces river water in mapgens that use
  7474. -- default:river_water
  7475. node_riverbed = "default:gravel",
  7476. depth_riverbed = 2,
  7477. -- Node placed under river water and thickness of this layer
  7478. node_cave_liquid = "default:lava_source",
  7479. node_cave_liquid = {"default:water_source", "default:lava_source"},
  7480. -- Nodes placed inside 50% of the medium size caves.
  7481. -- Multiple nodes can be specified, each cave will use a randomly
  7482. -- chosen node from the list.
  7483. -- If this field is left out or 'nil', cave liquids fall back to
  7484. -- classic behavior of lava and water distributed using 3D noise.
  7485. -- For no cave liquid, specify "air".
  7486. node_dungeon = "default:cobble",
  7487. -- Node used for primary dungeon structure.
  7488. -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
  7489. -- alias, if that is also absent, dungeon nodes fall back to the biome
  7490. -- 'node_stone'.
  7491. -- If present, the following two nodes are also used.
  7492. node_dungeon_alt = "default:mossycobble",
  7493. -- Node used for randomly-distributed alternative structure nodes.
  7494. -- If alternative structure nodes are not wanted leave this absent.
  7495. node_dungeon_stair = "stairs:stair_cobble",
  7496. -- Node used for dungeon stairs.
  7497. -- If absent, stairs fall back to 'node_dungeon'.
  7498. y_max = 31000,
  7499. y_min = 1,
  7500. -- Upper and lower limits for biome.
  7501. -- Alternatively you can use xyz limits as shown below.
  7502. max_pos = {x = 31000, y = 128, z = 31000},
  7503. min_pos = {x = -31000, y = 9, z = -31000},
  7504. -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
  7505. -- Biome is limited to a cuboid defined by these positions.
  7506. -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
  7507. -- 31000 in 'max_pos'.
  7508. vertical_blend = 8,
  7509. -- Vertical distance in nodes above 'y_max' over which the biome will
  7510. -- blend with the biome above.
  7511. -- Set to 0 for no vertical blend. Defaults to 0.
  7512. heat_point = 0,
  7513. humidity_point = 50,
  7514. -- Characteristic temperature and humidity for the biome.
  7515. -- These values create 'biome points' on a voronoi diagram with heat and
  7516. -- humidity as axes. The resulting voronoi cells determine the
  7517. -- distribution of the biomes.
  7518. -- Heat and humidity have average values of 50, vary mostly between
  7519. -- 0 and 100 but can exceed these values.
  7520. }
  7521. Decoration definition
  7522. ---------------------
  7523. See [Decoration types]. Used by `minetest.register_decoration`.
  7524. {
  7525. deco_type = "simple",
  7526. -- Type. "simple" or "schematic" supported
  7527. place_on = "default:dirt_with_grass",
  7528. -- Node (or list of nodes) that the decoration can be placed on
  7529. sidelen = 8,
  7530. -- Size of the square (X / Z) divisions of the mapchunk being generated.
  7531. -- Determines the resolution of noise variation if used.
  7532. -- If the chunk size is not evenly divisible by sidelen, sidelen is made
  7533. -- equal to the chunk size.
  7534. fill_ratio = 0.02,
  7535. -- The value determines 'decorations per surface node'.
  7536. -- Used only if noise_params is not specified.
  7537. -- If >= 10.0 complete coverage is enabled and decoration placement uses
  7538. -- a different and much faster method.
  7539. noise_params = {
  7540. offset = 0,
  7541. scale = 0.45,
  7542. spread = {x = 100, y = 100, z = 100},
  7543. seed = 354,
  7544. octaves = 3,
  7545. persistence = 0.7,
  7546. lacunarity = 2.0,
  7547. flags = "absvalue"
  7548. },
  7549. -- NoiseParams structure describing the perlin noise used for decoration
  7550. -- distribution.
  7551. -- A noise value is calculated for each square division and determines
  7552. -- 'decorations per surface node' within each division.
  7553. -- If the noise value >= 10.0 complete coverage is enabled and
  7554. -- decoration placement uses a different and much faster method.
  7555. biomes = {"Oceanside", "Hills", "Plains"},
  7556. -- List of biomes in which this decoration occurs. Occurs in all biomes
  7557. -- if this is omitted, and ignored if the Mapgen being used does not
  7558. -- support biomes.
  7559. -- Can be a list of (or a single) biome names, IDs, or definitions.
  7560. y_min = -31000,
  7561. y_max = 31000,
  7562. -- Lower and upper limits for decoration (inclusive).
  7563. -- These parameters refer to the Y co-ordinate of the 'place_on' node.
  7564. spawn_by = "default:water",
  7565. -- Node (or list of nodes) that the decoration only spawns next to.
  7566. -- Checks the 8 neighboring nodes on the same Y, and also the ones
  7567. -- at Y+1, excluding both center nodes.
  7568. num_spawn_by = 1,
  7569. -- Number of spawn_by nodes that must be surrounding the decoration
  7570. -- position to occur.
  7571. -- If absent or -1, decorations occur next to any nodes.
  7572. flags = "liquid_surface, force_placement, all_floors, all_ceilings",
  7573. -- Flags for all decoration types.
  7574. -- "liquid_surface": Instead of placement on the highest solid surface
  7575. -- in a mapchunk column, placement is on the highest liquid surface.
  7576. -- Placement is disabled if solid nodes are found above the liquid
  7577. -- surface.
  7578. -- "force_placement": Nodes other than "air" and "ignore" are replaced
  7579. -- by the decoration.
  7580. -- "all_floors", "all_ceilings": Instead of placement on the highest
  7581. -- surface in a mapchunk the decoration is placed on all floor and/or
  7582. -- ceiling surfaces, for example in caves and dungeons.
  7583. -- Ceiling decorations act as an inversion of floor decorations so the
  7584. -- effect of 'place_offset_y' is inverted.
  7585. -- Y-slice probabilities do not function correctly for ceiling
  7586. -- schematic decorations as the behavior is unchanged.
  7587. -- If a single decoration registration has both flags the floor and
  7588. -- ceiling decorations will be aligned vertically.
  7589. ----- Simple-type parameters
  7590. decoration = "default:grass",
  7591. -- The node name used as the decoration.
  7592. -- If instead a list of strings, a randomly selected node from the list
  7593. -- is placed as the decoration.
  7594. height = 1,
  7595. -- Decoration height in nodes.
  7596. -- If height_max is not 0, this is the lower limit of a randomly
  7597. -- selected height.
  7598. height_max = 0,
  7599. -- Upper limit of the randomly selected height.
  7600. -- If absent, the parameter 'height' is used as a constant.
  7601. param2 = 0,
  7602. -- Param2 value of decoration nodes.
  7603. -- If param2_max is not 0, this is the lower limit of a randomly
  7604. -- selected param2.
  7605. param2_max = 0,
  7606. -- Upper limit of the randomly selected param2.
  7607. -- If absent, the parameter 'param2' is used as a constant.
  7608. place_offset_y = 0,
  7609. -- Y offset of the decoration base node relative to the standard base
  7610. -- node position.
  7611. -- Can be positive or negative. Default is 0.
  7612. -- Effect is inverted for "all_ceilings" decorations.
  7613. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7614. -- to the 'place_on' node.
  7615. ----- Schematic-type parameters
  7616. schematic = "foobar.mts",
  7617. -- If schematic is a string, it is the filepath relative to the current
  7618. -- working directory of the specified Minetest schematic file.
  7619. -- Could also be the ID of a previously registered schematic.
  7620. schematic = {
  7621. size = {x = 4, y = 6, z = 4},
  7622. data = {
  7623. {name = "default:cobble", param1 = 255, param2 = 0},
  7624. {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
  7625. {name = "air", param1 = 255, param2 = 0},
  7626. ...
  7627. },
  7628. yslice_prob = {
  7629. {ypos = 2, prob = 128},
  7630. {ypos = 5, prob = 64},
  7631. ...
  7632. },
  7633. },
  7634. -- Alternative schematic specification by supplying a table. The fields
  7635. -- size and data are mandatory whereas yslice_prob is optional.
  7636. -- See 'Schematic specifier' for details.
  7637. replacements = {["oldname"] = "convert_to", ...},
  7638. -- Map of node names to replace in the schematic after reading it.
  7639. flags = "place_center_x, place_center_y, place_center_z",
  7640. -- Flags for schematic decorations. See 'Schematic attributes'.
  7641. rotation = "90",
  7642. -- Rotation can be "0", "90", "180", "270", or "random"
  7643. place_offset_y = 0,
  7644. -- If the flag 'place_center_y' is set this parameter is ignored.
  7645. -- Y offset of the schematic base node layer relative to the 'place_on'
  7646. -- node.
  7647. -- Can be positive or negative. Default is 0.
  7648. -- Effect is inverted for "all_ceilings" decorations.
  7649. -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
  7650. -- to the 'place_on' node.
  7651. }
  7652. Chat command definition
  7653. -----------------------
  7654. Used by `minetest.register_chatcommand`.
  7655. {
  7656. params = "<name> <privilege>", -- Short parameter description
  7657. description = "Remove privilege from player", -- Full description
  7658. privs = {privs=true}, -- Require the "privs" privilege to run
  7659. func = function(name, param),
  7660. -- Called when command is run. Returns boolean success and text output.
  7661. -- Special case: The help message is shown to the player if `func`
  7662. -- returns false without a text output.
  7663. }
  7664. Note that in params, use of symbols is as follows:
  7665. * `<>` signifies a placeholder to be replaced when the command is used. For
  7666. example, when a player name is needed: `<name>`
  7667. * `[]` signifies param is optional and not required when the command is used.
  7668. For example, if you require param1 but param2 is optional:
  7669. `<param1> [<param2>]`
  7670. * `|` signifies exclusive or. The command requires one param from the options
  7671. provided. For example: `<param1> | <param2>`
  7672. * `()` signifies grouping. For example, when param1 and param2 are both
  7673. required, or only param3 is required: `(<param1> <param2>) | <param3>`
  7674. Privilege definition
  7675. --------------------
  7676. Used by `minetest.register_privilege`.
  7677. {
  7678. description = "",
  7679. -- Privilege description
  7680. give_to_singleplayer = true,
  7681. -- Whether to grant the privilege to singleplayer.
  7682. give_to_admin = true,
  7683. -- Whether to grant the privilege to the server admin.
  7684. -- Uses value of 'give_to_singleplayer' by default.
  7685. on_grant = function(name, granter_name),
  7686. -- Called when given to player 'name' by 'granter_name'.
  7687. -- 'granter_name' will be nil if the priv was granted by a mod.
  7688. on_revoke = function(name, revoker_name),
  7689. -- Called when taken from player 'name' by 'revoker_name'.
  7690. -- 'revoker_name' will be nil if the priv was revoked by a mod.
  7691. -- Note that the above two callbacks will be called twice if a player is
  7692. -- responsible, once with the player name, and then with a nil player
  7693. -- name.
  7694. -- Return true in the above callbacks to stop register_on_priv_grant or
  7695. -- revoke being called.
  7696. }
  7697. Detached inventory callbacks
  7698. ----------------------------
  7699. Used by `minetest.create_detached_inventory`.
  7700. {
  7701. allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7702. -- Called when a player wants to move items inside the inventory.
  7703. -- Return value: number of items allowed to move.
  7704. allow_put = function(inv, listname, index, stack, player),
  7705. -- Called when a player wants to put something into the inventory.
  7706. -- Return value: number of items allowed to put.
  7707. -- Return value -1: Allow and don't modify item count in inventory.
  7708. allow_take = function(inv, listname, index, stack, player),
  7709. -- Called when a player wants to take something out of the inventory.
  7710. -- Return value: number of items allowed to take.
  7711. -- Return value -1: Allow and don't modify item count in inventory.
  7712. on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
  7713. on_put = function(inv, listname, index, stack, player),
  7714. on_take = function(inv, listname, index, stack, player),
  7715. -- Called after the actual action has happened, according to what was
  7716. -- allowed.
  7717. -- No return value.
  7718. }
  7719. HUD Definition
  7720. --------------
  7721. Since most values have multiple different functions, please see the
  7722. documentation in [HUD] section.
  7723. Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
  7724. {
  7725. hud_elem_type = "image",
  7726. -- Type of element, can be "image", "text", "statbar", "inventory",
  7727. -- "waypoint", "image_waypoint", "compass" or "minimap"
  7728. position = {x=0.5, y=0.5},
  7729. -- Top left corner position of element
  7730. name = "<name>",
  7731. scale = {x = 1, y = 1},
  7732. text = "<text>",
  7733. text2 = "<text>",
  7734. number = 0,
  7735. item = 0,
  7736. direction = 0,
  7737. -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
  7738. alignment = {x=0, y=0},
  7739. offset = {x=0, y=0},
  7740. world_pos = {x=0, y=0, z=0},
  7741. size = {x=0, y=0},
  7742. z_index = 0,
  7743. -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
  7744. style = 0,
  7745. }
  7746. Particle definition
  7747. -------------------
  7748. Used by `minetest.add_particle`.
  7749. {
  7750. pos = {x=0, y=0, z=0},
  7751. velocity = {x=0, y=0, z=0},
  7752. acceleration = {x=0, y=0, z=0},
  7753. -- Spawn particle at pos with velocity and acceleration
  7754. expirationtime = 1,
  7755. -- Disappears after expirationtime seconds
  7756. size = 1,
  7757. -- Scales the visual size of the particle texture.
  7758. -- If `node` is set, size can be set to 0 to spawn a randomly-sized
  7759. -- particle (just like actual node dig particles).
  7760. collisiondetection = false,
  7761. -- If true collides with `walkable` nodes and, depending on the
  7762. -- `object_collision` field, objects too.
  7763. collision_removal = false,
  7764. -- If true particle is removed when it collides.
  7765. -- Requires collisiondetection = true to have any effect.
  7766. object_collision = false,
  7767. -- If true particle collides with objects that are defined as
  7768. -- `physical = true,` and `collide_with_objects = true,`.
  7769. -- Requires collisiondetection = true to have any effect.
  7770. vertical = false,
  7771. -- If true faces player using y axis only
  7772. texture = "image.png",
  7773. -- The texture of the particle
  7774. -- v5.6.0 and later: also supports the table format described in the
  7775. -- following section
  7776. playername = "singleplayer",
  7777. -- Optional, if specified spawns particle only on the player's client
  7778. animation = {Tile Animation definition},
  7779. -- Optional, specifies how to animate the particle texture
  7780. glow = 0
  7781. -- Optional, specify particle self-luminescence in darkness.
  7782. -- Values 0-14.
  7783. node = {name = "ignore", param2 = 0},
  7784. -- Optional, if specified the particle will have the same appearance as
  7785. -- node dig particles for the given node.
  7786. -- `texture` and `animation` will be ignored if this is set.
  7787. node_tile = 0,
  7788. -- Optional, only valid in combination with `node`
  7789. -- If set to a valid number 1-6, specifies the tile from which the
  7790. -- particle texture is picked.
  7791. -- Otherwise, the default behavior is used. (currently: any random tile)
  7792. drag = {x=0, y=0, z=0},
  7793. -- v5.6.0 and later: Optional drag value, consult the following section
  7794. bounce = {min = ..., max = ..., bias = 0},
  7795. -- v5.6.0 and later: Optional bounce range, consult the following section
  7796. }
  7797. `ParticleSpawner` definition
  7798. ----------------------------
  7799. Used by `minetest.add_particlespawner`.
  7800. Before v5.6.0, particlespawners used a different syntax and had a more limited set
  7801. of features. Definition fields that are the same in both legacy and modern versions
  7802. are shown in the next listing, and the fields that are used by legacy versions are
  7803. shown separated by a comment; the modern fields are too complex to compactly
  7804. describe in this manner and are documented after the listing.
  7805. The older syntax can be used in combination with the newer syntax (e.g. having
  7806. `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
  7807. the new syntax will override the older syntax; on older servers, the newer syntax
  7808. will be ignored.
  7809. {
  7810. -- Common fields (same name and meaning in both new and legacy syntax)
  7811. amount = 1,
  7812. -- Number of particles spawned over the time period `time`.
  7813. time = 1,
  7814. -- Lifespan of spawner in seconds.
  7815. -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
  7816. -- a per-second basis.
  7817. collisiondetection = false,
  7818. -- If true collide with `walkable` nodes and, depending on the
  7819. -- `object_collision` field, objects too.
  7820. collision_removal = false,
  7821. -- If true particles are removed when they collide.
  7822. -- Requires collisiondetection = true to have any effect.
  7823. object_collision = false,
  7824. -- If true particles collide with objects that are defined as
  7825. -- `physical = true,` and `collide_with_objects = true,`.
  7826. -- Requires collisiondetection = true to have any effect.
  7827. attached = ObjectRef,
  7828. -- If defined, particle positions, velocities and accelerations are
  7829. -- relative to this object's position and yaw
  7830. vertical = false,
  7831. -- If true face player using y axis only
  7832. texture = "image.png",
  7833. -- The texture of the particle
  7834. playername = "singleplayer",
  7835. -- Optional, if specified spawns particles only on the player's client
  7836. animation = {Tile Animation definition},
  7837. -- Optional, specifies how to animate the particles' texture
  7838. -- v5.6.0 and later: set length to -1 to synchronize the length
  7839. -- of the animation with the expiration time of individual particles.
  7840. -- (-2 causes the animation to be played twice, and so on)
  7841. glow = 0,
  7842. -- Optional, specify particle self-luminescence in darkness.
  7843. -- Values 0-14.
  7844. node = {name = "ignore", param2 = 0},
  7845. -- Optional, if specified the particles will have the same appearance as
  7846. -- node dig particles for the given node.
  7847. -- `texture` and `animation` will be ignored if this is set.
  7848. node_tile = 0,
  7849. -- Optional, only valid in combination with `node`
  7850. -- If set to a valid number 1-6, specifies the tile from which the
  7851. -- particle texture is picked.
  7852. -- Otherwise, the default behavior is used. (currently: any random tile)
  7853. -- Legacy definition fields
  7854. minpos = {x=0, y=0, z=0},
  7855. maxpos = {x=0, y=0, z=0},
  7856. minvel = {x=0, y=0, z=0},
  7857. maxvel = {x=0, y=0, z=0},
  7858. minacc = {x=0, y=0, z=0},
  7859. maxacc = {x=0, y=0, z=0},
  7860. minexptime = 1,
  7861. maxexptime = 1,
  7862. minsize = 1,
  7863. maxsize = 1,
  7864. -- The particles' properties are random values between the min and max
  7865. -- values.
  7866. -- applies to: pos, velocity, acceleration, expirationtime, size
  7867. -- If `node` is set, min and maxsize can be set to 0 to spawn
  7868. -- randomly-sized particles (just like actual node dig particles).
  7869. }
  7870. ### Modern definition fields
  7871. After v5.6.0, spawner properties can be defined in several different ways depending
  7872. on the level of control you need. `pos` for instance can be set as a single vector,
  7873. in which case all particles will appear at that exact point throughout the lifetime
  7874. of the spawner. Alternately, it can be specified as a min-max pair, specifying a
  7875. cubic range the particles can appear randomly within. Finally, some properties can
  7876. be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
  7877. a tween table.
  7878. The following definitions are all equivalent, listed in order of precedence from
  7879. lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
  7880. property definition are present, the highest-precedence form will be selected
  7881. and all lower-precedence fields will be ignored, allowing for graceful
  7882. degradation in older clients).
  7883. {
  7884. -- old syntax
  7885. maxpos = {x = 0, y = 0, z = 0},
  7886. minpos = {x = 0, y = 0, z = 0},
  7887. -- absolute value
  7888. pos = 0,
  7889. -- all components of every particle's position vector will be set to this
  7890. -- value
  7891. -- vec3
  7892. pos = vector.new(0,0,0),
  7893. -- all particles will appear at this exact position throughout the lifetime
  7894. -- of the particlespawner
  7895. -- vec3 range
  7896. pos = {
  7897. -- the particle will appear at a position that is picked at random from
  7898. -- within a cubic range
  7899. min = vector.new(0,0,0),
  7900. -- `min` is the minimum value this property will be set to in particles
  7901. -- spawned by the generator
  7902. max = vector.new(0,0,0),
  7903. -- `max` is the minimum value this property will be set to in particles
  7904. -- spawned by the generator
  7905. bias = 0,
  7906. -- when `bias` is 0, all random values are exactly as likely as any
  7907. -- other. when it is positive, the higher it is, the more likely values
  7908. -- will appear towards the minimum end of the allowed spectrum. when
  7909. -- it is negative, the lower it is, the more likely values will appear
  7910. -- towards the maximum end of the allowed spectrum. the curve is
  7911. -- exponential and there is no particular maximum or minimum value
  7912. },
  7913. -- tween table
  7914. pos_tween = {...},
  7915. -- a tween table should consist of a list of frames in the same form as the
  7916. -- untweened pos property above, which the engine will interpolate between,
  7917. -- and optionally a number of properties that control how the interpolation
  7918. -- takes place. currently **only two frames**, the first and the last, are
  7919. -- used, but extra frames are accepted for the sake of forward compatibility.
  7920. -- any of the above definition styles can be used here as well in any combination
  7921. -- supported by the property type
  7922. pos_tween = {
  7923. style = "fwd",
  7924. -- linear animation from first to last frame (default)
  7925. style = "rev",
  7926. -- linear animation from last to first frame
  7927. style = "pulse",
  7928. -- linear animation from first to last then back to first again
  7929. style = "flicker",
  7930. -- like "pulse", but slightly randomized to add a bit of stutter
  7931. reps = 1,
  7932. -- number of times the animation is played over the particle's lifespan
  7933. start = 0.0,
  7934. -- point in the spawner's lifespan at which the animation begins. 0 is
  7935. -- the very beginning, 1 is the very end
  7936. -- frames can be defined in a number of different ways, depending on the
  7937. -- underlying type of the property. for now, all but the first and last
  7938. -- frame are ignored
  7939. -- frames
  7940. -- floats
  7941. 0, 0,
  7942. -- vec3s
  7943. vector.new(0,0,0),
  7944. vector.new(0,0,0),
  7945. -- vec3 ranges
  7946. { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7947. { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7948. -- mixed
  7949. 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
  7950. },
  7951. }
  7952. All of the properties that can be defined in this way are listed in the next
  7953. section, along with the datatypes they accept.
  7954. #### List of particlespawner properties
  7955. All of the properties in this list can be animated with `*_tween` tables
  7956. unless otherwise specified. For example, `jitter` can be tweened by setting
  7957. a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
  7958. Types used are defined in the previous section.
  7959. * vec3 range `pos`: the position at which particles can appear
  7960. * vec3 range `vel`: the initial velocity of the particle
  7961. * vec3 range `acc`: the direction and speed with which the particle
  7962. accelerates
  7963. * vec3 range `jitter`: offsets the velocity of each particle by a random
  7964. amount within the specified range each frame. used to create Brownian motion.
  7965. * vec3 range `drag`: the amount by which absolute particle velocity along
  7966. each axis is decreased per second. a value of 1.0 means that the particle
  7967. will be slowed to a stop over the space of a second; a value of -1.0 means
  7968. that the particle speed will be doubled every second. to avoid interfering
  7969. with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
  7970. be used instead of a uniform value.
  7971. * float range `bounce`: how bouncy the particles are when `collisiondetection`
  7972. is turned on. values less than or equal to `0` turn off particle bounce;
  7973. `1` makes the particles bounce without losing any velocity, and `2` makes
  7974. them double their velocity with every bounce. `bounce` is not bounded but
  7975. values much larger than `1.0` probably aren't very useful.
  7976. * float range `exptime`: the number of seconds after which the particle
  7977. disappears.
  7978. * table `attract`: sets the birth orientation of particles relative to various
  7979. shapes defined in world coordinate space. this is an alternative means of
  7980. setting the velocity which allows particles to emerge from or enter into
  7981. some entity or node on the map, rather than simply being assigned random
  7982. velocity values within a range. the velocity calculated by this method will
  7983. be **added** to that specified by `vel` if `vel` is also set, so in most
  7984. cases **`vel` should be set to 0**. `attract` has the fields:
  7985. * string `kind`: selects the kind of shape towards which the particles will
  7986. be oriented. it must have one of the following values:
  7987. * `"none"`: no attractor is set and the `attractor` table is ignored
  7988. * `"point"`: the particles are attracted to a specific point in space.
  7989. use this also if you want a sphere-like effect, in combination with
  7990. the `radius` property.
  7991. * `"line"`: the particles are attracted to an (infinite) line passing
  7992. through the points `origin` and `angle`. use this for e.g. beacon
  7993. effects, energy beam effects, etc.
  7994. * `"plane"`: the particles are attracted to an (infinite) plane on whose
  7995. surface `origin` designates a point in world coordinate space. use this
  7996. for e.g. particles entering or emerging from a portal.
  7997. * float range `strength`: the speed with which particles will move towards
  7998. `attractor`. If negative, the particles will instead move away from that
  7999. point.
  8000. * vec3 `origin`: the origin point of the shape towards which particles will
  8001. initially be oriented. functions as an offset if `origin_attached` is also
  8002. set.
  8003. * vec3 `direction`: sets the direction in which the attractor shape faces. for
  8004. lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
  8005. create a vertical line that passes through `origin`. for planes, `direction`
  8006. is the surface normal of an infinite plane on whose surface `origin` is
  8007. a point. functions as an offset if `direction_attached` is also set.
  8008. * entity `origin_attached`: allows the origin to be specified as an offset
  8009. from the position of an entity rather than a coordinate in world space.
  8010. * entity `direction_attached`: allows the direction to be specified as an offset
  8011. from the position of an entity rather than a coordinate in world space.
  8012. * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
  8013. that they will die as they cross the attractor threshold. this behavior
  8014. is the default but is undesirable for some kinds of animations; set it to
  8015. false to allow particles to live out their natural lives.
  8016. * vec3 range `radius`: if set, particles will be arranged in a sphere around
  8017. `pos`. A constant can be used to create a spherical shell of particles, a
  8018. vector to create an ovoid shell, and a range to create a volume; e.g.
  8019. `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
  8020. and 1 nodes away from `pos` but will cluster them towards the center of the
  8021. sphere. Usually if `radius` is used, `pos` should be a single point, but it
  8022. can still be a range if you really know what you're doing (e.g. to create a
  8023. "roundcube" emitter volume).
  8024. ### Textures
  8025. In versions before v5.6.0, particlespawner textures could only be specified as a single
  8026. texture string. After v5.6.0, textures can now be specified as a table as well. This
  8027. table contains options that allow simple animations to be applied to the texture.
  8028. texture = {
  8029. name = "mymod_particle_texture.png",
  8030. -- the texture specification string
  8031. alpha = 1.0,
  8032. -- controls how visible the particle is; at 1.0 the particle is fully
  8033. -- visible, at 0, it is completely invisible.
  8034. alpha_tween = {1, 0},
  8035. -- can be used instead of `alpha` to animate the alpha value over the
  8036. -- particle's lifetime. these tween tables work identically to the tween
  8037. -- tables used in particlespawner properties, except that time references
  8038. -- are understood with respect to the particle's lifetime, not the
  8039. -- spawner's. {1,0} fades the particle out over its lifetime.
  8040. scale = 1,
  8041. scale = {x = 1, y = 1},
  8042. -- scales the texture onscreen
  8043. scale_tween = {
  8044. {x = 1, y = 1},
  8045. {x = 0, y = 1},
  8046. },
  8047. -- animates the scale over the particle's lifetime. works like the
  8048. -- alpha_tween table, but can accept two-dimensional vectors as well as
  8049. -- integer values. the example value would cause the particle to shrink
  8050. -- in one dimension over the course of its life until it disappears
  8051. blend = "alpha",
  8052. -- (default) blends transparent pixels with those they are drawn atop
  8053. -- according to the alpha channel of the source texture. useful for
  8054. -- e.g. material objects like rocks, dirt, smoke, or node chunks
  8055. blend = "add",
  8056. -- adds the value of pixels to those underneath them, modulo the sources
  8057. -- alpha channel. useful for e.g. bright light effects like sparks or fire
  8058. blend = "screen",
  8059. -- like "add" but less bright. useful for subtler light effects. note that
  8060. -- this is NOT formally equivalent to the "screen" effect used in image
  8061. -- editors and compositors, as it does not respect the alpha channel of
  8062. -- of the image being blended
  8063. blend = "sub",
  8064. -- the inverse of "add"; the value of the source pixel is subtracted from
  8065. -- the pixel underneath it. a white pixel will turn whatever is underneath
  8066. -- it black; a black pixel will be "transparent". useful for creating
  8067. -- darkening effects
  8068. animation = {Tile Animation definition},
  8069. -- overrides the particlespawner's global animation property for a single
  8070. -- specific texture
  8071. }
  8072. Instead of setting a single texture definition, it is also possible to set a
  8073. `texpool` property. A `texpool` consists of a list of possible particle textures.
  8074. Every time a particle is spawned, the engine will pick a texture at random from
  8075. the `texpool` and assign it as that particle's texture. You can also specify a
  8076. `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
  8077. clients but will be sent to older (pre-v5.6.0) clients that do not implement
  8078. texpools.
  8079. texpool = {
  8080. "mymod_particle_texture.png";
  8081. { name = "mymod_spark.png", fade = "out" },
  8082. {
  8083. name = "mymod_dust.png",
  8084. alpha = 0.3,
  8085. scale = 1.5,
  8086. animation = {
  8087. type = "vertical_frames",
  8088. aspect_w = 16, aspect_h = 16,
  8089. length = 3,
  8090. -- the animation lasts for 3s and then repeats
  8091. length = -3,
  8092. -- repeat the animation three times over the particle's lifetime
  8093. -- (post-v5.6.0 clients only)
  8094. },
  8095. },
  8096. }
  8097. #### List of animatable texture properties
  8098. While animated particlespawner values vary over the course of the particlespawner's
  8099. lifetime, animated texture properties vary over the lifespans of the individual
  8100. particles spawned with that texture. So a particle with the texture property
  8101. alpha_tween = {
  8102. 0.0, 1.0,
  8103. style = "pulse",
  8104. reps = 4,
  8105. }
  8106. would be invisible at its spawning, pulse visible four times throughout its
  8107. lifespan, and then vanish again before expiring.
  8108. * float `alpha` (0.0 - 1.0): controls the visibility of the texture
  8109. * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
  8110. are multiples of the parent particle's assigned size (see the `size` property above)
  8111. `HTTPRequest` definition
  8112. ------------------------
  8113. Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
  8114. {
  8115. url = "http://example.org",
  8116. timeout = 10,
  8117. -- Timeout for request to be completed in seconds. Default depends on engine settings.
  8118. method = "GET", "POST", "PUT" or "DELETE"
  8119. -- The http method to use. Defaults to "GET".
  8120. data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
  8121. -- Data for the POST, PUT or DELETE request.
  8122. -- Accepts both a string and a table. If a table is specified, encodes
  8123. -- table as x-www-form-urlencoded key-value pairs.
  8124. user_agent = "ExampleUserAgent",
  8125. -- Optional, if specified replaces the default minetest user agent with
  8126. -- given string
  8127. extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
  8128. -- Optional, if specified adds additional headers to the HTTP request.
  8129. -- You must make sure that the header strings follow HTTP specification
  8130. -- ("Key: Value").
  8131. multipart = boolean
  8132. -- Optional, if true performs a multipart HTTP request.
  8133. -- Default is false.
  8134. -- Post only, data must be array
  8135. post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
  8136. -- Deprecated, use `data` instead. Forces `method = "POST"`.
  8137. }
  8138. `HTTPRequestResult` definition
  8139. ------------------------------
  8140. Passed to `HTTPApiTable.fetch` callback. Returned by
  8141. `HTTPApiTable.fetch_async_get`.
  8142. {
  8143. completed = true,
  8144. -- If true, the request has finished (either succeeded, failed or timed
  8145. -- out)
  8146. succeeded = true,
  8147. -- If true, the request was successful
  8148. timeout = false,
  8149. -- If true, the request timed out
  8150. code = 200,
  8151. -- HTTP status code
  8152. data = "response"
  8153. }
  8154. Authentication handler definition
  8155. ---------------------------------
  8156. Used by `minetest.register_authentication_handler`.
  8157. {
  8158. get_auth = function(name),
  8159. -- Get authentication data for existing player `name` (`nil` if player
  8160. -- doesn't exist).
  8161. -- Returns following structure:
  8162. -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
  8163. create_auth = function(name, password),
  8164. -- Create new auth data for player `name`.
  8165. -- Note that `password` is not plain-text but an arbitrary
  8166. -- representation decided by the engine.
  8167. delete_auth = function(name),
  8168. -- Delete auth data of player `name`.
  8169. -- Returns boolean indicating success (false if player is nonexistent).
  8170. set_password = function(name, password),
  8171. -- Set password of player `name` to `password`.
  8172. -- Auth data should be created if not present.
  8173. set_privileges = function(name, privileges),
  8174. -- Set privileges of player `name`.
  8175. -- `privileges` is in table form, auth data should be created if not
  8176. -- present.
  8177. reload = function(),
  8178. -- Reload authentication data from the storage location.
  8179. -- Returns boolean indicating success.
  8180. record_login = function(name),
  8181. -- Called when player joins, used for keeping track of last_login
  8182. iterate = function(),
  8183. -- Returns an iterator (use with `for` loops) for all player names
  8184. -- currently in the auth database
  8185. }
  8186. Bit Library
  8187. -----------
  8188. 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
  8189. See http://bitop.luajit.org/ for advanced information.
  8190. Error Handling
  8191. --------------
  8192. When an error occurs that is not caught, Minetest calls the function
  8193. `minetest.error_handler` with the error object as its first argument. The second
  8194. argument is the stack level where the error occurred. The return value is the
  8195. error string that should be shown. By default this is a backtrace from
  8196. `debug.traceback`. If the error object is not a string, it is first converted
  8197. with `tostring` before being displayed. This means that you can use tables as
  8198. error objects so long as you give them `__tostring` metamethods.
  8199. You can override `minetest.error_handler`. You should call the previous handler
  8200. with the correct stack level in your implementation.